<template>
  <div class="cmain">
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="患者ID" prop="patientId">
          <el-input v-model="form.patId" placeholder="请输入患者ID" clearable/>
        </el-form-item>
        <el-form-item label="近亲姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入近亲姓名" clearable/>
        </el-form-item>
        <el-form-item label="近亲关系" prop="kinship">
          <el-select v-model="form.kinship" placeholder="请选择近亲关系" clearable>
            <el-option v-for="dict in dict.type.nk_kinship" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="近亲地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入近亲地址" clearable/>
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入联系电话" clearable/>
        </el-form-item>
        <el-form-item label="工作名称" prop="workName">
          <el-input v-model="form.workName" placeholder="请输入工作名称" clearable/>
        </el-form-item>
        <el-form-item label="工作类别" prop="workCode">
          <el-input v-model="form.workCode" placeholder="请输入工作类别" clearable/>
        </el-form-item>
      </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: ['nk_kinship'],
  data() {
    return {
      form: {},
      rules: {
      }
    };
  },
  mounted() {
    if (this.param.id) {
      this.ajax({ url: '/work/nk/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/nk/edit', data: this.form }).then(response => {
                  this.$modal.msgSuccess("修改成功");
                  this.$layer.close(this.layerid);
                  this.$parent.getList();
              });
          } else {
              this.ajax({method: 'post',url: '/work/nk/add', data: this.form }).then(response => {
                  this.$modal.msgSuccess("新增成功");
                  this.$layer.close(this.layerid);
                  this.$parent.getList();
               });
          }
        }
      });
    }
  }
};
</script>
