<template>
    <el-dialog v-model="showDialog" :append-to-body="true" :destroy-on-close="true" title="新增人员" :close-on-click-modal="false">
        <FormMessage v-model="listQuery" :formList="formData" labelWidth="160px" ref="elform" :rules="rules">
        </FormMessage>
        <template #footer>
            <div class="flex just-center">
                <el-button @click="close">取消</el-button>
                <el-button type="primary" @click="submitForm">确认</el-button>
            </div>
        </template>
  </el-dialog>
</template>

<script setup>
import emitter from "@/utils/eventBus.js";
import FormMessage from "@/components/aboutTable/FormMessage.vue";
import { onMounted, reactive, ref ,getCurrentInstance} from 'vue';
const { proxy } = getCurrentInstance();
const { D_BZ_SF } = proxy.$dict('D_BZ_SF')
const elform = ref()
const showDialog = ref(false)
const listQuery = ref({})
const formData = ref([
  { label: "发现目标状态", prop: "fxmbzt", type: "select",options: D_BZ_SF },
  { label: "发现目标责任单位", prop: "fxmbzedw", type: "department" },
  { label: "发现目标责任民警", prop: "fxzrmj", type: "input" },
  { label: "是否本人", prop: "sfbr", type: "select",options: D_BZ_SF },
  { label: "处置时间", prop: "czsj", type: "datetime" },
  { label: "处置地址", prop: "czdz", type: "textarea",width:'100%'},
  { label: "详细地址", prop: "xxdz", type: "textarea",width:'100%' },
  { label: "处置责任单位", prop: "czzrdw", type: "department" },
  { label: "处置责任民警", prop: "czzrmj", type: "input" },
  { label: "常控处置措施类型", prop: "ckczcslx", type: "select" },
  { label: "常控处置措施细类", prop: "ckczcsxl", type: "select" },
  { label: "常控处置结果", prop: "ckczjg", type: "input" },
  { label: "常控立线侦察评估", prop: "cklxzcpg", type: "input" },
  { label: "常控立线侦察依据", prop: "cklxzcpgyj", type: "input" },
  { label: "常控从事职业类型", prop: "cszylx", type: "select" },
  { label: "是否尿检", prop: "sfnj", type: "radio",options:  D_BZ_SF  },
  { label: "常控不尿检理由", prop: "fjdz", type: "textarea",width:'100%' },
  { label: "常控处置反馈补充信息", prop: "fjdz", type: "input" },
])
const rules = reactive({
  fxmbzt: [{ required: true, message: "请选择发现目标状态", trigger: "change" }],
  fxmbzedw: [{ required: true, message: "请选择发现目标责任单位", trigger: "change" }],
  fxzrmj: [{ required: true, message: "请选择发现目标责任民警", trigger: "change" }],
  sfbr:[{ required: true, message: "请选择是否本人", trigger: "change" }],
  czsj:[{ required: true, message: "请选择处置时间", trigger: "change" }],
  czdz:[{ required: true, message: "请选择处置地址", trigger: "blur" }],
  xxdz:[{ required: true, message: "请选择详细地址", trigger: "blur" }],
  czzrdw:[{ required: true, message: "请选择处置责任单位", trigger: "change" }],
  czzrmj:[{ required: true, message: "请选择处置责任民警", trigger: "change" }],
  ckczcslx:[{ required: true, message: "请选择常控处置措施类型", trigger: "change" }],
  ckczcsxl:[{ required: true, message: "请选择常控处置措施细类", trigger: "change" }],
  ckczjg:[{ required: true, message: "请输入常控处置结果", trigger: "blur" }],
  cklxzcpg:[{ required: true, message: "请输入常控立线侦察评估", trigger: "blur" }],
  cklxzcpgyj:[{ required: true, message: "请输入常控立线侦察依据", trigger: "blur" }],
  cszylx:[{ required: true, message: "请选择常控从事职业类型", trigger: "change" }],
  sfnj:[{ required: true, message: "请选择是否尿检", trigger: "change" }],
})

onMounted(() => {
  emitter.on("openFkDialog", () => {
    showDialog.value = true
  })
})

const submitForm = () =>{
    elform.value.submit((val)=>{
        // let obj = { data:val,type:title.value ,index:order.value}
        // emit('change',obj)
        // emit('update:modelValue',false)
    })
}

const close = () => {
  elform.value.reset();
  listQuery.value = {}
  showDialog.value = false;
}
</script>

<style lang="scss" scoped>
.el-form{
    max-height: 60vh;
    overflow: hidden;
    overflow-y: auto;
}
</style>