From 1ed11ff9b539891e92f73940772b680497bda98f Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期二, 20 五月 2025 15:36:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/procurementManagement/procurementLedger/index.vue | 149 +++++++++++++++++++++---------------------------- 1 files changed, 65 insertions(+), 84 deletions(-) diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue index 393d7aa..1352682 100644 --- a/src/views/procurementManagement/procurementLedger/index.vue +++ b/src/views/procurementManagement/procurementLedger/index.vue @@ -40,9 +40,9 @@ <el-table-column label="鍗曚綅" prop="unit" /> <el-table-column label="鏁伴噺" prop="quantity" /> <el-table-column label="绋庣巼(%)" prop="taxRate" /> - <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" /> - <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" /> - <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" /> + <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" /> + <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" /> + <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" /> </el-table> </template> </el-table-column> @@ -50,9 +50,8 @@ <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" show-overflow-tooltip/> <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" show-overflow-tooltip/> <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" show-overflow-tooltip/> - <el-table-column label="涓氬姟鍛�" prop="businessPerson" show-overflow-tooltip/> <el-table-column label="椤圭洰鍚嶇О" prop="projectName" show-overflow-tooltip/> - <el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" show-overflow-tooltip/> + <el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" show-overflow-tooltip :formatter="formattedNumber"/> <el-table-column label="褰曞叆浜�" prop="recorderName" show-overflow-tooltip/> <el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" show-overflow-tooltip/> <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center"> @@ -96,20 +95,6 @@ </el-row> <el-row :gutter="30"> <el-col :span="12"> - <el-form-item label="涓氬姟鍛橈細" prop="businessPersonId"> - <el-select v-model="form.businessPersonId" placeholder="璇烽�夋嫨" clearable @change="setPhone"> - <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId"/> - </el-select> - </el-form-item> - </el-col> - <el-col :span="12"> - <el-form-item label="鐢佃瘽锛�" prop="phoneNumber"> - <el-input v-model="form.phoneNumber" placeholder="璇疯緭鍏�" clearable/> - </el-form-item> - </el-col> - </el-row> - <el-row :gutter="30"> - <el-col :span="12"> <el-form-item label="褰曞叆浜猴細" prop="recorderId"> <el-select v-model="form.recorderId" placeholder="璇烽�夋嫨" clearable disabled> <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId"/> @@ -137,7 +122,7 @@ <el-button plain type="danger" @click="deleteProduct">鍒犻櫎</el-button> </el-form-item> </el-row> - <el-table :data="productData" border @selection-change="productSelected"> + <el-table :data="productData" border @selection-change="productSelected" show-summary :summary-method="summarizeProTable"> <el-table-column align="center" type="selection" width="55" /> <el-table-column align="center" label="搴忓彿" type="index" width="60" /> <el-table-column label="浜у搧澶х被" prop="productCategory" /> @@ -145,12 +130,12 @@ <el-table-column label="鍗曚綅" prop="unit" /> <el-table-column label="鏁伴噺" prop="quantity" /> <el-table-column label="绋庣巼(%)" prop="taxRate" /> - <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" /> - <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" /> - <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" /> + <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber"/> + <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber"/> + <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber"/> <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center"> <template #default="scope"> - <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row);">缂栬緫</el-button> + <el-button link type="primary" size="small" @click="openProductForm('edit', scope.row, scope.$index);">缂栬緫</el-button> </template> </el-table-column> </el-table> @@ -199,9 +184,15 @@ <el-row :gutter="30"> <el-col :span="24"> <el-form-item label="浜у搧澶х被锛�" prop="productCategory"> - <el-select v-model="productForm.productCategory" placeholder="璇烽�夋嫨" clearable> - <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> - </el-select> + <el-tree-select + v-model="productForm.productCategory" + placeholder="璇烽�夋嫨" clearable + check-strictly + @change="getModels" + :data="productOptions" + :render-after-expand="false" + style="width: 100%" + /> </el-form-item> </el-col> </el-row> @@ -209,7 +200,7 @@ <el-col :span="24"> <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="specificationModel"> <el-select v-model="productForm.specificationModel" placeholder="璇烽�夋嫨" clearable> - <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/> + <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id"/> </el-select> </el-form-item> </el-col> @@ -229,7 +220,7 @@ <el-row :gutter="30"> <el-col :span="12"> <el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice"> - <el-input v-model="productForm.taxInclusiveUnitPrice" placeholder="璇疯緭鍏�" clearable/> + <el-input-number v-model="productForm.taxInclusiveUnitPrice" :precision="2" :step="0.1" clearable style="width: 100%"/> </el-form-item> </el-col> <el-col :span="12"> @@ -245,12 +236,12 @@ <el-row :gutter="30"> <el-col :span="12"> <el-form-item label="鍚◣鎬讳环(鍏�)锛�" prop="taxInclusiveTotalPrice"> - <el-input v-model="productForm.taxInclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable/> + <el-input-number v-model="productForm.taxInclusiveTotalPrice" :precision="2" :step="0.1" clearable style="width: 100%"/> </el-form-item> </el-col> <el-col :span="12"> <el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�" prop="taxExclusiveTotalPrice"> - <el-input v-model="productForm.taxExclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable/> + <el-input-number v-model="productForm.taxExclusiveTotalPrice" :precision="2" :step="0.1" clearable style="width: 100%"/> </el-form-item> </el-col> </el-row> @@ -297,7 +288,9 @@ const productData = ref([]) const selectedRows = ref([]) const productSelectedRows = ref([]) +const modelOptions = ref([]) const userList = ref([]) +const productOptions = ref([]) const salesContractList = ref([]) const supplierList = ref([]) const tableLoading = ref(false) @@ -308,6 +301,7 @@ const total = ref(0) const fileList = ref([]) import useUserStore from "@/store/modules/user" +import {modelList, productTreeList} from "@/api/basicData/product.js"; const userStore = useUserStore() @@ -325,8 +319,6 @@ recorderId: '', entryDate: '', productData: [], - businessPersonId: '', - phoneNumber: '', supplierName: '', supplierId: '', }, @@ -334,8 +326,6 @@ purchaseContractNumber: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], salesLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], projectName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], - businessPersonId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], - phoneNumber: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], } }) @@ -343,6 +333,7 @@ // 浜у搧琛ㄥ崟寮规鏁版嵁 const productFormVisible = ref(false) const productOperationType = ref('') +const productOperationIndex = ref('') const currentId = ref('') const productFormData = reactive({ productForm: { @@ -376,7 +367,9 @@ headers: { Authorization: "Bearer " + getToken() }, }) - +const formattedNumber = (row, column, cellValue) => { + return parseFloat(cellValue).toFixed(2); +}; // 鏌ヨ鍒楄〃 /** 鎼滅储鎸夐挳鎿嶄綔 */ const handleQuery = () => { @@ -431,50 +424,12 @@ } // 涓昏〃鍚堣鏂规硶 const summarizeMainTable = (param) => { - const { columns, data } = param; - const sums = []; - columns.forEach((column, index) => { - if (index === 0) { - sums[index] = '鍚堣'; - return; - } - const prop = column.property; - if (['contractAmount'].includes(prop)) { - const values = data.map(item => Number(item[prop])); - if (!values.every(value => isNaN(value))) { - sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); - } else { - sums[index] = ''; - } - } else { - sums[index] = ''; - } - }) - return sums; + return proxy.summarizeTable(param, ['contractAmount']); }; // 瀛愯〃鍚堣鏂规硶 -const summarizeChildrenTable = (param) => { - const { columns, data } = param; - const sums = []; - columns.forEach((column, index) => { - if (index === 0) { - sums[index] = '鍚堣'; - return; - } - const prop = column.property; - if (['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice'].includes(prop)) { - const values = data.map(item => Number(item[prop])); - if (!values.every(value => isNaN(value))) { - sums[index] = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); - } else { - sums[index] = ''; - } - } else { - sums[index] = ''; - } - }); - return sums; -} +const summarizeProTable = (param) => { + return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice']); +}; // 鎵撳紑寮规 const openForm = (type, row) => { operationType.value = type @@ -505,10 +460,6 @@ }) } dialogFormVisible.value = true -} -// 璧嬪�肩數璇� -const setPhone = (id) => { - form.value.phoneNumber = userList.value.find(u => u.userId === id)?.phonenumber || ''; } // 涓婁紶鍓嶆牎妫� function handleBeforeUpload(file) { @@ -577,14 +528,40 @@ dialogFormVisible.value = false } // 鎵撳紑浜у搧寮规 -const openProductForm = (type, row) => { +const openProductForm = (type, row, index) => { productOperationType.value = type + productOperationIndex.value = index productForm.value = {} proxy.resetForm("productFormRef") if (type === 'edit') { productForm.value = {...row} } productFormVisible.value = true + getProductOptions() +} +const getProductOptions = () => { + productTreeList().then(res => { + productOptions.value = convertIdToValue(res) + }) +} +const getModels =(value) => { + modelList({id: value}).then(res => { + modelOptions.value = res + }) +} +function convertIdToValue(data) { + return data.map(item => { + const { id, children, ...rest } = item; + const newItem = { + ...rest, + value: id // 灏� id 鏀逛负 value + }; + if (children && children.length > 0) { + newItem.children = convertIdToValue(children); + } + + return newItem; + }); } // 鎻愪氦浜у搧琛ㄥ崟 const submitProduct = () => { @@ -593,7 +570,11 @@ if (operationType.value === "edit") { submitProductEdit() } else { - productData.value.push({...productForm.value}) + if (productOperationType.value === 'add') { + productData.value.push({...productForm.value}) + } else { + productData.value[productOperationIndex.value] = {...productForm.value} + } closeProductDia() } } -- Gitblit v1.9.3