|
|
|
|
@ -594,9 +594,9 @@
|
|
|
|
|
</template>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 合同选择(如果所选的事前流程分支的need_contract为true) -->
|
|
|
|
|
<!-- 合同选择(如果所选的事前流程分支允许关联合同) -->
|
|
|
|
|
<el-card
|
|
|
|
|
v-if="selectedCategory?.need_contract"
|
|
|
|
|
v-if="allowsContractSelection(selectedCategory)"
|
|
|
|
|
class="form-section"
|
|
|
|
|
shadow="never"
|
|
|
|
|
>
|
|
|
|
|
@ -886,9 +886,9 @@
|
|
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<!-- 合同选择(支付分类需要关联合同时) -->
|
|
|
|
|
<!-- 合同选择(支付分类允许关联合同时) -->
|
|
|
|
|
<el-form-item
|
|
|
|
|
v-if="selectedPaymentCategory?.need_contract"
|
|
|
|
|
v-if="allowsContractSelection(selectedPaymentCategory)"
|
|
|
|
|
label="关联合同"
|
|
|
|
|
>
|
|
|
|
|
<!-- 如果第三步已选择合同,则复用第三步的合同,且不可更改 -->
|
|
|
|
|
@ -1979,6 +1979,19 @@ const loadingCategoryTree = ref(false)
|
|
|
|
|
const categoryTreeData = ref(null)
|
|
|
|
|
const selectedCategory = ref(null)
|
|
|
|
|
|
|
|
|
|
const getContractRequirement = (category) => {
|
|
|
|
|
if (!category) return 'none'
|
|
|
|
|
return category.contract_requirement || (category.need_contract ? 'required' : 'none')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const allowsContractSelection = (category) => {
|
|
|
|
|
return ['optional', 'required'].includes(getContractRequirement(category))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const requiresContractSelection = (category) => {
|
|
|
|
|
return getContractRequirement(category) === 'required'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 合同选择相关(第三步,当 need_contract 为 true 时)
|
|
|
|
|
const selectedExpenditureContract = ref(null)
|
|
|
|
|
const showExpenditureContractSelector = ref(false)
|
|
|
|
|
@ -4392,20 +4405,20 @@ const nextStep = async () => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(如果所选的事前流程分支的need_contract为true)
|
|
|
|
|
if (selectedCategory.value?.need_contract) {
|
|
|
|
|
if (!selectedExpenditureContract.value) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(如果所选的事前流程分支要求必须关联合同)
|
|
|
|
|
if (requiresContractSelection(selectedCategory.value) && !selectedExpenditureContract.value) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selectedExpenditureContract.value) {
|
|
|
|
|
const paymentCount = selectedExpenditureContract.value.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(selectedExpenditureContract.value.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(selectedExpenditureContract.value),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -4460,20 +4473,20 @@ const nextStep = async () => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(如果所选的事前流程分支的need_contract为true)
|
|
|
|
|
if (selectedCategory.value?.need_contract) {
|
|
|
|
|
if (!selectedExpenditureContract.value) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(如果所选的事前流程分支要求必须关联合同)
|
|
|
|
|
if (requiresContractSelection(selectedCategory.value) && !selectedExpenditureContract.value) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selectedExpenditureContract.value) {
|
|
|
|
|
const paymentCount = selectedExpenditureContract.value.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(selectedExpenditureContract.value.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(selectedExpenditureContract.value),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -4519,7 +4532,7 @@ const nextStep = async () => {
|
|
|
|
|
currentStep.value++
|
|
|
|
|
|
|
|
|
|
// 如果支付分类需要关联合同,检查合同是否已关联过非直接支付
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 获取实际使用的合同(如果复用第三步的合同,使用第三步的合同;否则使用第五步选择的合同)
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
|
|
|
|
|
@ -4530,9 +4543,9 @@ const nextStep = async () => {
|
|
|
|
|
const paidAmount = Number(actualContract.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(actualContract),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -4568,21 +4581,23 @@ const nextStep = async () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(支付分类需要关联合同时)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
if (requiresContractSelection(selectedPaymentCategory.value) && !(isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value)) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 获取实际使用的合同(如果复用第三步的合同,使用第三步的合同;否则使用第六步选择的合同)
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
|
|
|
|
|
if (!actualContract) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const paymentCount = actualContract.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(actualContract.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(actualContract),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -4672,10 +4687,8 @@ const canNextStep = computed(() => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(如果所选的事前流程分支的need_contract为true)
|
|
|
|
|
if (selectedCategory.value?.need_contract) {
|
|
|
|
|
if (!selectedExpenditureContract.value) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if (requiresContractSelection(selectedCategory.value) && !selectedExpenditureContract.value) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
@ -4693,7 +4706,7 @@ const canNextStep = computed(() => {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
// 验证合同选择(支付分类需要关联合同时)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
if (requiresContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 如果复用第三步的合同,使用第三步的合同;否则使用第五步选择的合同
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
if (!actualContract) {
|
|
|
|
|
@ -5369,8 +5382,8 @@ const loadPaymentTemplateElements = async () => {
|
|
|
|
|
if (response.code === 0) {
|
|
|
|
|
paymentTemplateElements.value = response.data || []
|
|
|
|
|
|
|
|
|
|
// 如果第三步已选择合同,且第六步也需要合同,则自动复用第三步的合同
|
|
|
|
|
if (selectedCategory.value?.need_contract && selectedExpenditureContract.value && selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
// 如果第三步已选择合同,且第六步也允许合同,则自动复用第三步的合同
|
|
|
|
|
if (allowsContractSelection(selectedCategory.value) && selectedExpenditureContract.value && allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
selectedPaymentContract.value = selectedExpenditureContract.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -5435,33 +5448,36 @@ const checkAndAutoProceedFromStep5 = async () => {
|
|
|
|
|
return // 金额验证不通过,不自动进入下一步
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(支付分类需要关联合同时)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
// 验证合同选择(支付分类允许关联合同时)
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 获取实际使用的合同(如果复用第三步的合同,使用第三步的合同;否则使用第五步选择的合同)
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
|
|
|
|
|
if (!actualContract) {
|
|
|
|
|
if (requiresContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 合同未选择,跳过')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 合同未选择,跳过')
|
|
|
|
|
return // 合同未选择,不自动进入下一步
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const paymentCount = actualContract.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(actualContract.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 合同已关联过,跳过')
|
|
|
|
|
return // 合同已关联过,不自动进入下一步
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证本次支付金额不能超过剩余金额
|
|
|
|
|
const remainingAmount = isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContractRemainingAmount.value
|
|
|
|
|
: paymentContractRemainingAmount.value
|
|
|
|
|
const paymentAmount = Number(paymentFormData.amount) || 0
|
|
|
|
|
if (paymentAmount > remainingAmount) {
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 金额超过剩余金额,跳过', paymentAmount, remainingAmount)
|
|
|
|
|
return // 金额超过剩余金额,不自动进入下一步
|
|
|
|
|
} else {
|
|
|
|
|
const paymentCount = actualContract.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(actualContract.payment_stats?.paid_amount || 0)
|
|
|
|
|
|
|
|
|
|
// 如果有已支付记录,说明已经关联过非直接支付,不允许继续
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 合同已关联过,跳过')
|
|
|
|
|
return // 合同已关联过,不自动进入下一步
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证本次支付金额不能超过剩余金额
|
|
|
|
|
const remainingAmount = isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContractRemainingAmount.value
|
|
|
|
|
: paymentContractRemainingAmount.value
|
|
|
|
|
const paymentAmount = Number(paymentFormData.amount) || 0
|
|
|
|
|
if (paymentAmount > remainingAmount) {
|
|
|
|
|
console.log('checkAndAutoProceedFromStep5: 金额超过剩余金额,跳过', paymentAmount, remainingAmount)
|
|
|
|
|
return // 金额超过剩余金额,不自动进入下一步
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -6036,15 +6052,17 @@ const autoFinalSubmit = async () => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(支付分类需要关联合同时)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
// 验证合同选择(支付分类允许关联合同时)
|
|
|
|
|
if (requiresContractSelection(selectedPaymentCategory.value) && !(isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value)) {
|
|
|
|
|
ElMessage.warning('已创建OA流程,但缺少关联合同,请选择合同后手动提交')
|
|
|
|
|
autoSubmitFailed.value = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
if (!actualContract) {
|
|
|
|
|
ElMessage.warning('已创建OA流程,但缺少关联合同,请选择合同后手动提交')
|
|
|
|
|
autoSubmitFailed.value = true
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (actualContract.amount_type === 'fixed') {
|
|
|
|
|
// 可选场景下允许不选
|
|
|
|
|
} else if (actualContract.amount_type === 'fixed') {
|
|
|
|
|
const remainingAmount = isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContractRemainingAmount.value
|
|
|
|
|
: paymentContractRemainingAmount.value
|
|
|
|
|
@ -6065,12 +6083,12 @@ const autoFinalSubmit = async () => {
|
|
|
|
|
const amountNumber = Number(paymentFormData.amount)
|
|
|
|
|
|
|
|
|
|
// 获取第三步选择的合同ID(如果need_contract为true)
|
|
|
|
|
const expenditureContractId = selectedCategory.value?.need_contract && selectedExpenditureContract.value
|
|
|
|
|
const expenditureContractId = allowsContractSelection(selectedCategory.value) && selectedExpenditureContract.value
|
|
|
|
|
? selectedExpenditureContract.value.id
|
|
|
|
|
: null
|
|
|
|
|
|
|
|
|
|
// 获取支付明细的合同ID(如果need_contract为true)
|
|
|
|
|
const paymentDetailContractId = selectedPaymentCategory.value?.need_contract
|
|
|
|
|
const paymentDetailContractId = allowsContractSelection(selectedPaymentCategory.value)
|
|
|
|
|
? (isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContract.value?.id
|
|
|
|
|
: selectedPaymentContract.value?.id)
|
|
|
|
|
@ -6198,24 +6216,27 @@ const handleFinalSubmit = async () => {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证合同选择(支付分类需要关联合同时)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
// 验证合同选择(支付分类允许关联合同时)
|
|
|
|
|
if (requiresContractSelection(selectedPaymentCategory.value) && !(isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value)) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 获取实际使用的合同(如果复用第三步的合同,使用第三步的合同;否则使用第六步选择的合同)
|
|
|
|
|
const actualContract = isPaymentContractReused.value ? reusedPaymentContract.value : selectedPaymentContract.value
|
|
|
|
|
|
|
|
|
|
if (!actualContract) {
|
|
|
|
|
ElMessage.warning('请选择关联合同')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 可选场景下允许不选
|
|
|
|
|
} else {
|
|
|
|
|
// 闭口合同:验证本次支付金额不能超过剩余金额
|
|
|
|
|
if (actualContract.amount_type === 'fixed') {
|
|
|
|
|
const remainingAmount = isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContractRemainingAmount.value
|
|
|
|
|
: paymentContractRemainingAmount.value
|
|
|
|
|
const paymentAmount = Number(paymentFormData.amount) || 0
|
|
|
|
|
if (paymentAmount > remainingAmount) {
|
|
|
|
|
ElMessage.warning(`本次支付金额不能超过合同剩余金额 ${formatAmount(remainingAmount)}`)
|
|
|
|
|
return
|
|
|
|
|
if (actualContract.amount_type === 'fixed') {
|
|
|
|
|
const remainingAmount = isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContractRemainingAmount.value
|
|
|
|
|
: paymentContractRemainingAmount.value
|
|
|
|
|
const paymentAmount = Number(paymentFormData.amount) || 0
|
|
|
|
|
if (paymentAmount > remainingAmount) {
|
|
|
|
|
ElMessage.warning(`本次支付金额不能超过合同剩余金额 ${formatAmount(remainingAmount)}`)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -6243,12 +6264,12 @@ const handleFinalSubmit = async () => {
|
|
|
|
|
const amountNumber = Number(paymentFormData.amount)
|
|
|
|
|
|
|
|
|
|
// 获取第三步选择的合同ID(如果need_contract为true)
|
|
|
|
|
const expenditureContractId = selectedCategory.value?.need_contract && selectedExpenditureContract.value
|
|
|
|
|
const expenditureContractId = allowsContractSelection(selectedCategory.value) && selectedExpenditureContract.value
|
|
|
|
|
? selectedExpenditureContract.value.id
|
|
|
|
|
: null
|
|
|
|
|
|
|
|
|
|
// 获取支付明细的合同ID(如果need_contract为true)
|
|
|
|
|
const paymentDetailContractId = selectedPaymentCategory.value?.need_contract
|
|
|
|
|
const paymentDetailContractId = allowsContractSelection(selectedPaymentCategory.value)
|
|
|
|
|
? (isPaymentContractReused.value
|
|
|
|
|
? reusedPaymentContract.value?.id
|
|
|
|
|
: selectedPaymentContract.value?.id)
|
|
|
|
|
@ -6445,7 +6466,7 @@ const getBreadcrumbPath = () => {
|
|
|
|
|
// 获取预览时应该显示的合同信息
|
|
|
|
|
const getPreviewContract = () => {
|
|
|
|
|
// 优先显示第六步的合同(如果第六步需要合同且已选择)
|
|
|
|
|
if (selectedPaymentCategory.value?.need_contract) {
|
|
|
|
|
if (allowsContractSelection(selectedPaymentCategory.value)) {
|
|
|
|
|
// 如果复用第三步的合同,使用第三步的合同
|
|
|
|
|
if (isPaymentContractReused.value && reusedPaymentContract.value) {
|
|
|
|
|
return reusedPaymentContract.value
|
|
|
|
|
@ -6456,7 +6477,7 @@ const getPreviewContract = () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 如果第六步没有合同,但第三步有合同,显示第三步的合同
|
|
|
|
|
if (selectedCategory.value?.need_contract && selectedExpenditureContract.value) {
|
|
|
|
|
if (allowsContractSelection(selectedCategory.value) && selectedExpenditureContract.value) {
|
|
|
|
|
return selectedExpenditureContract.value
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
@ -6499,6 +6520,27 @@ const formatAmount = (amount) => {
|
|
|
|
|
return '¥' + numAmount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const buildContractLinkedIndirectPaymentMessage = (contract) => {
|
|
|
|
|
const payments = Array.isArray(contract?.related_indirect_payments)
|
|
|
|
|
? contract.related_indirect_payments
|
|
|
|
|
: []
|
|
|
|
|
if (payments.length === 0) {
|
|
|
|
|
return '该合同已关联过非直接支付,不允许再次关联。请选择其他合同。'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const names = payments
|
|
|
|
|
.slice(0, 3)
|
|
|
|
|
.map((payment) => {
|
|
|
|
|
const name = payment.name || payment.oa_flow_title || payment.planned_expenditure_title || payment.serial_number || `非直接支付#${payment.id}`
|
|
|
|
|
const serial = payment.serial_number ? `(${payment.serial_number})` : ''
|
|
|
|
|
return `${name}${serial}`
|
|
|
|
|
})
|
|
|
|
|
const more = payments.length > names.length ? `等 ${payments.length} 条` : ''
|
|
|
|
|
return `该合同已关联过非直接支付:${names.join('、')}${more},不允许再次关联。请选择其他合同。`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const shouldBlockAlreadyLinkedContract = () => false
|
|
|
|
|
|
|
|
|
|
// 金额转中文大写(与直接支付页面一致)
|
|
|
|
|
const formatUppercaseAmount = (amount) => {
|
|
|
|
|
const n = Number(amount)
|
|
|
|
|
@ -6515,9 +6557,9 @@ const handleExpenditureContractSelected = async (contract) => {
|
|
|
|
|
// 统一按闭口合同逻辑处理:检查是否已关联过非直接支付
|
|
|
|
|
const paymentCount = contract.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(contract.payment_stats?.paid_amount || 0)
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(contract),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -6574,9 +6616,9 @@ const handlePaymentContractSelected = async (contract) => {
|
|
|
|
|
// 统一按闭口合同逻辑处理:检查是否已关联过非直接支付
|
|
|
|
|
const paymentCount = contract.payment_stats?.payment_count || 0
|
|
|
|
|
const paidAmount = Number(contract.payment_stats?.paid_amount || 0)
|
|
|
|
|
if (paidAmount > 0 || paymentCount > 0) {
|
|
|
|
|
if (shouldBlockAlreadyLinkedContract() && (paidAmount > 0 || paymentCount > 0)) {
|
|
|
|
|
await ElMessageBox.alert(
|
|
|
|
|
'该合同已关联过非直接支付,不允许再次关联。请选择其他合同。',
|
|
|
|
|
buildContractLinkedIndirectPaymentMessage(contract),
|
|
|
|
|
'提示',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
@ -6607,9 +6649,9 @@ const paymentContractRemainingAmount = computed(() => {
|
|
|
|
|
|
|
|
|
|
// 判断是否复用第三步的合同
|
|
|
|
|
const isPaymentContractReused = computed(() => {
|
|
|
|
|
return selectedCategory.value?.need_contract &&
|
|
|
|
|
return allowsContractSelection(selectedCategory.value) &&
|
|
|
|
|
selectedExpenditureContract.value &&
|
|
|
|
|
selectedPaymentCategory.value?.need_contract
|
|
|
|
|
allowsContractSelection(selectedPaymentCategory.value)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 获取复用的合同(第三步的合同)
|
|
|
|
|
|