<template>
    <vxe-modal v-model="dialogVisible" :title="title" show-zoom resize show-footer destroy-on-close transfer @hide="close" :width="width" :z-index="1002">
        <template #default>
            <div class="mb-10">是否确认将该事项的专家抽取审核为通过！</div>
            <div class="mb-8">专家人员指定：</div>
            <vxe-table border :data="[props.info]" min-height="0" max-height="100%">
                <vxe-column title="序号" align="center" type="seq" width="50" />
                <vxe-column title="标准名称" field="standardName" :formatter="colNoData" />
                <vxe-column title="企业名称" field="cpyname" :formatter="colNoData" />
                <vxe-column title="申报时间" width="150">
                    <template #default="{ row }">
                        <span>{{ row.createTime }}</span>
                    </template>
                </vxe-column>
                <vxe-column title="申报人" field="createByName" width="120" />
                <vxe-column title="事项状态" width="100">
                    <template #default="{ row }">
                        <DictTag :options="dm_expert_item_list" :value="row?.status"></DictTag>
                    </template>
                </vxe-column>
            </vxe-table>
        </template>
        <template #footer>
            <el-button @click="close">取消</el-button>
            <el-button type="primary" @click="submitForm">确认添加</el-button>
        </template>
    </vxe-modal>
</template>
<script setup name="ChooseDeclarationDecord" lang="tsx">
import { colNoData } from '@/utils/noData';
import { propTypes } from '@/utils/propTypes';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { dm_expert_item_list } = toRefs<any>(proxy?.useDict( 'dm_expert_item_list'));

// const { dm_person_type, dm_join_type, yes_no } = toRefs<any>(proxy?.useDict('dm_person_type', 'dm_join_type', 'yes_no', 'sys_sex_type'));
const emit = defineEmits(['update:show', 'close', 'success']);
const props = defineProps({
    show: propTypes.bool.def(false),
    info: propTypes.any.def(null),
    title: propTypes.string.def('审核通过'),
    width: propTypes.number.def(900),
    dict: propTypes.any.def(null),
});
const ChooseExpertRef = ref();
const showChoose = ref(false);
const dialogVisible = ref(props.show);
const close = () => {
    emit('update:show', false);
    emit('close', false);
};

// const list = ref<any[]>(props.info?.personInfo.map(item => {
//     return {
//         ...item,
//         isAppoint: item.isAppoint || '0',
//         personInfos: item.personInfos || [],
//     };
// }) || []);
const list = ref()
list.value =props.info

const rowInfo = ref<any>(null);
const addPerson = (row: any) => {
    rowInfo.value = row;
    showChoose.value = true;
};
const submitForm = async () => {
    try {
        // const persons = list.value.map(item => {
        //     return {
        //         personType: item.personType,
        //         personCount: item.personCount,
        //         isAppoint: item.isAppoint,
        //         personIds: +item.isAppoint ? item.personInfos.map((person: any) => person.id) : []
        //     };
        // });
        emit('success');
    } catch (error) {
        console.error(error);
    }
};
const changeSuccesss = (val: any) => {
    rowInfo.value.personInfos = [...val]
};
const closeTagPerson = (item: any, index: number) => {
    item.personInfos.splice(index, 1);
};
watch(
    () => props.show,
    (val) => {
        dialogVisible.value = val;
    }
);
</script>
