<template>
  <div style="display: flex;height:32px;">
    <div style="display: flex; flex-wrap: wrap;height:32px; width: 100%">
      <div>
        <span class="query">检查医生</span>
        <el-select v-model="doctorCheck.RegisterCheckEdit.checkDoctorId" filterable clearable 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">检查日期</span>
        <el-date-picker v-model="doctorCheck.RegisterCheckEdit.checkDate" type="datetime" style="width: 90px" size="small" />
      </div>
      <div>
        <span class="query">操作者</span>
        <el-input v-model="doctorCheck.RegisterCheckEdit.LastModifierId" size="small" style="width: 80px" disabled />
      </div>
      <div>
        <span class="query">操作日期</span>
        <el-input
          :value="doctorCheck.RegisterCheckEdit.LastModificationTime ? lmoment(doctorCheck.RegisterCheckEdit.LastModificationTime, 'yyyy-MM-DD') : ''"
          style="width: 90px" size="small" disabled></el-input>
      </div>
      <div>
        <span class="query">状态</span>
        <el-select v-model="doctorCheck.RegisterCheckEdit.completeFlag" style="width: 60px" size="small" disabled>
          <el-option v-for="item in dict.checkCompleteFlag" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
    </div>
  </div>
</template>
<script>
import moment from "moment";
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { arrayExistObj } from '@/utlis/proFunc';

export default {
  components: {},
  props: ["registerCheckId"],
  data() {
    return {
      users: [],
      dialogVisible: false,
    };
  },

  created() { },

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

  computed: {
    ...mapState(["window", "dataTransOpts", "dict", "doctorCheck", "patientRegister", "customerOrg"]),
    lmoment(date, forMat) {
      return moment(new Date(date)).format(forMat);
    },
  },
  methods: {
    // 初始化字典数据
    dictInit() {
      getapi('/api/identity/users/getlist?SkipCount=0&MaxResultCount=1000')
        .then(res => {
          if (res.code > -1) {
            this.users = res.data.items
          }
        })
    },

    // 放在 明细中获取，否则要获取两次
    // getRegisterCheck(id){
    //   if(id){
    //     getapi(`/api/app/registercheck/getregistercheck?id=${id}`).then(res =>{
    //       if(res.code != -1){
    //         this.doctorCheck.RegisterCheckEdit = res.data

    //         // 外部接口传入的数据，医生名字或能是具体的名称，而不是系统中的 userId ，故需添加一条外部记录
    //         if(res.data.checkDoctorId){
    //           let lfind = arrayExistObj(this.users,'id',res.data.checkDoctorId)
    //           if(lfind == -1){
    //             this.users.push({id:res.data.checkDoctorId,userName:res.data.checkDoctorId})
    //           }
    //         }
    //       }
    //     })        
    //   }else{
    //     this.doctorCheck.RegisterCheckEdit = {
    //       id:'',
    //       checkDoctorId:'',
    //       checkDate:'',
    //       LastModifierId:'',
    //       LastModificationTime:'',
    //       completeFlag:''
    //     }

    //   }
    // }
  },

  watch: {
    // "doctorCheck.RegisterCheckId":{
    //   immediate:true,
    //   handler(newVal,oldVal){
    //     this.getRegisterCheck(newVal)
    //   }
    // },

    //检查项目未切换换时 也可以强制刷新数据
    // "dataTransOpts.refresh.register_check.S":{
    //   immediate:true,
    //   handler(newVal, oldVal) {
    //     console.log(`watch 检查医生信息 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.register_check.id}`);        
    //     this.getRegisterCheck(this.dataTransOpts.tableS.register_check.id);
    //   }
    // },
  },

};
</script>
<style scoped>
.query {
  font-size: 14px;
  margin-left: 10px;
  margin-right: 2px;
  padding: 1px 1px;
}
</style>
