<style scoped>
  .splited-form {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }


  .splited-form .left-col {
    margin-right: 30px;
  }


</style>

<template>
  <div class="cmain">
    <el-form
      ref="form"
      label-position="right"
      :model="form" :rules="rules"
      label-width="100px"
      size="medium"
      style="width: 100%"
    >
      <!-- 将表单分为两列 -->
      <div class="splited-form">
        <!-- 左边的一列 -->
        <div class="left-col">
          <el-form-item label="患者ID" prop="patientId">
            <el-input v-model="form.patientId" placeholder="请输入患者ID" clearable/>
          </el-form-item>

          <el-form-item label="就诊卡号" prop="cardId">
            <el-input v-model="form.cardId" placeholder="请输入就诊卡号" clearable/>
          </el-form-item>

          <el-form-item label="患者类别" prop="patientCategory">
            <el-select v-model="form.patientCategory" placeholder="请选择患者类别" clearable>
              <el-option
                v-for="dict in dict.type.patient_category"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="患者位置" prop="bed">
            <el-input v-model="form.bed" placeholder="请输入患者位置" clearable/>
          </el-form-item>
          <el-form-item label="主治医师" prop="physician">
            <el-input v-model="form.physician" placeholder="请输入主治医师" clearable/>
          </el-form-item>
          <el-form-item label="主管护士代码" prop="nurseCode">
            <el-input v-model="form.nurseCode" placeholder="请输入主管护士代码" clearable/>
          </el-form-item>
          <el-form-item label="入院次数" prop="hospitalizedNumber">
            <el-input v-model="form.hospitalizedNumber" placeholder="请输入入院次数" clearable/>
          </el-form-item>
          <el-form-item label="收费类别" prop="feeCategory">
            <el-input v-model="form.feeCategory" type="textarea" placeholder="请输入内容" />
          </el-form-item>
          <el-form-item label="出院方式" prop="dischargeMethod">
            <el-select v-model="form.dischargeMethod" placeholder="请选择出院方式" clearable>
              <el-option
                v-for="dict in dict.type.discharge_method"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="患者信息ID" prop="msgId">
            <el-input v-model="form.msgId" placeholder="请输入患者信息ID" clearable/>
          </el-form-item>
        </div>

        <!-- 右边的一列 -->
        <div class="right-col">

          <el-form-item label="医疗机构代码" prop="medicalCode">
            <el-input v-model="form.medicalCode" placeholder="请输入医疗机构代码" clearable/>
          </el-form-item>
          <el-form-item label=" 在院状态" prop="hospitalStatus">
            <el-select v-model="form.hospitalStatus" placeholder="请选择 在院状态" clearable>
              <el-option
                v-for="dict in dict.type.hospital_status"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="门诊挂号状态">
            <el-radio-group v-model="form.registrationStatus">
              <el-radio
                v-for="dict in dict.type.registration_status"
                :key="dict.value"
                :label="dict.value"
              >{{dict.label}}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="入院时间" prop="admissionTime">
            <el-input v-model="form.admissionTime" placeholder="请输入入院时间" clearable/>
          </el-form-item>
          <el-form-item label="出院时间" prop="dischargeTime">
            <el-input v-model="form.dischargeTime" placeholder="请输入出院时间" clearable/>
          </el-form-item>
          <el-form-item label="创建时间" prop="createTime">
            <el-date-picker clearable
                            v-model="form.createTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择创建时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="创建人" prop="createBy">
            <el-input v-model="form.createBy" placeholder="请输入创建人" clearable/>
          </el-form-item>
          <el-form-item label="更新时间" prop="updateTime">
            <el-date-picker clearable
                            v-model="form.updateTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择更新时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="更新人" prop="updateBy">
            <el-input v-model="form.updateBy" placeholder="请输入更新人" clearable/>
          </el-form-item>

          <el-form-item label="科室" prop="department">
            <el-input v-model="form.department" placeholder="请输入科室" clearable/>
          </el-form-item>
        </div>


      </div>




    </el-form>
    <div class="mfooter">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="$layer.close(layerid)">取 消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  dicts: ['hospital_status', 'discharge_method', 'patient_category', 'registration_status'],
  data() {
    return {
      form: {},
      rules: {
      }
    };
  },
  mounted() {
    if (this.param.id) {
      this.ajax({ url: '/work/pv1/detail/' + this.param.id }).then(response => {
        this.form = response.data;
      });
    }
  },
  methods: {
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id) {
            this.ajax({method: 'post',url: '/work/pv1/edit', data: this.form }).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.$layer.close(this.layerid);
              this.$parent.getList();
            });
          } else {
            this.ajax({method: 'post',url: '/work/pv1/add', data: this.form }).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.$layer.close(this.layerid);
              this.$parent.getList();
            });
          }
        }
      });
    }
  }
};
</script>
