<template>
<div>
  <div style="display: flex">
    <div style="display: flex; flex-wrap: wrap;height:70px; width: 100%;">
      <div>
        <span class="query">条码号</span>
        <el-input placeholder="条码号" v-model="doctorCheck.prBase.patientRegisterNo" size="small" style="width: 140px;"
          clearable @change="onQueryByPatientRegisterNo" />
      </div>
      <div>
        <span class="query">档案号</span>
        <el-input placeholder="档案号" v-model="doctorCheck.prBase.patientNo" size="small" style="width: 100px;" clearable
          @change="onQueryByPatientNo" />
      </div>
      <div>
        <span class="query">姓名</span>
        <el-input placeholder="姓名" v-model="doctorCheck.prBase.patientName" size="small" style="width: 100px;" disabled />
      </div>
      <div>
        <span class="query">性别</span>
        <el-select v-model="doctorCheck.prBase.sexId" style="width: 80px;" size="small" disabled>
          <el-option v-for="item in dict.sex" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">体检次数</span>
        <el-input v-model="doctorCheck.prBase.medicalTimes" size="small" style="width: 40px;" disabled />
      </div>
      <div>
        <span class="query">婚姻</span>
        <el-select v-model="doctorCheck.prBase.maritalStatusId" style="width: 80px;" size="small" disabled>
          <el-option v-for="item in dict.maritalStatus" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">体检日期</span>
        <el-input :value="doctorCheck.prBase.creationTime ? lmoment(doctorCheck.prBase.creationTime, 'yyyy-MM-DD') : ''"
          style="width: 100px;" size="small" disabled></el-input>
      </div>
      <div>
        <span class="query">单位</span>
        <el-input :value="doctorCheck.prBase.customerOrgParentName" style="width: 120px;" size="small" disabled />
      </div>
      <div>
        <span class="query">部门</span>
        <el-input :value="doctorCheck.prBase.customerOrgName" style="width: 120px;" size="small" disabled />
      </div>
      <div>
        <span class="query">体检类别</span>
        <el-select v-model="doctorCheck.prBase.medicalTypeId" disabled style="width: 100px;" size="small">
          <el-option v-for="item in dict.medicalType" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">人员类别</span>
        <el-select v-model="doctorCheck.prBase.personnelTypeId" disabled style="width: 100px;" size="small">
          <el-option v-for="item in dict.personnelType" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">民族</span>
        <el-select v-model="doctorCheck.prBase.nationId" disabled style="width: 100px;" size="small">
          <el-option v-for="item in dict.nation" :key="item.id" :label="item.displayName" :value="item.id" />
        </el-select>
      </div>
      <div>
        <span class="query">手机</span>
        <el-input :value="doctorCheck.prBase.mobileTelephone" style="width: 120px;" size="small" disabled />
      </div>
    </div>
    </div>
  </div>
</template>
<script>
import moment from "moment";
import { mapState, mapMutations} from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { objCopy, opjCopy } from '../../utlis/proFunc'

export default {
  components: {},
  data() {
    return {
      dialogVisible: false,

     
    };
  },

  created() { },

  //挂载完成
  mounted() { },

  computed: {
    ...mapState(["dict", "doctorCheck", "sumDoctorCheck"]),    
  },
  methods: {
    ...mapMutations(['doctorCheckPrBaseInit','sumPREditInit']),
    //按条码号查个人数据
    onQueryByPatientRegisterNo() {
      let patientRegisterNo = this.doctorCheck.prBase.patientRegisterNo
      let body = {
        sType:1,
        patientRegisterNo
      }      
      console.log(`/api/app/patientregister/getpatientregisterorpatient`,body)
      postapi('/api/app/patientregister/getpatientregisterorpatient',body)
      .then((res) => {
        if (res.code != -1) {  
          
          this.doctorCheckPrBaseInit()
          this.doctorCheck.prBase.patientRegisterNo = patientRegisterNo
          objCopy(res.data,this.doctorCheck.prBase)

          this.sumPREditInit()
          objCopy(res.data,this.sumDoctorCheck.sumPREdit)
        }
      });
    },

    //按条码号查个人数据
    onQueryByPatientNo() {
      let patientNo = this.doctorCheck.prBase.patientNo
      let body = {
        sType:2,
        patientNo
      }      
      console.log(`/api/app/patientregister/getpatientregisterorpatient`,body)
      postapi('/api/app/patientregister/getpatientregisterorpatient',body)      
      .then((res) => {
        if (res.code != -1) {
          console.log('按条码号查个人数据',res.data)
          this.doctorCheckPrBaseInit()
          this.doctorCheck.prBase.patientNo = patientNo
          objCopy(res.data,this.doctorCheck.prBase)

          this.sumPREditInit()
          objCopy(res.data,this.sumDoctorCheck.sumPREdit)
        }
      });
    },

    lmoment(date, forMat) {
      return moment(new Date(date)).format(forMat);
    },

    //查询
    btnQuery() {
      this.doctorCheck.prBase.times++;
      console.log("this.doctorCheck.prBase", this.doctorCheck.prBase);
    },

    //读身份证
    readIdCard() {
      alert("读身份证");
    },
  },
};
</script>
<style scoped>
.query {
  margin-left: 10px;
  margin-right: 2px;
  padding: 1px 1px;
}
</style>
