<template>
  <div style="display: flex">
    <div style="display:block;">
      <div style="display: flex; flex-wrap: wrap; height:35px;">
        <div class="query">
          <span>体检单位：</span>
          <el-input placeholder="请选择单位" v-model="patientRegister.query.cusOrgOCX" style="width:240px;" size="small" disabled>          
            <el-button slot="append" icon="el-icon-search" @click="report.dialogCusOrgOCX = true" style="font-size: 20px;"></el-button>
          </el-input>
        </div>
        <div class="query">
          <span>性别：</span>
          <el-select v-model="patientRegister.query.sex" placeholder="请选择" style="width: 60px" size="small">
            <el-option v-for="item in dict.sex" :key="item.id" :label="item.displayName" :value="item.id" />
          </el-select>
        </div>
        <div class="query">
          <span>身份证号：</span>
          <el-input placeholder="身份证号" v-model="patientRegister.query.idCardNo" size="small" clearable
            style="width: 150px" />
        </div>
        <div class="query">
          <span>电话：</span>
          <el-input placeholder="手机号及电话" v-model="patientRegister.query.phone" size="small" clearable
            style="width: 110px" />
        </div>
        <div class="query">
          <span>检查状态：</span>
          <el-select v-model="patientRegister.query.completeFlag" placeholder="请选择" clearable style="width: 80px"
            size="small">
            <el-option v-for="item in dict.completeFlag" :key="item.id" :label="item.displayName" :value="item.id">
            </el-option>
          </el-select>
        </div>              
      </div>  
      <div style="display: flex; flex-wrap: wrap; height:35px;">  
        <div class="query">
          <span>条码号：</span>
          <el-input placeholder="条码号" v-model="patientRegister.query.patientRegisterNo" size="small" clearable
            style="width: 130px" />
        </div>
        <div class="query">
          <span>档案号：</span>
          <el-input placeholder="档案号" v-model="patientRegister.query.patientNo" size="small" clearable
            style="width: 120px" />
        </div>
        <div class="query">
          <span>姓名：</span>
          <el-input placeholder="姓名" v-model="patientRegister.query.patientName" size="small" clearable
            style="width: 100px" />
        </div>
        <div class="query" style="margin-left: 80px;">
          <span>审核：</span>
          <el-select v-model="patientRegister.query.isAudit" placeholder="请选择" clearable style="width: 75px"
            size="small">
            <el-option label="未审核" value="N"/>
            <el-option label="已审核" value="Y"/>
          </el-select>
        </div>  
        <div class="query">
          <span>上传：</span>
          <el-select v-model="patientRegister.query.isUpload" placeholder="请选择" clearable style="width: 75px"
            size="small">
            <el-option label="未上传" value="N"/>
            <el-option label="已上传" value="Y"/>
          </el-select>
        </div>
        <div class="query">
          <span>打印：</span>
          <el-select v-model="patientRegister.query.reportPrintTimes" placeholder="请选择" clearable style="width: 75px"
            size="small">
            <el-option label="未打印" value=0 />
            <el-option label="已打印" value=1 />
          </el-select>
        </div>
      </div>
    </div>
    <!--通用选单位、体检次数、分组的控件-->
    <el-dialog title="体检单位选择" :visible.sync="report.dialogCusOrgOCX"
      :close-on-click-modal="false" width="800px" height="600px">
      <CusOrgOCX/>
    </el-dialog>
  </div>
</template>
<script>
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import CusOrgOCX from "./CusOrgOCX.vue"

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

  created() { },

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

  computed: {
    ...mapState(["window", "dict", "patientRegister", "customerOrg","report"]),
  },
  methods: {

    //选择单位
    changeCustomerOrgId(v) {
      console.log(v)
      if (!v) {
        this.patientRegister.query.customerOrgRegister = null;
        return;
      }

      let customerOrgId = v[0];
      if (customerOrgId == this.dict.personOrgId) {
        this.patientRegister.query.customerOrgRegister = null;
        return;
      }
      getapi(
        `/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${customerOrgId}`
      ).then((res) => {
        //console.log('res.data',res.data)
        if (res.code != -1) {
          this.customerOrg.customerOrgRegisterList = res.data;
          if (res.data.length > 0) {
            this.patientRegister.query.customerOrgRegister = res.data[res.data.length - 1];
            this.patientRegister.query.dateRange = [
              res.data[res.data.length - 1].beginTime,
              res.data[res.data.length - 1].isComplete == 'N' ? new Date() : res.data[res.data.length - 1].endTime
            ]
          }
        }
      });
    },

    //选择单位体检次数是，更新起止日期
    changeMedicalTimes(v){
      this.patientRegister.query.customerOrgRegister = v;
      this.patientRegister.query.dateRange = [
        v.beginTime,
        v.isComplete == 'N' ? new Date() : v.endTime
      ];
    }
  },
};
</script>
<style scoped>
::v-deep .el-input__inner {
  /*text-align: center;*/
  padding-left: 5px;
  padding-right: 15px;
}
::v-deep .el-input__icon{
  width: 15px; /* 输入框下拉箭头或清除图标 默认 25 */
}
::v-deep .el-input-group__append{
  padding: 0 5px; /* 控件默认 0 20px;*/
}
.query {
  margin-left: 10px;
}
</style>
