<template>
    <lay-container fluid="true" class="organization-box">
      <div style="display: flex">
        <div :style="{ width: isFold ? `0px` : `230px` }" class="left-tree">
          <div v-if="!isFold">科室列表</div>
          <lay-tree v-show="!isFold" style="margin-top: 10px" :data="data" v-model:selectedKey="group_id"
            :showLine="false" @node-click="handleClick">
            <template #title="{ data }">
              <span :class="group_id == data.id ? 'isChecked' : ''">
                {{ data.name }}
              </span>
            </template>
          </lay-tree>
          <div class="isFold" @click="isFold = !isFold">
            &nbsp;<lay-icon v-if="!isFold" class="layui-icon-left"></lay-icon>
            <lay-icon v-else class="layui-icon-right"></lay-icon>
          </div>
        </div>
        <div style="flex: 1; padding: 10px; overflow: auto">
          <!-- table -->
          <lay-card>
            <lay-form>
              <lay-row>
                <lay-col :md="5">
                  <lay-form-item label="年度" label-width="80px">
                    <lay-date-picker type="year" v-model="yearmonth" placeholder="年度" allow-clear></lay-date-picker>
                  </lay-form-item>
                </lay-col>
                <lay-col :md="6">
                  <lay-form-item label="考评对象" label-width="80px">
                    <lay-select v-model="userId" :show-search="true" placeholder="请选择" :allowClear="true">
                      <lay-select-option v-for="item in dataSerSource" :value="item.id"
                        :label="item.nickname"></lay-select-option>
                    </lay-select>
                  </lay-form-item>
                </lay-col>
                <lay-col :md="5">
                  <lay-form-item label-width="20">
                    <lay-button style="margin-left: 20px" type="primary" size="sm" @click="toSearch">
                      查询
                    </lay-button>
                    <lay-button size="sm" @click="toReset"> 重置</lay-button>
                  </lay-form-item>
                </lay-col>
              </lay-row>
            </lay-form>
          </lay-card>
          <lay-tab v-model="tab_id" @change="openTab">
            <lay-tab-item v-for="item in tabList" :title="item.title" :id="item.id"></lay-tab-item>
          </lay-tab>
          <lay-table :page="page" height="600px" :columns="columns" :loading="loading" :data-source="dataSource"
            v-model:selected-keys="selectedKeys" @change="change">
            <template v-slot:scoringrecord_status="{ row }">
              <!-- 1.已自评  2.未自评 3.科室已评 4.医院已评 5.支部已评 6.总党支已评 -->
              <lay-tag v-if="row.scoringrecord_status == 1" type="primary">已自评</lay-tag>
              <lay-tag v-if="row.scoringrecord_status == 2">未自评</lay-tag>
              <lay-tag v-if="row.scoringrecord_status == 3" type="warm">科室已评</lay-tag>
              <lay-tag v-if="row.scoringrecord_status == 4" type="normal">医院已评</lay-tag>
              <lay-tag v-if="row.scoringrecord_status == 5" color="blue">支部已评</lay-tag>
              <lay-tag v-if="row.scoringrecord_status == 6" color="#000033">总党支已评 </lay-tag>
            </template>
            <template v-slot:nickname="{ row }">
              <div style="color: #00A394;cursor: pointer" @click="openUserListShow(row)">{{ row.nickname }}</div>
            </template>
            <template v-slot:operator="{ row }">
              <lay-space>
                <!-- <span style="color: #00A394;cursor: pointer"
                  v-if="row.scoringrecord_status == 6 && userStore.userInfo.level == 3"
                  @click="getInfo(row, 5)">医院评分</span>
                <span style="color: #00A394;cursor: pointer"
                  v-if="row.scoringrecord_status == 5 && userStore.userInfo.level == 5"
                  @click="getInfo(row, 4)">总党支评分</span>
                <span style="color: #00A394;cursor: pointer"
                  v-if="row.scoringrecord_status == 3 && userStore.userInfo.level == 4"
                  @click="getInfo(row, 3)">支部评分</span> -->
                <span style="color: #00A394;cursor: pointer"
                  v-if="row.scoringrecord_status == 1 && userStore.userInfo.level == 1"
                  @click="getInfo(row, 2)">科室评分</span>
                <span style="color: #00A394;cursor: pointer" v-if="row.scoringrecord_status != 2"
                  @click="getInfo(row, 1)">考评详情</span>
                <span style="color: #999999;cursor: not-allowed" v-if="row.scoringrecord_status == 2">未自评</span>
              </lay-space>
            </template>
          </lay-table>
        </div>
      </div>
      <lay-layer @close="layerEnd" v-model="infoShow" title="考评详情" :type="4" :shade="true" :area="['70%', '100%']"
        :btn="addIsInfo != 1 ? addButton : ''">
        <lay-container fluid="true" style="padding: 20px">
          <lay-table :default-expand-all="true" ref="tableRef6" children-column-name="children" :columns="columns6"
            :data-source="dataSource6">
            <template v-slot:base_score="{ data }">
              <div v-if="data.pid == 0">题目分：{{ data.base_score }}</div>
              <div v-if="data.pid != 0">{{ data.base_score }}</div>
            </template>
            <!-- 自评评分 -->
            <template v-slot:content_score="{ row }">
              <div v-if="row.pid == 0">已评分：{{ row.avg_score ? row.avg_score : 0 }}</div>
              <lay-input-number @change="inputChange(row)" v-if="row.pid != 0" :disabled="true" :min="0"
                :max="row.base_score" v-model="row.content_score" position="right"></lay-input-number>
            </template>
            <!-- 科室评分 -->
            <template v-slot:department_score="{ row }">
              <div v-if="row.pid == 0">已评分：{{ row.department_score ? row.department_score : 0 }}</div>
              <lay-input-number v-if="addIsInfo == 1 && row.pid != 0" :disabled="true" :min="0" :max="row.base_score"
                v-model="row.department_score" position="right"></lay-input-number>
              <lay-input-number v-if="addIsInfo != 1 && userStore.userInfo.level == 1 && row.pid != 0"
                @change="inputKsChange(row)" :min="0" :max="row.base_score" v-model="row.department_score"
                position="right"></lay-input-number>
            </template>
            <!-- 支部评分 -->
            <template v-slot:party_branch_score="{ row }">
              <div v-if="row.pid == 0">已评分：{{ row.party_branch_score ? row.party_branch_score : 0 }}</div>
              <lay-input-number v-if="addIsInfo == 1 && row.pid != 0" :disabled="true" :min="0" :max="row.base_score"
                v-model="row.party_branch_score" position="right"></lay-input-number>
              <lay-input-number v-if="addIsInfo != 1 && userStore.userInfo.level == 4 && row.pid != 0"
                @change="inputZbChange(row)" :min="0" :max="row.base_score" v-model="row.party_branch_score"
                position="right"></lay-input-number>
            </template>
            <!-- 党总支评分 -->
            <template v-slot:overall_party_score="{ row }">
              <div v-if="row.pid == 0">已评分：{{ row.overall_party_score ? row.overall_party_score : 0 }}</div>
              <lay-input-number v-if="addIsInfo == 1 && row.pid != 0" :disabled="true" :min="0" :max="row.base_score"
                v-model="row.overall_party_score" position="right"></lay-input-number>
              <lay-input-number v-if="addIsInfo != 1 && userStore.userInfo.level == 5 && row.pid != 0"
                @change="inputZdzChange(row)" :min="0" :max="row.base_score" v-model="row.overall_party_score"
                position="right"></lay-input-number>
            </template>
            <!-- 医院评分 -->
            <template v-slot:hospital_score="{ row }">
              <div v-if="row.pid == 0">已评分：{{ row.hospital_score ? row.hospital_score : 0 }}</div>
              <lay-input-number v-if="addIsInfo == 1 && row.pid != 0" :disabled="true" :min="0" :max="row.base_score"
                v-model="row.hospital_score" position="right"></lay-input-number>
              <lay-input-number v-if="addIsInfo != 1 && userStore.userInfo.level == 3 && row.pid != 0"
                @change="inputKsChange(row)" :min="0" :max="row.base_score" v-model="row.hospital_score"
                position="right"></lay-input-number>
            </template>
          </lay-table>
        </lay-container>
      </lay-layer>
      <lay-layer v-model="userShow" title="年末考评列表" :shade="true" :area="['90%', '90%']">
        <lay-container fluid="true" style="padding: 20px">
          <lay-row :space="10">
            <lay-col :md="24">
              <lay-card>
                <lay-form style="margin-top: 20px">
                  <lay-row>
                    <lay-col :md="5">
                      <lay-form-item label="年度：" label-width="50">
                        <lay-date-picker type="year" v-model="searchAccountUser" placeholder="请选择"
                          allow-clear></lay-date-picker>
                      </lay-form-item>
                    </lay-col>
                    <lay-col :md="4">
                      <lay-form-item label-width="0">
                        <lay-button type="primary" size="sm" @click="toUserSearch">查询</lay-button>
                        <lay-button size="sm" @click="toReset">重置</lay-button>
                      </lay-form-item>
                    </lay-col>
                  </lay-row>
                </lay-form>
              </lay-card>
            </lay-col>
            <lay-col :md="24">
              <lay-tab v-model="userTabId" type="button" @change="openUserTab">
                <lay-tab-item v-for="item in tabList" :title="item.title" :id="item.id"></lay-tab-item>
              </lay-tab>
              <lay-table height="400px" :default-expand-all="true" :columns="userColumns" :data-source="userDataSource">
                <template v-slot:scoringrecord_status="{ row }">
                  <lay-tag v-if="row.scoringrecord_status == 1" type="primary">已自评</lay-tag>
                  <lay-tag v-if="row.scoringrecord_status == 2">未自评</lay-tag>
                  <lay-tag v-if="row.scoringrecord_status == 3" type="warm">科室已评</lay-tag>
                  <lay-tag v-if="row.scoringrecord_status == 4" type="normal">医院已评</lay-tag>
                  <lay-tag v-if="row.scoringrecord_status == 5" color="blue">支部已评</lay-tag>
                  <lay-tag v-if="row.scoringrecord_status == 6" color="#000033">总党支已评 </lay-tag>
                </template>
                <template v-slot:operator="{ row }">
                  <span v-if="row.if == 2" style="color: #00A394;cursor: pointer"
                    @click="getMonthlyInfo(row, 1)">考评详情</span>
                  <span style="color: #999999;cursor: not-allowed" v-if="row.if == 1">未自评</span>
                </template>
              </lay-table>
            </lay-col>
          </lay-row>
        </lay-container>
      </lay-layer>
    </lay-container>
  </template>
  <script setup lang="ts">
  import { ref, reactive, onMounted } from 'vue'
  import { layer } from '@layui/layui-vue'
  import {
    getUserGroupNew,
    getGroupYear,
    getYearUserList,
    getYearListFind, getYearListUpdate,
    getAnnualFindData
  } from "@/api/module/home";
  import dayjs from "dayjs";
  import { useUserStore } from '@/store/user';
  import { useRoute } from 'vue-router'
  const route = useRoute()
  const userStore = useUserStore()
  const userId = ref();
  onMounted(() => {
    if (route.params.id) {
      userId.value = parseInt(route.params.id);
    }
    getLeftList();
  })
  const columns6 = ref([
    {
      title: "考评项目",
      width: "300px",
      key: "project_name"
    },
    {
      title: "分值",
      width: "80px",
      align: 'center',
      key: "base_score",
      customSlot: 'base_score',
      totalRow: true
    },
    {
      title: "自评分",
      width: "100px",
      align: 'center',
      customSlot: 'content_score',
      key: "content_score",
      totalRow: true
    }
  ])
  const inputChange = (row) => {
    //计算出dataSource6里分数在children下所有的已评总分 
    let total = 0;
    const index = dataSource6.value.findIndex(item => item.id === row.pid);
    dataSource6.value[index].children.forEach(item => {
      total += parseInt(item.content_score);
    });
    //找到row的index
    dataSource6.value[index].avg_score = total;
    dataSource6.value[index].content_score = total;
  }
  //科室评分总分
  const inputKsChange = (row) => {
    //计算出dataSource6里分数在children下所有的已评总分 
    let total = 0;
    const index = dataSource6.value.findIndex(item => item.id === row.pid);
    dataSource6.value[index].children.forEach(item => {
      total += parseInt(item.department_score);
    });
    dataSource6.value[index].department_score = total;
  }
  //支部评分总分
  const inputZbChange = (row) => {
    //计算出dataSource6里分数在children下所有的已评总分 
    let total = 0;
    const index = dataSource6.value.findIndex(item => item.id === row.pid);
    dataSource6.value[index].children.forEach(item => {
      total += parseInt(item.party_branch_score);
    });
    dataSource6.value[index].party_branch_score = total;
  }
  //支部评分总分
  const inputListZbShow = () => {
    //计算出dataSource6里分数在children下所有的已评总分 
    dataSource6.value.forEach((item, index) => {
      let total = 0;
      item.children.forEach(item2 => {
        total += parseInt(item2.party_branch_score);
      });
      dataSource6.value[index].party_branch_score = total;
    });
  }
  //医院评分总分
  const inputYyChange = (row) => {
    //计算出dataSource6里分数在children下所有的已评总分 
    let total = 0;
    const index = dataSource6.value.findIndex(item => item.id === row.pid);
    dataSource6.value[index].children.forEach(item => {
      total += parseInt(item.hospital_score);
    });
    dataSource6.value[index].hospital_score = total;
  }
  //总党支评分总分
  const inputListYyShow = () => {
    dataSource6.value.forEach((item, index) => {
      let total = 0;
      item.children.forEach(item2 => {
        total += parseInt(item2.hospital_score);
      });
      dataSource6.value[index].hospital_score = total;
    });
  }
  //总党支评分总分
  const inputZdzChange = (row) => {
    //计算出dataSource6里分数在children下所有的已评总分 
    let total = 0;
    const index = dataSource6.value.findIndex(item => item.id === row.pid);
    dataSource6.value[index].children.forEach(item => {
      total += parseInt(item.overall_party_score);
    });
    dataSource6.value[index].overall_party_score = total;
  }
  //总党支评分总分
  const inputListZdzShow = () => {
    dataSource6.value.forEach((item, index) => {
      let total = 0;
      item.children.forEach(item2 => {
        total += parseInt(item2.overall_party_score);
      });
      dataSource6.value[index].overall_party_score = total;
    });
  }
  //科室评分总分
  const inputListKsShow = () => {
    //计算出dataSource6里分数在children下所有的已评总分 
    dataSource6.value.forEach((item, index) => {
      let total = 0;
      item.children.forEach(item2 => {
        total += parseInt(item2.department_score);
      });
      dataSource6.value[index].department_score = total;
    });
  }
  //自评列表总分
  const inputListZpShow = () => {
    //计算出dataSource6里分数在children下所有的已评总分 
  
    dataSource6.value.forEach((item, index) => {
      let total = 0;
      item.children.forEach(item2 => {
        total += parseInt(item2.content_score);
      });
      dataSource6.value[index].avg_score = total;
      dataSource6.value[index].content_score = total;
    });
  }
  const userShow = ref(false);
  const userColumns = ref([
    { title: '年度', width: '80px', key: 'year', align: 'center' },
    { title: '考评对象', width: '100px', key: 'user', align: 'center' },
    { title: '参评时间', width: '100px', key: 'createtime', align: 'center' },
    { title: '自评总分', width: '100px', key: 'self_score', align: 'center' },
    { title: '科室评分', width: '100px', key: 'department_score', align: 'center' },
    { title: '支部评分', width: '100px', key: 'party_branch_score', align: 'center' },
    { title: '总党支评分', width: '100px', key: 'overall_party_score', align: 'center' },
    { title: '医院评分', width: '100px', key: 'hospital_score', align: 'center' },
    { title: '总得分', width: '100px', key: 'total_score', align: 'center' },
    { title: '状态', width: '100px', key: 'scoringrecord_status', customSlot: 'scoringrecord_status', align: 'center' },
    { title: '操作', width: '100px', key: 'operator', customSlot: 'operator', align: 'center' },
  ])
  const userDataSource = ref([]);
  const userTabId = ref(0);
  const userInfo = ref({});
  const searchAccountUser = ref(dayjs().year());
  const openUserListShow = (row) => {
    userInfo.value = row;
    userShow.value = true;
    getUserListInfo();
  }
  const getUserListInfo = () => {
    getAnnualFindData({
      'user_id': userInfo.value.id,
      'evaluation_id': userTabId.value,
      'time': searchAccountUser.value
    }).then((res) => {
      console.log(res)
      if (res.code == 1) {
        userDataSource.value = res.data;
      } else {
        userDataSource.value = [];
      }
    })
  }
  const openUserTab = (d) => {
    console.log(d)
    userTabId.value = d;
    userDataSource.value = [];
    getUserListInfo();
  }
  const getMonthlyInfo = (item, type) => {
    addIsInfo.value = type;
    infoShow.value = true;
    console.log(item);
    item.time = item.year;
    getInfoMode(item);
    if (type == 1) {
      columns6.value = [
        {
          title: "考评项目",
          width: "300px",
          key: "project_name"
        },
        {
          title: "分值",
          width: "80px",
          align: 'center',
          key: "base_score",
          customSlot: 'base_score',
          totalRow: true
        },
        {
          title: "自评分",
          width: "100px",
          align: 'center',
          customSlot: 'content_score',
          key: "content_score",
          totalRow: true
        }, {
          title: "科室评分",
          width: "100px",
          align: 'center',
          customSlot: 'department_score',
          key: "department_score",
          totalRow: true
        }, {
          title: "支部评分",
          width: "100px",
          align: 'center',
          customSlot: 'party_branch_score',
          key: "party_branch_score",
          totalRow: true
        }, {
          title: "总党支评分",
          width: "100px",
          align: 'center',
          customSlot: 'overall_party_score',
          key: "overall_party_score",
          totalRow: true
        }, {
          title: "医院评分",
          width: "100px",
          align: 'center',
          customSlot: 'hospital_score',
          key: "hospital_score",
          totalRow: true
        }
      ];
    }
    //科室评分
    else if (type == 2) {
      columns6.value.push({
        title: "科室评分",
        width: "100px",
        align: 'center',
        customSlot: 'department_score',
        key: "department_score",
        totalRow: true
      })
    } else if (type == 3) {
      columns6.value.push({
        title: "支部评分",
        width: "100px",
        align: 'center',
        customSlot: 'party_branch_score',
        key: "party_branch_score",
        totalRow: true
      })
    } else if (type == 4) {
      columns6.value.push({
        title: "总党支评分",
        width: "100px",
        align: 'center',
        customSlot: 'overall_party_score',
        key: "overall_party_score",
        totalRow: true
      })
    } else {
      columns6.value.push({
        title: "医院评分",
        width: "100px",
        align: 'center',
        customSlot: 'hospital_score',
        key: "hospital_score",
        totalRow: true
      })
    }
  }
  const toUserSearch = () => {
    getUserListInfo();
  }
  const openTab = (d) => {
    console.log(d)
    tab_id.value = d;
    dataSource.value = [];
    page.current = 1;
    getList();
  }
  const page = reactive({ current: 1, limit: 10, total: 1 })
  const change = (d) => {
    console.log(d);
    page.current = d.current;
    page.limit = d.limit;
    getList();
  }
  const addIsInfo = ref(1);
  const infoShow = ref(false);
  const yearmonth = ref(dayjs().year());
  const getList = () => {
    getYearUserList({
      'user_id': userId.value,
      'group_id': group_id.value,
      'time': yearmonth.value,
      'evaluation_schedule_id': tab_id.value,
      page: page.current,
      size: page.limit
    }).then((res) => {
      console.log(res)
      if (res.code == 1) {
        dataSource.value = res.data.result;
        page.total = res.data.count;
      } else {
        layer.msg(res.msg, { icon: 2 })
      }
    })
  }
  const dataSerSource = ref([]);
  const getSerList = () => {
    getYearUserList({
      'group_id': group_id.value,
      'time': yearmonth.value,
      'evaluation_schedule_id': tab_id.value,
      page: 1,
      size: 10000
    }).then((res) => {
      console.log(res)
      if (res.code == 1) {
        dataSerSource.value = res.data.result;
      } else {
        layer.msg(res.msg, { icon: 2 })
      }
    })
  }
  const thisInfo = ref();
  const getInfo = (row, type) => {
    infoShow.value = true;
    addIsInfo.value = type;
    thisInfo.value = row;
    getInfoMode(row);
    if (type == 1) {
      columns6.value = [
        {
          title: "考评项目",
          width: "300px",
          key: "project_name"
        },
        {
          title: "分值",
          width: "80px",
          align: 'center',
          key: "base_score",
          customSlot: 'base_score',
          totalRow: true
        },
        {
          title: "自评分",
          width: "100px",
          align: 'center',
          customSlot: 'content_score',
          key: "content_score",
          totalRow: true
        }, {
          title: "科室评分",
          width: "100px",
          align: 'center',
          customSlot: 'department_score',
          key: "department_score",
          totalRow: true
        }, {
          title: "支部评分",
          width: "100px",
          align: 'center',
          customSlot: 'party_branch_score',
          key: "party_branch_score",
          totalRow: true
        }, {
          title: "总党支评分",
          width: "100px",
          align: 'center',
          customSlot: 'overall_party_score',
          key: "overall_party_score",
          totalRow: true
        }, {
          title: "医院评分",
          width: "100px",
          align: 'center',
          customSlot: 'hospital_score',
          key: "hospital_score",
          totalRow: true
        }
      ];
    }
    //科室评分
    else if (type == 2) {
      columns6.value.push({
        title: "科室评分",
        width: "100px",
        align: 'center',
        customSlot: 'department_score',
        key: "department_score",
        totalRow: true
      })
    } else if (type == 3) {
      columns6.value.push({
        title: "支部评分",
        width: "100px",
        align: 'center',
        customSlot: 'party_branch_score',
        key: "party_branch_score",
        totalRow: true
      })
    } else if (type == 4) {
      columns6.value.push({
        title: "总党支评分",
        width: "100px",
        align: 'center',
        customSlot: 'overall_party_score',
        key: "overall_party_score",
        totalRow: true
      })
    } else {
      columns6.value.push({
        title: "医院评分",
        width: "100px",
        align: 'center',
        customSlot: 'hospital_score',
        key: "hospital_score",
        totalRow: true
      })
    }
  }
  const getInfoMode = (row) => {
    getYearListFind({
      evaluation_schedule_id: tab_id.value,
      month: row.time,
      user_id: row.id
    }).then((res) => {
      console.log(res)
      if (res.code == 1) {
        dataSource6.value = res.data;
        inputListZpShow();
        inputListKsShow();
        inputListZbShow();
        inputListZdzShow();
        inputListYyShow();
      } else {
        layer.msg(res.msg, { icon: 2 })
      }
    })
  }
  const tabList = ref([]);
  const tab_id = ref(0);
  const getTabList = () => {
    getGroupYear({ 'group_id': group_id.value }).then((res) => {
      console.log(res)
      if (res.code == 1) {
        tabList.value = res.data;
        tab_id.value = res.data[0].id;
        userTabId.value = res.data[0].id;
        getList();
      } else {
        layer.msg(res.msg, { icon: 2 })
      }
    })
  }
  const group_id = ref(1);
  const getLeftList = () => {
    getUserGroupNew({}).then((res) => {
      console.log(res)
      if (res.code == 1) {
        data.value = res.data;
        group_id.value = res.data[0].id;
        getTabList();
        getSerList();
      } else {
        layer.msg(res.msg, { icon: 2 })
      }
    })
  }
  const data = ref([])
  const isFold = ref(false)
  const searchQuery = ref({
    year: '',
    evaluateTarget: '',
    status: ''
  })
  
  function toReset() {
    searchQuery.value = {
      year: '',
      evaluateTarget: '',
      status: ''
    }
  }
  
  function handleClick(node: any) {
    // selectedNode.value = JSON.parse(JSON.stringify(node))
    page.current = 1;
    getList();
    // change(page)
  }
  
  function toSearch() {
    page.current = 1;
    getList();
  }
  
  const loading = ref(false)
  const selectedKeys = ref()
  const columns = ref([
    { title: '选项', width: '55px', type: 'checkbox', align: 'center' },
    { title: '序号', width: '60px', key: 'id', align: 'center' },
    { title: '年度', width: '80px', key: 'time', align: 'center' },
    { title: '考评对象', width: '100px', key: 'nickname', customSlot: 'nickname', align: 'center' },
    { title: '工号', width: '100px', key: 'code', align: 'center' },
    { title: '部门', width: '120px', key: 'group_name', align: 'center' },
    { title: '自评总分', width: '100px', key: 'user_scoringrecord', align: 'center' },
    { title: '科室评分', width: '100px', key: 'department_score_scoringrecord', align: 'center' },
    { title: '党支部评分', width: '100px', key: 'party_score_scoringrecord', align: 'center' },
    { title: '党总支评分', width: '100px', key: 'overall_score_scoringrecord', align: 'center' },
    { title: '医院评分', width: '100px', key: 'hospital_score_scoringrecord', align: 'center' },
    { title: '总得分', width: '100px', key: 'total_score', align: 'center' },
    { title: '自评状态', width: '100px', key: 'scoringrecord_status', customSlot: 'scoringrecord_status', align: 'center' },
    {
      title: '操作',
      width: '180px',
      customSlot: 'operator',
      key: 'operator',
      fixed: 'right', align: 'center'
    }
  ])
  const dataSource = ref()
  const addButton = ref([
    {
      text: "确认",
      callback: async () => {
        var json = JSON.stringify(dataSource6.value);
        var res = await getYearListUpdate({
          'type': thisInfo.value.scoringrecord_status,
          'term': thisInfo.value.time,
          'json': json,
          'user_id': thisInfo.value.id,
          evaluation_schedule_id: tab_id.value
        });
        console.log(res)
        if (res.code == 1) {
          layer.msg('提交成功！', { icon: 1 })
          thisInfo.value = {};
          infoShow.value = false;
          getList();
        } else {
          layer.msg(res.msg, { icon: 2 })
        }
      }
    },
    {
      text: "取消",
      callback: () => {
        infoShow.value = false;
      }
    }
  ])
  
  const layerEnd = () => {
    columns6.value = [
    {
      title: "考评项目",
      width: "300px",
      key: "project_name"
    },
    {
      title: "分值",
      width: "80px",
      align: 'center',
      key: "base_score",
      customSlot: 'base_score',
      totalRow: true
    },
    {
      title: "自评分",
      width: "100px",
      align: 'center',
      customSlot: 'content_score',
      key: "content_score",
      totalRow: true
    }
  ];
  }
  const dataSource6 = ref([])
  
  </script>
  
  <style>
  .layui-table-header .layui-table-cell {
    background-color: #ECF8FA !important;
  }
  
  .organization-box {
    width: calc(100vw - 240px);
    height: calc(100vh - 110px);
    margin-top: 10px;
    box-sizing: border-box;
    background-color: #fff;
    overflow: hidden;
  }
  
  .left-tree {
    display: inline-block;
    padding: 20px 15px 0 5px;
    height: 1200px;
    border-right: 1px solid #e6e6e6;
    box-sizing: border-box;
    position: relative;
  }
  
  /* todo layui-tree-entry 设置无效 */
  .layui-tree-entry {
    position: relative;
    padding: 10px 0;
    height: 20px;
    line-height: 20px;
    white-space: nowrap;
  }
  
  .isFold {
    position: absolute;
    top: 36%;
    right: -10px;
    width: 26px;
    height: 26px;
    line-height: 26px;
    border-radius: 13px;
    background-color: #fff;
    border: 1px solid #e6e6e6;
    cursor: pointer;
  }
  
  .search-input {
    display: inline-block;
    width: 98%;
    margin-right: 10px;
  }
  
  .isChecked {
    display: inline-block;
    background-color: #e8f1ff;
    color: red;
  }
  
  .layui-tab-content {
    padding: 0;
  }
  </style>
  