<template>
  <div style="display: flex;height:32px;margin-top: 2px;">
    <div style="display: flex; flex-wrap: wrap;height:32px; width: 100%">
      <div>
        <span class="query">体检结论</span>
        <el-select v-model="dataTransOpts.tableS.patient_register.medicalConclusionId" filterable clearable
          :disabled="dataTransOpts.tableS.patient_register.completeFlag == '3' ? true : false" placeholder="请选择"
          style="width: 80px" size="small">
          <el-option-group v-for="group in medicalConclusionGroup" :key="group.value" :label="group.label">
            <el-option v-for="item in group.options" :key="item.id" :label="item.displayName" :value="item.id" />
          </el-option-group>
        </el-select>
      </div>
      <div>
        <span class="query">{{ summary_check_doctor_alias[0] || '总检' }}医生</span>
        <el-select v-model="dataTransOpts.tableS.patient_register.summaryDoctorId" filterable clearable
          :disabled="(dataTransOpts.tableS.patient_register.completeFlag == '3' ? true : false) || summary_check_doctor_chooseable[0] == 'N'"
          placeholder="请选择" style="width: 80px" size="small">
          <el-option v-for="item in users" :key="item.id" :label="item.surname" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">{{ summary_check_doctor_alias[0] || '总检' }}日期</span>
        <el-date-picker v-model="dataTransOpts.tableS.patient_register.summaryDate" value-format="yyyy-MM-dd HH:mm:ss"
          :readonly="dataTransOpts.tableS.patient_register.completeFlag == '3' ? true : false" type="datetime"
          style="width: 140px" size="small" />
      </div>
      <div style="margin-top: 3px;">
        <span class="query">{{ summary_check_doctor_alias[0] || '总检' }}</span>
        <el-checkbox :value="dataTransOpts.tableS.patient_register.completeFlag == '3'" readonly></el-checkbox>
      </div>
      <div>
        <span class="query">{{ summary_check_doctor_alias[1] || '审核' }}医生</span>
        <el-select v-model="dataTransOpts.tableS.patient_register.auditDoctorId" style="width: 80px" placeholder="请选择" size="small"
          :disabled="summary_check_doctor_chooseable[1] == 'N' || dataTransOpts.tableS.patient_register.isAudit == 'Y'">
          <el-option v-for="item in users" :key="item.id" :label="item.surname" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">{{ summary_check_doctor_alias[1] || '审核' }}日期</span>
        <el-date-picker v-model="dataTransOpts.tableS.patient_register.auditDate" value-format="yyyy-MM-dd HH:mm:ss" readonly
          type="datetime" style="width: 140px" size="small" />
      </div>
      <div style="margin-top: 3px;">
        <span class="query">{{ summary_check_doctor_alias[1] || '审核' }}</span>
        <el-checkbox :value="dataTransOpts.tableS.patient_register.isAudit == 'Y'" readonly></el-checkbox>
      </div>
    </div>
  </div>
</template>
<script>

import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { arrayExistObj } from "../../utlis/proFunc"

export default {
  components: {},
  data() {
    return {
      users: [],
      medicalConclusion: [],
      medicalConclusionGroup: [],
      summary_check_doctor_alias: ["总检", "审核"],
      summary_check_doctor_chooseable: ["Y", "N"],
    };
  },

  created() {

  },

  //挂载完成
  mounted() {
    this.dictInit()
  },

  computed: {
    ...mapState(["dict", "window", "dataTransOpts"]),
  },
  methods: {
    // 初始化字典数据
    dictInit() {
      // 获取用户信息
      postapi('/api/identity/users/GetListByOperatorType', { operatorTypes: ["2", "3"] })
        .then(res => {
          if (res.code > -1) {
            this.users = res.data
          }
        })

      // 获取体检结论信息
      getapi('/api/app/medical-conclusion/in-type')
        .then(res => {
          if (res.code != -1) {
            this.medicalConclusion = res.data
            this.medicalConclusionHandle()
          }
        })

      postapi('/api/app/SysParmValue/GetSysParmValueBySysParmId', { sysParmId: "summary_check_doctor_alias" })
        .then(res => {
          if (res.code > -1) {
            this.summary_check_doctor_alias = JSON.parse(res.data)
          }
        })

      postapi('/api/app/SysParmValue/GetSysParmValueBySysParmId', { sysParmId: 'summary_check_doctor_chooseable' })
        .then(res => {
          if (res.code > -1) {
            this.summary_check_doctor_chooseable = JSON.parse(res.data)
          }
        })

    },

    medicalConclusionHandle() {
      //   <el-option-group
      //   v-for="group in options"
      //   :key="group.label"
      //   :label="group.label">
      //   <el-option
      //     v-for="item in group.options"
      //     :key="item.value"
      //     :label="item.label"
      //     :value="item.value">
      //   </el-option>
      // </el-option-group>
      this.medicalConclusionGroup = []
      this.medicalConclusion.forEach(e => {
        let lfind = arrayExistObj(this.medicalConclusionGroup, 'value', e.medicalConclusionTypeId)
        if (lfind > -1) {
          this.medicalConclusionGroup[lfind]["options"].push({ id: e.id, displayName: e.displayName })
        } else {
          this.medicalConclusionGroup.push({
            label: e.medicalConclusionTypeName,
            value: e.medicalConclusionTypeId,
            options: [{ id: e.id, displayName: e.displayName }]
          })
        }
      });
    },
  },
  //监听事件
  watch: {

  },
};
</script>
<style scoped>
::v-deep .el-select-group__title {
  font-size: 15px;
  background-color: #EEEEEE;
  color: black;
  font-weight: 700;
}

/*  popper-class="sumarySelect" :popper-append-to-body="false"
::v-deep .sumarySelect .el-select-dropdown__wrap {
  background-color: #FFF;
  max-height: 500px;
}
*/

.query {
  font-size: 14px;
  margin-left: 10px;
  margin-top: 5px;
  padding: 1px 1px;
}
</style>
