<template>
  <el-dialog v-model="showDialog" :destroy-on-close="true" title="采集录入" @close="close" :close-on-click-modal="false">
    <FormMessage v-model="listQuery" :formList="formData" labelWidth="120px" 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 FormMessage from "@/components/aboutTable/FormMessage.vue";
import { reactive, ref,getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
const { D_BZ_XB } = proxy.$dict("D_BZ_XB"); // 获取字典数据
const elform = ref()
const showDialog = ref(false)
const emit = defineEmits(['change'])
const listQuery = ref({})
const formData = ref([
    { label: "微信群", prop: "wxqId", type: "input" ,width:'45%'},
    { label: "QQ群", prop: "qqqId", type: "input" ,width:'45%'},
    { label: "群主昵称", prop: "qzNc", type: "input",width:'45%' },
    { label: "群主姓名", prop: "qzXm", type: "input",width:'45%' },
    { label: "群主联系电话", prop: "qzLxdh", type: "input",width:'45%' },
    { label: "群重要内容", prop: "qzynr", type: "textarea",width:'100%' },
])
const rules = reactive({
    wxqId: [{ required: true, message: "请输入微信群", trigger: "blur" }],
    qqqId: [{ required: true, message: "请输入QQ群", trigger: "blur" }],
    qzNc: [{ required: true, message: "请输入群主昵称", trigger: "blur" }],
    qzXm: [{ required: true, message: "请输入群主姓名", trigger: "blur" }],
    qzLxdh: [{ required: true, message: "请输入群主联系电话", trigger: "blur" }],
    qZynr: [{ required: true, message: "请输入群重要内容", trigger: "blur" }],
})
const type = ref('')
const init = (lx,row) =>{
    type.value = lx;
    if(row) listQuery.value = JSON.parse(JSON.stringify(row))
    showDialog.value = true;
}

const submitForm = () =>{
    elform.value.submit((val)=>{
        val.id = new Date().getTime();
        let obj = { type:type.value, data:val }
        emit('change',obj)
        showDialog.value = false;
    })
}

const close = () =>{
    elform.value.reset();
    listQuery.value.bqList = []
    showDialog.value = false;
}

defineExpose({init})
</script>

<style lang="scss" scoped>

</style>