From 4e1a85b2dbf91ba76bb5ecca1c6ebfb4fd64fc29 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期一, 05 一月 2026 15:39:03 +0800
Subject: [PATCH] 进销存·华玺砂浆》采购管理-采购台账可以创建采购模板,在新建采购时可以直接选择对应模板 进销存·华玺砂浆》采购管理-采购台账台账在新建采购时可以选择对应产品模板(并要加入审批人,进入协同审批的采购申请)
---
src/views/procurementManagement/procurementLedger/index.vue | 1623 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 982 insertions(+), 641 deletions(-)
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 4475f30..99a392f 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -44,32 +44,32 @@
<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
</div>
<el-table
- :data="tableData"
- border
- v-loading="tableLoading"
- @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys"
- :row-key="(row) => row.id"
- show-summary
- :summary-method="summarizeMainTable"
- @expand-change="expandChange"
- height="calc(100vh - 18.5em)"
- :row-class-name="tableRowClassName"
+ :data="tableData"
+ border
+ v-loading="tableLoading"
+ @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys"
+ :row-key="(row) => row.id"
+ show-summary
+ :summary-method="summarizeMainTable"
+ @expand-change="expandChange"
+ height="calc(100vh - 18.5em)"
+ :row-class-name="tableRowClassName"
>
<el-table-column align="center" type="selection" width="55" />
<el-table-column type="expand">
<template #default="props">
<el-table
- :data="props.row.children"
- border
- show-summary
- :summary-method="summarizeChildrenTable"
+ :data="props.row.children"
+ border
+ show-summary
+ :summary-method="summarizeChildrenTable"
>
<el-table-column
- align="center"
- label="搴忓彿"
- type="index"
- width="60"
+ align="center"
+ label="搴忓彿"
+ type="index"
+ width="60"
/>
<el-table-column label="浜у搧澶х被" prop="productCategory" />
<el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
@@ -77,41 +77,41 @@
<el-table-column label="鏁伴噺" prop="quantity" />
<el-table-column label="绋庣巼(%)" prop="taxRate" />
<el-table-column
- label="鍚◣鍗曚环(鍏�)"
- prop="taxInclusiveUnitPrice"
- :formatter="formattedNumber"
+ label="鍚◣鍗曚环(鍏�)"
+ prop="taxInclusiveUnitPrice"
+ :formatter="formattedNumber"
/>
<el-table-column
- label="鍚◣鎬讳环(鍏�)"
- prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
+ label="鍚◣鎬讳环(鍏�)"
+ prop="taxInclusiveTotalPrice"
+ :formatter="formattedNumber"
/>
<el-table-column
- label="涓嶅惈绋庢�讳环(鍏�)"
- prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
+ 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"
- width="200"
- show-overflow-tooltip
+ label="閲囪喘鍚堝悓鍙�"
+ prop="purchaseContractNumber"
+ width="200"
+ show-overflow-tooltip
/>
<el-table-column
- label="閿�鍞悎鍚屽彿"
- prop="salesContractNo"
- width="200"
- show-overflow-tooltip
+ label="閿�鍞悎鍚屽彿"
+ prop="salesContractNo"
+ width="200"
+ show-overflow-tooltip
/>
<el-table-column
- label="渚涘簲鍟嗗悕绉�"
- width="240"
- prop="supplierName"
- show-overflow-tooltip
+ label="渚涘簲鍟嗗悕绉�"
+ width="240"
+ prop="supplierName"
+ show-overflow-tooltip
/>
<el-table-column label="璁㈠崟鐘舵��" width="100" align="center">
<template #default="scope">
@@ -120,10 +120,10 @@
</template>
</el-table-column>
<el-table-column
- label="椤圭洰鍚嶇О"
- prop="projectName"
- width="420"
- show-overflow-tooltip
+ label="椤圭洰鍚嶇О"
+ prop="projectName"
+ width="420"
+ show-overflow-tooltip
/>
<el-table-column
label="瀹℃壒鐘舵��"
@@ -140,100 +140,100 @@
</template>
</el-table-column>
<el-table-column
- label="浠樻鏂瑰紡"
- width="100"
- prop="paymentMethod"
- show-overflow-tooltip
+ label="浠樻鏂瑰紡"
+ width="100"
+ prop="paymentMethod"
+ show-overflow-tooltip
/>
<el-table-column
- label="鍚堝悓閲戦(鍏�)"
- prop="contractAmount"
- width="200"
- show-overflow-tooltip
- :formatter="formattedNumber"
+ label="鍚堝悓閲戦(鍏�)"
+ prop="contractAmount"
+ width="200"
+ show-overflow-tooltip
+ :formatter="formattedNumber"
/>
<el-table-column
- label="褰曞叆浜�"
- prop="recorderName"
- width="100"
- show-overflow-tooltip
+ label="褰曞叆浜�"
+ prop="recorderName"
+ width="100"
+ show-overflow-tooltip
/>
<el-table-column
- label="褰曞叆鏃ユ湡"
- prop="entryDate"
- width="100"
- show-overflow-tooltip
+ label="褰曞叆鏃ユ湡"
+ prop="entryDate"
+ width="100"
+ show-overflow-tooltip
/>
<el-table-column
- fixed="right"
- label="鎿嶄綔"
- min-width="150"
- align="center"
+ fixed="right"
+ label="鎿嶄綔"
+ min-width="150"
+ align="center"
>
<template #default="scope">
<el-button
- link
- type="primary"
- size="small"
- @click="openForm('edit', scope.row)"
- >缂栬緫</el-button
+ link
+ type="primary"
+ size="small"
+ @click="openForm('edit', scope.row)"
+ >缂栬緫</el-button
>
<el-button
- link
- type="success"
- size="small"
- @click="showQRCode(scope.row)"
- >鐢熸垚浜岀淮鐮�</el-button
+ link
+ type="success"
+ size="small"
+ @click="showQRCode(scope.row)"
+ >鐢熸垚浜岀淮鐮�</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
- v-show="total > 0"
- :total="total"
- layout="total, sizes, prev, pager, next, jumper"
- :page="page.current"
- :limit="page.size"
- @pagination="paginationChange"
+ v-show="total > 0"
+ :total="total"
+ layout="total, sizes, prev, pager, next, jumper"
+ :page="page.current"
+ :limit="page.size"
+ @pagination="paginationChange"
/>
</div>
<el-dialog
- v-model="dialogFormVisible"
- :title="operationType === 'add' ? '鏂板閲囪喘鍙拌处椤甸潰' : '缂栬緫閲囪喘鍙拌处椤甸潰'"
- width="70%"
- @close="closeDia"
+ v-model="dialogFormVisible"
+ :title="operationType === 'add' ? '鏂板閲囪喘鍙拌处椤甸潰' : '缂栬緫閲囪喘鍙拌处椤甸潰'"
+ width="70%"
+ @close="closeDia"
>
<el-form
- :model="form"
- label-width="140px"
- label-position="top"
- :rules="rules"
- ref="formRef"
+ :model="form"
+ label-width="140px"
+ label-position="top"
+ :rules="rules"
+ ref="formRef"
>
<el-row :gutter="30">
<el-col :span="12">
<el-form-item label="閲囪喘鍚堝悓鍙凤細" prop="purchaseContractNumber">
<el-input
- v-model="form.purchaseContractNumber"
- placeholder="璇疯緭鍏�"
- clearable
+ v-model="form.purchaseContractNumber"
+ placeholder="璇疯緭鍏�"
+ clearable
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesLedgerId">
<el-select
- v-model="form.salesLedgerId"
- placeholder="璇烽�夋嫨"
- clearable
- @change="salesLedgerChange"
+ v-model="form.salesLedgerId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ @change="salesLedgerChange"
>
<el-option
- v-for="item in salesContractList"
- :key="item.id"
- :label="item.salesContractNo"
- :value="item.id"
+ v-for="item in salesContractList"
+ :key="item.id"
+ :label="item.salesContractNo"
+ :value="item.id"
/>
</el-select>
</el-form-item>
@@ -243,17 +243,17 @@
<el-col :span="12">
<el-form-item label="渚涘簲鍟嗗悕绉帮細" prop="supplierId">
<el-select
- v-model="form.supplierId"
- placeholder="璇烽�夋嫨"
- clearable
- filterable
- allow-create
+ v-model="form.supplierId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ filterable
+ allow-create
>
<el-option
- v-for="item in supplierList"
- :key="item.id"
- :label="item.supplierName"
- :value="item.id"
+ v-for="item in supplierList"
+ :key="item.id"
+ :label="item.supplierName"
+ :value="item.id"
/>
</el-select>
</el-form-item>
@@ -261,51 +261,65 @@
<el-col :span="12">
<el-form-item label="椤圭洰鍚嶇О锛�" prop="projectName">
<el-input
- v-model="form.projectName"
- placeholder="璇疯緭鍏�"
- clearable
+ v-model="form.projectName"
+ placeholder="璇疯緭鍏�"
+ clearable
/>
</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-col :span="12">
- <el-form-item label="绛捐鏃ユ湡锛�" prop="executionDate">
- <el-date-picker
- style="width: 100%"
- v-model="form.executionDate"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
- />
- </el-form-item>
- </el-col>
- </el-row>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="褰曞叆浜猴細" prop="recorderId">
+ <el-form-item label="浠樻鏂瑰紡">
+ <el-input
+ v-model="form.paymentMethod"
+ placeholder="璇疯緭鍏�"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="绛捐鏃ユ湡锛�" prop="executionDate">
+ <el-date-picker
+ style="width: 100%"
+ v-model="form.executionDate"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="30">
+ <el-col :span="12">
+ <el-form-item label="瀹℃壒浜猴細" prop="approverId">
<el-select
- v-model="form.recorderId"
- placeholder="璇烽�夋嫨"
- clearable
- disabled
+ v-model="form.approverId"
+ placeholder="璇烽�夋嫨瀹℃壒浜�"
+ clearable
>
<el-option
- v-for="item in userList"
- :key="item.userId"
- :label="item.nickName"
- :value="item.userId"
+ v-for="item in userList"
+ :key="item.userId"
+ :label="item.nickName"
+ :value="item.userId"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="褰曞叆浜猴細" prop="recorderId" v-show="false">
+ <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>
@@ -313,13 +327,13 @@
<el-col :span="12">
<el-form-item label="褰曞叆鏃ユ湡锛�" prop="entryDate">
<el-date-picker
- style="width: 100%"
- v-model="form.entryDate"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- type="date"
- placeholder="璇烽�夋嫨"
- clearable
+ style="width: 100%"
+ v-model="form.entryDate"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable
/>
</el-form-item>
</el-col>
@@ -327,64 +341,95 @@
<el-row>
<el-form-item label="浜у搧淇℃伅锛�" prop="entryDate">
<el-button type="primary" @click="openProductForm('add')"
- >娣诲姞</el-button
+ >娣诲姞</el-button
>
<el-button plain type="danger" @click="deleteProduct"
- >鍒犻櫎</el-button
+ >鍒犻櫎</el-button
>
</el-form-item>
+ <div class="select-button-group" style="width: 220px; margin: 20px 0;" v-if="operationType === 'add'">
+ <el-select
+ filterable
+ allow-create
+ :reserve-keyword="true"
+ :default-first-option="false"
+ v-model="templateName"
+ :input-value="filterInputValue"
+ @filter-change="onTemplateFilterChange"
+ @change="onTemplateChange"
+ style="width: 180px; border-right: none; border-radius: 4px 0 0 4px;"
+ placeholder="璇烽�夋嫨"
+ class="no-arrow-select"
+ >
+ <el-option
+ v-for="item in templateList"
+ :key="item.value"
+ :label="item.templateName"
+ :value="item.templateName"
+ ></el-option>
+ </el-select>
+ <!-- 鎸夐挳锛氫笌 Select 楂樺害鍖归厤锛屽幓鎺夊乏渚ц竟妗嗭紝鏃犵紳琛旀帴 -->
+ <el-button
+ size="small"
+ style="height: 32px; border-radius: 0 4px 4px 0; margin-left: -1px;"
+ @click="handleButtonClick"
+ :disabled="!templateName || templateName.trim() === '' || isTemplateNameDuplicate"
+ >
+ 淇濆瓨
+ </el-button>
+ </div>
</el-row>
<el-table
- :data="productData"
- border
- @selection-change="productSelected"
- show-summary
- :summary-method="summarizeProTable"
+ :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"
+ align="center"
+ label="搴忓彿"
+ type="index"
+ width="60"
/>
<el-table-column label="浜у搧澶х被" prop="productCategory" />
<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="warnNum" width="120" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" width="120" show-overflow-tooltip />
<el-table-column label="绋庣巼(%)" prop="taxRate" width="80" />
<el-table-column
- label="鍚◣鍗曚环(鍏�)"
- prop="taxInclusiveUnitPrice"
- :formatter="formattedNumber"
- width="150"
+ label="鍚◣鍗曚环(鍏�)"
+ prop="taxInclusiveUnitPrice"
+ :formatter="formattedNumber"
+ width="150"
/>
<el-table-column
- label="鍚◣鎬讳环(鍏�)"
- prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
- width="150"
+ label="鍚◣鎬讳环(鍏�)"
+ prop="taxInclusiveTotalPrice"
+ :formatter="formattedNumber"
+ width="150"
/>
<el-table-column
- label="涓嶅惈绋庢�讳环(鍏�)"
- prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
- width="150"
+ label="涓嶅惈绋庢�讳环(鍏�)"
+ prop="taxExclusiveTotalPrice"
+ :formatter="formattedNumber"
+ width="150"
/>
<el-table-column
- fixed="right"
- label="鎿嶄綔"
- min-width="60"
- align="center"
+ fixed="right"
+ label="鎿嶄綔"
+ min-width="60"
+ align="center"
>
<template #default="scope">
<el-button
- link
- type="primary"
- size="small"
- @click="openProductForm('edit', scope.row, scope.$index)"
- >缂栬緫</el-button
+ link
+ type="primary"
+ size="small"
+ @click="openProductForm('edit', scope.row, scope.$index)"
+ >缂栬緫</el-button
>
</template>
</el-table-column>
@@ -393,11 +438,11 @@
<el-col :span="24">
<el-form-item label="澶囨敞路锛�" prop="remark">
<el-input
- v-model="form.remark"
- placeholder="璇疯緭鍏�"
- clearable
- type="textarea"
- :rows="2"
+ v-model="form.remark"
+ placeholder="璇疯緭鍏�"
+ clearable
+ type="textarea"
+ :rows="2"
/>
</el-form-item>
</el-col>
@@ -406,16 +451,16 @@
<el-col :span="24">
<el-form-item label="闄勪欢鏉愭枡锛�" prop="remark">
<el-upload
- v-model:file-list="fileList"
- :action="upload.url"
- multiple
- ref="fileUpload"
- auto-upload
- :headers="upload.headers"
- :before-upload="handleBeforeUpload"
- :on-error="handleUploadError"
- :on-success="handleUploadSuccess"
- :on-remove="handleRemove"
+ v-model:file-list="fileList"
+ :action="upload.url"
+ multiple
+ ref="fileUpload"
+ auto-upload
+ :headers="upload.headers"
+ :before-upload="handleBeforeUpload"
+ :on-error="handleUploadError"
+ :on-success="handleUploadSuccess"
+ :on-remove="handleRemove"
>
<el-button type="primary">涓婁紶</el-button>
<template #tip>
@@ -437,30 +482,30 @@
</template>
</el-dialog>
<el-dialog
- v-model="productFormVisible"
- :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
- width="40%"
- @close="closeProductDia"
+ v-model="productFormVisible"
+ :title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
+ width="40%"
+ @close="closeProductDia"
>
<el-form
- :model="productForm"
- label-width="140px"
- label-position="top"
- :rules="productRules"
- ref="productFormRef"
+ :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="productId">
<el-tree-select
- v-model="productForm.productId"
- placeholder="璇烽�夋嫨"
- clearable
- check-strictly
- @change="getModels"
- :data="productOptions"
- :render-after-expand="false"
- style="width: 100%"
+ v-model="productForm.productId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ check-strictly
+ @change="getModels"
+ :data="productOptions"
+ :render-after-expand="false"
+ style="width: 100%"
/>
</el-form-item>
</el-col>
@@ -469,16 +514,16 @@
<el-col :span="24">
<el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
<el-select
- v-model="productForm.productModelId"
- placeholder="璇烽�夋嫨"
- clearable
- @change="getProductModel"
+ v-model="productForm.productModelId"
+ placeholder="璇烽�夋嫨"
+ clearable
+ @change="getProductModel"
>
<el-option
- v-for="item in modelOptions"
- :key="item.id"
- :label="item.model"
- :value="item.id"
+ v-for="item in modelOptions"
+ :key="item.id"
+ :label="item.model"
+ :value="item.id"
/>
</el-select>
</el-form-item>
@@ -488,75 +533,75 @@
<el-col :span="12">
<el-form-item label="鍗曚綅锛�" prop="unit">
<el-input
- v-model="productForm.unit"
- placeholder="璇疯緭鍏�"
- clearable
+ v-model="productForm.unit"
+ placeholder="璇疯緭鍏�"
+ clearable
/>
</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="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">
<el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
<el-input-number
- v-model="productForm.taxInclusiveUnitPrice"
- :precision="2"
- :step="0.1"
- clearable
- style="width: 100%"
- @change="mathNum"
+ v-model="productForm.taxInclusiveUnitPrice"
+ :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="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-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">
<el-form-item label="鍚◣鎬讳环(鍏�)锛�" prop="taxInclusiveTotalPrice">
<el-input-number
- v-model="productForm.taxInclusiveTotalPrice"
- :precision="2"
- :step="0.1"
- clearable
- style="width: 100%"
- @change="reverseMathNum('taxInclusiveTotalPrice')"
+ v-model="productForm.taxInclusiveTotalPrice"
+ :precision="2"
+ :step="0.1"
+ clearable
+ style="width: 100%"
+ @change="reverseMathNum('taxInclusiveTotalPrice')"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
- label="涓嶅惈绋庢�讳环(鍏�)锛�"
- prop="taxExclusiveTotalPrice"
+ label="涓嶅惈绋庢�讳环(鍏�)锛�"
+ prop="taxExclusiveTotalPrice"
>
- <el-input
- v-model="productForm.taxExclusiveTotalPrice"
- @change="reverseMathNum('taxExclusiveTotalPrice')"
+ <el-input
+ v-model="productForm.taxExclusiveTotalPrice"
+ @change="reverseMathNum('taxExclusiveTotalPrice')"
/>
</el-form-item>
</el-col>
@@ -565,26 +610,26 @@
<el-col :span="12">
<el-form-item label="鍙戠エ绫诲瀷锛�" prop="invoiceType">
<el-select
- v-model="productForm.invoiceType"
- placeholder="璇烽�夋嫨"
- clearable
+ v-model="productForm.invoiceType"
+ placeholder="璇烽�夋嫨"
+ clearable
>
<el-option label="澧炴櫘绁�" value="澧炴櫘绁�" />
<el-option label="澧炰笓绁�" value="澧炰笓绁�" />
</el-select>
</el-form-item>
</el-col>
- <el-col :span="12">
- <el-form-item label="搴撳瓨棰勮鏁伴噺锛�" prop="warnNum">
- <el-input-number
- v-model="productForm.warnNum"
- :precision="2"
- :step="0.1"
- clearable
- style="width: 100%"
- />
- </el-form-item>
- </el-col>
+ <el-col :span="12">
+ <el-form-item label="搴撳瓨棰勮鏁伴噺锛�" prop="warnNum">
+ <el-input-number
+ v-model="productForm.warnNum"
+ :precision="2"
+ :step="0.1"
+ clearable
+ style="width: 100%"
+ />
+ </el-form-item>
+ </el-col>
</el-row>
</el-form>
<template #footer>
@@ -594,13 +639,13 @@
</div>
</template>
</el-dialog>
-
+
<!-- 浜岀淮鐮佹樉绀哄璇濇 -->
<el-dialog
- v-model="qrCodeDialogVisible"
- title="閲囪喘鍚堝悓鍙蜂簩缁寸爜"
- width="400px"
- center
+ v-model="qrCodeDialogVisible"
+ title="閲囪喘鍚堝悓鍙蜂簩缁寸爜"
+ width="400px"
+ center
>
<div style="text-align: center;">
<img :src="qrCodeUrl" alt="浜岀淮鐮�" style="width:200px;height:200px;" />
@@ -612,27 +657,27 @@
<!-- 鎵爜鏂板瀵硅瘽妗� -->
<el-dialog
- v-model="scanAddDialogVisible"
- title="鎵爜鏂板閲囪喘鍙拌处"
- width="70%"
- @close="closeScanAddDialog"
+ v-model="scanAddDialogVisible"
+ title="鎵爜鏂板閲囪喘鍙拌处"
+ width="70%"
+ @close="closeScanAddDialog"
>
<el-form
- :model="scanAddForm"
- label-width="140px"
- label-position="top"
- :rules="scanAddRules"
- ref="scanAddFormRef"
+ :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"
+ v-model="scanAddForm.scanContent"
+ type="textarea"
+ :rows="3"
+ placeholder="璇锋壂鎻忎簩缁寸爜鎴栨墜鍔ㄨ緭鍏ラ噰璐悎鍚屼俊鎭�"
+ @input="parseScanContent"
/>
</el-form-item>
</el-col>
@@ -641,18 +686,18 @@
<el-col :span="12">
<el-form-item label="閲囪喘鍚堝悓鍙凤細" prop="purchaseContractNumber">
<el-input
- v-model="scanAddForm.purchaseContractNumber"
- placeholder="璇疯緭鍏�"
- clearable
+ 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
+ v-model="scanAddForm.supplierName"
+ placeholder="璇疯緭鍏�"
+ clearable
/>
</el-form-item>
</el-col>
@@ -661,21 +706,21 @@
<el-col :span="12">
<el-form-item label="椤圭洰鍚嶇О锛�" prop="projectName">
<el-input
- v-model="scanAddForm.projectName"
- placeholder="璇疯緭鍏�"
- clearable
+ 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="璇疯緭鍏�"
+ v-model="scanAddForm.contractAmount"
+ :precision="2"
+ :step="0.1"
+ clearable
+ style="width: 100%"
+ placeholder="璇疯緭鍏�"
/>
</el-form-item>
</el-col>
@@ -684,9 +729,9 @@
<el-col :span="12">
<el-form-item label="浠樻鏂瑰紡锛�">
<el-input
- v-model="scanAddForm.paymentMethod"
- placeholder="璇疯緭鍏�"
- clearable
+ v-model="scanAddForm.paymentMethod"
+ placeholder="璇疯緭鍏�"
+ clearable
/>
</el-form-item>
</el-col>
@@ -700,11 +745,11 @@
<el-col :span="24">
<el-form-item label="澶囨敞锛�">
<el-input
- v-model="scanAddForm.remark"
- type="textarea"
- :rows="2"
- placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�"
- clearable
+ v-model="scanAddForm.remark"
+ type="textarea"
+ :rows="2"
+ placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�"
+ clearable
/>
</el-form-item>
</el-col>
@@ -720,17 +765,17 @@
<!-- 鎵爜鐧昏瀵硅瘽妗� -->
<el-dialog
- v-model="scanDialogVisible"
- title="鎵爜鐧昏"
- width="60%"
- @close="closeScanDialog"
+ v-model="scanDialogVisible"
+ title="鎵爜鐧昏"
+ width="60%"
+ @close="closeScanDialog"
>
<el-form
- :model="scanForm"
- label-width="120px"
- label-position="left"
- :rules="scanRules"
- ref="scanFormRef"
+ :model="scanForm"
+ label-width="120px"
+ label-position="left"
+ :rules="scanRules"
+ ref="scanFormRef"
>
<el-row :gutter="20">
<el-col :span="12">
@@ -774,10 +819,10 @@
<el-col :span="24">
<el-form-item label="鎵爜澶囨敞锛�">
<el-input
- v-model="scanForm.scanRemark"
- type="textarea"
- :rows="3"
- placeholder="璇疯緭鍏ユ壂鐮佸娉ㄤ俊鎭�"
+ v-model="scanForm.scanRemark"
+ type="textarea"
+ :rows="3"
+ placeholder="璇疯緭鍏ユ壂鐮佸娉ㄤ俊鎭�"
/>
</el-form-item>
</el-col>
@@ -809,35 +854,42 @@
</div>
</template>
</el-dialog>
+
</div>
</template>
<script setup>
-import { getToken } from "@/utils/auth";
+import {getToken} from "@/utils/auth";
import pagination from "@/components/PIMTable/Pagination.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";
+import {getCurrentInstance, nextTick, onMounted, reactive, ref, toRefs} from "vue";
+import {Search} from "@element-plus/icons-vue";
+import {ElMessage, ElMessageBox} from "element-plus";
+import {userListNoPage} from "@/api/system/user.js";
import {
- getSalesLedgerWithProducts,
addOrUpdateSalesLedgerProduct,
- delProduct,
delLedgerFile,
+ delProduct,
getProductInfoByContractNo,
+ getSalesLedgerWithProducts,
} from "@/api/salesManagement/salesLedger.js";
import {
addOrEditPurchase,
- delPurchase,
- getSalesNo,
- purchaseListPage,
- productList,
- getPurchaseById,
- getOptions,
+ addPurchaseTemplate,
createPurchaseNo,
+ delPurchase,
+ getOptions,
+ getPurchaseById,
+ getPurchaseTemplateList,
+ getSalesNo,
+ productList,
+ purchaseListPage
} from "@/api/procurementManagement/procurementLedger.js";
import useFormData from "@/hooks/useFormData.js";
import QRCode from "qrcode";
+import useUserStore from "@/store/modules/user";
+import {modelList, productTreeList} from "@/api/basicData/product.js";
+import dayjs from "dayjs";
+
const { proxy } = getCurrentInstance();
const tableData = ref([]);
const productData = ref([]);
@@ -855,9 +907,6 @@
});
const total = ref(0);
const fileList = ref([]);
-import useUserStore from "@/store/modules/user";
-import { modelList, productTreeList } from "@/api/basicData/product.js";
-import dayjs from "dayjs";
const userStore = useUserStore();
@@ -870,6 +919,96 @@
0: '瀹℃壒涓�',
1: '瀹℃壒閫氳繃',
2: '瀹℃壒澶辫触'
+};
+
+
+const templateName = ref('');
+const filterInputValue = ref('');
+const templateList = ref([]);
+const isTemplateNameDuplicate = ref(false); // 鏍囪妯℃澘鍚嶇О鏄惁閲嶅
+
+// 妫�鏌ユā鏉垮悕绉版槸鍚﹂噸澶�
+const checkTemplateNameDuplicate = (name) => {
+ if (!name || name.trim() === '') {
+ isTemplateNameDuplicate.value = false;
+ return false;
+ }
+ const isDuplicate = templateList.value.some(item => item.templateName === name.trim());
+ isTemplateNameDuplicate.value = isDuplicate;
+ return isDuplicate;
+};
+
+// 闃叉姈瀹氭椂鍣�
+let duplicateCheckTimer = null;
+const onTemplateFilterChange = (val) => {
+ filterInputValue.value = val ?? '';
+ // 娓呴櫎涔嬪墠鐨勫畾鏃跺櫒
+ if (duplicateCheckTimer) {
+ clearTimeout(duplicateCheckTimer);
+ }
+ // 瀹炴椂妫�鏌ユā鏉垮悕绉版槸鍚﹂噸澶嶏紙闃叉姈澶勭悊锛岄伩鍏嶉绻佹彁绀猴級
+ if (val && val.trim()) {
+ duplicateCheckTimer = setTimeout(() => {
+ const isDuplicate = checkTemplateNameDuplicate(val);
+ if (isDuplicate) {
+ ElMessage({
+ message: '妯℃澘鍚嶇О宸插瓨鍦紝璇锋洿鎹㈡ā鏉垮悕绉�',
+ type: 'warning',
+ duration: 2000
+ });
+ }
+ }, 300); // 300ms 闃叉姈
+ } else {
+ isTemplateNameDuplicate.value = false;
+ }
+};
+
+// allow-create 鏃讹紝杈撳叆涓嶅瓨鍦ㄧ殑鍐呭浼氫綔涓� string 鍊艰繑鍥烇紱杩欓噷鍚屾鍥炶緭鍏ユ浠ョ‘淇濇枃瀛椾笉涓�
+const onTemplateChange = async (val) => {
+ if (typeof val === 'string') {
+ filterInputValue.value = val;
+ // 閫夋嫨鎴栬緭鍏ユ椂妫�鏌ラ噸澶�
+ checkTemplateNameDuplicate(val);
+ }
+
+ // 杩囨护鏁版嵁锛屾煡鎵惧尮閰嶇殑妯℃澘
+ const matchedTemplate = templateList.value.find(item => item.templateName === val);
+
+ if (matchedTemplate?.id) {
+ // 濡傛灉鎵惧埌妯℃澘锛屽姞杞芥ā鏉挎暟鎹�
+ form.value = {
+ ...form.value,
+ ...matchedTemplate,
+ };
+ productData.value = matchedTemplate.productData || [];
+ // 鐢熸垚鏂扮殑閲囪喘鍚堝悓鍙�
+ try {
+ const res = await createPurchaseNo();
+ if (res?.data) {
+ form.value.purchaseContractNumber = res.data;
+ }
+ } catch (error) {
+ console.error('鐢熸垚閲囪喘鍚堝悓鍙峰け璐�:', error);
+ }
+ } else {
+ // 濡傛灉娌℃湁鎵惧埌妯℃澘锛岄噸缃〃鍗曪紙淇濇寔褰撳墠琛ㄥ崟鐘舵�侊級
+ const currentFormData = { ...form.value };
+ const currentProductData = [...productData.value];
+
+ // 濡傛灉瀵硅瘽妗嗘湭鎵撳紑锛屽厛鎵撳紑
+ if (!dialogFormVisible.value) {
+ operationType.value = 'add';
+ dialogFormVisible.value = true;
+ }
+
+ // 绛夊緟涓嬩竴涓� tick 鍚庢仮澶嶆暟鎹�
+ await nextTick();
+ form.value = {
+ ...form.value,
+ ...currentFormData,
+ };
+ productData.value = currentProductData;
+ }
};
// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
@@ -895,7 +1034,7 @@
supplierName: "",
supplierId: "",
paymentMethod: "",
- executionDate: "",
+ executionDate: "",
},
rules: {
purchaseContractNumber: [
@@ -903,8 +1042,9 @@
],
projectName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
supplierId: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
- entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- executionDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ entryDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ approverId:[{ required: true, message: "璇烽�夋嫨瀹℃壒浜�", trigger: "change" }],
+ executionDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
},
});
const { form, rules } = toRefs(data);
@@ -928,7 +1068,7 @@
taxInclusiveTotalPrice: "",
taxExclusiveTotalPrice: "",
invoiceType: "",
- warnNum: "",
+ warnNum: "",
},
productRules: {
productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -939,7 +1079,7 @@
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
taxRate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- warnNum: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
+ warnNum: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
taxInclusiveTotalPrice: [
{ required: true, message: "璇疯緭鍏�", trigger: "blur" },
],
@@ -969,7 +1109,14 @@
};
const formattedNumber = (row, column, cellValue) => {
- return parseFloat(cellValue).toFixed(2);
+ if (cellValue === null || cellValue === undefined || cellValue === '') {
+ return '0.00';
+ }
+ const num = parseFloat(cellValue);
+ if (isNaN(num)) {
+ return '0.00';
+ }
+ return num.toFixed(2);
};
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -977,23 +1124,100 @@
page.current = 1;
getList();
};
+
+// 淇濆瓨妯℃澘
+const handleButtonClick = async () => {
+ // 妫�鏌ユā鏉垮悕绉版槸鍚︿负绌�
+ if (!templateName.value || templateName.value.trim() === '') {
+ ElMessage({
+ message: '璇疯緭鍏ユā鏉垮悕绉�',
+ type: 'warning',
+ });
+ return;
+ }
+
+ // 妫�鏌ユā鏉垮悕绉版槸鍚﹂噸澶�
+ const isDuplicate = checkTemplateNameDuplicate(templateName.value);
+ if (isDuplicate) {
+ ElMessage({
+ message: '妯℃澘鍚嶇О宸插瓨鍦紝璇锋洿鎹㈡ā鏉垮悕绉�',
+ type: 'warning',
+ });
+ return;
+ }
+
+ // 妫�鏌ヤ緵搴斿晢鏄惁閫夋嫨
+ if (!form.value.supplierId) {
+ ElMessage({
+ message: '璇峰厛閫夋嫨渚涘簲鍟�',
+ type: 'warning',
+ });
+ return;
+ }
+
+ // 妫�鏌ユ槸鍚︽湁浜у搧鏁版嵁
+ // if (!productData.value || productData.value.length === 0) {
+ // ElMessage({
+ // message: '璇峰厛娣诲姞浜у搧淇℃伅',
+ // type: 'warning',
+ // });
+ // return;
+ // }
+
+ try {
+ let params = {
+ productData: proxy.HaveJson(productData.value),
+ supplierId: form.value.supplierId,
+ paymentMethod: form.value.paymentMethod,
+ recorderId: form.value.recorderId,
+ approverId: form.value.approverId,
+ templateName: templateName.value.trim()
+ };
+ console.log(params);
+ let res = await addPurchaseTemplate(params);
+
+ if (res && res.code === 200) {
+ ElMessage({
+ message: '妯℃澘淇濆瓨鎴愬姛',
+ type: 'success',
+ });
+ // 淇濆瓨鎴愬姛鍚庨噸鏂拌幏鍙栨ā鏉垮垪琛�
+ await getTemplateList();
+ // 娓呯┖妯℃澘鍚嶇О杈撳叆
+ templateName.value = '';
+ filterInputValue.value = '';
+ isTemplateNameDuplicate.value = false;
+ } else {
+ ElMessage({
+ message: res?.msg || '妯℃澘淇濆瓨澶辫触',
+ type: 'error',
+ });
+ }
+ } catch (error) {
+ console.error('淇濆瓨妯℃澘澶辫触:', error);
+ ElMessage({
+ message: '妯℃澘淇濆瓨澶辫触锛岃绋嶅悗閲嶈瘯',
+ type: 'error',
+ });
+ }
+};
// 瀛愯〃鍚堣鏂规硶
const summarizeChildrenTable = (param) => {
return proxy.summarizeTable(
- param,
- [
- "taxInclusiveUnitPrice",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- "ticketsNum",
- "ticketsAmount",
- "futureTickets",
- "futureTicketsAmount",
- ],
- {
- ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
- }
+ param,
+ [
+ "taxInclusiveUnitPrice",
+ "taxInclusiveTotalPrice",
+ "taxExclusiveTotalPrice",
+ "ticketsNum",
+ "ticketsAmount",
+ "futureTickets",
+ "futureTicketsAmount",
+ ],
+ {
+ ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+ futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
+ }
);
};
const paginationChange = (obj) => {
@@ -1005,23 +1229,24 @@
tableLoading.value = true;
const { entryDate, ...rest } = searchForm;
purchaseListPage({ ...rest, ...page })
- .then((res) => {
- tableLoading.value = false;
- // tableData.value = res.data.records;
- // 澶勭悊鏁版嵁锛屾坊鍔犲け鏁堢姸鎬佹爣璁�
- tableData.value = res.data.records.map(record => ({
- ...record,
- isInvalid: record.isWhite === 1
- }));
- tableData.value.map((item) => {
- item.children = [];
+ .then((res) => {
+ tableLoading.value = false;
+ // tableData.value = res.data.records;
+ // 澶勭悊鏁版嵁锛屾坊鍔犲け鏁堢姸鎬佹爣璁�
+ tableData.value = res.data.records.map(record => ({
+ ...record,
+ isInvalid: record.isWhite === 1
+ }));
+ // 鍒濆鍖栧瓙鏁版嵁鏁扮粍
+ tableData.value.forEach((item) => {
+ item.children = [];
+ });
+ total.value = res.data.total;
+ expandedRowKeys.value = [];
+ })
+ .catch(() => {
+ tableLoading.value = false;
});
- total.value = res.data.total;
- expandedRowKeys.value = [];
- })
- .catch(() => {
- tableLoading.value = false;
- });
};
// 琛ㄦ牸閫夋嫨鏁版嵁
const handleSelectionChange = (selection) => {
@@ -1032,19 +1257,24 @@
};
const expandedRowKeys = ref([]);
// 灞曞紑琛�
-const expandChange = (row, expandedRows) => {
+const expandChange = async (row, expandedRows) => {
if (expandedRows.length > 0) {
expandedRowKeys.value = [];
try {
- 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.data;
- }
+ const res = await productList({ salesLedgerId: row.id, type: 2 });
+ const index = tableData.value.findIndex((item) => item.id === row.id);
+ if (index > -1) {
+ tableData.value[index].children = res.data || [];
expandedRowKeys.value.push(row.id);
- });
+ }
} catch (error) {
- console.log(error);
+ console.error('鍔犺浇浜у搧鍒楄〃澶辫触:', error);
+ proxy.$modal.msgError('鍔犺浇浜у搧鍒楄〃澶辫触');
+ // 灞曞紑澶辫触鏃讹紝绉婚櫎灞曞紑鐘舵��
+ const index = expandedRows.findIndex(item => item.id === row.id);
+ if (index > -1) {
+ expandedRows.splice(index, 1);
+ }
}
} else {
expandedRowKeys.value = [];
@@ -1063,41 +1293,63 @@
]);
};
// 鎵撳紑寮规
-const openForm = (type, row) => {
+const openForm = async (type, row) => {
+ await getTemplateList()
operationType.value = type;
form.value = {};
productData.value = [];
fileList.value = [];
- if (operationType.value == "add") {
- createPurchaseNo().then((res) => {
- form.value.purchaseContractNumber = res.data;
- });
- }
- userListNoPage().then((res) => {
- userList.value = res.data;
- });
- getSalesNo().then((res) => {
- salesContractList.value = res;
- });
- getOptions().then((res) => {
+ templateName.value = '';
+ filterInputValue.value = '';
+ isTemplateNameDuplicate.value = false;
+ try {
+ // 骞惰鍔犺浇鍩虹鏁版嵁
+ const [userRes, salesRes, supplierRes] = await Promise.all([
+ userListNoPage(),
+ getSalesNo(),
+ getOptions()
+ ]);
+
+ userList.value = userRes.data || [];
+ salesContractList.value = salesRes || [];
// 渚涘簲鍟嗚繃婊ゅ嚭isWhite=0 鐨勬暟鎹�
- supplierList.value = res.data.filter((item) => item.isWhite == 0);
- });
- form.value.recorderId = userStore.id;
- form.value.entryDate = getCurrentDate();
- if (type === "edit") {
- currentId.value = row.id;
- getPurchaseById({ id: row.id, type: 2 }).then((res) => {
- form.value = { ...res };
- productData.value = form.value.productData;
- if (form.value.salesLedgerFiles) {
- fileList.value = form.value.salesLedgerFiles;
- } else {
- fileList.value = [];
+ supplierList.value = (supplierRes.data || []).filter((item) => item.isWhite === 0);
+
+ // 璁剧疆榛樿鍊�
+ form.value.recorderId = userStore.id;
+ form.value.entryDate = getCurrentDate();
+
+ if (type === "add") {
+ // 鏂板鏃剁敓鎴愰噰璐悎鍚屽彿
+ try {
+ const purchaseNoRes = await createPurchaseNo();
+ if (purchaseNoRes?.data) {
+ form.value.purchaseContractNumber = purchaseNoRes.data;
+ }
+ } catch (error) {
+ console.error('鐢熸垚閲囪喘鍚堝悓鍙峰け璐�:', error);
+ proxy.$modal.msgWarning('鐢熸垚閲囪喘鍚堝悓鍙峰け璐�');
}
- });
+ } else if (type === "edit" && row?.id) {
+ // 缂栬緫鏃跺姞杞芥暟鎹�
+ currentId.value = row.id;
+ try {
+ const purchaseRes = await getPurchaseById({ id: row.id, type: 2 });
+ form.value = { ...purchaseRes };
+ productData.value = purchaseRes.productData || [];
+ fileList.value = purchaseRes.salesLedgerFiles || [];
+ } catch (error) {
+ console.error('鍔犺浇閲囪喘鍙拌处鏁版嵁澶辫触:', error);
+ proxy.$modal.msgError('鍔犺浇鏁版嵁澶辫触');
+ return;
+ }
+ }
+
+ dialogFormVisible.value = true;
+ } catch (error) {
+ console.error('鎵撳紑琛ㄥ崟澶辫触:', error);
+ proxy.$modal.msgError('鍔犺浇鍩虹鏁版嵁澶辫触');
}
- dialogFormVisible.value = true;
};
// 涓婁紶鍓嶆牎妫�
function handleBeforeUpload(file) {
@@ -1126,43 +1378,57 @@
}
}
// 绉婚櫎鏂囦欢
-function handleRemove(file) {
- console.log("handleRemove", file.id);
- if (file.size > 1024 * 1024 * 10) {
- // 浠呭墠绔竻鐞嗭紝涓嶈皟鐢ㄥ垹闄ゆ帴鍙e拰鎻愮ず
- return;
+async function handleRemove(file) {
+ if (!file?.id) {
+ return;
}
- if (operationType.value === "edit") {
- let ids = [];
- ids.push(file.id);
- delLedgerFile(ids).then((res) => {
+
+ if (file.size > 1024 * 1024 * 10) {
+ // 浠呭墠绔竻鐞嗭紝涓嶈皟鐢ㄥ垹闄ゆ帴鍙e拰鎻愮ず
+ return;
+ }
+
+ if (operationType.value === "edit" && file.id) {
+ try {
+ await delLedgerFile([file.id]);
proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- });
+ } catch (error) {
+ console.error('鍒犻櫎鏂囦欢澶辫触:', error);
+ proxy.$modal.msgError("鍒犻櫎鏂囦欢澶辫触");
+ }
}
}
// 鎻愪氦琛ㄥ崟
-const submitForm = () => {
- proxy.$refs["formRef"].validate((valid) => {
- if (valid) {
- if (productData.value.length > 0) {
- form.value.productData = proxy.HaveJson(productData.value);
- } else {
- proxy.$modal.msgWarning("璇锋坊鍔犱骇鍝佷俊鎭�");
- return;
- }
- let tempFileIds = [];
- if (fileList.value.length > 0) {
- tempFileIds = fileList.value.map((item) => item.tempId);
- }
- form.value.tempFileIds = tempFileIds;
- form.value.type = 2;
- addOrEditPurchase(form.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
+const submitForm = async () => {
+ try {
+ const valid = await proxy.$refs["formRef"].validate().catch(() => false);
+ if (!valid) {
+ return;
}
- });
+
+ if (!productData.value || productData.value.length === 0) {
+ proxy.$modal.msgWarning("璇锋坊鍔犱骇鍝佷俊鎭�");
+ return;
+ }
+
+ form.value.productData = proxy.HaveJson(productData.value);
+ form.value.tempFileIds = fileList.value
+ .filter(item => item.tempId)
+ .map((item) => item.tempId);
+ form.value.type = 2;
+
+ try {
+ await addOrEditPurchase(form.value);
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ } catch (error) {
+ console.error('鎻愪氦琛ㄥ崟澶辫触:', error);
+ proxy.$modal.msgError("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+ } catch (error) {
+ console.error('琛ㄥ崟楠岃瘉澶辫触:', error);
+ }
};
// 鍏抽棴寮规
const closeDia = () => {
@@ -1181,17 +1447,26 @@
productFormVisible.value = true;
getProductOptions();
};
-const getProductOptions = () => {
- productTreeList().then((res) => {
+const getProductOptions = async () => {
+ try {
+ const res = await productTreeList();
productOptions.value = convertIdToValue(res);
- });
+ } catch (error) {
+ console.error('鍔犺浇浜у搧閫夐」澶辫触:', error);
+ proxy.$modal.msgError('鍔犺浇浜у搧閫夐」澶辫触');
+ }
};
-const getModels = (value) => {
+const getModels = async (value) => {
if (value) {
productForm.value.productCategory = findNodeById(productOptions.value, value) || "";
- modelList({ id: value }).then((res) => {
- modelOptions.value = res;
- });
+ try {
+ const res = await modelList({ id: value });
+ modelOptions.value = res || [];
+ } catch (error) {
+ console.error('鍔犺浇瑙勬牸鍨嬪彿澶辫触:', error);
+ proxy.$modal.msgError('鍔犺浇瑙勬牸鍨嬪彿澶辫触');
+ modelOptions.value = [];
+ }
} else {
productForm.value.productCategory = "";
modelOptions.value = [];
@@ -1236,75 +1511,103 @@
});
}
// 鎻愪氦浜у搧琛ㄥ崟
-const submitProduct = () => {
- proxy.$refs["productFormRef"].validate((valid) => {
- if (valid) {
- if (operationType.value === "edit") {
- submitProductEdit();
- } else {
- if (productOperationType.value === "add") {
- productData.value.push({ ...productForm.value });
- console.log("productData.value---", productData.value);
- } else {
- productData.value[productOperationIndex.value] = {
- ...productForm.value,
- };
- }
- closeProductDia();
- }
+const submitProduct = async () => {
+ try {
+ const valid = await proxy.$refs["productFormRef"].validate().catch(() => false);
+ if (!valid) {
+ return;
}
- });
+
+ if (operationType.value === "edit") {
+ await submitProductEdit();
+ } else {
+ if (productOperationType.value === "add") {
+ productData.value.push({ ...productForm.value });
+ } else {
+ productData.value[productOperationIndex.value] = {
+ ...productForm.value,
+ };
+ }
+ closeProductDia();
+ }
+ } catch (error) {
+ console.error('鎻愪氦浜у搧琛ㄥ崟澶辫触:', error);
+ }
};
-const submitProductEdit = () => {
- productForm.value.salesLedgerId = currentId.value;
- productForm.value.type = 2;
- addOrUpdateSalesLedgerProduct(productForm.value).then((res) => {
+
+const submitProductEdit = async () => {
+ try {
+ productForm.value.salesLedgerId = currentId.value;
+ productForm.value.type = 2;
+ await addOrUpdateSalesLedgerProduct(productForm.value);
proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
closeProductDia();
- getPurchaseById({ id: currentId.value, type: 2 }).then((res) => {
- productData.value = res.productData;
- });
- });
+
+ // 閲嶆柊鍔犺浇浜у搧鏁版嵁
+ try {
+ const res = await getPurchaseById({ id: currentId.value, type: 2 });
+ productData.value = res.productData || [];
+ } catch (error) {
+ console.error('閲嶆柊鍔犺浇浜у搧鏁版嵁澶辫触:', error);
+ }
+ } catch (error) {
+ console.error('鎻愪氦浜у搧缂栬緫澶辫触:', error);
+ proxy.$modal.msgError("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
};
// 鍒犻櫎浜у搧
-const deleteProduct = () => {
+const deleteProduct = async () => {
if (productSelectedRows.value.length === 0) {
proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
return;
}
+
if (operationType.value === "add") {
+ // 鏂板妯″紡涓嬶紝鐩存帴浠庡墠绔暟鎹腑鍒犻櫎
productSelectedRows.value.forEach((selectedRow) => {
const index = productData.value.findIndex(
- (product) => product.id === selectedRow.id
+ (product) => product.id === selectedRow.id
);
if (index !== -1) {
productData.value.splice(index, 1);
}
});
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
} else {
- let ids = [];
- if (productSelectedRows.value.length > 0) {
- ids = productSelectedRows.value.map((item) => item.id);
+ // 缂栬緫妯″紡涓嬶紝闇�瑕佽皟鐢ㄦ帴鍙e垹闄�
+ const ids = productSelectedRows.value
+ .filter(item => item.id)
+ .map((item) => item.id);
+
+ if (ids.length === 0) {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏈夋晥鐨勬暟鎹�");
+ return;
}
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- delProduct(ids).then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- closeProductDia();
- getSalesLedgerWithProducts({ id: currentId.value, type: 2 }).then(
- (res) => {
- productData.value = res.productData;
- }
- );
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
+
+ try {
+ await ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎纭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
});
+
+ await delProduct(ids);
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ closeProductDia();
+
+ // 閲嶆柊鍔犺浇浜у搧鏁版嵁
+ try {
+ const res = await getSalesLedgerWithProducts({ id: currentId.value, type: 2 });
+ productData.value = res.productData || [];
+ } catch (error) {
+ console.error('閲嶆柊鍔犺浇浜у搧鏁版嵁澶辫触:', error);
+ }
+ } catch (error) {
+ if (error !== 'cancel') {
+ console.error('鍒犻櫎浜у搧澶辫触:', error);
+ proxy.$modal.msgError("鍒犻櫎澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+ }
}
};
// 鍏抽棴浜у搧寮规
@@ -1313,62 +1616,71 @@
productFormVisible.value = false;
};
// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/purchase/ledger/export", {}, "閲囪喘鍙拌处.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
+const handleOut = async () => {
+ try {
+ await ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭纭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
});
+ proxy.download("/purchase/ledger/export", {}, "閲囪喘鍙拌处.xlsx");
+ } catch (error) {
+ if (error !== 'cancel') {
+ console.error('瀵煎嚭澶辫触:', error);
+ proxy.$modal.msgError("瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+ }
};
+
// 鍒犻櫎
-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 {
+const handleDelete = async () => {
+ if (selectedRows.value.length === 0) {
proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
return;
}
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- delPurchase(ids).then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
+
+ // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
+ const unauthorizedData = selectedRows.value.filter(item => item.recorderName !== userStore.nickName);
+ if (unauthorizedData.length > 0) {
+ proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+ return;
+ }
+
+ const ids = selectedRows.value
+ .filter(item => item.id)
+ .map((item) => item.id);
+
+ if (ids.length === 0) {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏈夋晥鐨勬暟鎹�");
+ return;
+ }
+
+ try {
+ await ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎纭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
});
+
+ await delPurchase(ids);
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ } catch (error) {
+ if (error !== 'cancel') {
+ console.error('鍒犻櫎澶辫触:', error);
+ proxy.$modal.msgError("鍒犻櫎澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
+ }
};
// 鑾峰彇褰撳墠鏃ユ湡骞舵牸寮忓寲涓� 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}`;
+ return dayjs().format("YYYY-MM-DD");
}
const mathNum = () => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ if (!productForm.value.taxRate) {
+ proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
+ return;
+ }
if (!productForm.value.taxInclusiveUnitPrice) {
return;
}
@@ -1377,61 +1689,59 @@
}
// 鍚◣鎬讳环璁$畻
productForm.value.taxInclusiveTotalPrice =
- proxy.calculateTaxIncludeTotalPrice(
- productForm.value.taxInclusiveUnitPrice,
- productForm.value.quantity
- );
+ proxy.calculateTaxIncludeTotalPrice(
+ productForm.value.taxInclusiveUnitPrice,
+ productForm.value.quantity
+ );
if (productForm.value.taxRate) {
// 涓嶅惈绋庢�讳环璁$畻
productForm.value.taxExclusiveTotalPrice =
- proxy.calculateTaxExclusiveTotalPrice(
- productForm.value.taxInclusiveTotalPrice,
- productForm.value.taxRate
- );
+ proxy.calculateTaxExclusiveTotalPrice(
+ productForm.value.taxInclusiveTotalPrice,
+ productForm.value.taxRate
+ );
}
};
const reverseMathNum = (field) => {
- if (!productForm.value.taxRate) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨绋庣巼");
- return;
- }
+ 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);
+ 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.quantity =
+ (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
}
// 鍙嶇畻涓嶅惈绋庢�讳环
- productForm.value.taxExclusiveTotalPrice =
- (Number(productForm.value.taxInclusiveTotalPrice) / (1 + taxRate / 100)).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);
+ 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);
+ 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.quantity =
+ (Number(productForm.value.taxInclusiveTotalPrice) / Number(productForm.value.taxInclusiveUnitPrice)).toFixed(2);
}
}
};
// 閿�鍞悎鍚岄�夋嫨鏀瑰彉鏂规硶
const salesLedgerChange = async (row) => {
- console.log("row", row);
- var index = salesContractList.value.findIndex((item) => item.id == row);
- console.log("index", index);
+ const index = salesContractList.value.findIndex((item) => item.id === row);
if (index > -1) {
form.value.projectName = salesContractList.value[index].projectName;
await querygProductInfoByContractNo();
@@ -1478,14 +1788,19 @@
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("涓嬭浇鎴愬姛");
+
+ try {
+ const a = document.createElement('a');
+ a.href = qrCodeUrl.value;
+ a.download = `閲囪喘鍚堝悓鍙蜂簩缁寸爜_${dayjs().format('YYYYMMDDHHmmss')}.png`;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ proxy.$modal.msgSuccess("涓嬭浇鎴愬姛");
+ } catch (error) {
+ console.error('涓嬭浇浜岀淮鐮佸け璐�:', error);
+ proxy.$modal.msgError("涓嬭浇澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
};
// 鎵爜鏂板瀵硅瘽妗嗙浉鍏冲彉閲�
@@ -1538,7 +1853,7 @@
// 瑙f瀽鎵爜鍐呭锛堟ā鎷熻В鏋愪簩缁寸爜鏁版嵁锛�
const parseScanContent = (content) => {
if (!content) return;
-
+
// 妯℃嫙瑙f瀽浜岀淮鐮佸唴瀹癸紝杩欓噷鍙互鏍规嵁瀹為檯闇�姹傝皟鏁磋В鏋愰�昏緫
// 鍋囪鎵爜鍐呭鏍煎紡涓猴細鍚堝悓鍙穦渚涘簲鍟唡椤圭洰|閲戦|浠樻鏂瑰紡
const parts = content.split('|');
@@ -1558,30 +1873,35 @@
};
// 鎻愪氦鎵爜鏂板
-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 submitScanAdd = async () => {
+ try {
+ const valid = await proxy.$refs["scanAddFormRef"].validate().catch(() => false);
+ if (!valid) {
+ return;
}
- });
+
+ // 鏋勫缓鏂板鏁版嵁
+ 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
+ };
+
+ // await addOrEditPurchase(newData);
+
+ proxy.$modal.msgSuccess("鎵爜鏂板鎴愬姛锛�");
+ closeScanAddDialog();
+ getList(); // 鍒锋柊鍒楄〃
+ } catch (error) {
+ console.error('鎻愪氦鎵爜鏂板澶辫触:', error);
+ proxy.$modal.msgError("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
};
// 鎵撳紑鎵爜鐧昏瀵硅瘽妗�
@@ -1604,33 +1924,32 @@
};
// 鎻愪氦鎵爜鐧昏
-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();
+const submitScan = async () => {
+ try {
+ const valid = await proxy.$refs["scanFormRef"].validate().catch(() => false);
+ if (!valid) {
+ return;
}
- });
+
+ // 娣诲姞鎵爜璁板綍
+ scanRecords.value.push({
+ ...scanForm,
+ id: Date.now(), // 妯℃嫙ID
+ scanTime: getCurrentDateTime(),
+ });
+ scanForm.scanStatus = "宸叉壂鐮�";
+ scanForm.scanRemark = scanForm.scanRemark || "鏃�";
+ proxy.$modal.msgSuccess("鎵爜鐧昏鎴愬姛锛�");
+ closeScanDialog();
+ } catch (error) {
+ console.error('鎻愪氦鎵爜鐧昏澶辫触:', error);
+ proxy.$modal.msgError("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ }
};
// 鑾峰彇褰撳墠鏃ユ湡鏃堕棿
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}`;
+ return dayjs().format("YYYY-MM-DD HH:mm:ss");
}
// 娣诲姞琛岀被鍚嶆柟娉�
@@ -1638,8 +1957,18 @@
return row.isInvalid ? 'invalid-row' : '';
};
+// 鑾峰彇妯℃澘淇℃伅
+const getTemplateList =async ()=>{
+ let res = await getPurchaseTemplateList()
+ if(res && res.code===200 && Array.isArray(res.data)){
+ templateList.value = res.data
+ }
+}
+
onMounted(() => {
getList();
+ getTemplateList();
+
});
</script>
@@ -1648,4 +1977,16 @@
opacity: 0.6;
background-color: #f5f7fa;
}
+.el-row{
+ justify-content: space-between;
+ align-items: center
+}
+.no-arrow-select {
+ --el-select-suffix-icon-color: transparent; /* 闅愯棌榛樿涓嬫媺绠ご */
+}
+.select-button-group {
+ display: flex;
+ align-items: center;
+}
+
</style>
--
Gitblit v1.9.3