diff --git a/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue b/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
index 0959a74..7fc58a5 100644
--- a/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
+++ b/src/views/supermarketerp/purchaseManagement/smErpCgInventory/form.vue
@@ -81,6 +81,7 @@
border
:loading="loading"
show-overflow
+ show-footer
max-height="410"
:edit-config="{
trigger: 'click',
@@ -99,13 +100,14 @@
:resizable-config="{ dragMode: 'fixed' }"
:data="vxeTableData"
:edit-rules="validRules"
+ :footer-data="footerData"
@checkbox-all=""
@checkbox-change=""
size="mini"
align="center"
>
-
+
{{ row.productName }}
@@ -167,7 +169,13 @@
-->
-
+
@@ -249,6 +257,7 @@ const baseDataForm = reactive({
})
const vxeTableData = ref([])
const erpSpuSimpleAll = ref([])
+const footerData = ref([{ seq: "合计", totalAmount: "0" }])
// 基本信息表单校验规则
const dataRules = ref({
@@ -263,8 +272,9 @@ const validRules = ref>({
quantity: [{ required: true, type: "number", min: 1, message: "必需大于等于0" }],
})
-onMounted(() => {
- getInitData()
+onMounted(async () => {
+ await getInitData()
+ updateFootCount(vxeTableData.value)
})
// 初始化数据
@@ -361,6 +371,8 @@ const getSelectedRows = (selectionRows: any) => {
// vxeTableData.value = vxeTableData.value.filter(
// (item: any) => !removedItems.some((removeItem: any) => removeItem.erpSpuId === item.erpSpuId),
// )
+ updateFootCount(vxeTableData.value)
+
console.log("vxeTableData.value", vxeTableData.value)
}
@@ -371,6 +383,7 @@ const removeRow = () => {
const selectRecords = $table.getCheckboxRecords()
if (selectRecords.length > 0) {
vxeTableData.value = vxeTableData.value.filter((item: any) => !selectRecords.some((row) => row.erpSpuId === item.erpSpuId))
+ updateFootEvent()
}
}
}
@@ -378,6 +391,27 @@ const removeRow = () => {
// 重新计算累计总金额
const reComputeTotalAmount = (row: any, index: number) => {
vxeTableData.value[index].selectedUnitObj.totalAmount = Number((row.quantity * parseFloat(row.selectedUnitObj.realPrice || 0)).toFixed(2))
+ updateFootEvent()
+}
+
+// 更新尾行合计
+const updateFootEvent = () => {
+ const $table = vxeTableRef.value
+ if ($table) {
+ const fullData = $table.getFullData()
+ updateFootCount(fullData)
+ }
+}
+const updateFootCount = (list: any[]) => {
+ const [sumNObj] = footerData.value
+ sumNObj.totalAmount = sumNum(list, "totalAmount")
+}
+const sumNum = (list: any[], field: string) => {
+ let count = 0
+ list.forEach((item) => {
+ count += Number(item.selectedUnitObj[field])
+ })
+ return count.toFixed(2)
}
// 整理table数据