<template>
  <div style="height:75vh;overflow:auto" class="app-content">
    <a-spin :spinning="loading" style="width: 100%;height: 100%;">
      <div v-if="isShow" style="width: 100%;height: 100%;">
        <a-tabs type="card" @change="callback" :activeKey='tabsActive'>
          <a-tab-pane key="1" tab="评分"></a-tab-pane>
          <a-tab-pane key="2" tab="项目信息"></a-tab-pane>
        </a-tabs>
        <div class="table-content">
          <div v-show="tabsActive==='1'" style="height:100%;">
            <div style="height:calc(100% - 40px);overflow: auto;">
              <a-form-model ref="form" :model="formData" :rules="rules" class="from-table  font-line-space">
                <a-row type="flex" class="row_center">
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>评审指标</div>
                    </div>
                  </a-col>
                  <a-col :span="4" class="bg-gray">
                    <div class="special-middle">
                      <div>指标含义</div>
                    </div>
                  </a-col>
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>100-90分</div>
                    </div>
                  </a-col>
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>89-80分 </div>
                    </div>
                  </a-col>
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>79-70分</div>
                    </div>
                  </a-col>
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>69-60分</div>
                    </div>
                  </a-col>
                  <a-col :span="2" class="bg-gray">
                    <div class="special-middle">
                      <div>分值</div>
                    </div>
                  </a-col>
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>专家打分</div>
                    </div>
                  </a-col>
                </a-row>

                <a-row v-for="(tab, index) in tableData" :key="index" type="flex" class="row_center">
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle">
                      <div>
                        {{ tab.title }}
                      </div>
                    </div>
                  </a-col>
                  <a-col :span="4">
                    <div class="special-middle">
                      <div>
                        {{ tab.meaning }}
                      </div>
                    </div>
                  </a-col>

                  <a-col :span="3" v-for="(item,index) in tab.child" :key="'item'+index">
                    <div class="special-middle">
                      <div>
                        {{ item }}
                      </div>
                    </div>
                  </a-col>

                  <a-col :span="2">
                    <div class="special-middle">
                      <div>
                        {{ tab.score + '分' }}
                      </div>
                    </div>
                  </a-col>

                  <a-col :span="3" v-if="index==0">
                    <div class="special-middle">
                      <div>
                        <a-form-model-item :prop="'projectBasis'">
                          <a-input-number v-model="formData.projectBasis" :min="0" :max="10" :step="0.1" :precision="1" style="width: 80%" />
                        </a-form-model-item>
                      </div>
                    </div>
                  </a-col>
                  <a-col :span="3" v-if="index==1">
                    <div class="special-middle">
                      <div>
                        <a-form-model-item :prop="'academicValue'">
                          <a-input-number v-model="formData.academicValue" :min="0" :max="10" :step="0.1" :precision="1" style="width: 80%" />
                        </a-form-model-item>
                      </div>
                    </div>
                  </a-col>
                  <a-col :span="3" v-if="index==2">
                    <div class="special-middle">
                      <div>
                        <a-form-model-item :prop="'innovation'">
                          <a-input-number v-model="formData.innovation" :min="0" :max="30" :step="0.1" :precision="1" style="width: 80%" />
                        </a-form-model-item>
                      </div>
                    </div>
                  </a-col>
                  <a-col :span="3" v-if="index==3">
                    <div class="special-middle">
                      <div>
                        <a-form-model-item :prop="'researchPlan'">
                          <a-input-number v-model="formData.researchPlan" :min="0" :max="30" :step="0.1" :precision="1" style="width: 80%" />
                        </a-form-model-item>
                      </div>
                    </div>
                  </a-col>
                  <a-col :span="3" v-if="index==4">
                    <div class="special-middle">
                      <div>
                        <a-form-model-item :prop="'expectedResults'">
                          <a-input-number v-model="formData.expectedResults" :min="0" :max="20" :step="0.1" :precision="1" style="width: 80%" />
                        </a-form-model-item>
                      </div>
                    </div>
                  </a-col>
                </a-row>

                <a-row type="flex">
                  <a-col :span="3" class="bg-gray">
                    <div class="special-middle" style="text-align:center!important;">
                      <div>评审意见 </div>
                    </div>
                  </a-col>
                  <a-col :span="16">
                    <div>
                      <a-form-model-item prop="remark">
                        <a-textarea placeholder="评审意见" v-model="formData.remark" :maxLength="1000" style="width: 80%; height: 120px; margin-top: 6px" />
                      </a-form-model-item>
                    </div>
                  </a-col>
                  <a-col :span="2">
                    <div class="special-middle" style="text-align:center!important;">
                      <div>总分</div>
                    </div>
                  </a-col>
                  <a-col :span="3">
                    <div class="special-middle" style="text-align:center!important;">
                      <div>{{scoreCount ()}}</div>
                    </div>
                  </a-col>
                </a-row>
              </a-form-model>
            </div>
            <div style="height:40px;width:100%;text-align:center;padding:4px 0px;background: #fafafa;border:1px solid #e8e8e8; border-width: 0px 1px 1px 1px;border-style: solid;border-color: #e8e8e8;">
              <a-button @click="save" style="margin-right:16px">保存</a-button>
              <a-button type="primary" @click="submit">提交</a-button>
            </div>
          </div>
          <div v-show="tabsActive==='2'" style="height:100%;overflow: auto;">
            <project-view v-model="formData.projId" />
          </div>
        </div>
      </div>
      <div v-else style="width: 100%;height: 100%;">
        <div style="height:calc(100% - 40px);overflow: auto;">
          <div style="text-align:center;">
	<span style="line-height:2;"><strong>内蒙古自治区卫生健康委首府地区公立医院高水平临床专科建设科技项目</strong></span>
