<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="市场经营--客户回访列表" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-descriptions :column="2" border>
                <el-descriptions-item label="合同名称" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.contract_name }}</el-descriptions-item>
                <el-descriptions-item label="回访编号" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.code }}</el-descriptions-item>
                <el-descriptions-item label="回访方式" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.return_visit_type_text }}</el-descriptions-item>
                <el-descriptions-item label="回访表模板" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.template_name
                }}</el-descriptions-item>
                <el-descriptions-item label="回访人" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.create_user
                }}</el-descriptions-item>
                <el-descriptions-item label="回访时间" label-align="left" align="left" label-class-name="my-label"> {{
                    formData.create_time
                }}</el-descriptions-item>
                <el-descriptions-item label="附件" label-align="left" align="left" label-class-name="my-label">
                    <annexLink :annex="formData.annex"></annexLink>
                </el-descriptions-item>
            </el-descriptions>
            <el-card>
                <template #header>
                    调查内容
                </template>
                <el-table :data="formData.survey" stripe style="width: 100%">
                    <el-table-column label="调查内容" prop='survey_content' />
                    <el-table-column label="内容说明" prop='survey_content_desc' />
                    <el-table-column label="评价内容" prop='evaluate_content' />
                    <el-table-column label="备注" prop='remark' />
                </el-table>
            </el-card>
            <el-card>
                <template #header>
                    项目成员评价
                </template>
                <el-table :data="formData.evaluate" stripe style="width: 100%">
                    <el-table-column label="姓名" prop='name' />
                    <el-table-column label="岗位" prop='job' />
                    <el-table-column label="意见和建议" prop='opinions' />
                </el-table>
            </el-card>


        </popup>

    </div>
</template>

<script lang="ts" setup name="customdetail">
import Popup from '@/components/popup/index.vue'
import { apimarketing_custom_return_visit_surveyLists, apimarketing_custom_return_visit_evaluateLists } from '@/api/marketing_custom_return_visit'
import type { PropType } from 'vue'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const popupRef = shallowRef<InstanceType<typeof Popup>>()

// 表单数据
const formData = reactive({
    id: '',
    contract_id: '',
    code: '',
    return_visit_type: '',
    custom_return_visit_template_id: '',
    template_name: "",
    return_visit_type_text: "",
    annex: '',
    create_user: '',
    create_time: '',
    survey: [],
    evaluate: []
})

// 获取详情
const setFormData = async (data: Record<any, any>) => {
    for (const key in formData) {
        if (data[key] != null && data[key] != undefined) {
            //@ts-ignore
            formData[key] = data[key]
        }
    }
    let res = await apimarketing_custom_return_visit_surveyLists({ custom_return_visit_id: data.id })
    formData.survey = res.lists
    let res1 = await apimarketing_custom_return_visit_evaluateLists({ custom_return_visit_id: data.id })
    formData.evaluate = res1.lists

}




// 提交按钮
const handleSubmit = async () => {
    popupRef.value?.close()

}

//打开弹窗
const open = () => {
    popupRef.value?.open()
}

// 关闭回调
const handleClose = () => {
    emit('close')
}




defineExpose({
    open,
    setFormData,
})
</script>

