<template>
  <a-card>
    <sd-detail-form
      v-if="showForm"
      ref="docform"
      :record-id="docId"
      :page-id="pageId"
      :class="$style.docform"
      @saved="fwSaved"
    >
      <template>
        <!-- 文档积分  -->
        <a-card :class="$style.jifenTable">
          <p :class="$style.title">文档积分</p>
          <table border="1" width="100%">
            <tr>
              <th align="center">积分类型</th>
              <th align="center">积分行为</th>
              <th align="center" colspan="3">积分系数</th>
              <th align="center">日积分上限</th>
            </tr>
            <tr>
              <td rowspan="13">文档积分H=(A+F+G)</td>
              <td rowspan="2">文档阅读(A)</td>
              <td rowspan="2">阅读积分(A)</td>
              <td>知识文档</td>
              <sd-form-item-td name="docKnowledgeReadPoint" :label="null" />
              <sd-form-item-td :input-td-attrs="{ rowspan: 2 }" name="docReadLimit" :label="null" />
            </tr>
            <tr>
              <td>知识地图</td>
              <sd-form-item-td name="docMapReadPoint" :label="null" />
            </tr>
            <tr>
              <td rowspan="3">文档点评(F=B*C)</td>
              <td colspan="2">点评级别积分(B)</td>
              <sd-form-item-td name="docCommentPoint" :label="null" />
              <sd-form-item-td
                name="docCommentLimit"
                :input-td-attrs="{ rowspan: 3 }"
                :label="null"
              />
            </tr>

            <tr>
              <td rowspan="2">点评角色积分系数(C)</td>
              <td>员工</td>
              <sd-form-item-td name="docCommentStaffRate" :label="null" />
            </tr>
            <tr>
              <td>专家</td>
              <sd-form-item-td name="docCommentExpertRate" :label="null" />
            </tr>
            <tr>
              <td rowspan="4">文档推荐(G=D*E)</td>
              <td rowspan="2">推荐级别积分(D)</td>
              <td>推荐至门户</td>
              <sd-form-item-td name="docRecommendHomePoint" :label="null" />
              <sd-form-item-td
                :input-td-attrs="{ rowspan: 4 }"
                name="docRecommendLimit"
                :label="null"
              />
            </tr>
            <tr>
              <td>推荐至个人</td>
              <sd-form-item-td name="docRecommendPersonPoint" :label="null" />
            </tr>
            <tr>
              <td rowspan="2">推荐角色积分系数(E)</td>
              <td>员工</td>
              <sd-form-item-td name="docRecommendStaffRate" :label="null" />
            </tr>
            <tr>
              <td>专家</td>
              <sd-form-item-td name="docRecommendExpertRate" :label="null" />
            </tr>
            <tr>
              <td colspan="6" :class="$style.tips">
                <div>
                  <p>备注：</p>
                  <p>文档积分=文档阅读积分+文档点评积分+文档推荐积分</p>
                  <p>文档阅读积分=∑文档阅读积分*阅读次数</p>
                  <p>文档点评积分=∑不同角色文档点评积分*点评次数</p>
                  <p>文档推荐积分=∑不同角色文档推荐积分*推荐次数</p>
                </div>
              </td>
            </tr>
          </table>
        </a-card>

        <!-- 个人积分  -->
        <a-card :class="$style.jifenTable">
          <p :class="$style.title">个人积分</p>
          <table border="1" width="100%">
            <tr>
              <th align="center">积分类型</th>
              <th align="center" colspan="2">积分行为</th>
              <th align="center" colspan="2">积分系数</th>
              <th align="center">日积分上限</th>
            </tr>
            <tr>
              <td rowspan="8">个人积分</td>
              <td colspan="2">
                知识贡献
                <p>知识贡献积分=∑作为作者每篇文档积分</p>
              </td>
              <td>作者文档积分系数</td>
              <sd-form-item-td name="perAuthorPoint" :label="null" />
              <td>
                <a-input-number disabled type="text" />
              </td>
            </tr>
            <tr>
              <th colspan="2">知识索取</th>
              <td>个人文档阅读</td>
              <sd-form-item-td name="perReadPoint" :label="null" />

              <sd-form-item-td name="perReadLimit" :label="null" />
            </tr>
            <tr>
              <td rowspan="3">知识推进</td>
              <td>
                点评
                <p>个人点评文档次数*个人点评积分系数</p>
              </td>
              <td>个人点评</td>
              <sd-form-item-td name="perCommentPoint" :label="null" />

              <sd-form-item-td name="perCommentLimit" :label="null" />
            </tr>
            <tr>
              <td>
                推荐
                <p>个人推荐文档次数*个人推荐积分系数</p>
              </td>
              <td>个人推荐</td>
              <sd-form-item-td name="perRecommendPoint" :label="null" />

              <sd-form-item-td name="perRecommendLimit" :label="null" />
            </tr>
            <tr>
              <td>
                点赞
                <p>个人点赞文档次数*个人点赞积分系数</p>
              </td>
              <td>个人点赞</td>
              <sd-form-item-td name="perLikePoint" :label="null" />

              <sd-form-item-td name="perLikeLimit" :label="null" />
            </tr>

            <tr>
              <td colspan="6" :class="$style.tips">
                <p>备注：</p>
                <p>个人积分=知识贡献积分+知识索取积分+知识推进积分</p>
                <p>知识推进积分=个人点评积分+个人推荐积分+个人点赞积分</p>
              </td>
            </tr>
          </table>
        </a-card>
      </template>
    </sd-detail-form>
  </a-card>
</template>

<script>
import { Message } from 'ant-design-vue'
import KmKnowledageService from '../km-knowledage-service'
import components from './_import-components/km-integral-manage-import'

export default {
  name: 'KmIntegralManage',
  metaInfo: {
    title: '知识积分规则设置',
  },
  components,
  data() {
    return {
      knowledageId: '',
      pageId: 'km/admin/kmPointRule',
      docId: null,
      showForm: false,
    }
  },
  computed: {},
  created() {
    KmKnowledageService.getKnowledageCountId().then((res) => {
      if (res.data !== -1) {
        this.docId = res.data
        this.showForm = true
      } else {
        this.docId = undefined
        this.showForm = true
      }
    })
  },
  mounted() {},
  methods: {
    fwSaved() {
      Message.success('保存成功')
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.jifen-table {
  .title {
    font-size: $btn-font-size-sm;
    font-weight: bold;
    text-align: center;
  }
  table {
    th {
      height: $input-height-lg;
      font-weight: normal;
      line-height: $input-height-lg;
      text-align: center;
    }
    td {
      padding: 0 10px;
      text-align: center;
      :global(.ant-form-item) {
        margin-bottom: 0;
      }
      p {
        padding-top: 5px;
        margin-bottom: 0;
        color: $highlight-color;
      }
    }
    .tips {
      padding-left: 20px;
      color: $highlight-color;
      text-align: left;
    }
  }
}
.divflex {
  display: flex;
  justify-content: center;
  .item {
    padding-top: 8px;
  }
}
</style>