</div>
<div style="text-align:center;">
	<span style="line-height:2;"><strong>评审专家须知</strong></span>
</div>
<span style="line-height:2;">尊敬的专家：</span><br />
<span style="line-height:2;">&nbsp; &nbsp; &nbsp; &nbsp;您好，感谢您参与此次内蒙古自治区卫生健康委首府地区公立医院高水平临床专科建设科技项目网上评审。为做好此次评审工作，现将相关事宜通知如下，请务必仔细阅读和严格执行。</span><br />
<span style="line-height:2;">一、评审专家根据评价指标对本组所有申报项目（由于申报专业的不同，其中可能会有部分跨专业的项目，请专家一并评审打分，切勿遗漏）进行评阅打分，写出具体的评审意见及建议立项或不立项的主要原因。</span><br />
<span style="line-height:2;">二、为调动广大医务工作者参与科研工作的积极性，请在评审过程中按照评分标准打分，确保项目质量。</span><br />
<span style="line-height:2;">三、如申报项目涉及国家安全问题和其他可能造成不良舆论和后果的，或是存在境外机构或人员参与的，专家要从严审查审核。经评审确有不适宜公开的信息及数据或不适宜的观点及言论，可能危害国家安全或造成不良影响的项目，可评分为“0”并及时向我委具体负责同志反馈。</span><br />
<span style="line-height:2;">四、为贯彻落实2024年国务院《政府工作报告》中关于“加强健康、养老等民生科技研发应用”的要求，请专家在确保质量的情况下，重点关注“可实现成果转化或临床应用”的申报项目。</span><br />
<span style="line-height:2;">五、请严格遵守各项法律法规和评审纪律，评审工作做到实事求是、客观公正、科学规范、廉洁自律。</span><br />
<span style="line-height:2;">六、此次评审时间为2024年07月30日至2024年08月01日，请务必于2024年08月01日 24:00前提交评审结果。</span><br />
<span style="line-height:2;">&nbsp; &nbsp; &nbsp; 再次感谢您对我们工作的大力支持，未尽事宜，另行通知。</span><br />
<span style="line-height:2;">&nbsp; &nbsp; &nbsp; 联系电话：0471-6946011</span><br />
<br />
        </div>
        <div style="height:40px;width:100%;text-align:center;padding:4px 0px;background: #fafafa;border:1px solid #e8e8e8; ">
          <a-button type="primary" @click="loadExpertInfo" :disabled="check.disabled">{{check.title}}</a-button>
        </div>
      </div>
    </a-spin>
  </div>
</template>

<script>
import { getType } from '@/views/utils/auth'
import { isEmptyParams } from "@/views/utils/common"
import { budgetList } from '@/views/report/project/config'
import moment from 'moment'
import projectView from '@/views/evaluation/components/projectView'

