From fbb2c7eb5ac25ddc7d67604e07b0fa333bb60b91 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期五, 15 八月 2025 13:38:13 +0800 Subject: [PATCH] 采购台账扫码采集、韦德实业的设备监控 --- src/views/procurementManagement/procurementLedger/index.vue | 646 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 595 insertions(+), 51 deletions(-) diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue index 1086c81..2877efd 100644 --- a/src/views/procurementManagement/procurementLedger/index.vue +++ b/src/views/procurementManagement/procurementLedger/index.vue @@ -2,26 +2,47 @@ <div class="app-container"> <div class="search_form"> <div> - <span class="search_title">閲囪喘鍚堝悓鍙凤細</span> - <el-input - v-model="searchForm.purchaseContractNumber" - style="width: 240px" - placeholder="璇疯緭鍏�" - @change="handleQuery" - clearable - :prefix-icon="Search" - /> - <el-button type="primary" @click="handleQuery" style="margin-left: 10px" - >鎼滅储</el-button - > + <el-form :model="searchForm" :inline="true"> + <el-form-item label="渚涘簲鍟嗗悕绉帮細"> + <el-input v-model="searchForm.supplierName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search" + @change="handleQuery" /> + </el-form-item> + <el-form-item label="閲囪喘鍚堝悓鍙凤細"> + <el-input + v-model="searchForm.purchaseContractNumber" + style="width: 240px" + placeholder="璇疯緭鍏�" + @change="handleQuery" + clearable + :prefix-icon="Search" + /> + </el-form-item> + <el-form-item label="閿�鍞悎鍚屽彿锛�"> + <el-input v-model="searchForm.salesContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search" + @change="handleQuery" /> + </el-form-item> + <el-form-item label="椤圭洰鍚嶇О锛�"> + <el-input v-model="searchForm.projectName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search" + @change="handleQuery" /> + </el-form-item> + <el-form-item label="褰曞叆鏃ユ湡锛�"> + <el-date-picker v-model="searchForm.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange" + placeholder="璇烽�夋嫨" clearable @change="changeDaterange" /> + </el-form-item> + <el-form-item> + <el-button type="primary" @click="handleQuery"> 鎼滅储 </el-button> + </el-form-item> + </el-form> </div> - <div> + + </div> + <div class="table_list"> + <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;"> <el-button type="primary" @click="openForm('add')">鏂板鍙拌处</el-button> + <el-button type="success" @click="openScanAddDialog">鎵爜鏂板</el-button> <el-button @click="handleOut">瀵煎嚭</el-button> <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button> </div> - </div> - <div class="table_list"> <el-table :data="tableData" border @@ -76,43 +97,56 @@ <el-table-column label="閲囪喘鍚堝悓鍙�" prop="purchaseContractNumber" + width="200" show-overflow-tooltip /> <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" + width="200" show-overflow-tooltip /> <el-table-column label="渚涘簲鍟嗗悕绉�" + width="240" prop="supplierName" show-overflow-tooltip /> <el-table-column label="椤圭洰鍚嶇О" prop="projectName" + width="420" + show-overflow-tooltip + /> + <el-table-column + label="浠樻鏂瑰紡" + width="100" + prop="paymentMethod" show-overflow-tooltip /> <el-table-column label="鍚堝悓閲戦(鍏�)" prop="contractAmount" + width="200" show-overflow-tooltip :formatter="formattedNumber" /> <el-table-column label="褰曞叆浜�" prop="recorderName" + width="100" show-overflow-tooltip /> <el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" + width="100" show-overflow-tooltip /> <el-table-column fixed="right" label="鎿嶄綔" - min-width="60" + min-width="150" align="center" > <template #default="scope"> @@ -121,8 +155,17 @@ type="primary" size="small" @click="openForm('edit', scope.row)" + :disabled="scope.row.receiptPaymentAmount>0 || scope.row.recorderName !== userStore.nickName" >缂栬緫</el-button > + <el-button + link + type="success" + size="small" + @click="showQRCode(scope.row)" + >鐢熸垚浜岀淮鐮�</el-button + > + </template> </el-table-column> </el-table> @@ -236,6 +279,17 @@ </el-form-item> </el-col> </el-row> + <el-row :gutter="30"> + <el-col :span="12"> + <el-form-item label="浠樻鏂瑰紡"> + <el-input + v-model="form.paymentMethod" + placeholder="璇疯緭鍏�" + clearable + /> + </el-form-item> + </el-col> + </el-row> <el-row> <el-form-item label="浜у搧淇℃伅锛�" prop="entryDate"> <el-button type="primary" @click="openProductForm('add')" @@ -264,7 +318,7 @@ <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" /> <el-table-column label="鍗曚綅" prop="unit" width="70" /> <el-table-column label="鏁伴噺" prop="quantity" width="70" /> - <el-table-column label="绋庣巼(%)" prop="taxRate" width="70" /> + <el-table-column label="绋庣巼(%)" prop="taxRate" width="80" /> <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" @@ -405,16 +459,20 @@ /> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item label="鏁伴噺锛�" prop="quantity"> - <el-input - v-model="productForm.quantity" - placeholder="璇疯緭鍏�" - clearable - @change="mathNum" - /> - </el-form-item> - </el-col> + <el-col :span="12"> + <el-form-item label="绋庣巼(%)锛�" prop="taxRate"> + <el-select + v-model="productForm.taxRate" + placeholder="璇烽�夋嫨" + clearable + @change="mathNum" + > + <el-option label="1" value="1" /> + <el-option label="6" value="6" /> + <el-option label="13" value="13" /> + </el-select> + </el-form-item> + </el-col> </el-row> <el-row :gutter="30"> <el-col :span="12"> @@ -429,20 +487,19 @@ /> </el-form-item> </el-col> - <el-col :span="12"> - <el-form-item label="绋庣巼(%)锛�" prop="taxRate"> - <el-select - v-model="productForm.taxRate" - placeholder="璇烽�夋嫨" - clearable - @change="mathNum" - > - <el-option label="1" value="1" /> - <el-option label="6" value="6" /> - <el-option label="13" value="13" /> - </el-select> - </el-form-item> - </el-col> + <el-col :span="12"> + <el-form-item label="鏁伴噺锛�" prop="quantity"> + <el-input-number + :step="0.1" + clearable + :precision="2" + style="width: 100%" + v-model="productForm.quantity" + placeholder="璇疯緭鍏�" + @change="mathNum" + /> + </el-form-item> + </el-col> </el-row> <el-row :gutter="30"> <el-col :span="12"> @@ -453,7 +510,7 @@ :step="0.1" clearable style="width: 100%" - disabled + @change="reverseMathNum('taxInclusiveTotalPrice')" /> </el-form-item> </el-col> @@ -462,7 +519,10 @@ label="涓嶅惈绋庢�讳环(鍏�)锛�" prop="taxExclusiveTotalPrice" > - <el-input v-model="productForm.taxExclusiveTotalPrice" disabled /> + <el-input + v-model="productForm.taxExclusiveTotalPrice" + @change="reverseMathNum('taxExclusiveTotalPrice')" + /> </el-form-item> </el-col> </el-row> @@ -488,13 +548,228 @@ </div> </template> </el-dialog> + + <!-- 浜岀淮鐮佹樉绀哄璇濇 --> + <el-dialog + v-model="qrCodeDialogVisible" + title="閲囪喘鍚堝悓鍙蜂簩缁寸爜" + width="400px" + center + > + <div style="text-align: center;"> + <img :src="qrCodeUrl" alt="浜岀淮鐮�" style="width:200px;height:200px;" /> + <div style="margin: 20px;"> + <el-button type="primary" @click="downloadQRCode">涓嬭浇浜岀淮鐮佸浘鐗�</el-button> + </div> + </div> + </el-dialog> + + <!-- 鎵爜鏂板瀵硅瘽妗� --> + <el-dialog + v-model="scanAddDialogVisible" + title="鎵爜鏂板閲囪喘鍙拌处" + width="70%" + @close="closeScanAddDialog" + > + <el-form + :model="scanAddForm" + label-width="140px" + label-position="top" + :rules="scanAddRules" + ref="scanAddFormRef" + > + <el-row :gutter="20"> + <el-col :span="24"> + <el-form-item label="鎵爜鍐呭锛�"> + <el-input + v-model="scanAddForm.scanContent" + type="textarea" + :rows="3" + placeholder="璇锋壂鎻忎簩缁寸爜鎴栨墜鍔ㄨ緭鍏ラ噰璐悎鍚屼俊鎭�" + @input="parseScanContent" + /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="閲囪喘鍚堝悓鍙凤細" prop="purchaseContractNumber"> + <el-input + v-model="scanAddForm.purchaseContractNumber" + placeholder="璇疯緭鍏�" + clearable + /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierName"> + <el-input + v-model="scanAddForm.supplierName" + placeholder="璇疯緭鍏�" + clearable + /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="椤圭洰鍚嶇О锛�" prop="projectName"> + <el-input + v-model="scanAddForm.projectName" + placeholder="璇疯緭鍏�" + clearable + /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鍚堝悓閲戦(鍏�)锛�" prop="contractAmount"> + <el-input-number + v-model="scanAddForm.contractAmount" + :precision="2" + :step="0.1" + clearable + style="width: 100%" + placeholder="璇疯緭鍏�" + /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="浠樻鏂瑰紡锛�"> + <el-input + v-model="scanAddForm.paymentMethod" + placeholder="璇疯緭鍏�" + clearable + /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="褰曞叆浜猴細"> + <el-input v-model="scanAddForm.recorderName" disabled /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="24"> + <el-form-item label="澶囨敞锛�"> + <el-input + v-model="scanAddForm.remark" + type="textarea" + :rows="2" + placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�" + clearable + /> + </el-form-item> + </el-col> + </el-row> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitScanAdd">纭鏂板</el-button> + <el-button @click="closeScanAddDialog">鍙栨秷</el-button> + </div> + </template> + </el-dialog> + + <!-- 鎵爜鐧昏瀵硅瘽妗� --> + <el-dialog + v-model="scanDialogVisible" + title="鎵爜鐧昏" + width="60%" + @close="closeScanDialog" + > + <el-form + :model="scanForm" + label-width="120px" + label-position="left" + :rules="scanRules" + ref="scanFormRef" + > + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="閲囪喘鍚堝悓鍙凤細"> + <el-input v-model="scanForm.purchaseContractNumber" disabled /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="渚涘簲鍟嗗悕绉帮細"> + <el-input v-model="scanForm.supplierName" disabled /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="椤圭洰鍚嶇О锛�"> + <el-input v-model="scanForm.projectName" disabled /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鎵爜鏃堕棿锛�"> + <el-input v-model="scanForm.scanTime" disabled /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="12"> + <el-form-item label="鎵爜浜猴細"> + <el-input v-model="scanForm.scannerName" disabled /> + </el-form-item> + </el-col> + <el-col :span="12"> + <el-form-item label="鎵爜鐘舵�侊細"> + <el-tag :type="scanForm.scanStatus === '宸叉壂鐮�' ? 'success' : 'warning'"> + {{ scanForm.scanStatus }} + </el-tag> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="24"> + <el-form-item label="鎵爜澶囨敞锛�"> + <el-input + v-model="scanForm.scanRemark" + type="textarea" + :rows="3" + placeholder="璇疯緭鍏ユ壂鐮佸娉ㄤ俊鎭�" + /> + </el-form-item> + </el-col> + </el-row> + <el-row :gutter="20"> + <el-col :span="24"> + <el-form-item label="鎵爜璁板綍锛�"> + <el-table :data="scanRecords" border style="width: 100%"> + <el-table-column label="搴忓彿" type="index" width="60" align="center" /> + <el-table-column label="鎵爜鏃堕棿" prop="scanTime" width="180" /> + <el-table-column label="鎵爜浜�" prop="scannerName" width="120" /> + <el-table-column label="鎵爜鐘舵��" prop="scanStatus" width="100"> + <template #default="scope"> + <el-tag :type="scope.row.scanStatus === '宸叉壂鐮�' ? 'success' : 'warning'"> + {{ scope.row.scanStatus }} + </el-tag> + </template> + </el-table-column> + <el-table-column label="澶囨敞" prop="scanRemark" /> + </el-table> + </el-form-item> + </el-col> + </el-row> + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitScan">纭鎵爜</el-button> + <el-button @click="closeScanDialog">鍙栨秷</el-button> + </div> + </template> + </el-dialog> </div> </template> <script setup> import { getToken } from "@/utils/auth"; import pagination from "@/components/PIMTable/Pagination.vue"; -import { ref, onMounted } from "vue"; +import { ref, onMounted, reactive, toRefs, getCurrentInstance, nextTick } from "vue"; import { Search } from "@element-plus/icons-vue"; import { ElMessageBox } from "element-plus"; import { userListNoPage } from "@/api/system/user.js"; @@ -515,6 +790,8 @@ getOptions, createPurchaseNo, } from "@/api/procurementManagement/procurementLedger.js"; +import useFormData from "@/hooks/useFormData.js"; +import QRCode from "qrcode"; const { proxy } = getCurrentInstance(); const tableData = ref([]); const productData = ref([]); @@ -534,15 +811,29 @@ const fileList = ref([]); import useUserStore from "@/store/modules/user"; import { modelList, productTreeList } from "@/api/basicData/product.js"; +import dayjs from "dayjs"; const userStore = useUserStore(); + +// 浜岀淮鐮佺浉鍏冲彉閲� +const qrCodeDialogVisible = ref(false); +const qrCodeUrl = ref(""); // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁 const operationType = ref(""); const dialogFormVisible = ref(false); const data = reactive({ searchForm: { - purchaseContractNumber: "", + supplierName: "", // 渚涘簲鍟嗗悕绉� + purchaseContractNumber: "", // 閲囪喘鍚堝悓缂栧彿 + salesContractNo: "", // 閿�鍞悎鍚岀紪鍙� + projectName: "", // 椤圭洰鍚嶇О + entryDate: [ + dayjs().format("YYYY-MM-DD"), + dayjs().add(1, "day").format("YYYY-MM-DD"), + ], // 褰曞叆鏃ユ湡 + entryDateStart: dayjs().format("YYYY-MM-DD"), + entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"), }, form: { purchaseContractNumber: "", @@ -553,6 +844,7 @@ productData: [], supplierName: "", supplierId: "", + paymentMethod: "", }, rules: { purchaseContractNumber: [ @@ -562,7 +854,9 @@ supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }], }, }); -const { searchForm, form, rules } = toRefs(data); +const { form, rules } = toRefs(data); +const { form: searchForm } = useFormData(data.searchForm); + // 浜у搧琛ㄥ崟寮规鏁版嵁 const productFormVisible = ref(false); const productOperationType = ref(""); @@ -608,6 +902,17 @@ headers: { Authorization: "Bearer " + getToken() }, }); +const changeDaterange = (value) => { + if (value) { + searchForm.entryDateStart = dayjs(value[0]).format("YYYY-MM-DD"); + searchForm.entryDateEnd = dayjs(value[1]).format("YYYY-MM-DD"); + } else { + searchForm.entryDateStart = undefined; + searchForm.entryDateEnd = undefined; + } + handleQuery(); +}; + const formattedNumber = (row, column, cellValue) => { return parseFloat(cellValue).toFixed(2); }; @@ -643,14 +948,15 @@ }; const getList = () => { tableLoading.value = true; - purchaseListPage({ ...searchForm.value, ...page }) + const { entryDate, ...rest } = searchForm; + purchaseListPage({ ...rest, ...page }) .then((res) => { tableLoading.value = false; - tableData.value = res.records; + tableData.value = res.data.records; tableData.value.map((item) => { item.children = []; }); - total.value = res.total; + total.value = res.data.total; expandedRowKeys.value = []; }) .catch(() => { @@ -673,7 +979,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; + tableData.value[index].children = res.data; } expandedRowKeys.value.push(row.id); }); @@ -761,6 +1067,10 @@ // 绉婚櫎鏂囦欢 function handleRemove(file) { console.log("handleRemove", file.id); + if (file.size > 1024 * 1024 * 10) { + // 浠呭墠绔竻鐞嗭紝涓嶈皟鐢ㄥ垹闄ゆ帴鍙e拰鎻愮ず + return; + } if (operationType.value === "edit") { let ids = []; ids.push(file.id); @@ -954,6 +1264,12 @@ const handleDelete = () => { let ids = []; if (selectedRows.value.length > 0) { + // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹� + const unauthorizedData = selectedRows.value.filter(item => item.recorderName !== userStore.nickName); + if (unauthorizedData.length > 0) { + proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�"); + return; + } ids = selectedRows.value.map((item) => item.id); } else { proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁"); @@ -983,7 +1299,10 @@ return `${year}-${month}-${day}`; } const mathNum = () => { - console.log("productForm.value", productForm.value); + if (!productForm.value.taxRate) { + proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼"); + return; + } if (!productForm.value.taxInclusiveUnitPrice) { return; } @@ -1005,6 +1324,43 @@ ); } }; +const reverseMathNum = (field) => { + if (!productForm.value.taxRate) { + proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼"); + return; + } + const taxRate = Number(productForm.value.taxRate); + if (!taxRate) return; + if (field === 'taxInclusiveTotalPrice') { + // 宸茬煡鍚◣鎬讳环鍜屾暟閲忥紝鍙嶇畻鍚◣鍗曚环 + if (productForm.value.quantity) { + productForm.value.taxInclusiveUnitPrice = + (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2); + } + // 宸茬煡鍚◣鎬讳环鍜屽惈绋庡崟浠凤紝鍙嶇畻鏁伴噺 + else if (productForm.value.taxInclusiveUnitPrice) { + productForm.value.quantity = + (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2); + } + // 鍙嶇畻涓嶅惈绋庢�讳环 + productForm.value.taxExclusiveTotalPrice = + (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).toFixed(2); + } else if (field === 'taxExclusiveTotalPrice') { + // 鍙嶇畻鍚◣鎬讳环 + productForm.value.taxInclusiveTotalPrice = + (Number(productForm.value.taxExclusiveTotalPrice) * (1 + taxRate / 100)).toFixed(2); + // 宸茬煡鏁伴噺锛屽弽绠楀惈绋庡崟浠� + if (productForm.value.quantity) { + productForm.value.taxInclusiveUnitPrice = + (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.quantity)).toFixed(2); + } + // 宸茬煡鍚◣鍗曚环锛屽弽绠楁暟閲� + else if (productForm.value.taxInclusiveUnitPrice) { + productForm.value.quantity = + (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2); + } + } +}; // 閿�鍞悎鍚岄�夋嫨鏀瑰彉鏂规硶 const salesLedgerChange = async (row) => { console.log("row", row); @@ -1025,6 +1381,194 @@ } }; +// 鏄剧ず浜岀淮鐮� +const showQRCode = async (row) => { + try { + // 鏋勫缓浜岀淮鐮佸唴瀹癸紝鍙寘鍚噰璐悎鍚屽彿锛堢函鏂囨湰锛� + const qrContent = row.purchaseContractNumber || ''; + // 妫�鏌ュ唴瀹规槸鍚︿负绌� + if (!qrContent || qrContent.trim() === '') { + proxy.$modal.msgWarning("璇ヨ娌℃湁閲囪喘鍚堝悓鍙凤紝鏃犳硶鐢熸垚浜岀淮鐮�"); + return; + } + qrCodeUrl.value = await QRCode.toDataURL(qrContent, { + width: 200, + margin: 2, + color: { + dark: '#000000', + light: '#FFFFFF' + } + }); + qrCodeDialogVisible.value = true; + } catch (error) { + console.error('鐢熸垚浜岀淮鐮佸け璐�:', error); + proxy.$modal.msgError("鐢熸垚浜岀淮鐮佸け璐ワ細" + error.message); + } +}; + +// 涓嬭浇浜岀淮鐮� +const downloadQRCode = () => { + if (!qrCodeUrl.value) { + proxy.$modal.msgWarning("浜岀淮鐮佹湭鐢熸垚"); + return; + } + + const a = document.createElement('a'); + a.href = qrCodeUrl.value; + a.download = `閲囪喘鍚堝悓鍙蜂簩缁寸爜_${new Date().getTime()}.png`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + proxy.$modal.msgSuccess("涓嬭浇鎴愬姛"); +}; + +// 鎵爜鏂板瀵硅瘽妗嗙浉鍏冲彉閲� +const scanAddDialogVisible = ref(false); +const scanAddForm = reactive({ + scanContent: "", + purchaseContractNumber: "", + supplierName: "", + projectName: "", + contractAmount: "", + paymentMethod: "", + recorderName: "", + scanRemark: "", +}); +const scanAddRules = { + purchaseContractNumber: [{ required: true, message: "璇疯緭鍏ラ噰璐悎鍚屽彿", trigger: "blur" }], + supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }], + projectName: [{ required: true, message: "璇疯緭鍏ラ」鐩悕绉�", trigger: "blur" }], +}; + +// 鎵爜鐧昏瀵硅瘽妗嗙浉鍏冲彉閲� +const scanDialogVisible = ref(false); +const scanForm = reactive({ + purchaseContractNumber: "", + supplierName: "", + projectName: "", + scanTime: "", + scannerName: "", + scanStatus: "鏈壂鐮�", + scanRemark: "", +}); +const scanRules = { + scanRemark: [{ required: true, message: "璇疯緭鍏ユ壂鐮佸娉�", trigger: "blur" }], +}; +const scanRecords = ref([]); + +// 鎵撳紑鎵爜鏂板瀵硅瘽妗� +const openScanAddDialog = () => { + scanAddForm.scanContent = ""; + scanAddForm.purchaseContractNumber = ""; + scanAddForm.supplierName = ""; + scanAddForm.projectName = ""; + scanAddForm.contractAmount = ""; + scanAddForm.paymentMethod = ""; + scanAddForm.recorderName = userStore.nickName; + scanAddForm.scanRemark = ""; + scanAddDialogVisible.value = true; +}; + +// 瑙f瀽鎵爜鍐呭锛堟ā鎷熻В鏋愪簩缁寸爜鏁版嵁锛� +const parseScanContent = (content) => { + if (!content) return; + + // 妯℃嫙瑙f瀽浜岀淮鐮佸唴瀹癸紝杩欓噷鍙互鏍规嵁瀹為檯闇�姹傝皟鏁磋В鏋愰�昏緫 + // 鍋囪鎵爜鍐呭鏍煎紡涓猴細鍚堝悓鍙穦渚涘簲鍟唡椤圭洰|閲戦|浠樻鏂瑰紡 + const parts = content.split('|'); + if (parts.length >= 3) { + scanAddForm.purchaseContractNumber = parts[0] || ""; + scanAddForm.supplierName = parts[1] || ""; + scanAddForm.projectName = parts[2] || ""; + scanAddForm.contractAmount = parts[3] || ""; + scanAddForm.paymentMethod = parts[4] || ""; + } +}; + +// 鍏抽棴鎵爜鏂板瀵硅瘽妗� +const closeScanAddDialog = () => { + scanAddDialogVisible.value = false; + proxy.resetForm("scanAddFormRef"); +}; + +// 鎻愪氦鎵爜鏂板 +const submitScanAdd = () => { + proxy.$refs["scanAddFormRef"].validate((valid) => { + if (valid) { + // 鏋勫缓鏂板鏁版嵁 + const newData = { + purchaseContractNumber: scanAddForm.purchaseContractNumber, + supplierName: scanAddForm.supplierName, + projectName: scanAddForm.projectName, + contractAmount: scanAddForm.contractAmount, + paymentMethod: scanAddForm.paymentMethod, + recorderName: scanAddForm.recorderName, + entryDate: getCurrentDate(), + remark: scanAddForm.scanRemark, + type: 2 + }; + + // 妯℃嫙鏂板鎴愬姛 + proxy.$modal.msgSuccess("鎵爜鏂板鎴愬姛锛�"); + closeScanAddDialog(); + + // 鍙互閫夋嫨鏄惁鍒锋柊鍒楄〃 + // getList(); + } + }); +}; + +// 鎵撳紑鎵爜鐧昏瀵硅瘽妗� +const openScanDialog = (row) => { + scanForm.purchaseContractNumber = row.purchaseContractNumber; + scanForm.supplierName = row.supplierName; + scanForm.projectName = row.projectName; + scanForm.scanTime = getCurrentDateTime(); + scanForm.scannerName = userStore.nickName; + scanForm.scanStatus = "鏈壂鐮�"; + scanForm.scanRemark = ""; + scanRecords.value = []; + scanDialogVisible.value = true; +}; + +// 鍏抽棴鎵爜鐧昏瀵硅瘽妗� +const closeScanDialog = () => { + scanDialogVisible.value = false; + proxy.resetForm("scanFormRef"); +}; + +// 鎻愪氦鎵爜鐧昏 +const submitScan = () => { + proxy.$refs["scanFormRef"].validate((valid) => { + if (valid) { + // 娣诲姞鎵爜璁板綍 + scanRecords.value.push({ + ...scanForm, + id: Date.now(), // 妯℃嫙ID + scanTime: getCurrentDateTime(), + }); + scanForm.scanStatus = "宸叉壂鐮�"; + scanForm.scanRemark = scanForm.scanRemark || "鏃�"; + proxy.$modal.msgSuccess("鎵爜鐧昏鎴愬姛锛�"); + closeScanDialog(); + } + }); +}; + +// 鑾峰彇褰撳墠鏃ユ湡鏃堕棿 +function getCurrentDateTime() { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, "0"); + const day = String(now.getDate()).padStart(2, "0"); + const hours = String(now.getHours()).padStart(2, "0"); + const minutes = String(now.getMinutes()).padStart(2, "0"); + const seconds = String(now.getSeconds()).padStart(2, "0"); + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; +} + + + onMounted(() => { getList(); }); -- Gitblit v1.9.3