From c81c0415827887522631ca4d96e4966f6d5ee7c2 Mon Sep 17 00:00:00 2001 From: yinq Date: Mon, 20 Oct 2025 14:41:04 +0800 Subject: [PATCH] =?UTF-8?q?1.0.13=20=E5=90=88=E5=90=8C=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/oa/erp/contractInfo/edit.vue | 105 +++++++++++++++++++++--- src/views/oa/erp/contractInfo/index.vue | 12 +-- 2 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/views/oa/erp/contractInfo/edit.vue b/src/views/oa/erp/contractInfo/edit.vue index ce19e93..22dc4af 100644 --- a/src/views/oa/erp/contractInfo/edit.vue +++ b/src/views/oa/erp/contractInfo/edit.vue @@ -122,13 +122,21 @@ - - + + + + - - + + + 上传合同附件 @@ -208,7 +216,7 @@ - {{ dict.label }} + {{ dict.label }} @@ -326,6 +334,21 @@ + + + + + + + + + + @@ -340,6 +363,7 @@ import SaleMaterialSelect from '@/components/SaleMaterialSelect/index.vue'; import { ref } from 'vue'; import { listDept } from '@/api/system/dept'; import { getCrmCustomerInfoList } from '@/api/oa/crm/customerInfo'; +import { getBasePrintTemplateList } from '@/api/oa/base/printTemplate'; const route = useRoute(); const { proxy } = getCurrentInstance() as ComponentInternalInstance; @@ -350,6 +374,15 @@ const { contract_category, business_direction, active_flag, contract_flag, contr const buttonLoading = ref(false); const contractInfoFormRef = ref(); +const type = ref(0); +const dialog = reactive({ + visible: false, + title: '' +}); + +// OSS 上传内部 v-model 中转,避免直接绑定到 form 的未知属性 +const ossFileModel = ref(undefined); + // 合同编号生成状态 const isCodeGenerated = ref(false); @@ -363,6 +396,13 @@ const contractMaterialList = computed(() => { return (form.value as any).contractMaterialList || []; }); +/** 查询打印模板下拉框结构 */ +const printTemplateList = ref([]); +const getPrintTemplateListSelect = async () => { + let res = await getBasePrintTemplateList(null); + printTemplateList.value = res.data; +}; + /** 查询单位信息下拉框结构 */ const unitInfoList = ref([]); const getUnitInfoListSelect = async () => { @@ -419,7 +459,9 @@ const materialRules = { taxRate: [{ required: true, message: '税率不能为空', trigger: 'blur' }] }; -const initFormData: ContractInfoForm = { +type ContractInfoFormEx = ContractInfoForm & { file?: any }; + +const initFormData: ContractInfoFormEx = { contractId: undefined, contractFlag: '1', contractCode: undefined, @@ -445,10 +487,11 @@ const initFormData: ContractInfoForm = { taxRate: undefined, remark: undefined, activeFlag: '1', - contractMaterialList: [] + contractMaterialList: [], + file: undefined } as any; -const data = reactive<{ form: ContractInfoForm; rules: any }>({ +const data = reactive<{ form: ContractInfoFormEx; rules: any }>({ form: { ...initFormData }, rules: { contractId: [{ required: true, message: '合同ID不能为空', trigger: 'blur' }] @@ -476,7 +519,6 @@ watch( // 生成合同编号 const generateContractCode = async () => { if (isCodeGenerated.value) return; // 如果已经生成过,直接返回 - try { const params = { codeRuleCode: '1001' } as any; const res = await getRuleGenerateCode(params); @@ -509,6 +551,20 @@ const saleMaterialSelectCallBack = (data) => { } }; +/** 取消按钮 */ +function cancel() { + dialog.visible = false; +} + +/** 文件按钮操作 */ +const handleFile = () => { + type.value = 0; + dialog.visible = true; + dialog.title = '上传合同附件'; + // 打开时回显已有附件 + ossFileModel.value = form.value.ossId as any; +}; + const submitForm = () => { contractInfoFormRef.value?.validate(async (valid: boolean) => { if (valid) { @@ -524,6 +580,14 @@ const submitForm = () => { }); }; +// 确认上传,仅关闭弹窗并依赖 v-model 同步到 ossId +const submitOss = () => { + // 将上传组件返回的 ossId 串写回表单 + form.value.ossId = ossFileModel.value as any; + dialog.visible = false; + proxy?.$modal.msgSuccess('附件已更新'); +}; + // 获取合同物料列表 const getContractMaterialList = async () => { if (!form.value.contractId) return; @@ -670,8 +734,17 @@ const submitMaterialForm = () => { }); }; +//初始化调用 +const loadSelectOptions = () => { + getUnitInfoListSelect(); + getDeptInfoListSelect(); + getCustomerInfoListSelect(); + getPrintTemplateListSelect(); +}; + onMounted(async () => { const id = (route.query.id || route.params.id) as string | number; + loadSelectOptions(); if (id) { proxy?.$modal.loading('正在加载数据,请稍后...'); const res = await getContractInfo(id); @@ -697,8 +770,16 @@ onMounted(async () => { isCodeGenerated.value = false; } } - await getUnitInfoListSelect(); - await getDeptInfoListSelect(); - await getCustomerInfoListSelect(); }); + +// 监听上传组件返回的文件(ossId 串)并同步到表单字段 +// 同步表单初值到上传模型 +watch( + () => form.value.ossId, + (val) => { + if (!dialog.visible) { + ossFileModel.value = val as any; + } + } +); diff --git a/src/views/oa/erp/contractInfo/index.vue b/src/views/oa/erp/contractInfo/index.vue index d5a698a..be4b93f 100644 --- a/src/views/oa/erp/contractInfo/index.vue +++ b/src/views/oa/erp/contractInfo/index.vue @@ -81,8 +81,8 @@ - - + + - + - + - + - +