| | |
| | | </a-descriptions-item> |
| | | </a-descriptions> |
| | | </a-card> |
| | | <!-- <a-card title="语义词信息"> |
| | | <div v-if="semanticWords.length > 0"> |
| | | <a-descriptions title="" :column="1"> |
| | | <a-descriptions-item v-for="(word, index) in semanticWords" :key="index" :label="`语义词 ${index + 1}`"> |
| | | <span>{{ word.word || '-' }}</span> |
| | | </a-descriptions-item> |
| | | <a-descriptions-item v-for="(word, index) in semanticWords" :key="index" :label="`露出词 ${index + 1}`"> |
| | | <span>{{ word.outWord || '-' }}</span> |
| | | </a-descriptions-item> |
| | | </a-descriptions> |
| | | </div> |
| | | <div v-else> |
| | | <a-empty description="暂无语义词数据" /> |
| | | </div> |
| | | </a-card> --> |
| | | <a-card title="语义词信息"> |
| | | <div v-if="semanticWords.length > 0"> |
| | | <a-row :gutter="16"> |
| | |
| | | <script lang="ts"> |
| | | import { defineComponent, reactive, ref, onMounted } from 'vue'; |
| | | import { PageWrapper } from '/@/components/Page'; |
| | | import { message } from 'ant-design-vue'; |
| | | import { useRoute, useRouter } from 'vue-router'; |
| | | import { defHttp } from '/@/utils/http/axios'; |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | export default defineComponent({ |
| | | name: 'DescDetailKehu', |
| | | name: 'DescDetailYuyici', |
| | | components: { PageWrapper }, |
| | | setup() { |
| | | const route = useRoute(); |
| | | const router = useRouter(); |
| | | |
| | | // 初始数据 |
| | | const initialData = { |
| | | id: '', |
| | | createTime: '', |
| | | updateBy: null, |
| | | updateTime: null, |
| | | agentsId: null, |
| | | agentsName: null, |
| | | contractFileList: null, |
| | | contractName: '', |
| | | createBy: '', |
| | | // 页面展示用数据结构,尽量与模板字段对应 |
| | | const formData = reactive<any>({ |
| | | startDate: '', |
| | | endDate: '', |
| | | customer: { |
| | | id: '', |
| | | createBy: '', |
| | | createTime: '', |
| | | updateBy: null, |
| | | updateTime: null, |
| | | agentsName: null, |
| | | contactPerson: '', |
| | | contract: null, |
| | | customerAddress: '', |
| | | customerEmail: '', |
| | | customerPhone: '', |
| | | enterpriseName: '', |
| | | industry: '', |
| | | semanticWordList: null, |
| | | customerAddress: '', |
| | | contactPerson: '', |
| | | customerPhone: '', |
| | | customerEmail: '', |
| | | }, |
| | | customerName: '', |
| | | endDate: '', |
| | | rejectionReasons: null, |
| | | reviewStatus: '', |
| | | semanticWordList: null, |
| | | startDate: '', |
| | | sysOrgCode: '', |
| | | }; |
| | | }); |
| | | |
| | | // 响应式表单数据 |
| | | const formData = reactive({ ...initialData }); |
| | | |
| | | // 语义词列表 |
| | | // 语义词数据(右侧列表展示) |
| | | const semanticWords = ref<any[]>([]); |
| | | |
| | | // 合同文件列表 |
| | | // 合同文件、附件(接口暂无,保持空数组避免模板报错) |
| | | const contractFiles = ref<any[]>([]); |
| | | const attachmentFiles = ref<any[]>([]); |
| | | |
| | | // 加载客户数据 |
| | | const loadCustomerData = async () => { |
| | | // 从语义词列表接口按 id 获取一条数据 |
| | | const loadDataFromSemanticwordList = async () => { |
| | | const id = route.query.id as string; |
| | | console.log('当前请求的客户ID:', id); |
| | | if (id) { |
| | | try { |
| | | // 调用API根据id获取客户数据 |
| | | const result = await defHttp.get({ |
| | | url: '/contract/contract/queryById', |
| | | params: { id }, |
| | | }); |
| | | console.log('客户详情数据:', result); |
| | | if (result) { |
| | | const customerData = result; |
| | | // 填充表单数据 |
| | | Object.assign(formData, customerData); |
| | | if (!id) { |
| | | message.error('缺少ID参数'); |
| | | return; |
| | | } |
| | | try { |
| | | // 优先按 id 过滤请求,后端若不支持则回退到前端过滤 |
| | | const res = await defHttp.get({ |
| | | url: '/semanticword/semanticWord/list', |
| | | params: { id }, |
| | | }); |
| | | |
| | | // 加载合同文件数据 |
| | | await loadContractFiles(id); |
| | | |
| | | // 加载语义词数据 |
| | | await loadSemanticWords(id); |
| | | } else { |
| | | message.error('加载客户详情数据失败'); |
| | | } |
| | | } catch (error) { |
| | | console.error('加载客户详情数据失败:', error); |
| | | message.error('加载客户详情数据失败'); |
| | | // 兼容返回对象或数组 |
| | | let record: any | null = null; |
| | | if (Array.isArray(res)) { |
| | | record = res.find((item: any) => String(item.id) === String(id)) || res[0] || null; |
| | | } else if (res?.records && Array.isArray(res.records)) { |
| | | record = res.records.find((item: any) => String(item.id) === String(id)) || res.records[0] || null; |
| | | } else if (res && typeof res === 'object') { |
| | | // 可能直接返回单条 |
| | | record = res; |
| | | } |
| | | } else { |
| | | message.error('缺少客户ID参数'); |
| | | |
| | | if (!record) { |
| | | message.warning('未找到对应语义词数据'); |
| | | return; |
| | | } |
| | | |
| | | // 将可映射字段填充到页面已有结构 |
| | | formData.startDate = record.startDate || ''; |
| | | formData.endDate = record.endDate || ''; |
| | | |
| | | // 若列表项中包含客户相关信息,则尽可能填充 |
| | | formData.customer.enterpriseName = record.enterpriseName || record.customerName || ''; |
| | | formData.customer.industry = record.industry || ''; |
| | | formData.customer.customerAddress = record.customerAddress || ''; |
| | | formData.customer.contactPerson = record.contactPerson || ''; |
| | | formData.customer.customerPhone = record.customerPhone || ''; |
| | | formData.customer.customerEmail = record.customerEmail || ''; |
| | | |
| | | // 语义词信息面板:使用当前记录(含 word/outWord 等) |
| | | semanticWords.value = [record]; |
| | | |
| | | // 使用当前记录中的合同ID,继续查询合同详情列表进行信息填充 |
| | | const contractId = record?.contract?.id || record?.contractId || record?.contract_id; |
| | | if (contractId) { |
| | | await loadContractInfoById(contractId); |
| | | } |
| | | } catch (e) { |
| | | console.error('加载语义词详情失败:', e); |
| | | message.error('加载失败'); |
| | | } |
| | | }; |
| | | |
| | | // 加载合同文件数据 |
| | | const loadContractFiles = async (id: string) => { |
| | | // 通过 /contract/contract/list 获取合同并填充客户/合同信息 |
| | | const loadContractInfoById = async (contractId: string | number) => { |
| | | try { |
| | | const result = await defHttp.get({ |
| | | url: '/contract/contract/queryContractFileByMainId', |
| | | params: { id }, |
| | | const res = await defHttp.get({ |
| | | url: '/contract/contract/list', |
| | | params: { id: contractId }, |
| | | }); |
| | | console.log('合同文件数据:', result); |
| | | // 这里可以根据返回的数据结构处理合同文件 |
| | | if (result && Array.isArray(result)) { |
| | | // 根据 fileType 区分合同文件和附件 |
| | | const contractFileList = []; |
| | | const attachmentFileList = []; |
| | | |
| | | result.forEach((file: any) => { |
| | | const fileItem = { |
| | | uid: file.id, |
| | | name: file.appendixFile || '文件', |
| | | status: 'done', |
| | | url: file.appendixFile, |
| | | }; |
| | | |
| | | if (file.fileType === '合同文件') { |
| | | contractFileList.push(fileItem); |
| | | } else if (file.fileType === '合同附件') { |
| | | attachmentFileList.push(fileItem); |
| | | } |
| | | }); |
| | | |
| | | contractFiles.value = contractFileList; |
| | | attachmentFiles.value = attachmentFileList; |
| | | let contractRecord: any | null = null; |
| | | if (Array.isArray(res)) { |
| | | contractRecord = res.find((it: any) => String(it.id) === String(contractId)) || res[0] || null; |
| | | } else if (res?.records && Array.isArray(res.records)) { |
| | | contractRecord = res.records.find((it: any) => String(it.id) === String(contractId)) || res.records[0] || null; |
| | | } else if (res && typeof res === 'object') { |
| | | contractRecord = res; |
| | | } |
| | | } catch (error) { |
| | | console.error('加载合同文件失败:', error); |
| | | } |
| | | }; |
| | | |
| | | // 加载语义词数据 |
| | | const loadSemanticWords = async (id: string) => { |
| | | try { |
| | | const result = await defHttp.get({ |
| | | url: '/contract/contract/querySemanticWordByMainId', |
| | | params: { id }, |
| | | }); |
| | | console.log('语义词数据:', result); |
| | | // 这里可以根据返回的数据结构处理语义词 |
| | | if (result && Array.isArray(result)) { |
| | | // 将语义词列表保存到响应式变量中 |
| | | semanticWords.value = result; |
| | | } |
| | | } catch (error) { |
| | | console.error('加载语义词失败:', error); |
| | | if (!contractRecord) return; |
| | | |
| | | // 合同信息 |
| | | formData.startDate = contractRecord.startDate || formData.startDate; |
| | | formData.endDate = contractRecord.endDate || formData.endDate; |
| | | |
| | | // 客户信息(尽可能从合同记录或其 customer 字段提取) |
| | | const customer = contractRecord.customer || contractRecord; |
| | | formData.customer.enterpriseName = customer.enterpriseName || customer.customerName || formData.customer.enterpriseName; |
| | | formData.customer.industry = customer.industry || formData.customer.industry; |
| | | formData.customer.customerAddress = customer.customerAddress || formData.customer.customerAddress; |
| | | formData.customer.contactPerson = customer.contactPerson || formData.customer.contactPerson; |
| | | formData.customer.customerPhone = customer.customerPhone || formData.customer.customerPhone; |
| | | formData.customer.customerEmail = customer.customerEmail || formData.customer.customerEmail; |
| | | } catch (e) { |
| | | console.error('加载合同信息失败:', e); |
| | | } |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | loadCustomerData(); |
| | | loadDataFromSemanticwordList(); |
| | | }); |
| | | |
| | | // 返回功能 |
| | | const handleBack = () => { |
| | | router.back(); |
| | | }; |
| | | const handleBack = () => router.back(); |
| | | |
| | | return { |
| | | formData, |