<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" :model="form" :rules="rules" label-width="100px" label-position="left">
        <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="entryTime">
              <el-date-picker clearable
                              v-model="form.entryTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择入区时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="出区原因" prop="reasonArea">
              <el-select v-model="form.reasonArea" placeholder="请选择出区原因" clearable>
                <el-option
                  v-for="dict in dict.type.reason_area"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </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="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="updateTime">
              <el-date-picker clearable
                              v-model="form.updateTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择更新时间">
              </el-date-picker>
            </el-form-item>
          </div>
          <div class="right-col">
            <el-form-item label="危重级别">
              <el-radio-group v-model="form.level">
                <el-radio
                  v-for="dict in dict.type.pv2_level"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="出区时间" prop="exitTime">
              <el-date-picker clearable
                              v-model="form.exitTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择出区时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="婴儿信息标识">
              <el-radio-group v-model="form.babyCode">
                <el-radio
                  v-for="dict in dict.type.baby_code"
                  :key="dict.value"
                  :label="dict.value"
                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="更新人" prop="updateBy">
              <el-input v-model="form.updateBy" placeholder="请输入更新人" clearable/>
            </el-form-item>
            <el-form-item label="患者ID" prop="msgId">
              <el-input v-model="form.msgId" type="textarea" placeholder="请输入内容" />
            </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: ['reason_area', 'baby_code', 'pv2_level'],
  data() {
    return {
      form: {},
      rules: {
      }
    };
  },
  mounted() {
    if (this.param.id) {
      this.ajax({ url: '/work/pv2/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/pv2/edit', data: this.form }).then(response => {
                  this.$modal.msgSuccess("修改成功");
                  this.$layer.close(this.layerid);
                  this.$parent.getList();
              });
          } else {
              this.ajax({method: 'post',url: '/work/pv2/add', data: this.form }).then(response => {
                  this.$modal.msgSuccess("新增成功");
                  this.$layer.close(this.layerid);
                  this.$parent.getList();
               });
          }
        }
      });
    }
  }
};
</script>
