<template>
  <div class="dialog" v-if="dialogForm">
    <div class="head_box">
      <span class="title">涉爆重点人员{{ title }} </span>
      <div>
        <el-button type="primary" size="small" :loading="loading" @click="submit" >保存</el-button>
        <el-button size="small" @click="close">关闭</el-button>
      </div>
    </div>
    <div class="form_cnt">
      <FormMessage :formList="formData" ref="elform" :rules="rules"></FormMessage>
    </div>
  </div>
</template>

<script setup>
import FormMessage from '@/components/aboutTable/FormMessage.vue'
import { qcckGet, qcckPost, qcckPut } from "@/api/qcckApi.js";
import * as rule from "@/utils/rules.js";
import { ref, defineExpose, reactive, onMounted, defineEmits, getCurrentInstance, nextTick } from "vue";
const emit = defineEmits(["updateDate"]);
const props = defineProps({
  dic: Object
});
const { proxy } = getCurrentInstance();
const dialogForm = ref(false); //弹窗
const formData = ref([
  { label: "业务流水号", prop: "ywlsh",  type: "input" },
  { label: "行政区划", prop: "xzqh",  type: "input" },
  { label: "单位名称", prop: "dwmc",  type: "input" },
  { label: "姓名", prop: "xm",  type: "input" },
  { label: "别名", prop: "bm",  type: "input" },
  { label: "性别", prop: "xb",  type: "select",options: [{ label: "男", value: "1" }, { label: "女", value: "2" }]  },
  { label: "出生日期", prop: "csrq", type: "date",},
  { label: "民族", prop: "mz",  type: "input" },
  { label: "文化程度", prop: "whcd",  type: "input" },
  { label: "职业", prop: "zy",  type: "input" },
  { label: "身份证号", prop: "sfzh",  type: "input" },
  { label: "户籍地址", prop: "hjdz",  type: "input" },
  { label: "居住地址", prop: "jzdz",  type: "input" },
  { label: "身高", prop: "sg",  type: "input" },
  { label: "口音", prop: "ky",  type: "input" },
  { label: "移动电话", prop: "yddh",  type: "input" },
  { label: "重点人员体貌特征", prop: "zdrytz",  type: "input" },
  { label: "列管依据_详细情况", prop: "lgyj",  type: "input" },
  { label: "列管日期", prop: "lgrq",  type: "date" },
  { label: "填报人姓名", prop: "tbrxm",  type: "input" },
  { label: "填报日期", prop: "tbrq",  type: "date" },
  { label: "填报单位名称", prop: "tbdwmc",  type: "input" },
  { label: "备注", prop: "bz",  type: "textarea",width: '100%'   },
  { label: "照片", prop: "zp",  type: "upload",width: '100%'   },
]);
const listQuery = ref({
  sfbqdj: []
}); //表单
const loading = ref(false);
const elform = ref();
const title = ref("");
const rules = reactive({
  rwbt: [{ required: true, message: "请输入任务标题", trigger: "blur" }]
});
const editpeo = ref();
onMounted(() => {});
// 初始化数据
const init = (type, row,) => {
  dialogForm.value = true;
  title.value = type == 'add' ? "新增" : "编辑";
  if (row) getDataById(row.id);
};
// 根据id查询详情
const getDataById = (id) => {
  // qcckGet({}, '/mosty-gsxt/tbGsxtBqgl/'+id).then((res) => {
  //   listQuery.value = res;
  // });
};

// 提交
const submit = () => {
  elform.value.submit((data)=>{
    // let url =  title.value == "新增" ? '/mosty-gsxt/tbGsxtBqgl/save':'/mosty-gsxt/tbGsxtBqgl/update';
    // let params = { ...data }
    // qcckPost(params, url).then((res) => {
    //   proxy.$message({ type: "success", message: title.value + "成功" });
    //   emit("updateDate");
    //   close();
    // }).catch(() => {});
  });
};

// 关闭
const close = () => {
  listQuery.value = {};
  dialogForm.value = false;
  loading.value = false;
};
defineExpose({ init });
</script>

<style lang="scss" scoped>
@import "~@/assets/css/layout.scss";
@import "~@/assets/css/element-plus.scss";
</style>
