<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%;">
        <div style="height: 40px;">
          <a-tabs type="card" @change="callback" :activeKey='tabsActive'>
            <a-tab-pane key="1" tab="评分"></a-tab-pane>
            <!-- <a-tab-pane key="2" tab="指标说明" v-if="totalFunding > 50"></a-tab-pane> -->
            <a-tab-pane key="3" tab="项目信息"></a-tab-pane>
          </a-tabs>
        </div>
        <div class="table-content" style="overflow: auto;height: calc(100% - 40px);">
          <div v-show="tabsActive==='1'" style="height:100%;">
            <div style="height:calc(100% - 40px);overflow: auto;" ref="main">
              <div class="x_modal_content">
                <a-form-model ref="form" :model="formData" :rules="rules" class="from-table font-line-space">
                  <score-edit v-model="formData" />
                  <!-- <economy-edit v-model="formData" v-if="formData.expertType == 2" />
                  <div v-else>
                    <technology-evalucation v-model="formData"></technology-evalucation>                    
                  </div> -->
                </a-form-model>
              </div>
            </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>
              <span style="color: red;">（注：提交后在规定时间内可多次修改）</span>
            </div>
          </div>
          <div v-show="tabsActive==='2'" style="height:100%;overflow: auto;">
            <span style="line-height:2;">1. 意义及必要性</span><br />
            <span style="line-height:2;">（1）项目实施的意义及必要性：评价项目实施对相关科技创新工作提升的意义和必要性。</span><br />
            <span style="line-height:2;">2. 目标及考核指标</span><br />
            <span style="line-height:2;">（1）目标定位及可考核性：评价项目目标是否集中，定位是否准确合理；考核指标及预期提交的成果是否量化可考。</span><br />
            <span style="line-height:2;">（2）绩效目标设置合理性：评价项目绩效目标是否与研究内容及项目目标定位相匹配，分年度绩效目标设置是否合理。</span><br />
            <span style="line-height:2;">3. 主要内容</span><br />
            <span style="line-height:2;">（1）研发内容与目标实现关联度：评价项目提出的研发内容能否保障项目目标实现。</span><br />
            <span style="line-height:2;">（2）研究成果产业化成熟度：评价项目研究成果实现产业化的预期。</span><br />
            <span style="line-height:2;">（3）产业化市场竞争力及预期效益：评价项目产业化市场竞争力以及预期效益分析是否合理。</span><br />
            <span style="line-height:2;">4. 技术路线与实施方案</span><br />
            <span style="line-height:2;">（1）技术路线和实施方案设计：评价项目采用的技术路线和实施方案是否科学、合理、可行。</span><br />
            <span style="line-height:2;">（2）技术关键选择及创新性先进性：评价研究关键技术选择的准确性、创新性及先进性。</span><br />
            <span style="line-height:2;">（3）年度计划安排：评价研究内容及目标任务分解、阶段目标设置和时间安排的合理性。</span><br />
            <span style="line-height:2;">5. 工作基础及支撑条件</span><br />
            <span style="line-height:2;">（1）负责人及团队创新能力：评价项目负责人和团队创新能力是否满足项目要求。</span><br />
            <span style="line-height:2;">（2）研发平台及科研条件保障：评价是否具备项目顺利实施所需要的设备设施、场地、平台等基础设施科研条件保障。</span><br />
            <span style="line-height:2;">（3）前期工作基础：评价申报项目前期工作对支撑项目实施的能力。</span><br />
            <span style="line-height:2;">6. 组织运行与管理</span><br />
            <span style="line-height:2;">（1）经费预算合理性：评价项目经费总体预算及分配使用计划是否合理。</span><br />
            <span style="line-height:2;">（2）任务分工和权益分配：评价项目承担单位与参与单位之间以及团队人员之间是否有明确的分工，项目产生的权益分配是否明确合理。</span><br />
            <span style="line-height:2;">（3）项目组织协调及管理措施：评价是否具备为保障项目顺利实施所需要的组织协调及管理措施。</span><br />
            <span style="line-height:2;">7．项目风险分析</span><br />
            <span style="line-height:2;">（1）项目组织实施风险：评价项目组织实施是否存在风险。</span><br />
            <span style="line-height:2;">（2）目标实现风险：评价项目目标实现是否存在风险。</span>
          </div>
          <div v-show="tabsActive==='3'" style="height:100%;overflow: auto;">
            <project-info v-model="projectInfo" :tabsData.sync="tabsData" />
            <!-- <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>
            <p class="MsoNormal">
              <span>&nbsp;</span>
            </p>
            <p class="MsoNormal" align="center" style="text-align:center;">
              <b><span style="font-size:18.0pt;font-family:方正小标宋简体;">专家须知<span></span></span></b>
            </p>
            <p class="MsoNormal">
              <span style="font-size:12.0pt;font-family:仿宋;">尊敬的专家：<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:仿宋;">您好！感谢您参与云南省卫生健康委临床医学中心科研项目的评审工作。为确保评审顺利进行，现将相关事宜通知如下，请您务必仔细阅读并严格执行。<span></span></span>
            </p>
            <p class="MsoNormal" style="margin-left:0cm;text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:黑体;">一、</span><span style="font-size:12.0pt;font-family:黑体;">评审要求<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.1pt;">
              <b><span style="font-size:12.0pt;font-family:仿宋;">（一）</span></b><span style="font-size:12.0pt;font-family:仿宋;">根据评价指标，认真评阅本组所有申报项目并打分。由于申报专业的不同，其中可能会有部分跨专业的项目，请一并评审打分，切勿遗漏。撰写评审意见时，要详细评价项目并说明立项或不立项的主要理由。<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.1pt;">
              <b><span style="font-size:12.0pt;font-family:仿宋;">（二）</span></b><span style="font-size:12.0pt;font-family:仿宋;">若项目有不适宜公开的信息、数据或观点，或涉及境外机构、人员，请您从严审查审核。经评审确有可能危害国家安全或造成不良舆论和影响的项目，可评为“<span>0</span>”分并向委科教处及时反馈。<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:黑体;">二、评审纪律<span></span></span>
            </p>
            <p class="MsoNormal" align="left" style="text-indent:24.1pt;">
              <b><span style="font-size:12.0pt;font-family:仿宋;">（一）</span></b><span style="font-size:12.0pt;font-family:仿宋;">请严格遵守评审活动规则和工作纪律，实事求是、独立、客观、公正地评审，提供高质量的评审意见，为科技管理决策提供参考。发现与项目或申请者存在利益关系或其他可能影响公正性的关系时，要主动申明并回避。<span></span></span>
            </p>
            <p class="MsoNormal" align="left" style="text-indent:24.1pt;">
              <b><span style="font-size:12.0pt;font-family:仿宋;">（二）</span></b><span style="font-size:12.0pt;font-family:仿宋;">严守保密规定，不得泄露项目内容及有关技术、商业秘密，不得与评审对象私下接触、联系、串通，不得索取或接受礼品、钱物、可能影响公正性的宴请或其他好处，不得剽窃、复制、泄露、引用或存留评审材料内容。<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:黑体;">三、评审时间<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:仿宋;">此次专家评审时间为：{{exportTime.expertStart + '至' + exportTime.expertEnd}}，请务必于{{exportTime.expertEnd}}前提交评审结果，以免影响后续工作的开展。<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:24.0pt;">
              <span style="font-size:12.0pt;font-family:仿宋;">感谢您对我们工作的大力支持！如有未尽事宜，我们将另行通知。<span></span></span>
            </p>
            <p class="MsoNormal" style="text-indent:264.0pt;">
              <span style="font-size:12.0pt;font-family:仿宋;">&nbsp;</span>
            </p>
            <p class="MsoNormal" style="text-align:right;text-indent:264pt;padding-right: 200px;">
              <span style="font-size:12.0pt;font-family:仿宋;">云南省卫生健康委科教处<span></span></span>
            </p>
            <span style="font-size:12.0pt;font-family:仿宋;">
              <div style="text-align:right;padding-right: 200px;">
                <span style="font-size:12pt;">联系电话：</span><span style="font-size:12pt;">0871-67195167</span>
              </div>
            </span>
          </div>
        </div>
        <div style="height:40px;width:100%;text-align:center;padding:4px 0px;background: #fafafa;border:1px solid #e8e8e8; ">
          <a-checkbox @change="onReadChange">我已阅读</a-checkbox>&nbsp;
          <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, getEvaluationType } from "@/views/utils/common"
