|
|
@@ -6,7 +6,12 @@
|
|
|
<uni-section titleFontSize="1.3rem" title="基本信息" type="line"></uni-section>
|
|
|
<uni-forms ref="baseFormRef" :modelValue="baseForm" :rules="baseFormRules" label-position="left" :label-width="100" :border="true">
|
|
|
<uni-forms-item name="contract_number" label="合同编号">
|
|
|
- <uni-easyinput v-model="baseForm.contract_number" disabled placeholder="自动生成"></uni-easyinput>
|
|
|
+ <!-- 发起环节或字段可编辑时显示输入框 -->
|
|
|
+ <uni-easyinput v-if="isInitiateOrFieldEditable('contract_number')"
|
|
|
+ v-model="baseForm.contract_number"
|
|
|
+ placeholder="请输入合同编号"></uni-easyinput>
|
|
|
+ <!-- 否则显示只读文本 -->
|
|
|
+ <uni-easyinput v-else v-model="baseForm.contract_number" disabled></uni-easyinput>
|
|
|
</uni-forms-item>
|
|
|
<uni-forms-item name="contract_name" label="合同名称" required>
|
|
|
<uni-easyinput v-model="baseForm.contract_name"
|
|
|
@@ -594,7 +599,7 @@ import { ref, watch, computed, nextTick, onMounted } from 'vue'
|
|
|
import { useUserStore } from '@/store/user.js'
|
|
|
import config from '@/config.js'
|
|
|
import { uploadSignatureBoardImg, getSeal } from '@/api/process.js'
|
|
|
-import { getContractTypeList, getPaymentTypeList, getMaterialList, getSupplierList, getClientList, getPurchaseApplyList, getPurchaseDetailList } from '@/api/contract.js'
|
|
|
+import { getContractTypeList, getPaymentTypeList, getMaterialList, getSupplierList, getClientList, getPurchaseApplyList, getPurchaseDetailList, checkContractNumber } from '@/api/contract.js'
|
|
|
import $modal from '@/plugins/modal.js'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
@@ -686,7 +691,9 @@ const baseForm = ref<any>({
|
|
|
contract_entrying_operator: '',
|
|
|
contract_entrying_operator_name: '',
|
|
|
// 组织 ID
|
|
|
- unit_id: ''
|
|
|
+ unit_id: '',
|
|
|
+ // 合同ID(用于审批流程中排除自己)
|
|
|
+ universalid: ''
|
|
|
})
|
|
|
|
|
|
const baseFormRules = ref({
|
|
|
@@ -823,7 +830,9 @@ watch(() => props.formData, (newVal) => {
|
|
|
// 组织 ID
|
|
|
unit_id: newVal.unit_id || '',
|
|
|
// 保存公司名称,用于销售合同时对调需方供方(从后端获取)
|
|
|
- companyName: newVal.companyName || ''
|
|
|
+ companyName: newVal.companyName || '',
|
|
|
+ // 合同ID(用于审批流程中排除自己)
|
|
|
+ universalid: newVal.universalid || ''
|
|
|
}
|
|
|
|
|
|
// 从 contractMaterialList 中获取物料列表
|
|
|
@@ -1688,6 +1697,24 @@ function closeSignature() {
|
|
|
// 暴露验证方法给父组件
|
|
|
defineExpose({
|
|
|
validate: async () => {
|
|
|
+ // 合同编号验证(发起环节或字段可编辑时需要验证)
|
|
|
+ if (isSeModel.value || getFieldEditable('contract_number')) {
|
|
|
+ if (!baseForm.value.contract_number || !baseForm.value.contract_number.trim()) {
|
|
|
+ return Promise.reject(new Error('合同编号不能为空!'))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证合同编号唯一性(异步调用后端接口)
|
|
|
+ try {
|
|
|
+ const res = await checkContractNumber(userStore.user.useId, baseForm.value.contract_number, baseForm.value.universalid || '')
|
|
|
+ if (res.returnCode !== '1') {
|
|
|
+ return Promise.reject(new Error(res.returnMsg || '合同编号验证失败'))
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('合同编号验证失败', error)
|
|
|
+ return Promise.reject(new Error('合同编号验证失败,请重试'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 基本信息验证
|
|
|
if (!baseForm.value.contract_name || !baseForm.value.contract_name.trim()) {
|
|
|
return Promise.reject(new Error('合同名称不能为空!'))
|