<template>
  <div style="padding:10px">
    <h2 style="text-align: center;">综合事务部考核表</h2>
    <table class="table" ref="tableDatas">
      <tr>
        <td class="table-title">姓名</td>
        <td style="text-align:left;padding-left:10px;">{{ tableForm.nickName }}</td>
        <td class="table-title" style="width:50px">考核时间</td>
        <td>
          <el-date-picker v-model="tableForm.assessTime" type="month" placeholder="选择日期">
          </el-date-picker>
        </td>
        <td colspan="3" class="table-title">部门负责人考核意见</td>
        <td colspan="3" class="table-title" style="width:300px">分管领导考核意见</td>
      </tr>
      <tr>
        <td class="table-title">所在部门</td>
        <td colspan="3" style="text-align:left;padding-left:10px;">{{ tableForm.deptName }}</td>
        <td colspan="3">
          <el-radio-group v-model="tableForm.deptAssessment" :disabled="!isDeptLeader">
            <el-radio v-for="dict in dict.type.cmc_accessment" :key="dict.value" :label="dict.value">
              {{ dict.label }}
            </el-radio>
          </el-radio-group>
        </td>
        <td colspan="3">
          <el-radio-group v-model="tableForm.managerAssessment" :disabled="!isManager">
            <el-radio v-for="dict in dict.type.cmc_accessment" :key="dict.value" :label="dict.value">
              {{ dict.label }}
            </el-radio>
          </el-radio-group>
        </td>
      </tr>
      <tr>
        <td class="table-title">部门职务</td>
        <td colspan="3" style="text-align:left;padding-left:10px;">{{ tableForm.postGroup }}</td>
        <td colspan="3" rowspan="3">
          <el-input type="textarea" :rows="4" placeholder="请输入考核意见" v-model="tableForm.deptAdvice"
            :disabled="!isDeptLeader">
          </el-input>
          <el-row justify="center" type="flex">
            <el-col :span="12" style="text-align:center; padding-top:7px;">考核人：
              <span class="auditor"> {{ tableForm.deptAssesser ? tableForm.deptAssesser : deptAssesser }} </span>
            </el-col>
            <el-col :span="12" style="text-align:center; padding-top:7px;">日期：
              <span> {{ tableForm.deptTime ? tableForm.deptTime : deptTime }} </span>
            </el-col>
          </el-row>
        </td>
        <td colspan="3" rowspan="3">
          <el-input type="textarea" :rows="4" placeholder="请输入考核意见" v-model="tableForm.managerAdvice"
            :disabled="!isManager">
          </el-input>
          <el-row justify="center">
            <el-col :span="12" style="text-align:center; padding-top:7px;">考核人：
              <span class="auditor"> {{ tableForm.managerAssesser ? tableForm.managerAssesser : managerAssesser
              }} </span>
            </el-col>
            <el-col :span="12" style="text-align:center; padding-top:7px;">日期：
              <span> {{ tableForm.managerTime ? tableForm.managerTime : managerTime }} </span>
            </el-col>
          </el-row>
        </td>
      </tr>
      <tr>
        <td class="table-title">技术职称</td>
        <td colspan="3" style="text-align:left;padding-left:10px;">{{ tableForm.titles }}</td>
      </tr>
      <tr>
        <td class="table-title">入职年月</td>
        <td style="text-align:left;padding-left:10px;">{{ tableForm.entryDate != null ?
          tableForm.entryDate.substring(0, 10) : tableForm.entryDate }}</td>
        <td class="table-title">年龄</td>
        <td style="text-align:left;padding-left:10px;">{{ tableForm.age }}</td>
      </tr>
      <tr>
        <td rowspan="2" class="table-title">考核内容</td>
        <td colspan="5" class="table-fillin">被考核人填写</td>
        <td colspan="3" class="table-fzr" style="width:300px;">负责人考核</td>
      </tr>
      <tr>
        <td class="table-fillin">工作内容</td>
        <td class="table-fillin">单位</td>
        <td class="table-fillin">工作量</td>
        <td class="table-fillin">参与情况</td>
        <td class="table-fillin">备注</td>
        <td class="table-fzr">工作量</td>
        <td class="table-fzr">岗位综合表现</td>
        <td class="table-fzr">考核建议</td>
      </tr>
      <tr>
        <td rowspan="8">劳动组织</td>
        <td>组织会议</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0101 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0101"></el-input>
        </td>
        <td rowspan="8">
          <el-radio-group v-model="tableForm.role01" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>

        <td rowspan="8">
          <div v-if="!isStaff">{{ tableForm.remark01 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark01" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="8">
          <el-radio-group v-model="tableForm.workload01" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload01', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="8">
          <el-radio-group v-model="tableForm.assessment01" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment01', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="8">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice01" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>组织培训</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0102 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0102"></el-input>
        </td>
      </tr>
      <tr>
        <td>组织考察</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0103 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0103"></el-input>
        </td>
      </tr>
      <tr>
        <td>组织接待</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0104 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0104"></el-input>
        </td>
      </tr>
      <tr>
        <td>组织宣传</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0105 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0105"></el-input>
        </td>
      </tr>
      <tr>
        <td>公司发文管理</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0106 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0106">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>企业微信、公司官方群、公司网站维护</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0107 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0107">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>公司资质、员工信息更新、维护（含OA）</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0108 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0108">
          </el-input>
        </td>
      </tr>

      <!--  -->

      <tr>
        <td rowspan="5">设备物资</td>
        <td>设备、物资采购</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0201 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0201"></el-input>
        </td>
        <td rowspan="5">
          <el-radio-group v-model="tableForm.role02" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>
        <td rowspan="5">
          <div v-if="!isStaff">{{ tableForm.remark02 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark02" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="5">
          <el-radio-group v-model="tableForm.workload02" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload02', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="5">
          <el-radio-group v-model="tableForm.assessment02" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment02', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="5">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice02" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>物资、仪器设备领用、归还</td>
        <td>项</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0202 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0202"></el-input>
        </td>
      </tr>
      <tr>
        <td>设备维修</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0203 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0203"></el-input>
        </td>
      </tr>
      <tr>
        <td>设备检定</td>
        <td>台套</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0204 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0204"></el-input>
        </td>
      </tr>
      <tr>
        <td>设备保险办理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0205 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0205"></el-input>
        </td>
      </tr>
      <!--  -->

      <tr>
        <td rowspan="7">人力资源</td>
        <td>招聘（校招、社招、内部竞聘）</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0301 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0301"></el-input>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.role03" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <div v-if="!isStaff">{{ tableForm.remark03 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark03" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.workload03" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload03', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.assessment03" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment03', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice03" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>薪酬、考勤休假办理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0302 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0302"></el-input>
        </td>
      </tr>
      <tr>
        <td>社保三险办理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0303 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0303"></el-input>
        </td>
      </tr>
      <tr>
        <td>入、离职、退休办理</td>
        <td>台套</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0304 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0304"></el-input>
        </td>
      </tr>
      <tr>
        <td>劳动合同办理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0305 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0305"></el-input>
        </td>
      </tr>
      <tr>
        <td>绩效考评管理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0306 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0306"></el-input>
        </td>
      </tr>
      <tr>
        <td>职称管理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0307 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0307"></el-input>
        </td>
      </tr>

      <!--  -->
      <tr>
        <td rowspan="10">车辆管理</td>
        <td>车辆采购</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0401 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0401"></el-input>
        </td>
        <td rowspan="10">
          <el-radio-group v-model="tableForm.role04" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>
        <td rowspan="10">
          <div v-if="!isStaff">{{ tableForm.remark04 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark04" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="10">
          <el-radio-group v-model="tableForm.workload04" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload04', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="10">
          <el-radio-group v-model="tableForm.assessment04" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment04', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="10">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice04" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>车辆保险购置</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0402 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0402"></el-input>
        </td>
      </tr>
      <tr>
        <td>生产项目用车（安排）</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0403 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0403"></el-input>
        </td>
      </tr>
      <tr>
        <td>出差用车（安排）</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0404 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0404"></el-input>
        </td>
      </tr>
      <tr>
        <td>市周边临时驾驶接送（安排）</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0405 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0405"></el-input>
        </td>
      </tr>
      <tr>
        <td>驾驶车辆参与项目生产</td>
        <td>人天</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0406 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0406"></el-input>
        </td>
      </tr>
      <tr>
        <td>驾驶车辆参与出差</td>
        <td>人天</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0407 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0407"></el-input>
        </td>
      </tr>
      <tr>
        <td>年度驾驶里程</td>
        <td>km</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0408 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0408"></el-input>
        </td>
      </tr>
      <tr>
        <td>车辆维修保养</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0409 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0409"></el-input>
        </td>
      </tr>
      <tr>
        <td>车辆保险理赔</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0410 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0410"></el-input>
        </td>
      </tr>
      <!--  -->
      <tr>
        <td rowspan="7">办公区维护</td>
        <td>办公区办公设施检修</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0501 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0501"></el-input>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.role05" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <div v-if="!isStaff">{{ tableForm.remark05 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark05" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.workload05" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload05', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <el-radio-group v-model="tableForm.assessment05" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment05', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="7">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice05" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>办公区安全检查</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0502 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0502"></el-input>
        </td>
      </tr>
      <tr>
        <td>办公区绿植、送水统计</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0503 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0503"></el-input>
        </td>
      </tr>
      <tr>
        <td>办公区电子显示屏展示宣传</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0504 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0504"></el-input>
        </td>
      </tr>
      <tr>
        <td>办公区电子信息维护（电话、网络、电脑）</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0505 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0505"></el-input>
        </td>
      </tr>
      <tr>
        <td>会议室管理</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0506 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0506"></el-input>
        </td>
      </tr>
      <tr>
        <td>工作餐订制、快递、报纸收发</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0507 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0507"></el-input>
        </td>
      </tr>
      <!--  -->
      <tr>
        <td rowspan="2">党群、董事会</td>
        <td>党总支日常工作</td>
        <td>次</td>
        <td class="personInput">
          <span v-if="!isStaff">{{ tableForm.f0701 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0701"></el-input>
        </td>
        <td rowspan="2">
          <el-radio-group v-model="tableForm.role07" :disabled="!isStaff">
            <div><el-radio label="00">主办</el-radio></div>
            <div><el-radio label="01">参与</el-radio></div>
            <div><el-radio label="02">协助</el-radio></div>
          </el-radio-group>
        </td>
        <td rowspan="2">
          <div v-if="!isStaff">{{ tableForm.remark07 }}</div>
          <el-input v-if="isStaff" v-model="tableForm.remark07" type="textarea" :rows="4"></el-input>
        </td>
        <td rowspan="2">
          <el-radio-group v-model="tableForm.workload07" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_workload" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'workload07', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="2">
          <el-radio-group v-model="tableForm.assessment07" :disabled="!isPiLeader">
            <div v-for="dict in dict.type.cmc_accessment" style="text-align:left">
              <el-radio :key="dict.value" :label="dict.value"
                @click.native.prevent="cancelSelect(dict.value, 'assessment07', isStaff)">
                {{ dict.label }}
              </el-radio>
            </div>
          </el-radio-group>
        </td>
        <td rowspan="2">
          <el-input type="textarea" :rows="4" v-model="tableForm.advice07" :disabled="!isPiLeader">
          </el-input>
        </td>
      </tr>
      <tr>
        <td>董事会日常工作</td>
        <td>次</td>
        <td>
          <span v-if="!isStaff">{{ tableForm.f0702 }}</span>
          <el-input v-if="isStaff" v-model="tableForm.f0702"></el-input>
        </td>
      </tr>
      <!--  -->

      <tr style="height:90px;">
        <td>其他工作</td>
        <td colspan="9">
          <span v-if="!isStaff">{{ tableForm.otherWork }}</span>
          <el-input v-if="isStaff" v-model="tableForm.otherWork" type="textarea" :rows="2"></el-input>
        </td>
      </tr>
      <tr style="height:90px;">
        <td>年度自述</td>
        <td colspan="9">
          <span v-if="!isStaff">{{ tableForm.selfAssess }}</span>
          <el-input v-if="isStaff" v-model="tableForm.selfAssess" type="textarea" :rows="2"></el-input>
        </td>
      </tr>
    </table>
    <el-row justify="center" type="flex" style="margin-top:20px;">
      <el-button type="primary" size="mini" @click="submit">{{ taskName == '员工填报' ? '提交' : '审核通过' }}</el-button>
      <el-button v-if="taskName == '员工填报'" type="warning" size="mini" @click="$emit('close')">取消</el-button>
    </el-row>
  </div>
</template>

<script>
import { parseTime } from "@/utils/ruoyi";
import { mapGetters } from "vuex";
import { JYContent } from '@/assets/datas/JYContent'
import { getDicts as getDicts } from '@/api/system/dict/data'
import { complete, getNextFlowNode } from "@/api/flowable/todo";
import { getAssess, modifyAssess, submitAssess, listAssess } from '@/api/oa/assess/assess';
import { getUsersDeptLeader, getUsersManageLeader } from '@/api/system/post.js'
export default {
  dicts: ['cmc_role', 'cmc_skill', 'cmc_accessment', 'cmc_workload'],
  props: {
    taskName: {
      type: String
    },
    taskForm: {
      type: Object
    }
  },
  watch: {
    tableForm: function (newval, oldval) {
      this.formatForm();
    }
  },
  data() {
    return {
      deptAssesser: '',
      deptTime: undefined,
      managerAssesser: '',
      managerTime: undefined,
      tableForm: {},
      form: {},
      radio1: "",
      radio2: "",
      textarea1: "",
      textarea2: "",
      isDeptLeader: false,
      isPiLeader: false,
      isManager: false,
      isStaff: false,
    }
  },
  computed: {
    ...mapGetters(["userId", "name"]),
  },
  created() {
    if (this.taskName == '部门审核') {
      this.deptTime = parseTime(new Date(), '{y}-{m}-{d}')
      this.deptAssesser = this.name;
    }
    else if (this.taskName == '分管审核') {
      this.managerTime = parseTime(new Date(), '{y}-{m}-{d}')
      this.managerAssesser = this.name;
    }
    this.initForm();
  },
  mounted() {
    this.formatForm();
  },
  methods: {
    initForm() {
      getAssess(this.taskForm.formId).then(res => {
        let data = res.data;
        for (let d in data) {
          // if (d.includes('role')) {
          //   if (data[d] != "" && data[d] != undefined && data[d] != null)
          //     data[d] = data[d].split(',')
          // }
          if (d.includes('familiar')) {
            if (data[d] != "" && data[d] != undefined && data[d] != null)
              data[d] = parseInt(data[d])
          }
        }
        this.tableForm = data;
      })
    },
    formatForm() {

      if (this.taskName == '部门审核') {
        this.isPiLeader = true;
        this.isDeptLeader = true;
        this.isManager = false;
        this.isStaff = false;
      } else if (this.taskName == '分管审核') {
        this.isPiLeader = false;
        this.isDeptLeader = false;
        this.isManager = true;
        this.isStaff = false;
      } else if (this.taskName == '员工填报') {
        this.isPiLeader = false;
        this.isDeptLeader = false;
        this.isManager = false;
        this.isStaff = true;
      }
    },
    submit() {
      let flag = this.formValidate(this.tableForm)
      if (flag) {
        // this.$emit('submit', this.tableForm);
        let formData = new FormData();
        this.tableForm.formId = this.taskForm.formId;
        this.tableForm.assessType = '2';
        let form = JSON.stringify(this.tableForm);
        formData.append("form", form);
        listAssess({ assessId: this.tableForm.formId }).then(result => {
          let list = result;
          if (list.total != 0) {
            modifyAssess(formData);
          } else {
            submitAssess(formData);
          }
        })
        const params = { taskId: this.taskForm.taskId }
        getNextFlowNode(params).then(res => {
          if (this.taskName == '员工填报') {
            getUsersDeptLeader({ userId: this.tableForm.userId }).then(res => {
              if (res.data)
                this.$set(this.taskForm.variables, "approval", res.data.userId);
              complete(this.taskForm).then(response => {
                this.$modal.msgSuccess(response.msg);
                this.$emit("goBack");
              });
            })
          } else if (this.taskName == '部门审核') {
            getUsersManageLeader({ userId: this.tableForm.userId }).then(res => {
              let userId = res.data[0].userId;
              this.$set(this.taskForm.variables, "approval", userId);
              complete(this.taskForm).then(response => {
                this.$modal.msgSuccess(response.msg);
                this.$emit("goBack");
              });
            })
          } else if (this.taskName == '分管审核') {
            complete(this.taskForm).then(response => {
              this.$modal.msgSuccess(response.msg);
              this.$emit("goBack");
            });
          }
        })
      }
    },
    formValidate(form) {
      let flag = [];
      for (let f in form) {

        if (f.startsWith('familiar') && form[f] != null) {
          flag.push(f.slice(-2));
        } else if (f.length == 5 && f.startsWith('f')) {
          if (form[f] != "" && form[f] != undefined && form[f] != null)
            flag.push(f.substring(1, 3));
        }
      }
      let isF = false;
      if (flag.length == 0) {
        this.$modal.msgError("表格未填写，请填写表格");
      } else {
        isF = true
      }
      return isF
    },
    cancelSelect(value, name, disabled) {
      if (disabled) {
        return
      }
      if (this.isStaff) {
        if (this.tableForm[name] == value) {
          this.tableForm[name] = null
        } else {
          if (this.tableForm[name] !== undefined)
            this.tableForm[name] = value
          else {
            this.$set(this.tableForm, name, value)
          }
        }
      }
      if (this.isPiLeader) {
        if (this.tableForm[name] == value) {
          this.tableForm[name] = null
        } else {
          if (this.tableForm[name] !== undefined)
            this.tableForm[name] = value
        }
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.table {
  border-collapse: collapse;
  width: 100%;
}

.table-title {
  background-color: #90d6f1;
  font-weight: bold;
}

.table-fillin {
  background-color: #bfee93;
  font-weight: bold;
}

.table-fzr {
  background-color: #eead93;
  font-weight: bold;
}


.table,
th,
td {
  border: 1px solid black;
  text-align: center;
}

td {
  height: 50px;
  // width: 100px;
}

.head {
  background-color: #ccc;
}

::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #fff;
}

::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  background-color: #409eff;
  border-color: #409eff;
}

::v-deep .el-checkbox__input.is-disabled+span.el-checkbox__label {
  color: #000;
}

::v-deep .el-checkbox__label {
  font-size: 12px;
}

::v-deep .el-radio__input.is-disabled .el-radio__inner,
.el-radio__input.is-disabled.is-checked .el-radio__inner {
  background-color: #f1f1f1;
  border-color: #f1f1f1;
}

::v-deep .el-radio__input.is-disabled+span.el-radio__label {
  color: #000;
}


::v-deep .el-radio__input.is-checked .el-radio__inner::after {
  content: "";
  width: 10px;
  height: 5px;
  border: 2px solid #409eff;
  border-top: transparent;
  border-right: transparent;
  text-align: center;
  display: block;
  position: absolute;
  top: 2px;
  left: 2px;
  vertical-align: middle;
  transform: rotate(-45deg);
  border-radius: 0px;
  background: none;
}
</style>