import { budgetList } from '@/views/report/project/config'
import moment from 'moment'
import projectView from '@/views/evaluation/components/projectView'
import projectInfo from '@/views/evaluation/components/projectInfo'
import technologyEvalucation from '@/views/evaluation/components/technologyEvalucation'
import economyEdit from '@/views/evaluation/components/economyEdit'
import scoreEdit from '@/views/evaluation/components/scoreEdit'

export default {
  name: "score",
  components: {
    projectView, projectInfo, technologyEvalucation, economyEdit, scoreEdit
  },
  props: {
    value: {
      type: String,
      default: () => {
        return null;
      },
    },
    exportTime: {
      expertStart: {
        type: String,
        default: () => {
          return null;
        },
      },
      expertEnd: {
        type: String,
        default: () => {
          return null;
        },
      }
    },
    totalFunding: {
      type: Number,
      default: () => {
        return 0.00;
      },
    }
  },
  data () {
    return {
      loading: false,
      isShow: false,
      isExpertInfoLoad: false,
      isProjectInfoLoad: false,
      tabsActive: '1',
      check: {
        time: 5, title: '我已阅读', count: 5, disabled: false,
      },
      formData: {
        id: null, projId: null, expertId: null, expertName: null,
        score1: null, score2: null, score3: null, score4: null, score4: null, score5: null, score6: null, score7: null, score8: null, score9: null,
        score10: null, score11: null, score12: null, score13: null, score14: null, score15: null, score16: null, score17: null,
        totalScore: null, remark: null, supportState: null, projName: null, projNo: null, totalFunding: 0.00,
      },
      rules: {
        score1: { required: true, message: "*", trigger: "blur" },
        score2: { required: true, message: "*", trigger: "blur" },
        score3: { required: true, message: "*", trigger: "blur" },
        score4: { required: true, message: "*", trigger: "blur" },
        score5: { required: true, message: "*", trigger: "blur" },
        score6: { required: true, message: "*", trigger: "blur" },
        score7: { required: true, message: "*", trigger: "blur" },
        score8: { required: true, message: "*", trigger: "blur" },
        score9: { required: true, message: "*", trigger: "blur" },
        score10: { required: true, message: "*", trigger: "blur" },
        score11: { required: true, message: "*", trigger: "blur" },
        score12: { required: true, message: "*", trigger: "blur" },
        score13: { required: true, message: "*", trigger: "blur" },
        score14: { required: true, message: "*", trigger: "blur" },
        score15: { required: true, message: "*", trigger: "blur" },
        score16: { required: true, message: "*", trigger: "blur" },
        score17: { required: true, message: "*", trigger: "blur" },
        score18: { required: true, message: "*", trigger: "blur" },
        score19: { required: true, message: "*", trigger: "blur" },
        remark: [{ required: true, message: '请填写评审意见', trigger: 'blur' },],
        score18: { required: true, message: "*", trigger: "blur" },
        score19: { required: true, message: "*", trigger: "blur" },
        additionalScore: { required: true, message: "*", trigger: "blur" },
        recommendFunding: { required: true, message: "*", trigger: "blur" },
        // supportState: { required: true, message: "请选择是否支持立项", trigger: "blur" },
        evaluationType: { required: true, message: "*", trigger: "change" },
      },
      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: '' },
      tabsData: [
        { title: '全部', key: '0', isShow: true },
        { title: '项目基本信息', key: '1', isShow: true },
        //{ title: '项目组主要成员', key: '2', isShow: true },
        { title: '绩效目标表', key: '2', isShow: true },
        { title: '项目经费预算表', key: '3', isShow: true },
        { title: '申请书正文', key: '4', isShow: true },
        { title: '附件信息', key: '5', isShow: true },
        { title: '项目审核记录', key: '6', isShow: true },
      ],
    };
  },
  computed: {
    evaluationTypeA () {
      return getEvaluationType(0)
    },
    evaluationTypeB () {
      return getEvaluationType(1)
    },
    evaluationTypeC () {
      return getEvaluationType(2)
    },
  },
  created () {
    this.getAssignExpertById()
    this.getYear()
    this.countStart()
  },
  methods: {
    moment,
    getYear () {
      this.$api.batch.getCurrentYearBatch({ type: 5, projType: getType(), timeType: 1 }).then(({ data = {} }) => {
        if (data) {
          this.comBatch = data
        }
      }).catch(() => { this.loading = false })
    },
    countStart () {
      this.check.disabled = true
      this.check.title = '下一步'
    },
    onReadChange (e) {
      if (e.target.checked)
        this.check.disabled = false
      else
        this.check, disabled = true
    },
    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) {
          this.projectInfo = data
          this.formData.projName = data.projName
          this.formData.appUnitName = data.appUnitName
          this.formData.appPersonName = data.appPersonName
          this.formData.applyFunding = data.govFunding
          this.formData.recommendFunding = data.govFunding
          this.isProjectInfoLoad = true
          this.loading = false
        } else
          this.$emit('close', 'error')
      }).catch(() => {
        this.$message.warn('500 Internal Server Error！')
        this.$emit('close', 'error')
      })
    },
    callback (key) {
      this.tabsActive = key
    },
    changeScroll () {
      this.$refs.main.scrollTop = document.getElementsByClassName('x_modal_content')[0].offsetHeight
    },
    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'
          this.$message.error('评审信息未填写完全！')
          this.changeScroll()
        }
      })
    },
  },
};
</script>
<style scoped lang="less">
::v-deep .ant-spin-container {
  width: 100%;
  height: 100%;
}
.app-content {
  ::v-deep.ant-spin-nested-loading .ant-spin-container {
    height: 100%;
  }
  .table-content {
    border-width: 0px 1px 0px 1px;
    border-style: solid;
    border-color: #f0f0f0;
    // border: 0px 1px 1px 1px solid #f0f0f0;
    padding: 4px 4px 0px 4px;
  }
  ::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>
