From db80aba09d2aa09c4e0e091d0b7ebeccb57973fa Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 08 六月 2026 11:16:30 +0800
Subject: [PATCH] fix: 数量小数输入问题
---
src/views/inventoryManagement/receiptManagement/Record.vue | 604 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 434 insertions(+), 170 deletions(-)
diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
index cd103ea..0a01def 100644
--- a/src/views/inventoryManagement/receiptManagement/Record.vue
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -1,42 +1,90 @@
<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title ml10">鍏ュ簱鏃ユ湡锛�</span>
- <el-date-picker v-model="searchForm.timeStr"
- type="date"
- placeholder="璇烽�夋嫨鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- clearable
- @change="handleQuery"/>
- <span class="search_title ml10">浜у搧澶х被锛�</span>
- <el-input v-model="searchForm.productName"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- clearable/>
- <span class="search_title ml10">鏉ユ簮锛�</span>
- <el-select v-model="searchForm.recordType"
- style="width: 240px"
- placeholder="璇烽�夋嫨"
- clearable>
- <el-option v-for="item in stockRecordTypeOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"/>
- </el-select>
- <el-button type="primary"
- @click="handleQuery"
- style="margin-left: 10px">鎼滅储
- </el-button>
- </div>
- <div>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger"
- plain
- @click="handleDelete">鍒犻櫎
- </el-button>
- </div>
+ <div>
+ <div class="search_form"
+ style="margin-bottom: 10px;">
+ <el-form ref="searchFormRef"
+ :model="searchForm"
+ class="demo-form-inline">
+ <el-row :gutter="20">
+ <el-col :span="4">
+ <el-form-item label="鍏ュ簱鏃ユ湡"
+ prop="timeStr">
+ <el-date-picker v-model="searchForm.timeStr"
+ type="date"
+ placeholder="璇烽�夋嫨鏃ユ湡"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="4">
+ <el-form-item label="浜у搧澶х被"
+ prop="productName">
+ <el-input v-model="searchForm.productName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="4">
+ <el-form-item label="瑙勬牸鍨嬪彿"
+ prop="model">
+ <el-input v-model="searchForm.model"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="4">
+ <el-form-item label="鎵瑰彿"
+ prop="batchNo">
+ <el-input v-model="searchForm.batchNo"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable />
+ </el-form-item>
+ </el-col>
+ <el-col :span="4">
+ <el-form-item label="鏉ユ簮"
+ prop="recordType">
+ <el-select v-model="searchForm.recordType"
+ style="width: 240px"
+ placeholder="璇烽�夋嫨"
+ clearable>
+ <el-option v-for="item in stockRecordTypeOptions"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <!-- 鎸夐挳 -->
+ <el-col :span="4">
+ <el-form-item>
+ <el-button type="primary"
+ @click="getList">
+ 鎼滅储
+ </el-button>
+ <el-button @click="resetSearch">
+ 閲嶇疆
+ </el-button>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ </div>
+ <div class="actions">
+ <el-button type="primary"
+ :disabled="!canBatchApprove"
+ @click="handleBatchApprove">瀹℃壒</el-button>
+ <el-button :disabled="!canReverseApprove"
+ @click="handleReverseApprove">鍙嶅</el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ <el-button type="danger"
+ plain
+ :disabled="!canDelete"
+ @click="handleDelete">鍒犻櫎
+ </el-button>
</div>
<div class="table_list">
<el-table :data="tableData"
@@ -49,38 +97,61 @@
height="calc(100vh - 18.5em)">
<el-table-column align="center"
type="selection"
- width="55"/>
+ :selectable="isRowSelectable"
+ width="55" />
<el-table-column align="center"
label="搴忓彿"
type="index"
- width="60"/>
+ width="60" />
<el-table-column label="鍏ュ簱鎵规"
prop="inboundBatches"
- width="280"
- show-overflow-tooltip/>
+ width="200"
+ show-overflow-tooltip />
<el-table-column label="鍏ュ簱鏃堕棿"
prop="createTime"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
<el-table-column label="浜у搧澶х被"
prop="productName"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
<el-table-column label="瑙勬牸鍨嬪彿"
prop="model"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
+ <el-table-column label="鎵瑰彿"
+ prop="batchNo"
+ show-overflow-tooltip />
<el-table-column label="鍗曚綅"
prop="unit"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
<el-table-column label="鍏ュ簱鏁伴噺"
prop="stockInNum"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
<el-table-column label="鍏ュ簱浜�"
prop="createBy"
- show-overflow-tooltip/>
+ show-overflow-tooltip />
<el-table-column label="鏉ユ簮"
prop="recordType"
show-overflow-tooltip>
<template #default="scope">
{{ getRecordType(scope.row.recordType) }}
+ </template>
+ </el-table-column>
+ <el-table-column v-if="showSourceOrderNoColumn"
+ label="婧愬崟鍙�"
+ width="150"
+ prop="sourceOrderNo"
+ show-overflow-tooltip>
+ <template #default="scope">
+ {{ formatSourceOrderNo(scope.row?.sourceOrderNo) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="瀹℃壒鐘舵��"
+ prop="approvalStatus"
+ show-overflow-tooltip>
+ <template #default="scope">
+ <el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)"
+ size="small">
+ {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
+ </el-tag>
</template>
</el-table-column>
</el-table>
@@ -89,162 +160,355 @@
layout="total, sizes, prev, pager, next, jumper"
:page="page.current"
:limit="page.size"
- @pagination="pageProductChange"/>
+ @pagination="pageProductChange" />
</div>
</div>
</template>
<script setup>
-import pagination from "@/components/PIMTable/Pagination.vue";
-import {
- ref,
- reactive,
- toRefs,
- onMounted,
- getCurrentInstance,
-} from "vue";
-import {ElMessageBox} from "element-plus";
-import {
- getStockInRecordListPage,
- batchDeleteStockInRecords,
-} from "@/api/inventoryManagement/stockInRecord.js";
-import {
- findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions,
-} from "@/api/basicData/enum.js";
+ import pagination from "@/components/PIMTable/Pagination.vue";
+ import {
+ ref,
+ reactive,
+ toRefs,
+ computed,
+ onMounted,
+ getCurrentInstance,
+ } from "vue";
+ import { ElMessageBox } from "element-plus";
+ import {
+ getStockInRecordListPage,
+ batchDeletePendingStockInRecords,
+ batchApproveStockInRecords,
+ batchUnapproveStockInRecords,
+ } from "@/api/inventoryManagement/stockInRecord.js";
+ import {
+ findAllQualifiedStockInRecordTypeOptions,
+ // findAllUnQualifiedStockInRecordTypeOptions,
+ } from "@/api/basicData/enum.js";
-const {proxy} = getCurrentInstance();
+ const { proxy } = getCurrentInstance();
-const props = defineProps({
- type: {
- type: String,
- required: true,
- default: '0'
- }
-})
+ const props = defineProps({
+ type: {
+ type: String,
+ required: true,
+ default: "0",
+ },
+ topParentProductId: {
+ type: [String, Number],
+ default: undefined,
+ },
+ });
-const tableData = ref([]);
-const selectedRows = ref([]);
-const tableLoading = ref(false);
-// 鏉ユ簮绫诲瀷閫夐」
-const stockRecordTypeOptions = ref([]);
-const page = reactive({
- current: 1,
- size: 100,
-});
-const total = ref(0);
+ const tableData = ref([]);
+ const selectedRows = ref([]);
+ const tableLoading = ref(false);
+ // 鏉ユ簮绫诲瀷閫夐」
+ const stockRecordTypeOptions = ref([]);
+ const page = reactive({
+ current: 1,
+ size: 10,
+ });
+ const total = ref(0);
-const data = reactive({
- searchForm: {
- productName: "",
- timeStr: "",
- recordType: "",
- },
-});
-const {searchForm} = toRefs(data);
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
+ const data = reactive({
+ searchForm: {
+ productName: "",
+ batchNo: "",
+ model: "",
+ timeStr: "",
+ recordType: "",
+ },
+ });
+ const { searchForm } = toRefs(data);
+ const searchFormRef = ref(null);
-const getRecordType = (recordType) => {
- return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
-}
+ const resetSearch = () => {
+ searchFormRef.value?.resetFields();
+ page.current = 1;
+ getList();
+ };
-const pageProductChange = obj => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
+ const getRecordType = recordType => {
+ return (
+ stockRecordTypeOptions.value.find(item => item.value === recordType)
+ ?.label || ""
+ );
+ };
-const getList = () => {
- tableLoading.value = true;
- const params = {...page, type: props.type};
- params.timeStr = searchForm.value.timeStr;
- params.productName = searchForm.value.productName;
- params.recordType = searchForm.value.recordType;
- getStockInRecordListPage(params)
+ const approvalStatusLabelMap = {
+ 0: "寰呭鎵�",
+ 1: "閫氳繃",
+ 2: "椹冲洖",
+ pending: "寰呭鎵�",
+ approved: "閫氳繃",
+ rejected: "椹冲洖",
+ PENDING: "寰呭鎵�",
+ APPROVED: "閫氳繃",
+ REJECTED: "椹冲洖",
+ };
+ approvalStatusLabelMap[3] = "寰呯‘璁�";
+
+ const getApprovalStatusLabel = status => {
+ if (status === null || status === undefined || status === "") {
+ return "寰呭鎵�";
+ }
+ return approvalStatusLabelMap[status] || "寰呭鎵�";
+ };
+
+ // 閫氳繃/椹冲洖鍥哄畾鑹诧紱鍏朵綑锛堝惈寰呭鎵广�佺┖鍊笺�佹湭鏄犲皠浣嗘枃妗堜负寰呭鎵癸級缁熶竴鐢� warning 棰勮鑹�
+ const getApprovalStatusTagType = status => {
+ if (
+ status === 1 ||
+ status === "1" ||
+ status === "approved" ||
+ status === "APPROVED"
+ )
+ return "success";
+ if (
+ status === 2 ||
+ status === "2" ||
+ status === "rejected" ||
+ status === "REJECTED"
+ )
+ return "danger";
+ return "warning";
+ };
+
+ const isPendingApproval = status => {
+ return (
+ status === 0 ||
+ status === "0" ||
+ status === "pending" ||
+ status === "PENDING" ||
+ status === null ||
+ status === undefined ||
+ status === ""
+ );
+ };
+
+ const isRejectedApproval = status => {
+ return (
+ status === 2 ||
+ status === "2" ||
+ status === "rejected" ||
+ status === "REJECTED"
+ );
+ };
+
+ const isRowSelectable = row => {
+ return (
+ isPendingApproval(row?.approvalStatus) ||
+ isRejectedApproval(row?.approvalStatus)
+ );
+ };
+
+ const canBatchApprove = computed(() => {
+ return (
+ selectedRows.value.length > 0 &&
+ selectedRows.value.every(row => isPendingApproval(row.approvalStatus))
+ );
+ });
+
+ const canReverseApprove = computed(() => {
+ return (
+ selectedRows.value.length > 0 &&
+ selectedRows.value.every(row => isRejectedApproval(row.approvalStatus))
+ );
+ });
+
+ const canDelete = computed(() => canBatchApprove.value);
+ const showSourceOrderNoColumn = computed(() => {
+ const topParentProductId = Number(props.topParentProductId);
+ return topParentProductId === 276 || topParentProductId === 278;
+ });
+
+ const formatSourceOrderNo = value => {
+ const text = String(value ?? "").trim();
+ return text || "--";
+ };
+
+ const pageProductChange = obj => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+ };
+
+ const getList = () => {
+ tableLoading.value = true;
+ getStockInRecordListPage(
+ Object.assign(
+ {},
+ {
+ ...searchForm.value,
+ ...page,
+ topParentProductId: props.topParentProductId,
+ }
+ )
+ )
.then(res => {
tableData.value = res.data.records;
- }).finally(() => {
- tableLoading.value = false;
- })
-};
-
-// 鑾峰彇鏉ユ簮绫诲瀷閫夐」
-const fetchStockRecordTypeOptions = () => {
- if (props.type === '0') {
- findAllQualifiedStockInRecordTypeOptions()
- .then(res => {
- stockRecordTypeOptions.value = res.data;
- })
- return
- }
- findAllUnQualifiedStockInRecordTypeOptions()
- .then(res => {
- stockRecordTypeOptions.value = res.data;
+ total.value = res.data.total || 0;
})
-}
+ .finally(() => {
+ tableLoading.value = false;
+ });
+ };
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = selection => {
- selectedRows.value = selection.filter(item => item.id);
-};
+ // 鑾峰彇鏉ユ簮绫诲瀷閫夐」
+ const fetchStockRecordTypeOptions = () => {
+ if (props.type === "0") {
+ findAllQualifiedStockInRecordTypeOptions().then(res => {
+ stockRecordTypeOptions.value = res.data;
+ });
+ return;
+ }
+ // findAllUnQualifiedStockInRecordTypeOptions()
+ // .then(res => {
+ // stockRecordTypeOptions.value = res.data;
+ // })
+ };
-const expandedRowKeys = ref([]);
+ // 琛ㄦ牸閫夋嫨鏁版嵁
+ const handleSelectionChange = selection => {
+ selectedRows.value = selection.filter(
+ item => item.id && isRowSelectable(item)
+ );
+ };
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
+ const expandedRowKeys = ref([]);
+
+ const handleReverseApprove = () => {
+ if (!canReverseApprove.value) {
+ proxy.$modal.msgWarning("璇烽�夋嫨宸查┏鍥炵殑鏁版嵁");
+ return;
+ }
+ const ids = selectedRows.value.map(item => item.id);
+ ElMessageBox.confirm("鍙嶅鍚庤褰曞皢鎭㈠涓哄緟瀹℃壒鐘舵�侊紝鏄惁纭鍙嶅锛�", "鍙嶅", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
.then(() => {
- // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
- proxy.download("/stockInRecord/exportStockInRecord", {type: props.type}, props.type === '0' ? "鍚堟牸鍏ュ簱.xlsx" : "涓嶅悎鏍煎叆搴�.xlsx");
+ batchUnapproveStockInRecords({ ids })
+ .then(() => {
+ proxy.$modal.msgSuccess("鍙嶅鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍙嶅澶辫触");
+ });
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
});
-};
+ };
-// 鍒犻櫎
-const handleDelete = () => {
- if (selectedRows.value.length === 0) {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- const ids = selectedRows.value.map(item => item.id);
-
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
+ const handleBatchApprove = () => {
+ if (!canBatchApprove.value) {
+ proxy.$modal.msgWarning("璇烽�夋嫨寰呭鎵圭殑鏁版嵁");
+ return;
+ }
+ const ids = selectedRows.value.map(item => item.id);
+ ElMessageBox.confirm("璇烽�夋嫨瀹℃壒缁撴灉", "瀹℃壒", {
+ confirmButtonText: "閫氳繃",
+ cancelButtonText: "椹冲洖",
+ type: "warning",
+ distinguishCancelAndClose: true,
+ })
.then(() => {
- batchDeleteStockInRecords(ids)
+ batchApproveStockInRecords({ ids, approvalStatus: 1 })
+ .then(() => {
+ proxy.$modal.msgSuccess("瀹℃壒閫氳繃鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("瀹℃壒閫氳繃澶辫触");
+ });
+ })
+ .catch(action => {
+ if (action === "cancel") {
+ batchApproveStockInRecords({ ids, approvalStatus: 2 })
.then(() => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ proxy.$modal.msgSuccess("瀹℃壒椹冲洖鎴愬姛");
getList();
})
.catch(() => {
- proxy.$modal.msgError("鍒犻櫎澶辫触");
+ proxy.$modal.msgError("瀹℃壒椹冲洖澶辫触");
});
+ return;
+ }
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
+
+ // 瀵煎嚭
+ const handleOut = () => {
+ ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
+ proxy.download(
+ "/stockInRecord/exportStockInRecord",
+ { type: props.type },
+ props.type === "0" ? "鍚堟牸鍏ュ簱.xlsx" : "涓嶅悎鏍煎叆搴�.xlsx"
+ );
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
});
-};
+ };
-onMounted(() => {
- getList();
- fetchStockRecordTypeOptions();
-});
+ // 鍒犻櫎
+ const handleDelete = () => {
+ if (!canDelete.value) {
+ proxy.$modal.msgWarning("璇烽�夋嫨寰呭鎵圭殑鏁版嵁");
+ return;
+ }
+ const ids = selectedRows.value.map(item => item.id);
+
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ batchDeletePendingStockInRecords(ids)
+ .then(() => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+ };
+
+ onMounted(() => {
+ getList();
+ fetchStockRecordTypeOptions();
+ });
+
+ watch(
+ () => props.topParentProductId,
+ () => {
+ page.current = 1;
+ getList();
+ }
+ );
</script>
-<style scoped lang="scss"></style>
-
-
-
+<style scoped lang="scss">
+ .actions {
+ display: flex;
+ justify-content: flex-end;
+ margin-bottom: 10px;
+ }
+</style>
--
Gitblit v1.9.3