From 78dc79e8222f2f76ca7b9d93866e1dcb64f6dd63 Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期一, 26 五月 2025 16:34:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- src/views/procurementManagement/procurementLedger/index.vue | 228 ++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 146 insertions(+), 82 deletions(-) diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue index 92e9942..b836cde 100644 --- a/src/views/procurementManagement/procurementLedger/index.vue +++ b/src/views/procurementManagement/procurementLedger/index.vue @@ -40,20 +40,19 @@ <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> <el-table-column align="center" label="搴忓彿" type="index" width="60" /> <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" show-overflow-tooltip/> - <el-table-column label="閿�鍞悎鍚屽彿" prop="salesLedgerId" 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="salesman" 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="recorderId" 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"> <template #default="scope"> @@ -82,8 +81,10 @@ </el-row> <el-row :gutter="30"> <el-col :span="12"> - <el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierName"> - <el-input v-model="form.supplierName" placeholder="璇疯緭鍏�" clearable/> + <el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierId"> + <el-select v-model="form.supplierId" placeholder="璇烽�夋嫨" clearable> + <el-option v-for="item in supplierList" :key="item.id" :label="item.supplierName" :value="item.id"/> + </el-select> </el-form-item> </el-col> <el-col :span="12"> @@ -95,7 +96,7 @@ <el-row :gutter="30"> <el-col :span="12"> <el-form-item label="褰曞叆浜猴細" prop="recorderId"> - <el-select v-model="form.recorderId" placeholder="璇烽�夋嫨" clearable> + <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"/> </el-select> </el-form-item> @@ -103,6 +104,7 @@ <el-col :span="12"> <el-form-item label="褰曞叆鏃ユ湡锛�" prop="entryDate"> <el-date-picker + disabled style="width: 100%" v-model="form.entryDate" value-format="YYYY-MM-DD" @@ -120,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" /> @@ -128,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> @@ -181,18 +183,24 @@ <el-form :model="productForm" label-width="140px" label-position="top" :rules="productRules" ref="productFormRef"> <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-form-item label="浜у搧澶х被锛�" prop="productId"> + <el-tree-select + v-model="productForm.productId" + placeholder="璇烽�夋嫨" clearable + check-strictly + @change="getModels" + :data="productOptions" + :render-after-expand="false" + style="width: 100%" + /> </el-form-item> </el-col> </el-row> <el-row :gutter="30"> <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-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId"> + <el-select v-model="productForm.productModelId" placeholder="璇烽�夋嫨" clearable @change="getProductModel"> + <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id"/> </el-select> </el-form-item> </el-col> @@ -212,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"> @@ -228,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%" @change="mathNum"/> </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 v-model="productForm.taxExclusiveTotalPrice" disabled/> </el-form-item> </el-col> </el-row> @@ -273,15 +281,18 @@ delPurchase, getSalesNo, purchaseList, - productList, getPurchaseById + productList, getPurchaseById, getOptions } from "@/api/procurementManagement/procurementLedger.js"; const { proxy } = getCurrentInstance() const tableData = ref([]) 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) const page = reactive({ current: 1, @@ -289,6 +300,10 @@ }) const total = ref(0) const fileList = ref([]) +import useUserStore from "@/store/modules/user" +import {modelList, productTreeList} from "@/api/basicData/product.js"; + +const userStore = useUserStore() // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁 const operationType = ref('') @@ -303,24 +318,28 @@ projectName: '', recorderId: '', entryDate: '', - productData: [] + productData: [], + supplierName: '', + supplierId: '', }, rules: { purchaseContractNumber: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], salesLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], projectName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], - recorderId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], - entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], + supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], } }) const { searchForm, form, rules } = toRefs(data) // 浜у搧琛ㄥ崟寮规鏁版嵁 const productFormVisible = ref(false) const productOperationType = ref('') +const productOperationIndex = ref('') const currentId = ref('') const productFormData = reactive({ productForm: { + productId: '', productCategory: '', + productModelId: '', specificationModel: '', unit: '', quantity: '', @@ -331,8 +350,8 @@ invoiceType: '', }, productRules: { - productCategory: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], - specificationModel: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], + productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], + productModelId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }], unit: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], quantity: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], taxInclusiveUnitPrice: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], @@ -350,12 +369,22 @@ headers: { Authorization: "Bearer " + getToken() }, }) +const formattedNumber = (row, column, cellValue) => { + return parseFloat(cellValue).toFixed(2); +}; // 鏌ヨ鍒楄〃 /** 鎼滅储鎸夐挳鎿嶄綔 */ const handleQuery = () => { page.current = 1 getList() } +// 瀛愯〃鍚堣鏂规硶 +const summarizeChildrenTable = (param) => { + return proxy.summarizeTable(param, ['taxInclusiveUnitPrice', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice', 'ticketsNum', 'ticketsAmount', 'futureTickets', 'futureTicketsAmount'], { + ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁� + futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁� + }); +}; const paginationChange = ({ current, limit }) => { page.current = current; page.size = limit; @@ -371,6 +400,8 @@ }) total.value = res.total expandedRowKeys.value = [] + }).catch(() => { + tableLoading.value = false }) } // 琛ㄦ牸閫夋嫨鏁版嵁 @@ -389,7 +420,7 @@ productList({salesLedgerId: row.id, type: 2}).then(res => { const index = tableData.value.findIndex(item => item.id === row.id); if (index > -1) { - tableData.value[index].children = res.rows; + tableData.value[index].children = res; } expandedRowKeys.value.push(row.id) }) @@ -402,61 +433,29 @@ } // 涓昏〃鍚堣鏂规硶 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 form.value = {} productData.value = [] + fileList.value = [] userListNoPage().then(res => { userList.value = res.data }) getSalesNo().then(res => { salesContractList.value = res }) + getOptions().then(res => { + supplierList.value = res.data + }) + form.value.recorderId = userStore.id + form.value.entryDate = getCurrentDate(); if (type === 'edit') { currentId.value = row.id; getPurchaseById({id: row.id, type: 2}).then(res => { @@ -474,7 +473,7 @@ // 涓婁紶鍓嶆牎妫� function handleBeforeUpload(file) { // 鏍℃鏂囦欢澶у皬 - if (file.size > 1024 * 1024) { + if (file.size > 1024 * 1024 * 10) { proxy.$modal.msgError('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!') return false } @@ -499,11 +498,10 @@ } // 绉婚櫎鏂囦欢 function handleRemove (file) { - console.log('handleRemove', file) - console.log('operationType.value', operationType.value) + console.log('handleRemove', file.id) if (operationType.value === 'edit') { let ids = [] - ids.push(file.value.id) + ids.push(file.id) delLedgerFile(ids).then(res => { proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") }) @@ -539,14 +537,63 @@ 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) => { + productForm.value.productCategory = findNodeById(productOptions.value, value) + modelList({id: value}).then(res => { + modelOptions.value = res + }) +} +const getProductModel =(value) => { + const index = modelOptions.value.findIndex(item => item.id === value); + if (index !== -1) { + productForm.value.specificationModel = modelOptions.value[index].model; + } else { + productForm.value.specificationModel = null; + } +} +const findNodeById = (nodes, productId) => { + for (let i = 0; i < nodes.length; i++) { + if (nodes[i].value === productId) { + return nodes[i].label; // 鎵惧埌鑺傜偣锛岃繑鍥炶鑺傜偣 + } + if (nodes[i].children && nodes[i].children.length > 0) { + const foundNode = findNodeById(nodes[i].children, productId); + if (foundNode) { + return foundNode.label; // 鍦ㄥ瓙鑺傜偣涓壘鍒帮紝杩斿洖璇ヨ妭鐐� + } + } + } + return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull +}; +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 = () => { @@ -555,7 +602,12 @@ if (operationType.value === "edit") { submitProductEdit() } else { - productData.value.push({...productForm.value}) + if (productOperationType.value === 'add') { + productData.value.push({...productForm.value}) + console.log('productData.value---', productData.value) + } else { + productData.value[productOperationIndex.value] = {...productForm.value} + } closeProductDia() } } @@ -563,10 +615,11 @@ } const submitProductEdit = () => { productForm.value.salesLedgerId = currentId.value + productForm.value.type = 2 addOrUpdateSalesLedgerProduct(productForm.value).then(res => { proxy.$modal.msgSuccess("鎻愪氦鎴愬姛") closeProductDia() - getSalesLedgerWithProducts({id: currentId.value}).then(res => { + getPurchaseById({id: currentId.value, type: 2}).then(res => { productData.value = res.productData }) }) @@ -600,7 +653,7 @@ delProduct(ids).then(res => { proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") closeProductDia() - getSalesLedgerWithProducts({id: currentId.value}).then(res => { + getSalesLedgerWithProducts({id: currentId.value, type: 2}).then(res => { productData.value = res.productData }) }) @@ -655,6 +708,17 @@ proxy.$modal.msg("宸插彇娑�") }) } +// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� YYYY-MM-DD +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}`; +} +const mathNum = (val) => { + productForm.value.taxExclusiveTotalPrice = proxy.calculateTaxExclusiveTotalPrice(val, productForm.value.taxRate) +} getList() </script> -- Gitblit v1.9.3