From a00484ae729aed9a664050362fa2b8c6a4ce4fd6 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期四, 12 六月 2025 10:29:11 +0800 Subject: [PATCH] 1.库存管理页面联调 --- src/api/salesOutbound/index.js | 27 +++ src/views/warehouseManagement/index.vue | 187 +++++++++++++++++++--- src/utils/getCurrentDate.js | 9 + src/views/salesOutbound/index.vue | 42 +++- src/main.js | 4 src/views/salesOutbound/components/formDia.vue | 91 +++++++--- src/api/warehouseManagement/index.js | 16 ++ src/views/inspectionManagement/index.vue | 13 + src/utils/summarizeTable.js | 48 ++++++ 9 files changed, 367 insertions(+), 70 deletions(-) diff --git a/src/api/salesOutbound/index.js b/src/api/salesOutbound/index.js new file mode 100644 index 0000000..0d83ebe --- /dev/null +++ b/src/api/salesOutbound/index.js @@ -0,0 +1,27 @@ +// 閿�鍞嚭搴� +import request from '@/utils/request' + +// 鏌ヨ鍒楄〃 +export function salesRecordList(query) { + return request({ + url: '/salesRecord/list', + method: 'get', + params: query + }) +} +// 鎻愪氦鏂板銆佷慨鏀� +export function addOrEditSalesRecord(query) { + return request({ + url: '/salesRecord/addOrEditSalesRecord', + method: 'post', + data: query + }) +} +// 鏌ヨ瀹㈡埛 +export function customerList(query) { + return request({ + url: '/customer/customerList', + method: 'get', + params: query + }) +} \ No newline at end of file diff --git a/src/api/warehouseManagement/index.js b/src/api/warehouseManagement/index.js index 047a7e2..859f8e9 100644 --- a/src/api/warehouseManagement/index.js +++ b/src/api/warehouseManagement/index.js @@ -48,4 +48,20 @@ method: 'get', params: query }) +} +// 鎻愪氦鍚堝苟 +export function merge(query) { + return request({ + url: '/officialInventory/merge', + method: 'post', + data: query + }) +} +// 姝e紡搴撳瓨缂栬緫 +export function editOfficial(query) { + return request({ + url: '/officialInventory/editOfficial', + method: 'post', + data: query + }) } \ No newline at end of file diff --git a/src/main.js b/src/main.js index 2110fac..117280e 100644 --- a/src/main.js +++ b/src/main.js @@ -43,6 +43,8 @@ import ImagePreview from "@/components/ImagePreview" // 瀛楀吀鏍囩缁勪欢 import DictTag from '@/components/DictTag' +import {summarizeTable} from "@/utils/summarizeTable.js"; +import {getCurrentDate} from "@/utils/getCurrentDate.js"; const app = createApp(App) @@ -55,6 +57,8 @@ app.config.globalProperties.addDateRange = addDateRange app.config.globalProperties.selectDictLabel = selectDictLabel app.config.globalProperties.selectDictLabels = selectDictLabels +app.config.globalProperties.summarizeTable = summarizeTable +app.config.globalProperties.getCurrentDate = getCurrentDate // 鍏ㄥ眬缁勪欢鎸傝浇 app.component('DictTag', DictTag) diff --git a/src/utils/getCurrentDate.js b/src/utils/getCurrentDate.js new file mode 100644 index 0000000..d8be927 --- /dev/null +++ b/src/utils/getCurrentDate.js @@ -0,0 +1,9 @@ +// src/utils/utils.js + +export function getCurrentDate() { + const today = new Date(); + const year = today.getFullYear(); + const month = String(today.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮� + const day = String(today.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +} \ No newline at end of file diff --git a/src/utils/summarizeTable.js b/src/utils/summarizeTable.js new file mode 100644 index 0000000..e24d99f --- /dev/null +++ b/src/utils/summarizeTable.js @@ -0,0 +1,48 @@ +/** + * 閫氱敤鐨勮〃鏍煎悎璁℃柟娉� + * @param {Object} param - 鍖呭惈琛ㄦ牸鍒楅厤缃拰鏁版嵁婧愮殑瀵硅薄 + * @param {Array<string>} summaryProps - 闇�瑕佹眹鎬荤殑瀛楁鍚嶆暟缁� + * @param {Object} specialFormat - 鐗规畩鏍煎紡鍖栬鍒欙細瀛楁鍚� -> 鏍煎紡鍖栭�夐」锛堝鏄惁鍘绘帀灏忔暟锛� + * @returns {Array} 鍚堣琛屾暟鎹� + */ +const summarizeTable = (param, summaryProps, specialFormat = {}) => { + const { columns, data } = param; + const sums = []; + columns.forEach((column, index) => { + if (index === 0) { + sums[index] = '鍚堣'; + return; + } + const prop = column.property; + if (summaryProps.includes(prop)) { + const values = data.map(item => Number(item[prop])); + // 鍙鏈夋晥鏁板瓧杩涜姹傚拰 + if (!values.every(isNaN)) { + const sum = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); + if (specialFormat[prop] && specialFormat[prop].noDecimal) { + // 濡傛灉鎸囧畾浜嗕笉闇�瑕佷繚鐣欏皬鏁帮紝鍒欑洿鎺ヨ浆鎹负鏁存暟 + sums[index] = Math.round(sum).toString(); + } else { + // 榛樿淇濈暀涓や綅灏忔暟 + sums[index] = parseFloat(sum).toFixed(specialFormat[prop]?.decimalPlaces ?? 2); + } + } else { + sums[index] = ''; + } + } else { + sums[index] = ''; + } + }); + return sums; +} +// 涓嶅惈绋庢�讳环璁$畻 +const calculateTaxExclusiveTotalPrice = (taxInclusiveTotalPrice, taxRate) => { + const taxRateDecimal = taxRate / 100; + return (taxInclusiveTotalPrice / (1 + taxRateDecimal)).toFixed(2); +} +// 鍚◣鎬讳环璁$畻 +const calculateTaxIncludeTotalPrice = (taxInclusiveUnitPrice, quantity) => { + return (taxInclusiveUnitPrice * quantity).toFixed(2); +} +// 瀵煎嚭鍑芥暟渚涘叾浠栨枃浠朵娇鐢� +export { summarizeTable, calculateTaxExclusiveTotalPrice ,calculateTaxIncludeTotalPrice}; diff --git a/src/views/inspectionManagement/index.vue b/src/views/inspectionManagement/index.vue new file mode 100644 index 0000000..458acb2 --- /dev/null +++ b/src/views/inspectionManagement/index.vue @@ -0,0 +1,13 @@ +<template> + <div class="app-container"> + + </div> +</template> + +<script setup> + +</script> + +<style scoped> + +</style> \ No newline at end of file diff --git a/src/views/salesOutbound/components/formDia.vue b/src/views/salesOutbound/components/formDia.vue index 67e86df..d9d8059 100644 --- a/src/views/salesOutbound/components/formDia.vue +++ b/src/views/salesOutbound/components/formDia.vue @@ -2,12 +2,12 @@ <div> <el-dialog :title="operationType === 'add' ? '鏂板鍑哄簱' : '缂栬緫鍑哄簱'" v-model="dialogVisitable" width="800px" @close="cancel"> - <el-form :model="form" :rules="rules" ref="userRef" label-width="100px"> + <el-form :model="form" :rules="rules" ref="formRef" label-width="120px"> <el-row> <el-col :span="12"> - <el-form-item label="閿�鍞棩鏈�" prop="userName"> + <el-form-item label="閿�鍞棩鏈�" prop="saleDate"> <el-date-picker - v-model="form.userName" + v-model="form.saleDate" type="date" value-format="YYYY-MM-DD" format="YYYY-MM-DD" @@ -18,8 +18,8 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="瀹㈡埛" prop="nickName"> - <el-select v-model="form.nickName" placeholder="璇烽�夋嫨瀹㈡埛"> + <el-form-item label="瀹㈡埛" prop="customerId"> + <el-select v-model="form.customerId" placeholder="璇烽�夋嫨瀹㈡埛"> <el-option v-for="item in customerOptions" :key="item.value" @@ -32,8 +32,8 @@ </el-row> <el-row> <el-col :span="12"> - <el-form-item label="鐓ょ" prop="type"> - <el-select v-model="form.nickName" placeholder="璇烽�夋嫨鐓ょ"> + <el-form-item label="鐓ょ" prop="coalId"> + <el-select v-model="form.coalId" placeholder="璇烽�夋嫨鐓ょ"> <el-option v-for="item in typeOptions" :key="item.value" @@ -44,39 +44,56 @@ </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="鍗曚綅" prop="nickName"> - <el-input v-model="form.nickName" placeholder="璇疯緭鍏ュ崟浣�" maxlength="30" /> + <el-form-item label="鍗曚綅" prop="unit"> + <el-input v-model="form.unit" placeholder="璇疯緭鍏ュ崟浣�" maxlength="30" /> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="閿�鍞暟閲�" prop="userName"> - <el-input v-model="form.userName" placeholder="璇疯緭鍏ラ攢鍞暟閲�" maxlength="30" type="number" /> + <el-form-item label="搴撳瓨鏁伴噺" prop="inventoryQuantity"> + <el-input v-model="form.inventoryQuantity" placeholder="璇疯緭鍏ラ攢鍞暟閲�" maxlength="30" type="number" /> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="閿�鍞崟浠�" prop="userName"> - <el-input v-model="form.userName" placeholder="璇疯緭鍏ラ攢鍞崟浠�(鍚◣)" maxlength="30" type="number" /> + <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax"> + <el-input v-model="form.priceIncludingTax" placeholder="璇疯緭鍏ラ攢鍞崟浠�(鍚◣)" maxlength="30" type="number" /> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="閿�鍞�讳环" prop="userName"> - <el-input v-model="form.userName" placeholder="璇疯緭鍏ラ攢鍞�讳环(鍚◣)" maxlength="30" type="number" /> + <el-form-item label="閿�鍞暟閲�" prop="saleQuantity"> + <el-input v-model="form.saleQuantity" placeholder="璇疯緭鍏ラ攢鍞暟閲�" maxlength="30" type="number" /> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="鐑��" prop="userName"> - <el-input v-model="form.userName" placeholder="璇疯緭鍏ョ儹鍊�" maxlength="30" /> + <el-form-item label="閿�鍞崟浠�(鍚◣)" prop="salePrice"> + <el-input v-model="form.salePrice" placeholder="璇疯緭鍏ラ攢鍞崟浠�(鍚◣)" maxlength="30" type="number" /> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="鍒╂鼎" prop="userName"> - <el-input v-model="form.userName" placeholder="鍒╂鼎" maxlength="30" type="number" /> + <el-form-item label="璐攢鐓ょ◣鐜�(%)" prop="taxCoal"> + <el-input v-model="form.taxCoal" placeholder="璇疯緭鍏ラ攢鍞�讳环(鍚◣)" maxlength="30" type="number" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="杩愯緭绋庣巼(%)" prop="taxTrans"> + <el-input v-model="form.taxTrans" placeholder="璇疯緭鍏ラ攢鍞�讳环(鍚◣)" maxlength="30" type="number" /> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="姣涘埄娑�" prop="grossProfit"> + <el-input v-model="form.grossProfit" placeholder="姣涘埄娑�" maxlength="30" type="number" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鍑�鍒╂鼎" prop="netProfit"> + <el-input v-model="form.netProfit" placeholder="鍑�鍒╂鼎" maxlength="30" type="number" /> </el-form-item> </el-col> </el-row> @@ -93,6 +110,7 @@ <script setup> import {ref, reactive} from "vue"; +import {addOrEditSalesRecord, customerList} from "../../../api/salesOutbound/index.js"; const { proxy } = getCurrentInstance() const emit = defineEmits() @@ -101,13 +119,23 @@ const customerOptions = ref([]) // 瀹㈡埛涓嬫媺妗� const typeOptions = ref([]) // 鐓ょ涓嬫媺妗� const data = reactive({ - form: {}, + form: { + saleDate: '', + customerId: '', + coalId: '', + unit: '', + saleQuantity: '', + salePrice: '', + totalAmount: '', + taxCoal: '', + taxTrans: '', + grossProfit: '', + netProfit: '', + inventoryQuantity: '', + priceIncludingTax: '', + }, rules: { - userName: [{ required: true, message: "鐧诲綍璐﹀彿涓嶈兘涓虹┖", trigger: "blur" },], - nickName: [{ required: true, message: "鐢ㄦ埛濮撳悕涓嶈兘涓虹┖", trigger: "blur" }], - roleIds: [{ required: true, message: "瑙掕壊涓嶈兘涓虹┖", trigger: "change" }], - deptId: [{ required: true, message: "閮ㄩ棬涓嶈兘涓虹┖", trigger: "change" }], - password: [{ required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" }, { min: 5, max: 20, message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "涓嶈兘鍖呭惈闈炴硶瀛楃锛�< > \" ' \\\ |", trigger: "blur" }], + saleDate: [{ required: true, message: "璇烽�夋嫨鏃ユ湡", trigger: "change" },], } }) @@ -117,18 +145,25 @@ const openDialog = (type, row) => { console.log('openDialog', type, row) dialogVisitable.value = true + form.value.saleDate = proxy.getCurrentDate() + customerList().then((res) => { + console.log(res) + }) } // 鎻愪氦鍚堝苟琛ㄥ崟 const submitForm = () => { - proxy.$refs["userRef"].validate(valid => { + proxy.$refs["formRef"].validate(valid => { if (valid) { - + addOrEditSalesRecord(form.value).then(() => { + cancel() + proxy.$modal.msgSuccess('鎻愪氦鎴愬姛') + }) } }) } // 鍏抽棴鍚堝苟琛ㄥ崟 const cancel = () => { - proxy.resetForm("userRef") + proxy.resetForm("formRef") dialogVisitable.value = false emit('closeDia') } diff --git a/src/views/salesOutbound/index.vue b/src/views/salesOutbound/index.vue index 955cd78..fca072b 100644 --- a/src/views/salesOutbound/index.vue +++ b/src/views/salesOutbound/index.vue @@ -79,12 +79,13 @@ </template> <script setup> -import {ref, reactive} from "vue"; +import {ref, reactive, onMounted} from "vue"; const { proxy } = getCurrentInstance() import {Delete, Download, Plus} from "@element-plus/icons-vue"; import ETable from "@/components/Table/ETable.vue"; import Pagination from "@/components/Pagination/index.vue"; import FormDia from "@/views/salesOutbound/components/formDia.vue"; +import {salesRecordList} from "../../api/salesOutbound/index.js"; const formDia = ref() const activeTab = ref("out"); @@ -96,17 +97,21 @@ const tableLoading = ref(false); const tableData = ref([]); const columns = ref([ - { prop: "supplierName", label: "閿�鍞棩鏈�", minWidth: 160 }, - { prop: "identifyNumber", label: "瀹㈡埛", minWidth: 120 }, - { prop: "address", label: "鐓ょ", minWidth: 150 }, + { prop: "saleDate", label: "閿�鍞棩鏈�", minWidth: 160 }, + { prop: "customer", label: "瀹㈡埛", minWidth: 120 }, + { prop: "coal", label: "鐓ょ", minWidth: 150 }, { prop: "unit", label: "鍗曚綅", minWidth: 150 }, - { prop: "bank", label: "搴撳瓨鏁伴噺", minWidth: 120 }, - { prop: "bankAccount", label: "閿�鍞崟浠�(鍚◣)", minWidth: 150 }, - { prop: "contacts", label: "閿�鍞�讳环(鍚◣)", minWidth: 120 }, - { prop: "contacts", label: "鍒╂鼎", minWidth: 90 }, - { prop: "contactAddress", label: "鐑��", minWidth: 150 }, - { prop: "maintainer", label: "缁存姢浜�", minWidth: 100 }, - { prop: "maintainDate", label: "缁存姢鏃ユ湡", minWidth: 100 }, + { prop: "priceIncludingTax", label: "鍗曚环(鍚◣)", minWidth: 150 }, + { prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minWidth: 120 }, + { prop: "saleQuantity", label: "閿�鍞暟閲�", minWidth: 120 }, + { prop: "salePrice", label: "閿�鍞崟浠�(鍚◣)", minWidth: 150 }, + { prop: "totalAmount", label: "閿�鍞�讳环(鍚◣)", minWidth: 120 }, + { prop: "taxCoal", label: "璐攢鐓ょ◣鐜�(%)", minWidth: 120 }, + { prop: "taxTrans", label: "杩愯緭绋庣巼(%)", minWidth: 120 }, + { prop: "grossProfit", label: "姣涘埄娑�", minWidth: 90 }, + { prop: "netProfit", label: "鍑�鍒╂鼎", minWidth: 90 }, + { prop: "registrant", label: "鐧昏浜�", minWidth: 100 }, + { prop: "registrationDate", label: "鐧昏鏃ユ湡", minWidth: 100 }, ]); const selectedRows = ref([]); const total = ref(0); @@ -119,13 +124,22 @@ identifyNumber: "", address: "", }) - +onMounted(() => { + handleQuery() +}); // 鐐瑰嚮鏌ヨ const handleQuery = () => { + pageNum.value = 1 + pageSize.value = 10 + getList() +} +const getList = () => { tableLoading.value = true; - setTimeout(() => { + salesRecordList({...queryParams, current: pageNum.value, size: pageSize.value}).then(res => { tableLoading.value = false; - }, 500); + tableData.value = res.data.records; + total.value = res.data.total; + }) } // 閲嶇疆鏌ヨ const resetQuery = () => { diff --git a/src/views/warehouseManagement/index.vue b/src/views/warehouseManagement/index.vue index 734e33c..8905e20 100644 --- a/src/views/warehouseManagement/index.vue +++ b/src/views/warehouseManagement/index.vue @@ -38,29 +38,32 @@ </el-tabs> <!-- 鎿嶄綔鎸夐挳鍖� --> <el-space> - <el-button type="danger" :icon="Delete">鍒犻櫎</el-button> +<!-- <el-button type="danger" :icon="Delete">鍒犻櫎</el-button>--> <el-button type="info" plain :icon="Download">瀵煎嚭</el-button> - <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows">鍚堝苟</el-button> + <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows('merge')">鍚堝苟</el-button> </el-space> <div> - <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%"> + <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%" show-summary :summary-method="summarizeChildrenTable"> <el-table-column type="selection" width="55" align="center" /> <el-table-column label="搴忓彿" type="index" width="60" align="center" /> <el-table-column prop="supplierName" label="渚涜揣鍟嗗悕绉�" width="180" sortable/> <el-table-column prop="coal" label="鐓ょ" sortable/> <el-table-column prop="unit" label="鍗曚綅" width="70"/> <el-table-column prop="inventoryQuantity" label="搴撳瓨鏁伴噺" sortable min-width="110"/> - <el-table-column prop="priceIncludingTax" label="鍗曚环锛堝惈绋庯級" sortable width="130"/> - <el-table-column prop="totalPriceIncludingTax" label="鎬讳环锛堝惈绋庯級" width="130" /> - <el-table-column prop="costPerUnit" label="鎴愭湰鍗曚环" /> + <el-table-column prop="priceIncludingTax" label="鍗曚环(鍚◣)" sortable width="130"/> + <el-table-column prop="totalPriceIncludingTax" label="鎬讳环(鍚◣)" width="130" /> + <el-table-column prop="priceExcludingTax" label="鍗曚环(涓嶅惈绋�)" width="130" /> + <el-table-column prop="totalPriceExcludingTax" label="鎬讳环(涓嶅惈绋�)" width="130" /> + <el-table-column prop="pendingReplenishment" label="寰呰ˉ搴�" width="130" /> <el-table-column label="鐓よ川" align="center" v-if="activeTab=== 'officialInventory'" width="600"> <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/> </el-table-column> <el-table-column prop="registrantId" label="鐧昏浜�" width="180"/> <el-table-column prop="registrationDate" label="鐧昏鏃ユ湡" width="180"/> - <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center" v-if="activeTab !== 'officialInventory'"> + <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center"> <template #default="scope"> - <el-button link type="primary" size="small" @click="reviewDia(scope.row)">瀹℃牳</el-button> + <el-button link type="primary" size="small" @click="reviewDia(scope.row)" v-if="activeTab !== 'officialInventory'">瀹℃牳</el-button> + <el-button link type="primary" size="small" @click="mergeRows('edit', scope.row)" v-else>缂栬緫</el-button> </template> </el-table-column> </el-table> @@ -115,10 +118,17 @@ </el-row> <el-row> <el-col :span="12"> - <el-form-item label="鎴愭湰鍗曚环" prop="costPerUnit"> - <el-input v-model="form.costPerUnit" placeholder="璇疯緭鍏ユ垚鏈崟浠�" maxlength="30" /> + <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax"> + <el-input v-model="form.priceExcludingTax" placeholder="璇疯緭鍏ユ垚鏈崟浠�" maxlength="30" /> </el-form-item> </el-col> + <el-col :span="12"> + <el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax"> + <el-input v-model="form.totalPriceExcludingTax" placeholder="璇疯緭鍏ユ垚鏈崟浠�" maxlength="30" /> + </el-form-item> + </el-col> + </el-row> + <el-row> <el-col :span="12"> <el-form-item label="鐓よ川鏂规" prop="qualityPlan"> <el-select v-model="form.qualityPlan" placeholder="璇烽�夋嫨" @change="coalPlanByIdList" clearable> @@ -150,40 +160,60 @@ </el-dialog> <!-- 鍚堝苟鏁版嵁寮规 --> <el-dialog title="鍚堝苟搴撳瓨" v-model="mergeVisible" width="800px"> - <el-form :model="form" :rules="rules" ref="userRef" label-width="100px"> + <el-form :model="mergeForm" :rules="mergeRules" ref="mergeRef" label-width="100px"> <el-row> <el-col :span="12"> <el-form-item label="渚涜揣鍟嗗悕绉�" prop="supplierName"> - <el-input v-model="form.supplierName" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" maxlength="30" /> + <el-input v-model="mergeForm.supplierName" placeholder="璇疯緭鍏ヤ緵璐у晢鍚嶇О" maxlength="30" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="鐓ょ" prop="coal"> - <el-input v-model="form.coal" placeholder="璇疯緭鍏ュ鍚�" maxlength="30" /> + <el-input v-model="mergeForm.coal" placeholder="璇疯緭鍏ョ叅绉�" maxlength="30" /> + </el-form-item> + </el-col> + </el-row> + <el-row> + <el-col :span="12"> + <el-form-item label="鍗曚綅" prop="unit"> + <el-input v-model="mergeForm.unit" placeholder="璇疯緭鍏ュ崟浣�" maxlength="30" /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="搴撳瓨鏁伴噺" prop="inventoryQuantity"> + <el-input v-model="mergeForm.inventoryQuantity" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" :max="inventoryQuantity" type="number"/> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> <el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax"> - <el-input v-model="form.priceIncludingTax" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" maxlength="30" /> + <el-input v-model="mergeForm.priceIncludingTax" placeholder="璇疯緭鍏ュ崟浠�(鍚◣)" maxlength="30" /> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax"> - <el-input v-model="form.totalPriceIncludingTax" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" maxlength="30" /> + <el-input v-model="mergeForm.totalPriceIncludingTax" placeholder="璇疯緭鍏ユ�讳环(鍚◣)" maxlength="30" /> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="12"> - <el-form-item label="鎴愭湰鍗曚环" prop="costPerUnit"> - <el-input v-model="form.costPerUnit" placeholder="璇疯緭鍏ュ鍚�" maxlength="30" /> + <el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax"> + <el-input v-model="mergeForm.priceExcludingTax" placeholder="璇疯緭鍏ュ崟浠�(涓嶅惈绋�)" maxlength="30" /> </el-form-item> </el-col> <el-col :span="12"> - <el-form-item label="鐓よ川" prop="userName"> - <el-input v-model="form.userName" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" maxlength="30" /> + <el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax"> + <el-input v-model="mergeForm.totalPriceExcludingTax" placeholder="璇疯緭鍏ユ�讳环(涓嶅惈绋�)" maxlength="30" /> + </el-form-item> + </el-col> + </el-row> + <el-divider></el-divider> + <el-row> + <el-col :span="12" v-for="item in filteredList" :key="item.id"> + <el-form-item :label="item.fieldName"> + <el-input v-model="mergeForm[item.fields]" /> </el-form-item> </el-col> </el-row> @@ -208,12 +238,12 @@ coalPlanList, officialInventoryList, pendingInventoryList } from "@/api/warehouseManagement/index.js"; +import {editOfficial, merge} from "../../api/warehouseManagement/index.js"; const { proxy } = getCurrentInstance() const tableData = ref([]) const selectedRows = ref([]) -const columns = ref([]) const qualityPlanOption = ref([]) const filteredList = ref([]) const tableLoading = ref(false); @@ -221,10 +251,14 @@ const pageNum = ref(1); const pageSize = ref(10); const inventoryQuantity = ref(0); +const count = ref(0); +const mean = ref(0); +const totalPrice = ref(0); // 瀹℃牳寮规 const reviewVisible = ref(false); // 鍚堝苟寮规 const mergeVisible = ref(false) +const operationType = ref('') const data = reactive({ form: { supplierName: '', @@ -233,7 +267,20 @@ inventoryQuantity: '', priceIncludingTax: '', totalPriceIncludingTax: '', - costPerUnit: '', + priceExcludingTax: '', + totalPriceExcludingTax: '', + qualityPlan: '', + pId: '', + }, + mergeForm: { + supplierName: '', + coal: '', + unit: '', + inventoryQuantity: '', + priceIncludingTax: '', + totalPriceIncludingTax: '', + priceExcludingTax: '', + totalPriceExcludingTax: '', qualityPlan: '', pId: '', }, @@ -242,10 +289,16 @@ coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }], unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }], qualityPlan: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], + }, + mergeRules: { + supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }], + coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }], + unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }], + qualityPlan: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], } }) -const { form, rules } = toRefs(data) +const { form, rules, mergeForm, mergeRules } = toRefs(data) // 褰撳墠鏍囩 const activeTab = ref("pendingInbound"); const tabName = ref("pendingInbound"); @@ -269,6 +322,9 @@ tableData.value = []; getList(); }; +const summarizeChildrenTable = (param) => { + return proxy.summarizeTable(param, ['inventoryQuantity', 'priceIncludingTax', 'totalPriceIncludingTax','priceExcludingTax','totalPriceExcludingTax']); +} // 鐐瑰嚮鏌ヨ const handleQuery = () => { pageNum.value = 1 @@ -326,6 +382,7 @@ // 鎵撳紑瀹℃牳寮规 const reviewDia = (row) => { reviewVisible.value = true + filteredList.value = [] form.value = {...row} form.value.pId = row.id inventoryQuantity.value = row.inventoryQuantity @@ -359,19 +416,93 @@ }) } // 鍚堝苟搴撳瓨鏁版嵁鏂规硶 -const mergeRows = () => { - if (selectedRows.value.length < 2) { - proxy.$modal.msgWarning('璇疯嚦灏戦�夋嫨涓ゆ潯鏁版嵁') - return +const mergeRows = (type,row) => { + coalFieldListOption(); + mergeVisible.value = true; + operationType.value = type; + if (type === 'edit') { + mergeForm.value = {...row} + } else { + if (selectedRows.value.length < 2) { + proxy.$modal.msgWarning('璇疯嚦灏戦�夋嫨涓ゆ潯鏁版嵁') + return + } + filteredList.value.forEach(item => { + mergeForm.value[item.fields] = '' + }) + const data = selectedRows.value + const selectedIds = selectedRows.value.map(row => row.id); + // 鍒濆鍖栧悎璁″拰鍧囧�煎彉閲� + let totalInventory = 0; + let totalPriceIncludingTax = 0; + let totalPriceExcludingTax = 0; + let priceIncludingTaxSum = 0; + let priceExcludingTaxSum = 0; + // 閬嶅巻鎵�鏈夐�変腑鏁版嵁锛岀疮鍔犺绠� + data.forEach(row => { + totalInventory += parseFloat(row.inventoryQuantity) || 0; + priceIncludingTaxSum += parseFloat(row.priceIncludingTax) || 0; + totalPriceIncludingTax += parseFloat(row.totalPriceIncludingTax) || 0; + priceExcludingTaxSum += parseFloat(row.priceExcludingTax) || 0; + totalPriceExcludingTax += parseFloat(row.totalPriceExcludingTax) || 0; + }); + // 璁$畻骞冲潎鍊煎苟淇濈暀涓や綅灏忔暟 + const avgPriceIncludingTax = Number((priceIncludingTaxSum / data.length).toFixed(2)); + const avgTotalPriceIncludingTax = Number((totalPriceIncludingTax / data.length).toFixed(2)); + const avgPriceExcludingTax = Number((priceExcludingTaxSum / data.length).toFixed(2)); + const avgTotalPriceExcludingTax = Number((totalPriceExcludingTax / data.length).toFixed(2)); + // 璁剧疆琛ㄥ崟鏄剧ず + mergeForm.value.inventoryQuantity = totalInventory; + mergeForm.value.priceIncludingTax = avgPriceIncludingTax; + mergeForm.value.totalPriceIncludingTax = avgTotalPriceIncludingTax; + mergeForm.value.priceExcludingTax = avgPriceExcludingTax; + mergeForm.value.totalPriceExcludingTax = avgTotalPriceExcludingTax; + mergeForm.value.ids = selectedIds; } - mergeVisible.value = true } // 鎻愪氦鍚堝苟琛ㄥ崟 const submitForm = () => { - + proxy.$refs.mergeRef.validate(valid => { + if (valid) { + delete mergeForm.value.createTime + delete mergeForm.value.updateTime + if (operationType.value === 'edit') { + mergeForm.value.fields = filteredList.value.reduce((acc, item) => { + const key = item.fields; + const value = mergeForm.value[key]; + // 鍒ゆ柇鏄惁鏈夊�硷紙浣犲彲浠ユ牴鎹渶瑕佷慨鏀瑰垽鏂潯浠讹級 + if (value !== null && value !== undefined && value !== '') { + acc.push({ [key]: value }); + } + return acc; + }, []); + editOfficial(mergeForm.value).then(() => { + cancel() + proxy.$modal.msgSuccess('淇敼鎴愬姛') + handleQuery() + }) + } else { + mergeForm.value.fields = filteredList.value.reduce((acc, item) => { + const key = item.fields; + const value = mergeForm.value[key]; + // 鍒ゆ柇鏄惁鏈夊�硷紙浣犲彲浠ユ牴鎹渶瑕佷慨鏀瑰垽鏂潯浠讹級 + if (value !== null && value !== undefined && value !== '') { + acc.push({ [key]: value }); + } + return acc; + }, []); + merge(mergeForm.value).then(() => { + cancel() + proxy.$modal.msgSuccess('鍚堝苟鎴愬姛') + handleQuery() + }) + } + } + }) } // 鍏抽棴鍚堝苟琛ㄥ崟 const cancel = () => { + proxy.$refs.mergeRef.resetFields(); mergeVisible.value = false } // 鎻愪氦瀹℃牳琛ㄥ崟 -- Gitblit v1.9.3