From 3eaa7e28218b227bda647f2da21e6d9317832eef Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 15 九月 2025 15:08:15 +0800
Subject: [PATCH] 库存预警修改
---
src/views/warehouseManagement/index.vue | 769 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 558 insertions(+), 211 deletions(-)
diff --git a/src/views/warehouseManagement/index.vue b/src/views/warehouseManagement/index.vue
index 49e5824..1f4bcba 100644
--- a/src/views/warehouseManagement/index.vue
+++ b/src/views/warehouseManagement/index.vue
@@ -1,20 +1,23 @@
<template>
<div class="app-container">
<el-form :inline="true" :model="queryParams" class="search-form">
- <el-form-item label="渚涘簲鍟嗗悕绉�">
- <el-input
- v-model="queryParams.supplierName"
- placeholder="璇疯緭鍏�"
- clearable
- :style="{ width: '100%' }"
+ <el-form-item label="鐧昏鏃ユ湡">
+ <el-date-picker
+ v-model="queryParams.registrationDate"
+ type="date"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable
+ style="width: 100%"
+ placeholder="璇烽�夋嫨鏃ユ湡"
/>
</el-form-item>
<el-form-item label="鐓ょ">
<el-input
- v-model="queryParams.coal"
- placeholder="璇疯緭鍏�"
- clearable
- :style="{ width: '100%' }"
+ v-model="queryParams.coal"
+ placeholder="璇疯緭鍏ョ叅绉�"
+ clearable
+ :style="{ width: '100%' }"
/>
</el-form-item>
<el-form-item>
@@ -25,55 +28,169 @@
<el-card>
<!-- 鏍囩椤� -->
<el-tabs
- v-model="activeTab"
- class="info-tabs"
- @tab-click="handleTabClick"
+ v-model="activeTab"
+ class="info-tabs"
+ @tab-click="handleTabClick"
>
<el-tab-pane
- v-for="tab in tabs"
- :key="tab.name"
- :label="tab.label"
- :name="tab.name"
+ v-for="tab in tabs"
+ :key="tab.name"
+ :label="tab.label"
+ :name="tab.name"
/>
</el-tabs>
<!-- 鎿嶄綔鎸夐挳鍖� -->
<el-space>
-<!-- <el-button type="danger" :icon="Delete">鍒犻櫎</el-button>-->
- <el-button type="info" plain :icon="Download">瀵煎嚭</el-button>
- <el-button type="success" plain :icon="Refresh" v-if="activeTab=== 'officialInventory'" @click="mergeRows('merge')">鍚堝苟</el-button>
+ <!-- <el-button type="danger" :icon="Delete">鍒犻櫎</el-button>-->
+ <!-- <el-button type="info" plain :icon="Download">瀵煎嚭</el-button> -->
+ <el-button
+ type="success"
+ plain
+ :icon="Refresh"
+ v-if="activeTab === 'officialInventory'"
+ @click="mergeRows('merge')"
+ >鍚堝苟</el-button
+ >
+ <el-button
+ type="info"
+ plain
+ :icon="Download"
+ v-if="activeTab === 'officialInventory'"
+ @click="handleExport"
+ >瀵煎嚭</el-button
+ >
</el-space>
<div>
- <el-table :data="tableData" border @selection-change="selectionChange" style="width: 100%;height: calc(100vh - 30em)" show-summary :summary-method="summarizeChildrenTable">
+ <el-table
+ :data="tableData"
+ border
+ @selection-change="selectionChange"
+ style="width: 100%; height: calc(100vh - 30em)"
+ show-summary
+ :summary-method="summarizeChildrenTable"
+ :row-class-name="tableRowClassName"
+ >
<el-table-column type="selection" width="55" align="center" />
- <el-table-column label="搴忓彿" type="index" width="60" align="center" />
- <el-table-column prop="supplierName" label="渚涜揣鍟嗗悕绉�" width="180" sortable/>
- <el-table-column prop="coal" label="鐓ょ" sortable/>
- <el-table-column prop="unit" label="鍗曚綅" width="70"/>
- <el-table-column prop="inventoryQuantity" label="搴撳瓨鏁伴噺" sortable min-width="110"/>
- <el-table-column prop="priceIncludingTax" label="鍗曚环(鍚◣)" sortable width="130"/>
- <el-table-column prop="totalPriceIncludingTax" label="鎬讳环(鍚◣)" width="130" />
- <el-table-column prop="priceExcludingTax" label="鍗曚环(涓嶅惈绋�)" width="130" />
- <el-table-column prop="totalPriceExcludingTax" label="鎬讳环(涓嶅惈绋�)" width="130" />
- <el-table-column prop="pendingReplenishment" label="寰呰ˉ搴�" width="130" v-if="activeTab=== 'officialInventory'"/>
- <el-table-column label="鐓よ川" align="center" v-if="activeTab=== 'officialInventory'" width="600">
- <el-table-column v-for="col in columnTitle" :key="col.prop" :prop="col.prop" :label="col.label" align="center" sortable min-width="200"/>
- </el-table-column>
- <el-table-column prop="registrant" label="鐧昏浜�" width="180"/>
- <el-table-column prop="registrationDate" label="鐧昏鏃ユ湡" width="180"/>
- <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
+ <el-table-column
+ label="搴忓彿"
+ type="index"
+ width="60"
+ align="center"
+ />
+ <el-table-column
+ prop="code"
+ label="缂栧彿"
+ width="180"
+ />
+ <el-table-column
+ prop="supplierName"
+ label="渚涜揣鍟嗗悕绉�"
+ width="180"
+ sortable
+ />
+ <el-table-column prop="type" label="鐓ゆ枡绫诲瀷">
<template #default="scope">
- <el-button link type="primary" size="small" @click="reviewDia(scope.row)" v-if="activeTab !== 'officialInventory'">瀹℃牳</el-button>
- <el-button link type="primary" size="small" @click="mergeRows('edit', scope.row)" v-else>缂栬緫</el-button>
+ {{scope.row.type == 1 ? '鎴愬搧' : '鍘熸枡'}}
+ </template>
+ </el-table-column>
+ <el-table-column prop="coal" label="鐓ょ" sortable />
+ <el-table-column prop="unit" label="鍗曚綅" width="70" />
+ <el-table-column
+ prop="inventoryQuantity"
+ label="搴撳瓨鏁伴噺"
+ sortable
+ min-width="110"
+ />
+ <el-table-column
+ prop="priceIncludingTax"
+ label="鍗曚环(鍚◣)"
+ sortable
+ width="130"
+ />
+ <el-table-column
+ prop="totalPriceIncludingTax"
+ label="鎬讳环(鍚◣)"
+ width="130"
+ />
+ <el-table-column
+ prop="priceExcludingTax"
+ label="鍗曚环(涓嶅惈绋�)"
+ width="130"
+ />
+ <el-table-column
+ prop="totalPriceExcludingTax"
+ label="鎬讳环(涓嶅惈绋�)"
+ width="130"
+ />
+ <el-table-column
+ prop="pendingReplenishment"
+ label="寰呰ˉ搴�"
+ width="130"
+ v-if="activeTab === 'officialInventory'"
+ />
+ <el-table-column
+ label="鐓よ川"
+ align="center"
+ v-if="activeTab === 'officialInventory'"
+ width="600"
+ >
+ <el-table-column
+ v-for="col in columnTitle"
+ :key="col.prop"
+ :prop="col.prop"
+ :label="col.label"
+ align="center"
+ sortable
+ min-width="200"
+ />
+ </el-table-column>
+ <el-table-column prop="registrant" label="鐧昏浜�" width="180" />
+ <el-table-column
+ prop="registrationDate"
+ label="鐧昏鏃ユ湡"
+ width="180"
+ />
+ <el-table-column
+ fixed="right"
+ label="鎿嶄綔"
+ min-width="100"
+ align="center"
+ >
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ size="small"
+ @click="reviewDia(scope.row)"
+ v-if="activeTab !== 'officialInventory'"
+ >瀹℃牳</el-button
+ >
+ <el-button
+ link
+ type="primary"
+ size="small"
+ @click="mergeRows('edit', scope.row)"
+ v-if="activeTab === 'officialInventory'"
+ >缂栬緫</el-button
+ >
+ <el-button
+ link
+ type="primary"
+ size="small"
+ @click="mergeRows('view', scope.row)"
+ v-if="activeTab === 'officialInventory'"
+ >璇︽儏</el-button
+ >
</template>
</el-table-column>
</el-table>
<pagination
- v-if="total>0"
- :page-num="pageNum"
- :page-size="pageSize"
- :total="total"
- @pagination="handleQuery"
- :layout="'total, prev, pager, next, jumper'"
+ v-if="total > 0"
+ :page="pageNum"
+ :limit="pageSize"
+ :total="total"
+ @pagination="handlePagination"
+ :layout="'total, prev, pager, next, jumper'"
/>
</div>
</el-card>
@@ -84,14 +201,24 @@
<el-col :span="12">
<el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierId">
<el-select v-model="form.supplierId" placeholder="璇烽�夋嫨渚涘簲鍟�">
- <el-option :label="item.label" v-for="item in supplyList" :key="item.value" :value="item.value"/>
+ <el-option
+ :label="item.label"
+ v-for="item in supplyList"
+ :key="item.value"
+ :value="item.value"
+ />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鐓ょ" prop="coalId">
<el-select v-model="form.coalId" placeholder="璇烽�夋嫨鐓ょ">
- <el-option :label="item.label" v-for="item in coalList" :key="item.value" :value="item.value"/>
+ <el-option
+ :label="item.label"
+ v-for="item in coalList"
+ :key="item.value"
+ :value="item.value"
+ />
</el-select>
</el-form-item>
</el-col>
@@ -99,48 +226,78 @@
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚綅" prop="unit">
- <el-input v-model="form.unit" placeholder="璇疯緭鍏ュ崟浣�" maxlength="30" />
+ <el-input
+ v-model="form.unit"
+ placeholder="璇疯緭鍏ュ崟浣�"
+ maxlength="30"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="搴撳瓨鏁伴噺" prop="inventoryQuantity">
- <el-input v-model="form.inventoryQuantity" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" :max="inventoryQuantity" type="number"/>
+ <el-input
+ v-model="form.inventoryQuantity"
+ placeholder="璇疯緭鍏ュ簱瀛樻暟閲�"
+ :max="inventoryQuantity"
+ type="number"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
- <el-input v-model="form.priceIncludingTax" placeholder="璇疯緭鍏ュ崟浠�(鍚◣)" maxlength="30" />
+ <el-input
+ v-model="form.priceIncludingTax"
+ placeholder="璇疯緭鍏ュ崟浠�(鍚◣)"
+ maxlength="30"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax">
- <el-input v-model="form.totalPriceIncludingTax" placeholder="璇疯緭鍏ユ�讳环(鍚◣)" maxlength="30" />
+ <el-input
+ v-model="form.totalPriceIncludingTax"
+ placeholder="璇疯緭鍏ユ�讳环(鍚◣)"
+ maxlength="30"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
- <el-input v-model="form.priceExcludingTax" placeholder="璇疯緭鍏ユ垚鏈崟浠�" maxlength="30" />
+ <el-input
+ v-model="form.priceExcludingTax"
+ placeholder="璇疯緭鍏ユ垚鏈崟浠�"
+ maxlength="30"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax">
- <el-input v-model="form.totalPriceExcludingTax" placeholder="璇疯緭鍏ユ垚鏈崟浠�" maxlength="30" />
+ <el-input
+ v-model="form.totalPriceExcludingTax"
+ placeholder="璇疯緭鍏ユ垚鏈崟浠�"
+ maxlength="30"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
- <el-form-item label="鐓よ川鏂规" prop="qualityPlan">
- <el-select v-model="form.qualityPlan" placeholder="璇烽�夋嫨" @change="coalPlanByIdList" clearable>
+ <el-form-item label="鐓よ川鏂规" prop="coalPlanId">
+ <el-select
+ v-model="form.coalPlanId"
+ placeholder="璇烽�夋嫨"
+ @change="coalPlanByIdList"
+ clearable
+ >
<el-option
- v-for="dict in qualityPlanOption"
- :key="dict.id"
- :label="dict.plan"
- :value="dict.id"
+ v-for="dict in qualityPlanOption"
+ :key="dict.id"
+ :label="dict.plan"
+ :value="dict.id"
></el-option>
</el-select>
</el-form-item>
@@ -163,20 +320,47 @@
</template>
</el-dialog>
<!-- 鍚堝苟鏁版嵁寮规 -->
- <el-dialog title="鍚堝苟搴撳瓨" v-model="mergeVisible" width="800px">
- <el-form :model="mergeForm" :rules="mergeRules" ref="mergeRef" label-width="100px">
+ <el-dialog
+ :title="operationType.value === 'edit' ? '缂栬緫搴撳瓨' : '鍚堝苟搴撳瓨'"
+ v-model="mergeVisible"
+ width="800px"
+ >
+ <el-form
+ :model="mergeForm"
+ :rules="mergeRules"
+ ref="mergeRef"
+ label-width="100px"
+ >
<el-row>
<el-col :span="12">
<el-form-item label="渚涘簲鍟嗗悕绉�" prop="supplierId">
- <el-select v-model="mergeForm.supplierId" placeholder="璇烽�夋嫨渚涘簲鍟�">
- <el-option :label="item.label" v-for="item in supplyList" :key="item.value" :value="item.value"/>
+ <el-select
+ v-model="mergeForm.supplierId"
+ placeholder="璇烽�夋嫨渚涘簲鍟�"
+ :disabled="operationType === 'view'"
+ >
+ <el-option
+ :label="item.label"
+ v-for="item in supplyList"
+ :key="item.value"
+ :value="item.value"
+ />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鐓ょ" prop="coalId">
- <el-select v-model="mergeForm.coalId" placeholder="璇烽�夋嫨鐓ょ">
- <el-option :label="item.label" v-for="item in coalList" :key="item.value" :value="item.value"/>
+ <el-select
+ v-model="mergeForm.coalId"
+ placeholder="璇烽�夋嫨鐓ょ"
+ :disabled="operationType === 'view'"
+ >
+ <el-option
+ :label="item.label"
+ v-for="item in coalList"
+ :key="item.value"
+ :value="item.value"
+ />
</el-select>
</el-form-item>
</el-col>
@@ -184,36 +368,103 @@
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚綅" prop="unit">
- <el-input v-model="mergeForm.unit" placeholder="璇疯緭鍏ュ崟浣�" maxlength="30" />
+ <el-input
+ v-model="mergeForm.unit"
+ placeholder="璇疯緭鍏ュ崟浣�"
+ maxlength="30"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="搴撳瓨鏁伴噺" prop="inventoryQuantity">
- <el-input v-model="mergeForm.inventoryQuantity" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" :max="inventoryQuantity" type="number"/>
+ <el-input
+ v-model="mergeForm.inventoryQuantity"
+ placeholder="璇疯緭鍏ュ簱瀛樻暟閲�"
+ :max="inventoryQuantity"
+ type="number"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚环(鍚◣)" prop="priceIncludingTax">
- <el-input v-model="mergeForm.priceIncludingTax" placeholder="璇疯緭鍏ュ崟浠�(鍚◣)" maxlength="30" />
+ <el-input
+ v-model="mergeForm.priceIncludingTax"
+ placeholder="璇疯緭鍏ュ崟浠�(鍚◣)"
+ maxlength="30"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鎬讳环(鍚◣)" prop="totalPriceIncludingTax">
- <el-input v-model="mergeForm.totalPriceIncludingTax" placeholder="璇疯緭鍏ユ�讳环(鍚◣)" maxlength="30" />
+ <el-input
+ v-model="mergeForm.totalPriceIncludingTax"
+ placeholder="璇疯緭鍏ユ�讳环(鍚◣)"
+ maxlength="30"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="鍗曚环(涓嶅惈绋�)" prop="priceExcludingTax">
- <el-input v-model="mergeForm.priceExcludingTax" placeholder="璇疯緭鍏ュ崟浠�(涓嶅惈绋�)" maxlength="30" />
+ <el-input
+ v-model="mergeForm.priceExcludingTax"
+ placeholder="璇疯緭鍏ュ崟浠�(涓嶅惈绋�)"
+ maxlength="30"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="鎬讳环(涓嶅惈绋�)" prop="totalPriceExcludingTax">
- <el-input v-model="mergeForm.totalPriceExcludingTax" placeholder="璇疯緭鍏ユ�讳环(涓嶅惈绋�)" maxlength="30" />
+ <el-input
+ v-model="mergeForm.totalPriceExcludingTax"
+ placeholder="璇疯緭鍏ユ�讳环(涓嶅惈绋�)"
+ maxlength="30"
+ :disabled="operationType === 'view'"
+ />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="鐓よ川鏂规" prop="coalPlanId">
+ <el-select
+ v-model="mergeForm.coalPlanId"
+ placeholder="璇烽�夋嫨"
+ @change="coalPlanByIdList"
+ clearable
+ :disabled="operationType === 'view'"
+ >
+ <el-option
+ v-for="dict in qualityPlanOption"
+ :key="dict.id"
+ :label="dict.plan"
+ :value="dict.id"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鐓ゆ枡绫诲瀷" prop="type">
+ <el-select
+ v-model="mergeForm.type"
+ placeholder="璇烽�夋嫨鐓ゆ枡绫诲瀷"
+ :disabled="operationType === 'view'"
+ >
+ <el-option
+ :label="item.label"
+ v-for="item in typeList"
+ :key="item.value"
+ :value="item.value"
+ />
+ </el-select>
</el-form-item>
</el-col>
</el-row>
@@ -221,7 +472,10 @@
<el-row>
<el-col :span="12" v-for="item in filteredList" :key="item.id">
<el-form-item :label="item.fieldName">
- <el-input v-model="mergeForm[item.fields]" />
+ <el-input
+ v-model="mergeForm[item.fields]"
+ :disabled="operationType === 'view'"
+ />
</el-form-item>
</el-col>
</el-row>
@@ -237,25 +491,28 @@
</template>
<script setup>
-import {onMounted, ref} from "vue";
-import {Delete, Download, Refresh} from "@element-plus/icons-vue";
+import { onMounted, ref } from "vue";
+import { Delete, Download, Refresh } from "@element-plus/icons-vue";
import Pagination from "@/components/Pagination/index.vue";
import {
addOrEditCoalValue,
- coalFieldList, coalPlanById,
- coalPlanList, officialInventoryList,
- pendingInventoryList
+ coalFieldList,
+ coalPlanById,
+ coalPlanList,
+ officialInventoryList,
+ pendingInventoryList,
} from "@/api/warehouseManagement/index.js";
-import {editOfficial, merge} from "../../api/warehouseManagement/index.js";
-import {getSupplyList} from "@/api/procureMent/index.js";
-import {getCoalInfoList} from "@/api/production/index.js";
+import { editOfficial, merge } from "../../api/warehouseManagement/index.js";
+import { getSupplyList } from "@/api/procureMent/index.js";
+import { getCoalInfoList } from "@/api/production/index.js";
+import { ElMessage } from "element-plus";
-const { proxy } = getCurrentInstance()
+const { proxy } = getCurrentInstance();
-const tableData = ref([])
-const selectedRows = ref([])
-const qualityPlanOption = ref([])
-const filteredList = ref([])
+const tableData = ref([]);
+const selectedRows = ref([]);
+const qualityPlanOption = ref([]);
+const filteredList = ref([]);
const tableLoading = ref(false);
const total = ref(0);
const pageNum = ref(1);
@@ -267,48 +524,68 @@
// 瀹℃牳寮规
const reviewVisible = ref(false);
// 鍚堝苟寮规
-const mergeVisible = ref(false)
-const operationType = ref('')
+const mergeVisible = ref(false);
+const operationType = ref("");
+const typeList = ref([
+ {
+ label: "鎴愬搧",
+ value: 1,
+ },
+ {
+ label: "鍘熸枡",
+ value: 2,
+ },
+]);
const data = reactive({
form: {
- supplierName: '',
- coal: '',
- unit: '',
- inventoryQuantity: '',
- priceIncludingTax: '',
- totalPriceIncludingTax: '',
- priceExcludingTax: '',
- totalPriceExcludingTax: '',
- qualityPlan: '',
- pId: '',
+ supplierName: "",
+ coal: "",
+ unit: "",
+ inventoryQuantity: "",
+ priceIncludingTax: "",
+ totalPriceIncludingTax: "",
+ priceExcludingTax: "",
+ totalPriceExcludingTax: "",
+ coalPlanId: "",
+ pId: "",
},
mergeForm: {
- supplierId: '',
- coalId: '',
- unit: '',
- inventoryQuantity: '',
- priceIncludingTax: '',
- totalPriceIncludingTax: '',
- priceExcludingTax: '',
- totalPriceExcludingTax: '',
- qualityPlan: '',
- pId: '',
+ supplierId: "",
+ coalId: "",
+ unit: "",
+ inventoryQuantity: "",
+ priceIncludingTax: "",
+ totalPriceIncludingTax: "",
+ priceExcludingTax: "",
+ totalPriceExcludingTax: "",
+ coalPlanId: "",
+ pId: "",
},
rules: {
- supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }],
+ supplierName: [
+ { required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" },
+ ],
coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }],
unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }],
- qualityPlan: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ coalPlanId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ supplierId: [
+ { required: true, message: "璇烽�夋嫨渚涘簲鍟�", trigger: "change" },
+ ],
},
mergeRules: {
- supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }],
+ supplierName: [
+ { required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" },
+ ],
coal: [{ required: true, message: "璇疯緭鍏ョ叅绉�", trigger: "blur" }],
unit: [{ required: true, message: "璇疯緭鍏ュ崟浣�", trigger: "blur" }],
- qualityPlan: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
- }
-})
+ coalPlanId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
+ supplierId: [
+ { required: true, message: "璇烽�夋嫨渚涘簲鍟�", trigger: "change" },
+ ],
+ },
+});
-const { form, rules, mergeForm, mergeRules } = toRefs(data)
+const { form, rules, mergeForm, mergeRules } = toRefs(data);
// 褰撳墠鏍囩
const activeTab = ref("pendingInbound");
const tabName = ref("pendingInbound");
@@ -319,10 +596,10 @@
]);
// 鏌ヨ鍙傛暟
const queryParams = reactive({
- supplierName: "",
+ registrationDate: "",
coal: "",
-})
-const columnTitle = ref([])
+});
+const columnTitle = ref([]);
const supplyList = ref([]);
const coalList = ref([]);
@@ -360,46 +637,66 @@
getList();
};
const summarizeChildrenTable = (param) => {
- return proxy.summarizeTable(param, ['inventoryQuantity', 'priceIncludingTax', 'totalPriceIncludingTax','priceExcludingTax','totalPriceExcludingTax']);
-}
+ return proxy.summarizeTable(param, [
+ "inventoryQuantity",
+ "priceIncludingTax",
+ "totalPriceIncludingTax",
+ "priceExcludingTax",
+ "totalPriceExcludingTax",
+ ]);
+};
// 鐐瑰嚮鏌ヨ
const handleQuery = () => {
- pageNum.value = 1
- pageSize.value = 10
- getList()
-}
+ pageNum.value = 1;
+ pageSize.value = 10;
+ getList();
+};
+// 鍒嗛〉澶勭悊
+const handlePagination = (val) => {
+ pageNum.value = val.page;
+ pageSize.value = val.limit;
+ getList();
+};
const getList = () => {
tableLoading.value = true;
// 璧嬪�肩叅璐ㄨ〃澶村睍绀哄瓧娈�
if (tabName.value === "pendingInbound") {
- pendingInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
+ pendingInventoryList({
+ ...queryParams,
+ current: pageNum.value,
+ size: pageSize.value,
+ }).then((res) => {
tableLoading.value = false;
tableData.value = res.data.records;
total.value = res.data.total;
- })
+ });
} else {
- officialInventoryList({ ...queryParams, current: pageNum.value, size: pageSize.value }).then(res => {
+ officialInventoryList({
+ ...queryParams,
+ current: pageNum.value,
+ size: pageSize.value,
+ }).then((res) => {
tableLoading.value = false;
const result = flattenFields(res.data.records);
tableData.value = result;
total.value = res.data.total;
- coalFieldListOption()
- })
+ coalFieldListOption();
+ });
}
};
// 鎵佸钩鍖栧鐞嗗嚱鏁�
const flattenFields = (data) => {
- return data.map(item => {
+ return data.map((item) => {
const mergedFields = item.fields.reduce((acc, obj) => {
const key = Object.keys(obj)[0];
acc[key] = obj[key];
return acc;
}, {});
-
+
// 鍚堝苟涓诲璞′笌鎻愬彇鍑虹殑 fields 瀛楁
return {
...item,
- ...mergedFields
+ ...mergedFields,
};
});
};
@@ -414,62 +711,92 @@
};
// 琛ㄦ牸閫夋嫨鏁版嵁
const selectionChange = (rows) => {
- selectedRows.value = rows
-}
+ selectedRows.value = rows;
+};
// 鎵撳紑瀹℃牳寮规
const reviewDia = (row) => {
- reviewVisible.value = true
- filteredList.value = []
- form.value = {...row}
- form.value.pId = row.id
- inventoryQuantity.value = row.inventoryQuantity
- getDropdownData()
- coalPlanListOptions()
-}
+ reviewVisible.value = true;
+ filteredList.value = [];
+ form.value = { ...row };
+ form.value.pId = row.id;
+ inventoryQuantity.value = row.inventoryQuantity;
+ getDropdownData();
+ coalPlanListOptions();
+};
// 鏌ヨ鐓よ川鏂规涓嬫媺妗�
const coalPlanListOptions = () => {
- coalPlanList().then(res => {
- qualityPlanOption.value = res.data
- })
-}
+ coalPlanList().then((res) => {
+ qualityPlanOption.value = res.data;
+ });
+};
// 鏌ヨ鐓よ川鏂规瀛楁
const coalPlanByIdList = (id) => {
- coalPlanById({id: id}).then(res => {
- filteredList.value = res.data
- if(!id) {
- filteredList.value = []
+ coalPlanById({ id: id }).then((res) => {
+ filteredList.value = res.data;
+ if (!id) {
+ filteredList.value = [];
}
- })
-}
+ });
+};
// 鏌ヨ鐓よ川瀛楁
const coalFieldListOption = () => {
- coalFieldList().then(res => {
- filteredList.value = res.data
- columnTitle.value = res.data.map(item => {
+ coalFieldList().then((res) => {
+ filteredList.value = res.data;
+ columnTitle.value = res.data.map((item) => {
return {
prop: item.fields,
- label: item.fieldName // 浣跨敤 fieldName 浣滀负 label
+ label: item.fieldName, // 浣跨敤 fieldName 浣滀负 label
};
});
- })
-}
+ });
+};
+const handleExport = () => {
+ const config = { api: "/officialInventory/export", name: "姝e紡搴�" };
+ proxy.$modal
+ .confirm(
+ "鏄惁瑕佸鍑�" +
+ (selectedRows.value.length > 0
+ ? `閫変腑鐨�${selectedRows.value.length}鏉
+ : "鍏ㄩ儴") +
+ "鏁版嵁锛�"
+ )
+ .then((res) => {
+ console.log(res);
+ if (res) {
+ ElMessage.success("姝e湪瀵煎嚭鏁版嵁锛岃绋嶅��...");
+ exportData(config.api, config.name);
+ }
+ })
+ .catch(() => {});
+};
+const exportData = (api, name) => {
+ proxy.download(
+ api,
+ { exportIds: selectedRows.value.map((row) => row.id) },
+ `${new Date().getTime()}${name}${new Date().toLocaleDateString("en-CA")}.xlsx`
+ );
+};
// 鍚堝苟搴撳瓨鏁版嵁鏂规硶
-const mergeRows = (type,row) => {
- coalFieldListOption();
- mergeVisible.value = true;
+const mergeRows = (type, row) => {
+ getDropdownData();
+ coalPlanListOptions();
+ if (type === "edit" || type === "view") {
+ mergeVisible.value = true;
+ }
operationType.value = type;
- if (type === 'edit') {
- mergeForm.value = {...row}
+ if (type !== "merge") {
+ mergeForm.value = { ...row };
} else {
if (selectedRows.value.length < 2) {
- proxy.$modal.msgWarning('璇疯嚦灏戦�夋嫨涓ゆ潯鏁版嵁')
- return
+ proxy.$modal.msgWarning("璇疯嚦灏戦�夋嫨涓ゆ潯鏁版嵁");
+ return;
}
- filteredList.value.forEach(item => {
- mergeForm.value[item.fields] = ''
- })
- const data = selectedRows.value
- const selectedIds = selectedRows.value.map(row => row.id);
+ mergeVisible.value = true;
+ filteredList.value.forEach((item) => {
+ mergeForm.value[item.fields] = "";
+ });
+ const data = selectedRows.value;
+ const selectedIds = selectedRows.value.map((row) => row.id);
// 鍒濆鍖栧悎璁″拰鍧囧�煎彉閲�
let totalInventory = 0;
let totalPriceIncludingTax = 0;
@@ -477,7 +804,7 @@
let priceIncludingTaxSum = 0;
let priceExcludingTaxSum = 0;
// 閬嶅巻鎵�鏈夐�変腑鏁版嵁锛岀疮鍔犺绠�
- data.forEach(row => {
+ data.forEach((row) => {
totalInventory += parseFloat(row.inventoryQuantity) || 0;
priceIncludingTaxSum += parseFloat(row.priceIncludingTax) || 0;
totalPriceIncludingTax += parseFloat(row.totalPriceIncludingTax) || 0;
@@ -485,10 +812,18 @@
totalPriceExcludingTax += parseFloat(row.totalPriceExcludingTax) || 0;
});
// 璁$畻骞冲潎鍊煎苟淇濈暀涓や綅灏忔暟
- const avgPriceIncludingTax = Number((priceIncludingTaxSum / data.length).toFixed(2));
- const avgTotalPriceIncludingTax = Number((totalPriceIncludingTax / data.length).toFixed(2));
- const avgPriceExcludingTax = Number((priceExcludingTaxSum / data.length).toFixed(2));
- const avgTotalPriceExcludingTax = Number((totalPriceExcludingTax / data.length).toFixed(2));
+ const avgPriceIncludingTax = Number(
+ (priceIncludingTaxSum / data.length).toFixed(2)
+ );
+ const avgTotalPriceIncludingTax = Number(
+ (totalPriceIncludingTax / data.length).toFixed(2)
+ );
+ const avgPriceExcludingTax = Number(
+ (priceExcludingTaxSum / data.length).toFixed(2)
+ );
+ const avgTotalPriceExcludingTax = Number(
+ (totalPriceExcludingTax / data.length).toFixed(2)
+ );
// 璁剧疆琛ㄥ崟鏄剧ず
mergeForm.value.inventoryQuantity = totalInventory;
mergeForm.value.priceIncludingTax = avgPriceIncludingTax;
@@ -497,81 +832,93 @@
mergeForm.value.totalPriceExcludingTax = avgTotalPriceExcludingTax;
mergeForm.value.ids = selectedIds;
}
-}
+};
// 鎻愪氦鍚堝苟琛ㄥ崟
const submitForm = () => {
- proxy.$refs.mergeRef.validate(valid => {
+ proxy.$refs.mergeRef.validate((valid) => {
if (valid) {
- delete mergeForm.value.createTime
- delete mergeForm.value.updateTime
- if (operationType.value === 'edit') {
+ delete mergeForm.value.createTime;
+ delete mergeForm.value.updateTime;
+ if (operationType.value === "edit") {
mergeForm.value.fields = filteredList.value.reduce((acc, item) => {
const key = item.fields;
const value = mergeForm.value[key];
// 鍒ゆ柇鏄惁鏈夊�硷紙浣犲彲浠ユ牴鎹渶瑕佷慨鏀瑰垽鏂潯浠讹級
- if (value !== null && value !== undefined && value !== '') {
+ if (value !== null && value !== undefined && value !== "") {
acc.push({ [key]: value });
}
return acc;
}, []);
editOfficial(mergeForm.value).then(() => {
- cancel()
- proxy.$modal.msgSuccess('淇敼鎴愬姛')
- handleQuery()
- })
+ cancel();
+ proxy.$modal.msgSuccess("淇敼鎴愬姛");
+ handleQuery();
+ });
} else {
mergeForm.value.fields = filteredList.value.reduce((acc, item) => {
const key = item.fields;
const value = mergeForm.value[key];
// 鍒ゆ柇鏄惁鏈夊�硷紙浣犲彲浠ユ牴鎹渶瑕佷慨鏀瑰垽鏂潯浠讹級
- if (value !== null && value !== undefined && value !== '') {
+ if (value !== null && value !== undefined && value !== "") {
acc.push({ [key]: value });
}
return acc;
}, []);
- mergeForm.value.type = 2
+ mergeForm.value.type = 2;
merge(mergeForm.value).then(() => {
- cancel()
- proxy.$modal.msgSuccess('鍚堝苟鎴愬姛')
- handleQuery()
- })
+ cancel();
+ proxy.$modal.msgSuccess("鍚堝苟鎴愬姛");
+ handleQuery();
+ });
}
}
- })
-}
+ });
+};
// 鍏抽棴鍚堝苟琛ㄥ崟
const cancel = () => {
proxy.$refs.mergeRef.resetFields();
- mergeVisible.value = false
-}
+ mergeVisible.value = false;
+};
// 鎻愪氦瀹℃牳琛ㄥ崟
const submitReviewForm = () => {
proxy.$refs.formRef.validate((valid) => {
if (valid) {
- delete form.value.registrationTime
- delete form.value.createTime
- delete form.value.updateTime
- form.value.type = 1
- form.value.fieldValue = filteredList.value.map(item => ({
- [item.fields]: form.value[item.fields]
- }))
+ delete form.value.registrationTime;
+ delete form.value.createTime;
+ delete form.value.updateTime;
+ form.value.type = 1;
+ form.value.fieldValue = filteredList.value.map((item) => ({
+ [item.fields]: form.value[item.fields],
+ }));
addOrEditCoalValue(form.value).then(() => {
- cancelReview()
- proxy.$modal.msgSuccess('鎻愪氦鎴愬姛')
- handleQuery()
- })
+ cancelReview();
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ handleQuery();
+ });
}
- })
-}
+ });
+};
+
+// 娣诲姞鍒ゆ柇琛岀被鍚嶇殑鍑芥暟
+const tableRowClassName = (row) => {
+ if (activeTab.value === 'officialInventory' && row.row.inventoryQuantity < 3) {
+ return 'low-inventory-row';
+ }
+ return '';
+};
// 鍏抽棴瀹℃牳寮规
const cancelReview = () => {
- proxy.$refs.formRef.resetFields()
- reviewVisible.value = false
-}
+ proxy.$refs.formRef.resetFields();
+ reviewVisible.value = false;
+};
</script>
<style scoped>
:deep(.el-table) {
margin: 20px 0;
}
-</style>
\ No newline at end of file
+
+:deep(.low-inventory-row) {
+ background-color: #ffcccc;
+}
+</style>
--
Gitblit v1.9.3