export default {
  name: "score",
  components: {
    projectView
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null;
      },
    },
  },
  data () {
    return {
      loading: false,
      isShow: false,
      isExpertInfoLoad: false,
      isProjectInfoLoad: false,
      tabsActive: '1',
      check: {
        time: 10, title: '我已阅读', count: 10, disabled: false,
      },
      formData: { id: null, projId: null, expertId: null, expertName: null, projectBasis: null, academicValue: null, innovation: null, researchPlan: null, expectedResults: null, totalScore: null, remark: null, projName: null, projNo: null, },
      tableData: [
        {
          title: '立项依据', meaning: '立足于重大疾病、常见病和多发病防治新技术、新方法的研究项目，在医药卫生工作中有较好的应用前景。', child: [
            '立项依据充分，科学性较强，研究内容明确。',
            '立项依据充分，有科学性，研究内容较明确。',
            '立项依据欠充分，研究内容一般，科学性不强。',
            '立项依据不充分，研究内容欠明确，缺乏科学性。'], score: 10, grade: null
        },
        {
          title: '项目研究的学术价值和发展趋势分析', meaning: '项目在国际及省内外的发展现状分析情况，以及对未来发展趋势的预测。', child: [
            '科研思路清晰，条理清楚、能透彻分析国际和省内外发展现状，准确把握项目实施、发展趋势。',
            '科研思路清晰，条理较清楚、了解国际和省内外发展现状，能够准确把握项目实施、发展趋势。',
            '科研思路基本成立，条理清楚、基本了解国际和省内外发展现状，基本把握项目实施。',
            '科学性不强，条理性差，对发展现状及趋势不清楚，项目实施不到位。'], score: 10, grade: null
        },
        {
          title: '创新性与科学意义', meaning: '指与省内外同类技术相比，其总体技术水平、研究方法、技术参数、临床效果或应用前景指标等所处的位置。', child: [
            '学术思想新颖，有明显的创新和特色，创造性突出，有重大科学意义和很好应用前景。',
            '学术思想较好，有一定的创新性和特色，有较大的科学意义和较好的应用前景。',
            '学术思想一般，无创新性，有一定的科学意义和一般的应用前景。',
            '学术思想一般，科学意义不大或应用前景较小。'], score: 30, grade: null
        },
        {
          title: '研究方案', meaning: '指项目的研究内容、研究方法和技术路线等。', child: [
            '研究内容适合我省目前卫生计生事业发展需求；重点突出，拟解决的关键问题选择准确，研究方法可行，具有创新性；技术路线先进、合理。',
            '研究内容符合我省目前卫生计生事业发展需求，关键问题选择较准确，研究方法可行，对现有方法有改进；技术路线合理、可行。',
            '研究内容较符合我省目前卫生计生事业需求，关键问题选择较准确；研究方法可行；技术路线可行。',
            '研究内容不够适合我省需求，只抓住部分关键问题；研究方法可行住不足；技术路线基本合理。'], score: 30, grade: null
        },
        {
          title: '预期结果', meaning: '指通过该项目的实施，在科技进步、人民健康或人才培养等方面可能产生的社会或经济效应等。具有自主知识产权的项目可酌情加分。', child: [
            '实用性理，应用前景广阔，具有明显的社会、经济效益，在基层有指导推广作用。可实现技术跨越，对专业技术进步、人民健康或人才培养作用显著。',
            '实用性较强，可在一定范围应用，可取得较好的社会、经济效益；对行业科技进步、人民健康、人才培养作用明显。',
            '实用性一般，可部分应用，社会、经济效益一般，可使技术水平有所提高，对行业科技进步、人民健康、人才培养作用一般。',
            '实用性较差或难以应用；较难实现社会或经济效益；难以推动行业技术水平提高。'], score: 20, grade: null
        },
      ],
      rules: {
        projectBasis: { required: true, message: '*', trigger: 'blur' },
        academicValue: { required: true, message: '*', trigger: 'blur' },
        innovation: { required: true, message: '*', trigger: 'blur' },
        researchPlan: { required: true, message: '*', trigger: 'blur' },
        expectedResults: { required: true, message: '*', trigger: 'blur' },
        remark: { required: true, message: '*', trigger: 'blur' }
      },
      projectInfo: {
        projName: '',
        startDate: '',
        endDate: '',
        applyMoney: '',
        projClassName: '',
        appPersonName: '',
        sex: '',
        titleName: '',
        degreeName: '',
        specName: '',
        jobUnit: '',
        mobile: '',
        address: '',
        appUnitName: '',
        linkName: '',
        linkEmail: '',
        linkTel: '',
        knowledgeName: '',
        projContent: '',
        projTarget: '',
        projKeywords: '',
        // 合作单位
        together: [],
        // 项目组成员
        members: [],
        // 经费
        budget: budgetList(),
        projDoc: null,
        fileList: [],
        auditList: [],
      },
      comBatch: { expertStart: '', expertEnd: '' },
    };
  },
  created () {
    this.getAssignExpertById()
    this.getYear()
    this.countStart()
  },
  methods: {
    moment,
    getYear () {
      this.$api.batch.getCurrentYearBatch({ type: 5, projType: getType() }).then(({ data = {} }) => {
        if (data) {
          this.comBatch = data
        }
      }).catch(() => { this.loading = false })
    },
    countStart () {
      this.check.disabled = true
      this.check.title = '阅读中...(' + this.check.count + 's)'
      let time = setInterval(() => {
        if (this.check.count == 1) {
          clearInterval(time)
          this.check.title = '我已阅读'
          this.check.count = this.check.time
          this.check.disabled = false
        } else {
          this.check.count--
          this.check.title = '阅读中...(' + this.check.count + 's)'
        }
      }, 1000)
    },
    loadExpertInfo () {
      this.isShow = true
      if (!this.isExpertInfoLoad)
        this.loading = false
    },
    getAssignExpertById () {
      if (!!this.value) {
        this.loading = true
        this.$api.projectAssign.getAssignExpertById({ id: this.value }).then(({ data = {} }) => {
          if (data) {
            this.formData = data
            this.getProjectInfoById(data.projId)
            this.isExpertInfoLoad = true
            this.loading = false
          } else
            this.$emit('close', 'error')
        }).catch(() => {
          this.$message.warn('500 Internal Server Error！')
          this.$emit('close', 'error')
        })
      }
    },
    getProjectInfoById (id) {
      this.$api.project.getProjectInfoById({ id: id }).then(({ data = {} }) => {
        if (data) {
          let fileArr = []
          this.projectInfo = data
          for (let i = 0; i < this.projectInfo.fileList.length; i++) {
            if (this.projectInfo.fileList[i].fileExplain.indexOf("项目申报简要信息首页") == -1 && this.projectInfo.fileList[i].fileExplain.indexOf("项目组成员签字") == -1)
              fileArr.push(this.projectInfo.fileList[i])
          }
          this.projectInfo.fileList = fileArr
          this.isProjectInfoLoad = true
          this.loading = false
        } else
          this.$emit('close', 'error')
      }).catch(() => {
        this.$message.warn('500 Internal Server Error！')
        this.$emit('close', 'error')
      })
    },
    scoreCount () {
      let total = 0.0
      if (!!this.formData.projectBasis)
        total = (total * 100 + this.formData.projectBasis * 100) / 100
      if (!!this.formData.academicValue)
        total = (total * 100 + this.formData.academicValue * 100) / 100
      if (!!this.formData.innovation)
        total = (total * 100 + this.formData.innovation * 100) / 100
      if (!!this.formData.researchPlan)
        total = (total * 100 + this.formData.researchPlan * 100) / 100
      if (!!this.formData.expectedResults)
        total = (total * 100 + this.formData.expectedResults * 100) / 100
      this.formData.totalScore = total
      return total
    },
    callback (key) {
      this.tabsActive = key
    },
    save () {
      if (this.checkInfo()) {
        this.loading = true
        if (!this.formData.auditState || this.formData.auditState == 0)
          this.formData.auditState = 1
        let pars = isEmptyParams(this.formData)
        let par = { ...pars }
        this.$api.projectAssign.expertEvaluation(par).then(({ data = {} }) => {
          if (data) {
            this.$message.success('保存成功')
            this.$emit('close', 'save')
          }
          this.loading = false
        }).catch(() => { this.loading = false })
      } else {
        this.$message.warn('请填写信息后再保存！')
      }
    },
    checkInfo () {
      if (!!!this.formData.totalScore && !!!this.formData.remark) {
        return false
      } else {
        return true
      }
    },
    submit () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.loading = true
          this.formData.auditState = 2
          let pars = isEmptyParams(this.formData)
          let par = { ...pars }
          this.$api.projectAssign.expertEvaluation(par).then(({ data = {} }) => {
            if (data) {
              this.$message.success('提交成功')
              this.$emit('close', 'submit')
            }
            this.loading = false
          }).catch(() => { this.loading = false })
        } else { this.tabsActive = '1' }
      })
    },
  },
};
</script>
<style scoped lang="less">
.app-content {
  ::v-deep.ant-spin-nested-loading .ant-spin-container {
    height: 100%;
  }
  .table-content {
    height: calc(100% - 40px);
    border-width: 0px 1px 1px 1px;
    border-style: solid;
    border-color: #e8e8e8;

    // border:1px solid #e8e8e8;

    padding: 6px 6px;
  }
  padding: 0;
  ::v-deep.ant-tabs .ant-tabs-bar {
    margin: 0 !important;
  }
  ::v-deep
    .ant-tabs
    .ant-tabs-bar
    .ant-tabs-nav-container
    .ant-tabs-nav-wrap
    .ant-tabs-nav-scroll
    .ant-tabs-nav
    .ant-tabs-tab {
    min-width: 160px !important;
    text-align: center;
  }
}
</style>
ant-tabs