From 2c783310e724c54f3936856410b701a3be79eab4 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期六, 16 五月 2026 10:16:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_NEW_pro' into dev_NEW_pro
---
src/views/procurementManagement/purchaseReturnOrder/New.vue | 324 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 260 insertions(+), 64 deletions(-)
diff --git a/src/views/procurementManagement/purchaseReturnOrder/New.vue b/src/views/procurementManagement/purchaseReturnOrder/New.vue
index d2fe2a9..2c6801d 100644
--- a/src/views/procurementManagement/purchaseReturnOrder/New.vue
+++ b/src/views/procurementManagement/purchaseReturnOrder/New.vue
@@ -26,6 +26,7 @@
v-model="formState.no"
:placeholder="formState.isDefaultNo ? '浣跨敤绯荤粺缂栧彿' : '璇疯緭鍏ラ��鏂欏崟鍙�'"
:disabled="formState.isDefaultNo"
+ style="width: 240px"
>
<template #append>
<el-checkbox v-model="formState.isDefaultNo" size="large" @change="handleChangeIsDefaultNo" />
@@ -69,6 +70,7 @@
v-model="formState.supplierId"
placeholder="璇烽�夋嫨渚涘簲鍟�"
style="width: 240px"
+ filterable
@focus="fetchSupplierOptions"
@change="handleChangeSupplierId"
>
@@ -77,25 +79,6 @@
:key="item.id"
:label="item.supplierName"
:value="item.id"
- />
- </el-select>
- </el-form-item>
-
- <el-form-item
- label="椤圭洰"
- prop="projectId"
- >
- <el-select
- v-model="formState.projectId"
- placeholder="璇烽�夋嫨椤圭洰"
- style="width: 240px"
- @focus="fetchProjectOptions"
- >
- <el-option
- v-for="item in projectOptions"
- :key="item.id"
- :label="item.name"
- :value="item.id"
/>
</el-select>
</el-form-item>
@@ -159,6 +142,7 @@
:reserve-keyword="false"
style="width: 240px"
@focus="fetchUserOptions"
+ @change="formState.preparedUserName = userOptions.find(item => item.userId === formState.preparedUserId)?.nickName || ''"
>
<el-option
v-for="item in userOptions"
@@ -189,6 +173,7 @@
style="width: 240px"
:reserve-keyword="false"
@focus="fetchUserOptions"
+ @change="formState.returnUserName = userOptions.find(item => item.userId === formState.returnUserId)?.nickName || ''"
>
<el-option
v-for="item in userOptions"
@@ -233,7 +218,7 @@
label="澶囨敞锛�"
prop="remark"
>
- <el-input v-model="formState.remark" type="textarea" placeholder="璇疯緭鍏ュ娉�"/>
+ <el-input style="width: 240px" v-model="formState.remark" :rows="1" type="textarea" placeholder="璇疯緭鍏ュ娉�"/>
</el-form-item>
<div style="margin: 20px 0;">
@@ -242,10 +227,11 @@
<span class="title-text">浜у搧鍒楄〃</span>
</div>
<el-button type="primary" size="small" style="margin-bottom: 20px" @click="isShowProductsModal = true" :disabled="!formState.purchaseLedgerId">娣诲姞浜у搧</el-button>
- <el-table :data="formState.purchaseReturnOrderProductsDtos"
+ <div class="product-table-scroll">
+ <el-table class="product-table-inner"
+ :data="formState.purchaseReturnOrderProductsDtos"
border
max-height="400"
- :scroll-y="true"
show-summary
:summary-method="summarizeChildrenTable">
<el-table-column align="center"
@@ -255,6 +241,12 @@
label="搴忓彿"
type="index"
width="60" />
+ <el-table-column label="鍏ュ簱鍗曞彿"
+ prop="inboundBatches"
+ width="150" />
+ <el-table-column label="鎵规鍙�"
+ prop="batchNo"
+ width="150" />
<el-table-column label="浜у搧澶х被"
prop="productCategory" />
<el-table-column label="瑙勬牸鍨嬪彿"
@@ -263,8 +255,17 @@
prop="unit"
width="70" />
<el-table-column label="鏁伴噺"
- prop="quantity"
- width="70" />
+ prop="stockInNum"
+ width="100" />
+ <el-table-column label="鍙��璐ф暟閲�"
+ prop="unQuantity"
+ width="130" />
+ <el-table-column label="宸查��璐ф暟閲�"
+ width="130">
+ <template #default="scope">
+ {{ calcAlreadyReturned(scope.row) }}
+ </template>
+ </el-table-column>
<el-table-column label="閫�璐ф暟閲�"
prop="returnQuantity"
width="180">
@@ -272,34 +273,35 @@
<el-input-number v-model="scope.row.returnQuantity"
controls-position="right"
:step="1"
- :min="1"
- :max="scope.row.quantity"
+ :min="0"
+ :max="getReturnQtyMax(scope.row)"
+ :disabled="getReturnQtyMax(scope.row) <= 0"
+ @change="syncReturnTotal(scope.row)"
required
placeholder="璇疯緭鍏ラ��璐ф暟閲�" />
</template>
</el-table-column>
- <el-table-column label="搴撳瓨棰勮鏁伴噺"
+ <!-- <el-table-column label="搴撳瓨棰勮鏁伴噺"
prop="warnNum"
width="120"
show-overflow-tooltip />
<el-table-column label="绋庣巼(%)"
prop="taxRate"
- width="80" />
+ width="80" /> -->
<el-table-column label="鍚◣鍗曚环(鍏�)"
prop="taxInclusiveUnitPrice"
:formatter="formattedNumber"
- width="150" />
- <el-table-column label="鍚◣鎬讳环(鍏�)"
+ width="120" />
+ <el-table-column label="閫�璐ф�讳环(鍏�)"
prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
- width="150" />
- <el-table-column label="涓嶅惈绋庢�讳环(鍏�)"
- prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
- width="150" />
+ width="120">
+ <template #default="scope">
+ {{ formatAmount(getReturnTotal(scope.row)) || '--' }}
+ </template>
+ </el-table-column>
<el-table-column label="鏄惁璐ㄦ"
prop="isChecked"
- width="150">
+ width="100">
<template #default="scope">
<el-tag :type="scope.row.isChecked ? 'success' : 'info'">
{{ scope.row.isChecked ? '鏄�' : '鍚�' }}
@@ -322,6 +324,7 @@
</template>
</el-table-column>
</el-table>
+ </div>
</div>
<div class="section-title">
@@ -346,26 +349,54 @@
label="鏁村崟鎶樻墸鐜囷細"
prop="totalDiscountAmount"
>
- <el-input-number v-model="formState.totalDiscountRate"
+ <el-input v-model="formState.totalDiscountRate"
controls-position="right"
:step="0.01"
:precision="2"
style="width: 100%;"
- placeholder="璇疯緭鍏ユ暣鍗曟姌鎵g巼"/>
+ @change="totalDiscount"
+ placeholder="璇疯緭鍏ユ暣鍗曟姌鎵g巼">
+ <template #append>
+ %
+ </template>
+ </el-input>
</el-form-item>
<el-form-item
label="鎴愪氦閲戦锛�"
prop="totalAmount"
+ :rules="[
+ {
+ required: true,
+ message: '璇疯緭鍏ユ垚浜ら噾棰�',
+ trigger: 'change',
+ }
+ ]"
>
<el-input-number v-model="formState.totalAmount"
controls-position="right"
:step="0.01"
:precision="2"
style="width: 100%;"
- @change="handleChangeTotalAmount"
placeholder="璇疯緭鍏ユ垚浜ら噾棰�"/>
</el-form-item>
+ <el-form-item label="鏀舵鏂瑰紡" prop="incomeType" :rules="[
+ {
+ required: true,
+ message: '璇烽�夋嫨鏀舵鏂瑰紡',
+ trigger: 'change',
+ }
+ ]">
+ <el-select
+ style="width: 240px;"
+ v-model="formState.incomeType"
+ placeholder="璇烽�夋嫨"
+ clearable
+
+ >
+ <el-option :label="item.label" :value="item.value" v-for="(item,index) in payment_methods" :key="index" />
+ </el-select>
+ </el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
@@ -386,7 +417,7 @@
</template>
<script setup>
-import {ref, computed, getCurrentInstance} from "vue";
+import {ref, computed, getCurrentInstance, watch, defineAsyncComponent} from "vue";
import {createPurchaseReturnOrder} from "@/api/procurementManagement/purchase_return_order.js";
import {getOptions, purchaseList} from "@/api/procurementManagement/procurementLedger.js";
import {userListNoPageByTenantId} from "@/api/system/user.js";
@@ -398,6 +429,24 @@
}
});
let { proxy } = getCurrentInstance()
+const payment_methods = [
+ {
+ "label": "鐜伴噾",
+ "value": "0",
+ },
+ {
+ "label": "鏀エ",
+ "value": "1",
+ },
+ {
+ "label": "閾惰杞处",
+ "value": "2",
+ },
+ {
+ "label": "鍏朵粬",
+ "value": "3",
+ },
+]
const emit = defineEmits(['update:visible', 'completed']);
// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
@@ -405,6 +454,7 @@
no: '',
isDefaultNo: true,
returnType: 0,
+ incomeType: undefined,
remark: '',
supplierId: undefined,
projectId: undefined,
@@ -420,8 +470,6 @@
});
// 渚涘簲鍟嗛�夐」
const supplierOptions = ref([])
-// 椤圭洰閫夐」
-const projectOptions = ref([])
// 椤圭洰闃舵閫夐」
const projectStageOptions = ref([
{
@@ -465,6 +513,72 @@
return parseFloat(cellValue).toFixed(2);
};
+const formatAmount = (value) => {
+ if (value === null || value === undefined || value === '') {
+ return '--'
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return '--'
+ }
+ return num.toFixed(2)
+}
+
+const toNumber = (val) => {
+ const num = Number(val)
+ return Number.isNaN(num) ? 0 : num
+}
+
+/** 宸查��璐ф暟閲� = 鍏ュ簱琛屾�绘暟閲� 鈭� 褰撳墠鍙��璐ф暟閲忥紙鍓╀綑锛� */
+const calcAlreadyReturned = (row) => {
+ const total = Number(row?.stockInNum ?? row?.totalQuantity ?? row?.quantity ?? 0)
+ const un = Number(row?.unQuantity ?? 0)
+ if (!Number.isFinite(total) || !Number.isFinite(un)) return 0
+ return Math.max(total - un, 0)
+}
+
+const getReturnTotal = (row) => {
+ const qty = toNumber(row?.returnQuantity)
+ const unitPrice = toNumber(row?.taxInclusiveUnitPrice)
+ const total = qty * unitPrice
+ return Number(total.toFixed(2))
+}
+
+const syncReturnTotal = (row) => {
+ if (!row) {
+ return
+ }
+ row.taxInclusiveTotalPrice = getReturnTotal(row)
+}
+
+const getBaseAmount = () => {
+ const rows = formState.value.purchaseReturnOrderProductsDtos || []
+ return rows.reduce((sum, item) => {
+ return sum + toNumber(item.taxInclusiveTotalPrice)
+ }, 0)
+}
+
+// 鍚屾鎶樻墸棰�
+const totalDiscount = () => {
+ const discountRate = toNumber(formState.value.totalDiscountRate)
+ if (discountRate < 0 || discountRate > 100) {
+ proxy.$modal.msgError("璇疯緭鍏�0-100涔嬮棿鐨勬姌鎵g巼")
+ return
+ }
+ const baseAmount = getBaseAmount()
+ // 鎶樻墸棰� = 浜у搧閫�璐ф�讳环鍚堣 * 鎶樻墸鐜�
+ formState.value.totalDiscountAmount = Number((baseAmount * (discountRate / 100)).toFixed(2))
+ syncTotalAmount()
+}
+
+const getReturnQtyMax = (row) => {
+ const max = Number(row?.unQuantity)
+ if (Number.isNaN(max) || max < 0) {
+ return 0
+ }
+ return max
+}
+
const closeModal = () => {
isShow.value = false;
};
@@ -473,25 +587,58 @@
return proxy.summarizeTable(
param,
[
- "quantity",
+ "stockInNum",
+ "unQuantity",
"returnQuantity",
"taxInclusiveUnitPrice",
"taxInclusiveTotalPrice",
"taxExclusiveTotalPrice",
],
{
- quantity: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+ stockInNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
returnQuantity: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+ unQuantity: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
}
);
};
const handleChangeTotalDiscountAmount= () => {
- formState.value.totalAmount = formState.value.totalDiscountAmount * -1
+ const discountAmount = toNumber(formState.value.totalDiscountAmount)
+ if (discountAmount < 0) {
+ proxy.$modal.msgError("鏁村崟鎶樻墸棰濅笉鑳藉皬浜�0")
+ formState.value.totalDiscountAmount = 0
+ }
+
+ const baseAmount = getBaseAmount()
+ const normalizedAmount = toNumber(formState.value.totalDiscountAmount)
+ if (baseAmount <= 0) {
+ formState.value.totalDiscountRate = 0
+ syncTotalAmount()
+ return
+ }
+
+ if (normalizedAmount > baseAmount) {
+ proxy.$modal.msgError("鏁村崟鎶樻墸棰濅笉鑳藉ぇ浜庝骇鍝侀��璐ф�讳环鍚堣")
+ formState.value.totalDiscountAmount = Number(baseAmount.toFixed(2))
+ }
+
+ const discountRate = (toNumber(formState.value.totalDiscountAmount) / baseAmount) * 100
+ formState.value.totalDiscountRate = Number(discountRate.toFixed(2))
+ syncTotalAmount()
}
-const handleChangeTotalAmount= () => {
- formState.value.totalDiscountAmount = formState.value.totalAmount * -1
+const resetFeeInfo = () => {
+ formState.value.totalDiscountAmount = 0
+ formState.value.totalDiscountRate = undefined
+ formState.value.totalAmount = 0
+ formState.value.incomeType = undefined
+}
+
+const syncTotalAmount = () => {
+ const baseAmount = getBaseAmount()
+ const discount = toNumber(formState.value.totalDiscountAmount)
+ // 鎴愪氦閲戦 = 浜у搧閫�璐ф�讳环鍚堣 - 鎶樻墸棰�
+ formState.value.totalAmount = Number((baseAmount - discount).toFixed(2))
}
// 鑾峰彇渚涘簲鍟嗛�夐」
@@ -504,13 +651,6 @@
});
}
-// 鑾峰彇椤圭洰閫夐」
-const fetchProjectOptions = () => {
- if (projectOptions.value.length > 0) {
- return
- }
- // todo 椤圭洰閫夐」
-}
// 鑾峰彇鐢ㄦ埛閫夐」
const fetchUserOptions = () => {
@@ -525,6 +665,7 @@
// 澶勭悊鏀瑰彉渚涘簲鍟嗘暟鎹�
const handleChangeSupplierId = () => {
formState.value.purchaseLedgerId = undefined
+ formState.value.supplierName = supplierOptions.value.find(item => item.id === formState.value.supplierId)?.supplierName || ''
fetchPurchaseLedgerOptions()
}
@@ -532,15 +673,17 @@
const fetchPurchaseLedgerOptions = () => {
purchaseLedgerOptions.value = []
if (formState.value.supplierId) {
- purchaseList({supplierId: formState.value.supplierId}).then((res) => {
+ purchaseList({supplierId: formState.value.supplierId,approvalStatus:3}).then((res) => {
purchaseLedgerOptions.value = res.rows;
});
}
}
-// 澶勭悊鏀瑰彉閲囪喘鍙拌处鏁版嵁
+// 澶勭悊鏀瑰彉閲囪喘鍙拌处鏁版嵁锛堜笉璇锋眰鎺ュ彛鍥炴樉浜у搧锛屼骇鍝佷粎鍦ㄣ�屾坊鍔犱骇鍝併�嶅脊绐楀嬀閫夊悗鍐欏叆锛�
const handleChangePurchaseLedgerId = () => {
+ resetFeeInfo()
formState.value.purchaseReturnOrderProductsDtos = []
+ syncTotalAmount()
}
// 澶勭悊鏀瑰彉鏄惁榛樿缂栧彿
@@ -556,28 +699,63 @@
const newProducts = selectedRows.filter(item => !existingIds.has(item.id)).map(item => ({
...item,
returnQuantity: undefined,
- salesLedgerProductId: item.id,
+ taxInclusiveTotalPrice: 0,
+ // salesLedgerProductId: item.salesLedgerProductId,
}));
formState.value.purchaseReturnOrderProductsDtos.push(...newProducts);
+ syncTotalAmount()
}
// 鍒犻櫎鍗曢」浜у搧
const delProduct = (index) => {
formState.value.purchaseReturnOrderProductsDtos.splice(index, 1)
+ syncTotalAmount()
}
// 鎻愪氦琛ㄥ崟
const handleSubmit = () => {
- // 楠岃瘉閫�璐ф暟閲�
- const hasEmptyReturnQuantity = formState.value.purchaseReturnOrderProductsDtos.some(item => !item.returnQuantity || item.returnQuantity <= 0);
- if (hasEmptyReturnQuantity) {
- proxy.$modal.msgError("璇蜂负鎵�鏈変骇鍝佸~鍐欓��璐ф暟閲�");
- return;
+ const productList = formState.value.purchaseReturnOrderProductsDtos || []
+
+ productList.forEach(syncReturnTotal)
+
+ if (productList.length === 0) {
+ proxy.$modal.msgError("璇峰厛閫夋嫨浜у搧")
+ return
+ }
+
+ // 閫愯鏍¢獙閫�璐ф暟閲忥細浠绘剰涓�琛屾湭濉�/闈炴硶/瓒呴檺閮戒笉鍏佽鎻愪氦
+ const invalidRowIndex = productList.findIndex((item) => {
+ const qty = Number(item.returnQuantity)
+ const maxQty = Number(item.unQuantity)
+
+ if (item.returnQuantity === null || item.returnQuantity === undefined || item.returnQuantity === "") {
+ return true
+ }
+ if (Number.isNaN(qty) || qty <= 0) {
+ return true
+ }
+ if (!Number.isNaN(maxQty) && maxQty > 0 && qty > maxQty) {
+ return true
+ }
+ return false
+ })
+
+ if (invalidRowIndex !== -1) {
+ proxy.$modal.msgError(`绗�${invalidRowIndex + 1}琛岄��璐ф暟閲忔湭濉啓鎴栦笉鍚堟硶`)
+ return
}
proxy.$refs["formRef"].validate(valid => {
if (valid) {
- createPurchaseReturnOrder(formState.value).then(res => {
+ console.log(productList)
+ const submitPayload = {
+ ...formState.value,
+ purchaseReturnOrderProductsDtos: productList.map((row) => ({
+ ...row,
+ stockInRecordId: row.id,
+ })),
+ }
+ createPurchaseReturnOrder(submitPayload).then(res => {
// 鍏抽棴妯℃�佹
isShow.value = false;
// 鍛婄煡鐖剁粍浠跺凡瀹屾垚
@@ -587,6 +765,15 @@
}
})
};
+
+watch(
+ () => formState.value.purchaseReturnOrderProductsDtos,
+ (rows) => {
+ (rows || []).forEach(syncReturnTotal)
+ syncTotalAmount()
+ },
+ { deep: true }
+)
defineExpose({
closeModal,
@@ -615,4 +802,13 @@
border-radius: 50%;
margin-right: 8px;
}
+
+.product-table-scroll {
+ width: 100%;
+ overflow-x: auto;
+}
+
+.product-table-inner {
+ min-width: 1280px;
+}
</style>
\ No newline at end of file
--
Gitblit v1.9.3