From fa4ea8dd99638f58da60ac283186113619cc7e6e Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 23 一月 2026 16:11:57 +0800
Subject: [PATCH] Merge branch 'dev_New' of http://114.132.189.42:9002/r/product-inventory-management into dev_New
---
src/views/equipmentManagement/upkeep/index.vue | 9
src/api/basicData/enum.js | 23
src/views/inventoryManagement/stockManagement/New.vue | 180 ++
src/views/basicData/product/ProductSelectDialog.vue | 113
src/views/basicData/supplierManage/index.vue | 9
src/api/inventoryManagement/stockUninventory.js | 27
src/api/inventoryManagement/stockInRecord.js | 27
src/views/equipmentManagement/repair/index.vue | 190 +-
src/views/inventoryManagement/stockManagement/Qualified.vue | 158 +
src/views/salesManagement/salesLedger/index.vue | 2
src/api/inventoryManagement/stockInventory.js | 37
src/views/basicData/supplierManage/filesDia.vue | 4
src/views/inventoryManagement/dispatchLog/Record.vue | 711 ++++++++
src/views/productionManagement/productStructure/Detail/index.vue | 467 +++-
/dev/null | 302 ---
src/api/inventoryManagement/stockOut.js | 37
src/views/inventoryManagement/receiptManagement/index.vue | 548 ------
src/views/inventoryManagement/stockManagement/index.vue | 428 -----
src/views/inventoryManagement/stockManagement/Subtract.vue | 199 ++
src/views/inventoryManagement/stockManagement/Unqualified.vue | 158 +
src/views/inventoryManagement/dispatchLog/index.vue | 884 ----------
src/views/inventoryManagement/receiptManagement/Record.vue | 251 +++
22 files changed, 2,344 insertions(+), 2,420 deletions(-)
diff --git a/src/api/basicData/enum.js b/src/api/basicData/enum.js
new file mode 100644
index 0000000..0d35692
--- /dev/null
+++ b/src/api/basicData/enum.js
@@ -0,0 +1,23 @@
+import request from "@/utils/request.js";
+
+export function findAllStockRecordTypeOptions() {
+ return request({
+ url: '/basic/enum/stockRecordType',
+ method: 'get'
+ })
+}
+
+
+export function findAllQualifiedStockRecordTypeOptions() {
+ return request({
+ url: '/basic/enum/StockQualifiedRecordTypeEnum',
+ method: 'get'
+ })
+}
+
+export function findAllUnqualifiedStockRecordTypeOptions() {
+ return request({
+ url: '/basic/enum/StockUnQualifiedRecordTypeEnum',
+ method: 'get'
+ })
+}
diff --git a/src/api/inventoryManagement/stockInRecord.js b/src/api/inventoryManagement/stockInRecord.js
new file mode 100644
index 0000000..1746bfe
--- /dev/null
+++ b/src/api/inventoryManagement/stockInRecord.js
@@ -0,0 +1,27 @@
+import request from "@/utils/request";
+
+// 鏌ヨ鍏ュ簱淇℃伅鍒楄〃
+export const getStockInRecordListPage = (params) => {
+ return request({
+ url: "/stockInRecord/listPage",
+ method: "get",
+ params,
+ });
+};
+
+
+export const updateStockInRecord = (id, data) => {
+ return request({
+ url: "/stockInRecord/" + id,
+ method: "put",
+ data: data,
+ });
+};
+
+export const batchDeleteStockInRecords = (ids) => {
+ return request({
+ url: "/stockInRecord",
+ method: "delete",
+ data: ids,
+ });
+};
\ No newline at end of file
diff --git a/src/api/inventoryManagement/stockInventory.js b/src/api/inventoryManagement/stockInventory.js
new file mode 100644
index 0000000..a50194a
--- /dev/null
+++ b/src/api/inventoryManagement/stockInventory.js
@@ -0,0 +1,37 @@
+import request from "@/utils/request.js";
+// 鍒嗛〉鏌ヨ搴撳瓨璁板綍鍒楄〃
+export const getStockInventoryListPage = (params) => {
+ return request({
+ url: "/stockInventory/pagestockInventory",
+ method: "get",
+ params,
+ });
+};
+
+// 鍒涘缓搴撳瓨璁板綍
+export const createStockInventory = (params) => {
+ return request({
+ url: "/stockInventory/addstockInventory",
+ method: "post",
+ data: params,
+ });
+};
+
+// 鍑忓皯搴撳瓨璁板綍
+export const subtractStockInventory = (params) => {
+ return request({
+ url: "/stockInventory/subtractStockInventory",
+ method: "post",
+ data: params,
+ });
+};
+
+export const exportStockInventory = (params) => {
+ return request({
+ url: "/stockInventory/exportStockInventory",
+ method: "post",
+ data: params,
+ });
+};
+
+
diff --git a/src/api/inventoryManagement/stockOut.js b/src/api/inventoryManagement/stockOut.js
index f1b36d9..3d260b3 100644
--- a/src/api/inventoryManagement/stockOut.js
+++ b/src/api/inventoryManagement/stockOut.js
@@ -3,44 +3,17 @@
// 鍑哄簱鍙拌处-閲囪喘鍑哄簱鏌ヨ鍑哄簱鍒楄〃
export const getStockOutPage = (params) => {
return request({
- url: "/stockmanagement/listPage",
+ url: "/stockOutRecord/listPage",
method: "get",
params,
});
};
-
-// 鍑哄簱鍙拌处-鐢熶骇鍑哄簱鏌ヨ鍑哄簱鍒楄〃
-export const getStockOutSemiProductPage = (params) => {
- return request({
- url: "/stockmanagement/listPageBySemiProduct",
- method: "get",
- params,
- });
-};
-
-//鏂板鍑哄簱淇℃伅
-export const addStockOut = (data) => {
- return request({
- url: '/stockout/add',
- method: 'post',
- data: data
- })
-}
-
-//淇敼鍑哄簱淇℃伅
-export const updateStockOut = (data) => {
- return request({
- url: "/stockout/update",
- method: "put",
- data,
- });
-}
//鍒犻櫎鍑哄簱淇℃伅
export const delStockOut = (ids) => {
return request({
- url: '/stockmanagement/del',
- method: 'post',
- data: ids
- })
+ url: "/stockOutRecord",
+ method: "delete",
+ data: ids,
+ });
}
diff --git a/src/api/inventoryManagement/stockUninventory.js b/src/api/inventoryManagement/stockUninventory.js
new file mode 100644
index 0000000..bdde283
--- /dev/null
+++ b/src/api/inventoryManagement/stockUninventory.js
@@ -0,0 +1,27 @@
+import request from "@/utils/request.js";
+// 鍒嗛〉鏌ヨ搴撳瓨璁板綍鍒楄〃
+export const getStockUninventoryListPage = (params) => {
+ return request({
+ url: "/stockUninventory/pagestockUninventory",
+ method: "get",
+ params,
+ });
+};
+
+// 鍒涘缓搴撳瓨璁板綍
+export const createStockUnInventory = (params) => {
+ return request({
+ url: "/stockUninventory/addstockUninventory",
+ method: "post",
+ data: params,
+ });
+};
+
+// 鍑忓皯搴撳瓨璁板綍
+export const subtractStockUnInventory = (params) => {
+ return request({
+ url: "/stockUninventory/subtractstockUninventory",
+ method: "post",
+ data: params,
+ });
+};
diff --git a/src/views/basicData/product/ProductSelectDialog.vue b/src/views/basicData/product/ProductSelectDialog.vue
index 246cd88..70dbb16 100644
--- a/src/views/basicData/product/ProductSelectDialog.vue
+++ b/src/views/basicData/product/ProductSelectDialog.vue
@@ -1,28 +1,12 @@
<template>
- <el-dialog
- v-model="visible"
- title="閫夋嫨浜у搧"
- width="900px"
- destroy-on-close
- :close-on-click-modal="false"
- >
+ <el-dialog v-model="visible" title="閫夋嫨浜у搧" width="900px" destroy-on-close :close-on-click-modal="false">
<el-form :inline="true" :model="query" class="mb-2">
<el-form-item label="浜у搧澶х被">
- <el-input
- v-model="query.productName"
- placeholder="杈撳叆浜у搧澶х被"
- clearable
- @keyup.enter="onSearch"
- />
+ <el-input v-model="query.productName" placeholder="杈撳叆浜у搧澶х被" clearable @keyup.enter="onSearch" />
</el-form-item>
<el-form-item label="鍨嬪彿鍚嶇О">
- <el-input
- v-model="query.model"
- placeholder="杈撳叆鍨嬪彿鍚嶇О"
- clearable
- @keyup.enter="onSearch"
- />
+ <el-input v-model="query.model" placeholder="杈撳叆鍨嬪彿鍚嶇О" clearable @keyup.enter="onSearch" />
</el-form-item>
<el-form-item>
@@ -32,32 +16,19 @@
</el-form>
<!-- 鍒楄〃 -->
- <el-table
- v-loading="loading"
- :data="tableData"
- height="420"
- highlight-current-row
- row-key="id"
- @selection-change="handleSelectionChange"
- >
+ <el-table ref="tableRef" v-loading="loading" :data="tableData" height="420" highlight-current-row row-key="id"
+ @selection-change="handleSelectionChange" @select="handleSelect">
<el-table-column type="selection" width="55" />
- <el-table-column type="index" label="#" width="60"/>
- <el-table-column prop="productName" label="浜у搧澶х被" min-width="160"/>
- <el-table-column prop="model" label="鍨嬪彿鍚嶇О" min-width="200"/>
- <el-table-column prop="unit" label="鍗曚綅" min-width="160"/>
+ <el-table-column type="index" label="搴忓彿" width="60" />
+ <el-table-column prop="productName" label="浜у搧澶х被" min-width="160" />
+ <el-table-column prop="model" label="鍨嬪彿鍚嶇О" min-width="200" />
+ <el-table-column prop="unit" label="鍗曚綅" min-width="160" />
</el-table>
<div class="mt-3 flex justify-end">
- <el-pagination
- background
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- v-model:page-size="page.pageSize"
- v-model:current-page="page.pageNum"
- :page-sizes="[10, 20, 50, 100]"
- @size-change="onPageChange"
- @current-change="onPageChange"
- />
+ <el-pagination background layout="total, sizes, prev, pager, next, jumper" :total="total"
+ v-model:page-size="page.pageSize" v-model:current-page="page.pageNum" :page-sizes="[10, 20, 50, 100]"
+ @size-change="onPageChange" @current-change="onPageChange" />
</div>
<template #footer>
@@ -70,9 +41,9 @@
</template>
<script setup lang="ts">
-import {computed, onMounted, reactive, ref, watch} from "vue";
-import {ElMessage} from "element-plus";
-import {productModelList} from '@/api/basicData/productModel'
+import { computed, onMounted, reactive, ref, watch, nextTick } from "vue";
+import { ElMessage } from "element-plus";
+import { productModelList } from '@/api/basicData/productModel'
export type ProductRow = {
id: number;
@@ -83,6 +54,7 @@
const props = defineProps<{
modelValue: boolean;
+ single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
}>();
const emit = defineEmits(['update:modelValue', 'confirm']);
@@ -105,14 +77,48 @@
const loading = ref(false);
const tableData = ref<ProductRow[]>([]);
const total = ref(0);
-const multipleSelection = ref<ProductRow[]>([])
+const multipleSelection = ref<ProductRow[]>([]);
+const tableRef = ref();
function close() {
visible.value = false;
}
const handleSelectionChange = (val: ProductRow[]) => {
- multipleSelection.value = val
+ if (props.single && val.length > 1) {
+ // 濡傛灉闄愬埗涓哄崟涓�夋嫨锛屽彧淇濈暀鏈�鍚庝竴涓�変腑鐨�
+ const lastSelected = val[val.length - 1];
+ multipleSelection.value = [lastSelected];
+ // 娓呯┖琛ㄦ牸閫変腑鐘舵�侊紝鐒跺悗閲嶆柊閫変腑鏈�鍚庝竴涓�
+ nextTick(() => {
+ if (tableRef.value) {
+ tableRef.value.clearSelection();
+ tableRef.value.toggleRowSelection(lastSelected, true);
+ }
+ });
+ } else {
+ multipleSelection.value = val;
+ }
+}
+
+// 澶勭悊鍗曚釜閫夋嫨
+const handleSelect = (selection: ProductRow[], row: ProductRow) => {
+ if (props.single) {
+ // 濡傛灉闄愬埗涓哄崟涓紝娓呯┖鍏朵粬閫夋嫨锛屽彧淇濈暀褰撳墠琛�
+ if (selection.includes(row)) {
+ // 閫変腑褰撳墠琛屾椂锛屾竻绌哄叾浠栭�変腑
+ multipleSelection.value = [row];
+ nextTick(() => {
+ if (tableRef.value) {
+ tableData.value.forEach((item) => {
+ if (item.id !== row.id) {
+ tableRef.value.toggleRowSelection(item, false);
+ }
+ });
+ }
+ });
+ }
+ }
}
function onSearch() {
@@ -136,7 +142,11 @@
ElMessage.warning("璇烽�夋嫨涓�鏉′骇鍝�");
return;
}
- emit("confirm", multipleSelection.value);
+ if (props.single && multipleSelection.value.length > 1) {
+ ElMessage.warning("鍙兘閫夋嫨涓�涓骇鍝�");
+ return;
+ }
+ emit("confirm", props.single ? [multipleSelection.value[0]] : multipleSelection.value);
close();
}
@@ -144,7 +154,7 @@
loading.value = true;
try {
multipleSelection.value = []; // 缈婚〉/鎼滅储鍚庢竻绌洪�夋嫨鏇寸鍚堥鏈�
- const res = await productModelList({
+ const res: any = await productModelList({
productName: query.productName.trim(),
model: query.model.trim(),
current: page.pageNum,
@@ -157,6 +167,13 @@
}
}
+// 鐩戝惉寮圭獥鎵撳紑锛岄噸缃�夋嫨
+watch(() => props.modelValue, (visible) => {
+ if (visible) {
+ multipleSelection.value = [];
+ }
+});
+
onMounted(() => {
loadData()
})
diff --git a/src/views/basicData/supplierManage/filesDia.vue b/src/views/basicData/supplierManage/filesDia.vue
index 6284d6b..7943185 100644
--- a/src/views/basicData/supplierManage/filesDia.vue
+++ b/src/views/basicData/supplierManage/filesDia.vue
@@ -30,6 +30,10 @@
:isSelection="true"
@selection-change="handleSelectionChange"
height="500"
+ @pagination-change="paginationSearch"
+ :total="total"
+ :page="page.current"
+ :limit="page.size"
>
</PIMTable>
<pagination
diff --git a/src/views/basicData/supplierManage/index.vue b/src/views/basicData/supplierManage/index.vue
index 963a3db..bb83fcf 100644
--- a/src/views/basicData/supplierManage/index.vue
+++ b/src/views/basicData/supplierManage/index.vue
@@ -26,6 +26,15 @@
return {
activeTab: 'home'
}
+ },
+ watch: {
+ activeTab(newVal) {
+ if (newVal === 'home') {
+ this.$refs.homeTab && this.$refs.homeTab.getList()
+ } else if (newVal === 'blacklist') {
+ this.$refs.blacklistTab && this.$refs.blacklistTab.getList()
+ }
+ }
}
}
</script>
diff --git a/src/views/equipmentManagement/repair/index.vue b/src/views/equipmentManagement/repair/index.vue
index 477e880..40a3c39 100644
--- a/src/views/equipmentManagement/repair/index.vue
+++ b/src/views/equipmentManagement/repair/index.vue
@@ -85,17 +85,17 @@
</div>
</div>
<PIMTable
- rowKey="id"
- isSelection
- :column="columns"
- :tableData="dataList"
- :page="{
+ rowKey="id"
+ isSelection
+ :column="columns"
+ :tableData="dataList"
+ :page="{
current: pagination.currentPage,
size: pagination.pageSize,
total: pagination.total,
}"
- @selection-change="handleSelectionChange"
- @pagination="changePage"
+ @selection-change="handleSelectionChange"
+ @pagination="changePage"
>
<template #statusRef="{ row }">
<el-tag v-if="row.status === 2" type="danger">澶辫触</el-tag>
@@ -130,17 +130,18 @@
</template>
</PIMTable>
</div>
- <RepairModal ref="repairModalRef" @ok="getTableData" />
- <MaintainModal ref="maintainModalRef" @ok="getTableData" />
+ <RepairModal ref="repairModalRef" @ok="getTableData"/>
+ <MaintainModal ref="maintainModalRef" @ok="getTableData"/>
</div>
</template>
<script setup>
import { usePaginationApi } from "@/hooks/usePaginationApi";
-import { getRepairPage, delRepair } from "@/api/equipmentManagement/repair";
import { onMounted, getCurrentInstance, computed } from "vue";
+import {usePaginationApi} from "@/hooks/usePaginationApi";
+import {getRepairPage, delRepair} from "@/api/equipmentManagement/repair";
import RepairModal from "./Modal/RepairModal.vue";
-import { ElMessageBox, ElMessage } from "element-plus";
+import {ElMessageBox, ElMessage} from "element-plus";
import dayjs from "dayjs";
import MaintainModal from "./Modal/MaintainModal.vue";
@@ -148,7 +149,7 @@
name: "璁惧鎶ヤ慨",
});
-const { proxy } = getCurrentInstance();
+const {proxy} = getCurrentInstance();
// 妯℃�佹瀹炰緥
const repairModalRef = ref();
@@ -167,85 +168,85 @@
resetFilters,
onCurrentChange,
} = usePaginationApi(
- getRepairPage,
- {
- deviceName: undefined,
- deviceModel: undefined,
- remark: undefined,
- maintenanceName: undefined,
- repairTimeStr: undefined,
- maintenanceTimeStr: undefined,
- },
- [
+ getRepairPage,
{
- label: "璁惧鍚嶇О",
- align: "center",
- prop: "deviceName",
+ deviceName: undefined,
+ deviceModel: undefined,
+ remark: undefined,
+ maintenanceName: undefined,
+ repairTimeStr: undefined,
+ maintenanceTimeStr: undefined,
},
- {
- label: "瑙勬牸鍨嬪彿",
- align: "center",
- prop: "deviceModel",
- },
- {
- label: "鎶ヤ慨鏃ユ湡",
- align: "center",
- prop: "repairTime",
- formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"),
- },
- {
- label: "鎶ヤ慨浜�",
- align: "center",
- prop: "repairName",
- },
- {
- label: "鏁呴殰鐜拌薄",
- align: "center",
- prop: "remark",
- },
- {
- label: "缁翠慨浜�",
- align: "center",
- prop: "maintenanceName",
- },
- {
- label: "缁翠慨缁撴灉",
- align: "center",
- prop: "maintenanceResult",
- },
- {
- label: "缁翠慨鏃ユ湡",
- align: "center",
- prop: "maintenanceTime",
- formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
- },
- {
- label: "鐘舵��",
- align: "center",
- prop: "status",
- dataType: "slot",
- slot: "statusRef",
- },
- {
- fixed: "right",
- label: "鎿嶄綔",
- dataType: "slot",
- slot: "operation",
- align: "center",
- width: "200px",
- },
- ]
+ [
+ {
+ label: "璁惧鍚嶇О",
+ align: "center",
+ prop: "deviceName",
+ },
+ {
+ label: "瑙勬牸鍨嬪彿",
+ align: "center",
+ prop: "deviceModel",
+ },
+ {
+ label: "鎶ヤ慨鏃ユ湡",
+ align: "center",
+ prop: "repairTime",
+ formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"),
+ },
+ {
+ label: "鎶ヤ慨浜�",
+ align: "center",
+ prop: "repairName",
+ },
+ {
+ label: "鏁呴殰鐜拌薄",
+ align: "center",
+ prop: "remark",
+ },
+ {
+ label: "缁翠慨浜�",
+ align: "center",
+ prop: "maintenanceName",
+ },
+ {
+ label: "缁翠慨缁撴灉",
+ align: "center",
+ prop: "maintenanceResult",
+ },
+ {
+ label: "缁翠慨鏃ユ湡",
+ align: "center",
+ prop: "maintenanceTime",
+ formatData: (cell) => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
+ },
+ {
+ label: "鐘舵��",
+ align: "center",
+ prop: "status",
+ dataType: "slot",
+ slot: "statusRef",
+ },
+ {
+ fixed: "right",
+ label: "鎿嶄綔",
+ dataType: "slot",
+ slot: "operation",
+ align: "center",
+ width: "300px",
+ },
+ ]
);
// type === 1 缁翠慨 2鎶ヤ慨闂�
-const handleDateChange = (value,type) => {
+const handleDateChange = (value, type) => {
filters.maintenanceTimeStr = null
filters.c = null
- if(type === 1){
+ if (type === 1) {
if (value) {
filters.maintenanceTimeStr = dayjs(value).format("YYYY-MM-DD");
}
- }else{
+ } else {
if (value) {
filters.repairTimeStr = dayjs(value).format("YYYY-MM-DD");
}
@@ -278,10 +279,10 @@
maintainModalRef.value.open(row.id, row);
};
-const changePage = ({ page, limit }) => {
- pagination.currentPage = page;
- pagination.pageSize = limit;
- onCurrentChange(page);
+const changePage = ({page, limit}) => {
+ pagination.currentPage = page;
+ pagination.pageSize = limit;
+ onCurrentChange(page);
};
// 鍗曡鍒犻櫎
@@ -292,18 +293,18 @@
const record = dataList.value.find(item => item.id === id);
return record && record.status === 1;
});
-
+
if (hasFinished) {
ElMessage.warning('涓嶈兘鍒犻櫎鐘舵�佷负瀹岀粨鐨勮褰�');
return;
}
-
+
ElMessageBox.confirm("纭鍒犻櫎鎶ヤ慨鏁版嵁, 姝ゆ搷浣滀笉鍙��?", "璀﹀憡", {
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
type: "warning",
}).then(async () => {
- const { code } = await delRepair(ids);
+ const {code} = await delRepair(ids);
if (code === 200) {
ElMessage.success("鍒犻櫎鎴愬姛");
getTableData();
@@ -318,12 +319,12 @@
cancelButtonText: "鍙栨秷",
type: "warning",
})
- .then(() => {
- proxy.download("/device/repair/export", {}, "璁惧鎶ヤ慨.xlsx");
- })
- .catch(() => {
- ElMessage.info("宸插彇娑�");
- });
+ .then(() => {
+ proxy.download("/device/repair/export", {}, "璁惧鎶ヤ慨.xlsx");
+ })
+ .catch(() => {
+ ElMessage.info("宸插彇娑�");
+ });
};
onMounted(() => {
@@ -335,6 +336,7 @@
.table_list {
margin-top: unset;
}
+
.actions {
display: flex;
justify-content: space-between;
diff --git a/src/views/equipmentManagement/upkeep/index.vue b/src/views/equipmentManagement/upkeep/index.vue
index 44f4af7..7ef639c 100644
--- a/src/views/equipmentManagement/upkeep/index.vue
+++ b/src/views/equipmentManagement/upkeep/index.vue
@@ -172,6 +172,13 @@
</template>
<template #operation="{ row }">
<el-button
+ type="primary"
+ text
+ @click="addMaintain(row)"
+ >
+ 鏂板淇濆吇
+ </el-button>
+ <el-button
type="primary"
link
:disabled="row.status === 1"
@@ -377,7 +384,7 @@
dataType: "slot",
slot: "operation",
align: "center",
- width: "200px",
+ width: "300px",
},
])
diff --git a/src/views/inventoryManagement/dispatchLog/Record.vue b/src/views/inventoryManagement/dispatchLog/Record.vue
new file mode 100644
index 0000000..73792da
--- /dev/null
+++ b/src/views/inventoryManagement/dispatchLog/Record.vue
@@ -0,0 +1,711 @@
+<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-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>
+ <el-button type="primary" plain @click="handlePrint">鎵撳嵃</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <el-table
+ :data="tableData"
+ border
+ v-loading="tableLoading"
+ @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys"
+ :row-key="(row) => row.id"
+ style="width: 100%"
+ height="calc(100vh - 18.5em)"
+ >
+ <el-table-column align="center" type="selection" width="55" />
+ <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+ <el-table-column
+ label="鍑哄簱鎵规"
+ prop="outboundBatches"
+ min-width="100"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="鍑哄簱鏃ユ湡"
+ prop="createTime"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="浜у搧澶х被"
+ prop="productName"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="瑙勬牸鍨嬪彿"
+ prop="model"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="鍗曚綅"
+ prop="unit"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="鍑哄簱鏁伴噺"
+ prop="stockOutNum"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="鍑哄簱浜�"
+ prop="createBy"
+ 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>
+ <pagination
+ v-show="total > 0"
+ :total="total"
+ layout="total, sizes, prev, pager, next, jumper"
+ :page="page.current"
+ :limit="page.size"
+ @pagination="paginationChange"
+ />
+ </div>
+ </div>
+</template>
+
+<script setup>
+import pagination from "@/components/PIMTable/Pagination.vue";
+import { ref } from "vue";
+import { ElMessageBox } from "element-plus";
+import useUserStore from "@/store/modules/user";
+import { getCurrentDate } from "@/utils/index.js";
+import {
+ getStockOutPage,
+ delStockOut,
+} from "@/api/inventoryManagement/stockOut.js";
+import {
+ findAllQualifiedStockRecordTypeOptions,
+ findAllStockRecordTypeOptions,
+ findAllUnqualifiedStockRecordTypeOptions
+} from "@/api/basicData/enum.js";
+
+const userStore = useUserStore();
+const { proxy } = getCurrentInstance();
+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 props = defineProps({
+ type: {
+ type: String,
+ required: true,
+ default: '0'
+ }
+})
+
+// 鎵撳嵃鐩稿叧
+const printPreviewVisible = ref(false);
+const printData = ref([]);
+
+// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
+const data = reactive({
+ searchForm: {
+ supplierName: "",
+ timeStr: "",
+ recordType: "",
+ }
+});
+const { searchForm } = toRefs(data);
+
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1;
+ getList();
+};
+const paginationChange = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+const getList = () => {
+ tableLoading.value = true;
+ getStockOutPage({ ...searchForm.value, ...page, type: props.type })
+ .then((res) => {
+ tableLoading.value = false;
+ tableData.value = res.data.records;
+ tableData.value.map((item) => {
+ item.children = [];
+ });
+ total.value = res.data.total;
+ })
+ .catch(() => {
+ tableLoading.value = false;
+ });
+};
+
+const getRecordType = (recordType) => {
+ return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
+}
+
+// 鑾峰彇鏉ユ簮绫诲瀷閫夐」
+const fetchStockRecordTypeOptions = () => {
+ if (props.type === '0') {
+ findAllQualifiedStockRecordTypeOptions()
+ .then(res => {
+ stockRecordTypeOptions.value = res.data;
+ })
+ return
+ }
+ findAllUnqualifiedStockRecordTypeOptions()
+ .then(res => {
+ stockRecordTypeOptions.value = res.data;
+ })
+}
+
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ // 杩囨护鎺夊瓙鏁版嵁
+ selectedRows.value = selection.filter((item) => item.id);
+ console.log("selection", selectedRows.value);
+};
+const expandedRowKeys = ref([]);
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ proxy.download("/stockmanagement/export", {}, "鍑哄簱鍙拌处.xlsx");
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
+// 鍒犻櫎
+const handleDelete = () => {
+ let ids = [];
+ if (selectedRows.value.length > 0) {
+ ids = selectedRows.value.map((item) => item.id);
+ } else {
+ proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+ return;
+ }
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ delStockOut(ids).then((res) => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
+// 鎵撳嵃鍔熻兘
+const handlePrint = () => {
+ if (selectedRows.value.length === 0) {
+ proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
+ return;
+ }
+ printData.value = [...selectedRows.value];
+ console.log('鎵撳嵃鏁版嵁:', printData.value);
+ printPreviewVisible.value = true;
+};
+
+// 鎵ц鎵撳嵃
+const executePrint = () => {
+ console.log('寮�濮嬫墽琛屾墦鍗帮紝鏁版嵁鏉℃暟:', printData.value.length);
+ console.log('鎵撳嵃鏁版嵁:', printData.value);
+
+ // 鍒涘缓涓�涓柊鐨勬墦鍗扮獥鍙�
+ const printWindow = window.open('', '_blank', 'width=800,height=600');
+
+ // 鏋勫缓鎵撳嵃鍐呭
+ let printContent = `
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <meta charset="UTF-8">
+ <title>鎵撳嵃棰勮</title>
+ <style>
+ body {
+ margin: 0;
+ padding: 0;
+ font-family: "SimSun", serif;
+ background: white;
+ }
+ .print-page {
+ width: 200mm;
+ height: 75mm;
+ padding: 10mm;
+ padding-left: 20mm;
+ background: white;
+ box-sizing: border-box;
+ page-break-after: always;
+ page-break-inside: avoid;
+ }
+ .print-page:last-child {
+ page-break-after: avoid;
+ }
+ .delivery-note {
+ width: 100%;
+ height: 100%;
+ font-size: 12px;
+ line-height: 1.2;
+ display: flex;
+ flex-direction: column;
+ color: #000;
+ }
+ .header {
+ text-align: center;
+ margin-bottom: 8px;
+ }
+ .company-name {
+ font-size: 18px;
+ font-weight: bold;
+ margin-bottom: 4px;
+ }
+ .document-title {
+ font-size: 16px;
+ font-weight: bold;
+ }
+ .info-section {
+ margin-bottom: 8px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+ .info-row {
+ line-height: 20px;
+ }
+ .label {
+ font-weight: bold;
+ width: 60px;
+ font-size: 12px;
+ }
+ .value {
+ margin-right: 20px;
+ min-width: 80px;
+ font-size: 12px;
+ }
+ .table-section {
+ margin-bottom: 40px;
+ // flex: 0.6;
+ }
+ .product-table {
+ width: 100%;
+ border-collapse: collapse;
+ border: 1px solid #000;
+ }
+ .product-table th, .product-table td {
+ border: 1px solid #000;
+ padding: 6px;
+ text-align: center;
+ font-size: 12px;
+ line-height: 1.4;
+ }
+ .product-table th {
+ font-weight: bold;
+ }
+ .total-value {
+ font-weight: bold;
+ }
+ .footer-section {
+ margin-top: auto;
+ }
+ .footer-row {
+ display: flex;
+ margin-bottom: 3px;
+ line-height: 22px;
+ justify-content: space-between;
+ }
+ .footer-item {
+ display: flex;
+ margin-right: 20px;
+ }
+ .footer-item .label {
+ font-weight: bold;
+ width: 80px;
+ font-size: 12px;
+ }
+ .footer-item .value {
+ min-width: 80px;
+ font-size: 12px;
+ }
+ .address-item .address-value {
+ min-width: 200px;
+ }
+ @media print {
+ body {
+ margin: 0;
+ padding: 0;
+ }
+ .print-page {
+ margin: 0;
+ padding: 10mm;
+ /* padding-left: 20mm; */
+ page-break-inside: avoid;
+ page-break-after: always;
+ }
+ .print-page:last-child {
+ page-break-after: avoid;
+ }
+ }
+ </style>
+ </head>
+ <body>
+ `;
+
+ // 涓烘瘡鏉℃暟鎹敓鎴愭墦鍗伴〉闈�
+ printData.value.forEach((item, index) => {
+ printContent += `
+ <div class="print-page">
+ <div class="delivery-note">
+ <div class="header">
+ <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
+ <div class="document-title">闆跺敭鍙戣揣鍗�</div>
+ </div>
+
+ <div class="info-section">
+ <div class="info-row">
+ <div>
+ <span class="label">鍙戣揣鏃ユ湡锛�</span>
+ <span class="value">${formatDate(item.createTime)}</span>
+ </div>
+ <div>
+ <span class="label">瀹㈡埛鍚嶇О锛�</span>
+ <span class="value">${item.supplierName || '寮犵埍鏈�'}</span>
+ </div>
+ </div>
+ <div class="info-row">
+ <span class="label">鍗曞彿锛�</span>
+ <span class="value">${item.code || ''}</span>
+ </div>
+ </div>
+
+ <div class="table-section">
+ <table class="product-table">
+ <thead>
+ <tr>
+ <th>浜у搧鍚嶇О</th>
+ <th>瑙勬牸鍨嬪彿</th>
+ <th>鍗曚綅</th>
+ <th>鍗曚环</th>
+ <th>闆跺敭鏁伴噺</th>
+ <th>闆跺敭閲戦</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>${item.productName || '鐮傜伆鐮�'}</td>
+ <td>${item.model || '鏍囧噯'}</td>
+ <td>${item.unit || '鍧�'}</td>
+ <td>${item.taxInclusiveUnitPrice || '0'}</td>
+ <td>${item.inboundNum || '2000'}</td>
+ <td>${item.taxInclusiveTotalPrice || '0'}</td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <td class="label">鍚堣</td>
+ <td class="total-value"></td>
+ <td class="total-value"></td>
+ <td class="total-value"></td>
+ <td class="total-value">${item.inboundNum || '2000'}</td>
+ <td class="total-value">${item.taxInclusiveTotalPrice || '0'}</td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
+
+ <div class="footer-section">
+ <div class="footer-row">
+ <div class="footer-item">
+ <span class="label">鏀惰揣鐢佃瘽锛�</span>
+ <span class="value"></span>
+ </div>
+ <div class="footer-item">
+ <span class="label">鏀惰揣浜猴細</span>
+ <span class="value"></span>
+ </div>
+ <div class="footer-item address-item">
+ <span class="label">鏀惰揣鍦板潃锛�</span>
+ <span class="value address-value"></span>
+ </div>
+ </div>
+ <div class="footer-row">
+ <div class="footer-item">
+ <span class="label">鎿嶄綔鍛橈細</span>
+ <span class="value">${userStore.nickName || '鎾曞紑鍓�'}</span>
+ </div>
+ <div class="footer-item">
+ <span class="label">鎵撳嵃鏃ユ湡锛�</span>
+ <span class="value">${formatDateTime(new Date())}</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ `;
+ });
+
+ printContent += `
+ </body>
+ </html>
+ `;
+
+ // 鍐欏叆鍐呭鍒版柊绐楀彛
+ printWindow.document.write(printContent);
+ printWindow.document.close();
+
+ // 绛夊緟鍐呭鍔犺浇瀹屾垚鍚庢墦鍗�
+ printWindow.onload = () => {
+ setTimeout(() => {
+ printWindow.print();
+ printWindow.close();
+ printPreviewVisible.value = false;
+ }, 500);
+ };
+};
+
+
+
+// 鏍煎紡鍖栨棩鏈�
+const formatDate = (dateString) => {
+ if (!dateString) return getCurrentDate();
+ const date = new Date(dateString);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
+ return `${year}/${month}/${day}`;
+};
+
+// 鏍煎紡鍖栨棩鏈熸椂闂�
+const formatDateTime = (date) => {
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
+ const hours = String(date.getHours()).padStart(2, "0");
+ const minutes = String(date.getMinutes()).padStart(2, "0");
+ const seconds = String(date.getSeconds()).padStart(2, "0");
+ return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
+};
+onMounted(() => {
+ getList();
+ fetchStockRecordTypeOptions();
+});
+</script>
+
+<style scoped lang="scss">
+.print-preview-dialog {
+ .el-dialog__body {
+ padding: 0;
+ max-height: 80vh;
+ overflow-y: auto;
+ }
+}
+
+.print-preview-container {
+ .print-preview-header {
+ padding: 15px;
+ border-bottom: 1px solid #e4e7ed;
+ text-align: center;
+
+ .el-button {
+ margin: 0 10px;
+ }
+ }
+
+ .print-preview-content {
+ padding: 20px;
+ background-color: #f5f5f5;
+ min-height: 400px;
+ }
+}
+
+.print-page {
+ width: 220mm;
+ height: 90mm;
+ padding: 10mm;
+ margin: 0 auto;
+ background: white;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+ margin-bottom: 10px;
+ box-sizing: border-box;
+}
+
+.delivery-note {
+ width: 100%;
+ height: 100%;
+ font-family: "SimSun", serif;
+ font-size: 10px;
+ line-height: 1.2;
+ display: flex;
+ flex-direction: column;
+}
+
+.header {
+ text-align: center;
+ margin-bottom: 8px;
+
+ .company-name {
+ font-size: 18px;
+ font-weight: bold;
+ margin-bottom: 4px;
+ }
+
+ .document-title {
+ font-size: 16px;
+ font-weight: bold;
+ }
+}
+
+.info-section {
+ margin-bottom: 8px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .info-row {
+ line-height: 20px;
+
+ .label {
+ font-weight: bold;
+ width: 60px;
+ font-size: 14px;
+ }
+
+ .value {
+ margin-right: 20px;
+ min-width: 80px;
+ font-size: 14px;
+ }
+ }
+}
+
+.table-section {
+ margin-bottom: 4px;
+ flex: 1;
+
+ .product-table {
+ width: 100%;
+ border-collapse: collapse;
+ border: 1px solid #000;
+
+ th, td {
+ border: 1px solid #000;
+ padding: 6px;
+ text-align: center;
+ font-size: 14px;
+ line-height: 1.4;
+ }
+
+ th {
+ font-weight: bold;
+ }
+
+ .total-label {
+ text-align: right;
+ font-weight: bold;
+ }
+
+ .total-value {
+ font-weight: bold;
+ }
+ }
+}
+
+.footer-section {
+ .footer-row {
+ display: flex;
+ margin-bottom: 3px;
+ line-height: 20px;
+ justify-content: space-between;
+
+ .footer-item {
+ display: flex;
+ margin-right: 20px;
+
+ .label {
+ font-weight: bold;
+ width: 80px;
+ font-size: 14px;
+ }
+
+ .value {
+ min-width: 80px;
+ font-size: 14px;
+ }
+
+ &.address-item {
+ .address-value {
+ min-width: 200px;
+ }
+ }
+ }
+ }
+}
+
+@media print {
+ .app-container {
+ display: none;
+ }
+
+ .print-page {
+ box-shadow: none;
+ margin: 0;
+ padding: 10mm;
+ padding-left: 20mm;
+ page-break-inside: avoid;
+ page-break-after: always;
+ }
+ .print-page:last-child {
+ page-break-after: avoid;
+ }
+}
+</style>
diff --git a/src/views/inventoryManagement/dispatchLog/index.vue b/src/views/inventoryManagement/dispatchLog/index.vue
index b485aa7..88d9984 100644
--- a/src/views/inventoryManagement/dispatchLog/index.vue
+++ b/src/views/inventoryManagement/dispatchLog/index.vue
@@ -1,858 +1,38 @@
+<!-- 鍦ㄤ綘鐨勪富椤甸潰涓� -->
<template>
- <div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">渚涘簲鍟嗗悕绉帮細</span>
- <el-input
- v-model="searchForm.supplierName"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- @change="handleQuery"
- clearable
- prefix-icon="Search"
- />
- <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"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
- >鎼滅储</el-button
- >
- </div>
- <div>
- <!-- <el-button type="primary" @click="openForm('add')">鏂板</el-button> -->
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- <el-button type="primary" plain @click="handlePrint">鎵撳嵃</el-button>
- </div>
- </div>
- <div class="table_list">
- <el-table
- :data="tableData"
- border
- v-loading="tableLoading"
- @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys"
- :row-key="(row) => row.id"
- show-summary
- style="width: 100%"
- :summary-method="summarizeMainTable"
- height="calc(100vh - 18.5em)"
- >
- <el-table-column align="center" type="selection" width="55" />
- <el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column
- label="鍑哄簱鏃ユ湡"
- prop="createTime"
- min-width="250"
- show-overflow-tooltip
- />
- <el-table-column
- label="渚涘簲鍟嗗悕绉�"
- prop="supplierName"
- width="250"
- show-overflow-tooltip
- />
- <el-table-column
- label="浜у搧澶х被"
- prop="productCategory"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="瑙勬牸鍨嬪彿"
- prop="specificationModel"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="鍗曚綅"
- prop="unit"
- width="80"
- show-overflow-tooltip
- />
- <el-table-column
- label="鍑哄簱鏁伴噺"
- prop="inboundNum"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="鍚◣鍗曚环(鍏�)"
- prop="taxInclusiveUnitPrice"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="鍚◣鎬讳环(鍏�)"
- prop="taxInclusiveTotalPrice"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="绋庣巼(%)"
- prop="taxRate"
- width="100"
- show-overflow-tooltip
- />
- <el-table-column
- label="涓嶅惈绋庢�讳环(鍏�)"
- prop="taxExclusiveTotalPrice"
- width="180"
- show-overflow-tooltip
- />
- <el-table-column
- label="鍑哄簱浜�"
- prop="createBy"
- width="80"
- show-overflow-tooltip
- />
- <!-- <el-table-column
- fixed="right"
- label="鎿嶄綔"
- min-width="60"
- align="center"
- >
- <template #default="scope">
- <el-button
- link
- type="primary"
- size="small"
- @click="openForm('edit', 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"
- />
- </div>
-
- <!-- 鎵撳嵃棰勮寮圭獥 -->
- <el-dialog
- v-model="printPreviewVisible"
- title="鎵撳嵃棰勮"
- width="90%"
- :close-on-click-modal="false"
- class="print-preview-dialog"
- >
- <div class="print-preview-container">
- <div class="print-preview-header">
- <el-button type="primary" @click="executePrint">鎵ц鎵撳嵃</el-button>
- <el-button @click="printPreviewVisible = false">鍏抽棴棰勮</el-button>
- </div>
- <div class="print-preview-content">
- <div v-if="printData.length === 0" style="text-align: center; padding: 50px; color: #999;">
- 鏆傛棤鎵撳嵃鏁版嵁
- </div>
- <div v-else style="text-align: center; padding: 10px; color: #666; font-size: 14px; background: #e8f4fd; margin-bottom: 10px;">
- 鍏� {{ printData.length }} 鏉℃暟鎹緟鎵撳嵃
- </div>
- <div v-for="(item, index) in printData" :key="index" class="print-page">
- <div class="delivery-note">
- <div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
- <div class="document-title">闆跺敭鍙戣揣鍗�</div>
- </div>
-
- <div class="info-section">
- <div class="info-row">
- <div>
- <span class="label">鍙戣揣鏃ユ湡锛�</span>
- <span class="value">{{ formatDate(item.createTime) }}</span>
- </div>
- <div>
-
- <span class="label">瀹㈡埛鍚嶇О锛�</span>
- <span class="value">{{ item.supplierName || '寮犵埍鏈�' }}</span>
- </div>
- </div>
- <div class="info-row">
- <span class="label">鍗曞彿锛�</span>
- <span class="value">{{ item.code }}</span>
- </div>
- </div>
-
- <div class="table-section">
- <table class="product-table">
- <thead>
- <tr>
- <th>浜у搧鍚嶇О</th>
- <th>瑙勬牸鍨嬪彿</th>
- <th>鍗曚綅</th>
- <th>鍗曚环</th>
- <th>闆跺敭鏁伴噺</th>
- <th>闆跺敭閲戦</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{ item.productCategory || '鐮傜伆鐮�' }}</td>
- <td>{{ item.specificationModel || '鏍囧噯' }}</td>
- <td>{{ item.unit || '鍧�' }}</td>
- <td>{{ item.taxInclusiveUnitPrice || '0' }}</td>
- <td>{{ item.inboundNum || '2000' }}</td>
- <td>{{ item.taxInclusiveTotalPrice || '0' }}</td>
- </tr>
- </tbody>
- <tfoot>
- <tr>
- <td class="label">鍚堣</td>
- <td class="total-value"></td>
- <td class="total-value"></td>
- <td class="total-value"></td>
- <td class="total-value">{{ item.inboundNum || '2000' }}</td>
- <td class="total-value">{{ item.taxInclusiveTotalPrice || '0' }}</td>
- </tr>
- </tfoot>
- </table>
- </div>
-
- <div class="footer-section">
- <div class="footer-row">
- <div class="footer-item">
- <span class="label">鏀惰揣鐢佃瘽锛�</span>
- <span class="value"></span>
- </div>
- <div class="footer-item">
- <span class="label">鏀惰揣浜猴細</span>
- <span class="value"></span>
- </div>
- <div class="footer-item address-item">
- <span class="label">鏀惰揣鍦板潃锛�</span>
- <span class="value address-value"></span>
- </div>
- </div>
- <div class="footer-row">
- <div class="footer-item">
- <span class="label">鎿嶄綔鍛橈細</span>
- <span class="value">{{ userStore.nickName || '鎾曞紑鍓�' }}</span>
- </div>
- <div class="footer-item">
- <span class="label">鎵撳嵃鏃ユ湡锛�</span>
- <span class="value">{{ formatDateTime(new Date()) }}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </el-dialog>
-
-
- </div>
+ <div class="app-container">
+ <el-tabs v-model="activeTab" @tab-change="handleTabChange">
+ <el-tab-pane v-for="tab in tabs"
+ :label="tab.label"
+ :name="tab.name"
+ :key="tab.name">
+ <record :type="tab.type" v-if="activeTab === tab.name" />
+ </el-tab-pane>
+ </el-tabs>
+ </div>
</template>
<script setup>
-import pagination from "@/components/PIMTable/Pagination.vue";
-import { ref } from "vue";
-import { ElMessageBox } from "element-plus";
-import useUserStore from "@/store/modules/user";
-import { getCurrentDate } from "@/utils/index.js";
-import {
- getStockOutPage,
- delStockOut,
-} from "@/api/inventoryManagement/stockOut.js";
+import Record from "@/views/inventoryManagement/dispatchLog/Record.vue";
+const activeTab = ref('qualified')
+const type = ref(0)
+const tabs = computed(() => {
+ return [
+ {
+ label: '鍚堟牸鍑哄簱',
+ name: 'qualified',
+ type: '0'
+ },
+ {
+ label: '涓嶅悎鏍煎嚭搴�',
+ name: 'unqualified',
+ type: '1'
+ }
+ ]
+})
-const userStore = useUserStore();
-const { proxy } = getCurrentInstance();
-const tableData = ref([]);
-const selectedRows = ref([]);
-const tableLoading = ref(false);
-const page = reactive({
- current: 1,
- size: 100,
-});
-const total = ref(0);
-
-// 鎵撳嵃鐩稿叧
-const printPreviewVisible = ref(false);
-const printData = ref([]);
-
-// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
-const data = reactive({
- searchForm: {
- supplierName: "",
- timeStr: "",
- },
- form: {
- supplierId: null,
- supplierName: '',
- productId: null,
- productName: '',
- userId: userStore.userId,
- nickName: '',
- model: '',
- productModelId: null,
- unit: '',
- productrecordId: null,
- taxInclusiveUnitPrice: '',
- taxInclusiveTotalPrice: '',
- taxRate: '',
- taxExclusiveTotalPrice: '',
- inboundTime: '',
- inboundBatch: '',
- inboundQuantity: ''
- },
-});
-const { searchForm } = toRefs(data);
-
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const paginationChange = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- getStockOutPage({ ...searchForm.value, ...page })
- .then((res) => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- tableData.value.map((item) => {
- item.children = [];
- });
- total.value = res.data.total;
- })
- .catch(() => {
- tableLoading.value = false;
- });
-};
-
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
- // 杩囨护鎺夊瓙鏁版嵁
- selectedRows.value = selection.filter((item) => item.id);
- console.log("selection", selectedRows.value);
-};
-const expandedRowKeys = ref([]);
-
-// 涓昏〃鍚堣鏂规硶
-const summarizeMainTable = (param) => {
- return proxy.summarizeTable(param, [
- "contractAmount",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- ]);
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- proxy.download("/stockmanagement/export", {}, "鍑哄簱鍙拌处.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-// 鍒犻櫎
-const handleDelete = () => {
- let ids = [];
- if (selectedRows.value.length > 0) {
- ids = selectedRows.value.map((item) => item.id);
- } else {
- proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
- return;
- }
- ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- delStockOut({ids:ids}).then((res) => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-// 鎵撳嵃鍔熻兘
-const handlePrint = () => {
- if (selectedRows.value.length === 0) {
- proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
- return;
- }
- printData.value = [...selectedRows.value];
- console.log('鎵撳嵃鏁版嵁:', printData.value);
- printPreviewVisible.value = true;
-};
-
-// 鎵ц鎵撳嵃
-const executePrint = () => {
- console.log('寮�濮嬫墽琛屾墦鍗帮紝鏁版嵁鏉℃暟:', printData.value.length);
- console.log('鎵撳嵃鏁版嵁:', printData.value);
-
- // 鍒涘缓涓�涓柊鐨勬墦鍗扮獥鍙�
- const printWindow = window.open('', '_blank', 'width=800,height=600');
-
- // 鏋勫缓鎵撳嵃鍐呭
- let printContent = `
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>鎵撳嵃棰勮</title>
- <style>
- body {
- margin: 0;
- padding: 0;
- font-family: "SimSun", serif;
- background: white;
- }
- .print-page {
- width: 200mm;
- height: 75mm;
- padding: 10mm;
- padding-left: 20mm;
- background: white;
- box-sizing: border-box;
- page-break-after: always;
- page-break-inside: avoid;
- }
- .print-page:last-child {
- page-break-after: avoid;
- }
- .delivery-note {
- width: 100%;
- height: 100%;
- font-size: 12px;
- line-height: 1.2;
- display: flex;
- flex-direction: column;
- color: #000;
- }
- .header {
- text-align: center;
- margin-bottom: 8px;
- }
- .company-name {
- font-size: 18px;
- font-weight: bold;
- margin-bottom: 4px;
- }
- .document-title {
- font-size: 16px;
- font-weight: bold;
- }
- .info-section {
- margin-bottom: 8px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .info-row {
- line-height: 20px;
- }
- .label {
- font-weight: bold;
- width: 60px;
- font-size: 12px;
- }
- .value {
- margin-right: 20px;
- min-width: 80px;
- font-size: 12px;
- }
- .table-section {
- margin-bottom: 40px;
- // flex: 0.6;
- }
- .product-table {
- width: 100%;
- border-collapse: collapse;
- border: 1px solid #000;
- }
- .product-table th, .product-table td {
- border: 1px solid #000;
- padding: 6px;
- text-align: center;
- font-size: 12px;
- line-height: 1.4;
- }
- .product-table th {
- font-weight: bold;
- }
- .total-value {
- font-weight: bold;
- }
- .footer-section {
- margin-top: auto;
- }
- .footer-row {
- display: flex;
- margin-bottom: 3px;
- line-height: 22px;
- justify-content: space-between;
- }
- .footer-item {
- display: flex;
- margin-right: 20px;
- }
- .footer-item .label {
- font-weight: bold;
- width: 80px;
- font-size: 12px;
- }
- .footer-item .value {
- min-width: 80px;
- font-size: 12px;
- }
- .address-item .address-value {
- min-width: 200px;
- }
- @media print {
- body {
- margin: 0;
- padding: 0;
- }
- .print-page {
- margin: 0;
- padding: 10mm;
- /* padding-left: 20mm; */
- page-break-inside: avoid;
- page-break-after: always;
- }
- .print-page:last-child {
- page-break-after: avoid;
- }
- }
- </style>
- </head>
- <body>
- `;
-
- // 涓烘瘡鏉℃暟鎹敓鎴愭墦鍗伴〉闈�
- printData.value.forEach((item, index) => {
- printContent += `
- <div class="print-page">
- <div class="delivery-note">
- <div class="header">
- <div class="company-name">榧庤瘹鐟炲疄涓氭湁闄愯矗浠诲叕鍙�</div>
- <div class="document-title">闆跺敭鍙戣揣鍗�</div>
- </div>
-
- <div class="info-section">
- <div class="info-row">
- <div>
- <span class="label">鍙戣揣鏃ユ湡锛�</span>
- <span class="value">${formatDate(item.createTime)}</span>
- </div>
- <div>
- <span class="label">瀹㈡埛鍚嶇О锛�</span>
- <span class="value">${item.supplierName || '寮犵埍鏈�'}</span>
- </div>
- </div>
- <div class="info-row">
- <span class="label">鍗曞彿锛�</span>
- <span class="value">${item.code || ''}</span>
- </div>
- </div>
-
- <div class="table-section">
- <table class="product-table">
- <thead>
- <tr>
- <th>浜у搧鍚嶇О</th>
- <th>瑙勬牸鍨嬪彿</th>
- <th>鍗曚綅</th>
- <th>鍗曚环</th>
- <th>闆跺敭鏁伴噺</th>
- <th>闆跺敭閲戦</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>${item.productCategory || '鐮傜伆鐮�'}</td>
- <td>${item.specificationModel || '鏍囧噯'}</td>
- <td>${item.unit || '鍧�'}</td>
- <td>${item.taxInclusiveUnitPrice || '0'}</td>
- <td>${item.inboundNum || '2000'}</td>
- <td>${item.taxInclusiveTotalPrice || '0'}</td>
- </tr>
- </tbody>
- <tfoot>
- <tr>
- <td class="label">鍚堣</td>
- <td class="total-value"></td>
- <td class="total-value"></td>
- <td class="total-value"></td>
- <td class="total-value">${item.inboundNum || '2000'}</td>
- <td class="total-value">${item.taxInclusiveTotalPrice || '0'}</td>
- </tr>
- </tfoot>
- </table>
- </div>
-
- <div class="footer-section">
- <div class="footer-row">
- <div class="footer-item">
- <span class="label">鏀惰揣鐢佃瘽锛�</span>
- <span class="value"></span>
- </div>
- <div class="footer-item">
- <span class="label">鏀惰揣浜猴細</span>
- <span class="value"></span>
- </div>
- <div class="footer-item address-item">
- <span class="label">鏀惰揣鍦板潃锛�</span>
- <span class="value address-value"></span>
- </div>
- </div>
- <div class="footer-row">
- <div class="footer-item">
- <span class="label">鎿嶄綔鍛橈細</span>
- <span class="value">${userStore.nickName || '鎾曞紑鍓�'}</span>
- </div>
- <div class="footer-item">
- <span class="label">鎵撳嵃鏃ユ湡锛�</span>
- <span class="value">${formatDateTime(new Date())}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- `;
- });
-
- printContent += `
- </body>
- </html>
- `;
-
- // 鍐欏叆鍐呭鍒版柊绐楀彛
- printWindow.document.write(printContent);
- printWindow.document.close();
-
- // 绛夊緟鍐呭鍔犺浇瀹屾垚鍚庢墦鍗�
- printWindow.onload = () => {
- setTimeout(() => {
- printWindow.print();
- printWindow.close();
- printPreviewVisible.value = false;
- }, 500);
- };
-};
-
-
-
-// 鏍煎紡鍖栨棩鏈�
-const formatDate = (dateString) => {
- if (!dateString) return getCurrentDate();
- const date = new Date(dateString);
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, "0");
- const day = String(date.getDate()).padStart(2, "0");
- return `${year}/${month}/${day}`;
-};
-
-// 鏍煎紡鍖栨棩鏈熸椂闂�
-const formatDateTime = (date) => {
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, "0");
- const day = String(date.getDate()).padStart(2, "0");
- const hours = String(date.getHours()).padStart(2, "0");
- const minutes = String(date.getMinutes()).padStart(2, "0");
- const seconds = String(date.getSeconds()).padStart(2, "0");
- return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
-};
-onMounted(() => {
- getList();
-});
+const handleTabChange = (tabName) => {
+ activeTab.value = tabName;
+ type.value = tabName === 'qualified' ? 0 : 1
+}
</script>
-
-<style scoped lang="scss">
-.print-preview-dialog {
- .el-dialog__body {
- padding: 0;
- max-height: 80vh;
- overflow-y: auto;
- }
-}
-
-.print-preview-container {
- .print-preview-header {
- padding: 15px;
- border-bottom: 1px solid #e4e7ed;
- text-align: center;
-
- .el-button {
- margin: 0 10px;
- }
- }
-
- .print-preview-content {
- padding: 20px;
- background-color: #f5f5f5;
- min-height: 400px;
- }
-}
-
-.print-page {
- width: 220mm;
- height: 90mm;
- padding: 10mm;
- margin: 0 auto;
- background: white;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- margin-bottom: 10px;
- box-sizing: border-box;
-}
-
-.delivery-note {
- width: 100%;
- height: 100%;
- font-family: "SimSun", serif;
- font-size: 10px;
- line-height: 1.2;
- display: flex;
- flex-direction: column;
-}
-
-.header {
- text-align: center;
- margin-bottom: 8px;
-
- .company-name {
- font-size: 18px;
- font-weight: bold;
- margin-bottom: 4px;
- }
-
- .document-title {
- font-size: 16px;
- font-weight: bold;
- }
-}
-
-.info-section {
- margin-bottom: 8px;
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- .info-row {
- line-height: 20px;
-
- .label {
- font-weight: bold;
- width: 60px;
- font-size: 14px;
- }
-
- .value {
- margin-right: 20px;
- min-width: 80px;
- font-size: 14px;
- }
- }
-}
-
-.table-section {
- margin-bottom: 4px;
- flex: 1;
-
- .product-table {
- width: 100%;
- border-collapse: collapse;
- border: 1px solid #000;
-
- th, td {
- border: 1px solid #000;
- padding: 6px;
- text-align: center;
- font-size: 14px;
- line-height: 1.4;
- }
-
- th {
- font-weight: bold;
- }
-
- .total-label {
- text-align: right;
- font-weight: bold;
- }
-
- .total-value {
- font-weight: bold;
- }
- }
-}
-
-.footer-section {
- .footer-row {
- display: flex;
- margin-bottom: 3px;
- line-height: 20px;
- justify-content: space-between;
-
- .footer-item {
- display: flex;
- margin-right: 20px;
-
- .label {
- font-weight: bold;
- width: 80px;
- font-size: 14px;
- }
-
- .value {
- min-width: 80px;
- font-size: 14px;
- }
-
- &.address-item {
- .address-value {
- min-width: 200px;
- }
- }
- }
- }
-}
-
-@media print {
- .app-container {
- display: none;
- }
-
- .print-page {
- box-shadow: none;
- margin: 0;
- padding: 10mm;
- padding-left: 20mm;
- page-break-inside: avoid;
- page-break-after: always;
- }
- .print-page:last-child {
- page-break-after: avoid;
- }
-}
-</style>
diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
new file mode 100644
index 0000000..a477547
--- /dev/null
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -0,0 +1,251 @@
+<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="table_list">
+ <el-table :data="tableData"
+ border
+ v-loading="tableLoading"
+ @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys"
+ :row-key="row => row.id"
+ style="width: 100%"
+ height="calc(100vh - 18.5em)">
+ <el-table-column align="center"
+ type="selection"
+ width="55"/>
+ <el-table-column align="center"
+ label="搴忓彿"
+ type="index"
+ width="60"/>
+ <el-table-column label="鍏ュ簱鎵规"
+ prop="inboundBatches"
+ width="280"
+ show-overflow-tooltip/>
+ <el-table-column label="鍏ュ簱鏃堕棿"
+ prop="createTime"
+ show-overflow-tooltip/>
+ <el-table-column label="浜у搧澶х被"
+ prop="productName"
+ show-overflow-tooltip/>
+ <el-table-column label="瑙勬牸鍨嬪彿"
+ prop="model"
+ show-overflow-tooltip/>
+ <el-table-column label="鍗曚綅"
+ prop="unit"
+ show-overflow-tooltip/>
+ <el-table-column label="鍏ュ簱鏁伴噺"
+ prop="stockInNum"
+ show-overflow-tooltip/>
+ <el-table-column label="鍏ュ簱浜�"
+ prop="createBy"
+ 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>
+ <pagination v-show="total > 0"
+ :total="total"
+ layout="total, sizes, prev, pager, next, jumper"
+ :page="page.current"
+ :limit="page.size"
+ @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 {
+ findAllQualifiedStockRecordTypeOptions,
+ findAllUnqualifiedStockRecordTypeOptions
+} from "@/api/basicData/enum.js";
+
+const {proxy} = getCurrentInstance();
+
+const props = defineProps({
+ type: {
+ type: String,
+ required: true,
+ default: '0'
+ }
+})
+
+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 data = reactive({
+ searchForm: {
+ productName: "",
+ timeStr: "",
+ recordType: "",
+ },
+});
+const {searchForm} = toRefs(data);
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1;
+ getList();
+};
+
+const getRecordType = (recordType) => {
+ return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
+}
+
+const pageProductChange = obj => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList();
+};
+
+const getList = () => {
+ tableLoading.value = true;
+ const params = {...page, type: props.type};
+ params.timeStr = searchForm.value.timeStr;
+ params.productName = searchForm.value.productName;
+ getStockInRecordListPage(params)
+ .then(res => {
+ tableData.value = res.data.records;
+ }).finally(() => {
+ tableLoading.value = false;
+ })
+};
+
+// 鑾峰彇鏉ユ簮绫诲瀷閫夐」
+const fetchStockRecordTypeOptions = () => {
+ if (props.type === '0') {
+ findAllQualifiedStockRecordTypeOptions()
+ .then(res => {
+ stockRecordTypeOptions.value = res.data;
+ })
+ return
+ }
+ findAllUnqualifiedStockRecordTypeOptions()
+ .then(res => {
+ stockRecordTypeOptions.value = res.data;
+ })
+}
+
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = selection => {
+ selectedRows.value = selection.filter(item => item.id);
+};
+
+const expandedRowKeys = ref([]);
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
+ let exportUrl = "/stockin/export";
+ proxy.download(exportUrl, {}, "鍏ュ簱鍙拌处.xlsx");
+ })
+ .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",
+ })
+ .then(() => {
+ batchDeleteStockInRecords(ids)
+ .then(() => {
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ getList();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ });
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
+onMounted(() => {
+ getList();
+ fetchStockRecordTypeOptions();
+});
+</script>
+
+<style scoped lang="scss"></style>
+
+
+
diff --git a/src/views/inventoryManagement/receiptManagement/components/formDia.vue b/src/views/inventoryManagement/receiptManagement/components/formDia.vue
deleted file mode 100644
index 5ea86b2..0000000
--- a/src/views/inventoryManagement/receiptManagement/components/formDia.vue
+++ /dev/null
@@ -1,400 +0,0 @@
-<template>
- <el-dialog v-model="dialogFormVisible" :title="getDialogTitle()" width="70%"
- @close="closeDia">
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
- <el-form-item label="閲囪喘璁㈠崟鍙�" prop="purchaseContractNumber">
- <el-select
- v-model="form.purchaseContractNumber"
- placeholder="璇烽�夋嫨閲囪喘璁㈠崟鍙�"
- clearable
- filterable
- :loading="loadingPurchaseOptions"
- @change="handlePurchaseChange"
- :disabled="operationType === 'edit'"
- style="width: 100%"
- >
- <el-option
- v-for="item in purchaseOptions"
- :key="item.purchaseContractNumber"
- :label="formatPurchaseOption(item)"
- :value="item.purchaseContractNumber"
- />
- </el-select>
- </el-form-item>
- <el-table
- :data="productList"
- border
- v-loading="loadingProducts"
- @selection-change="handleSelectionChange"
- >
- <el-table-column align="center" type="selection" width="55" />
- <el-table-column
- align="center"
- label="搴忓彿"
- type="index"
- width="60"
- />
- <el-table-column label="浜у搧澶х被" prop="productCategory" />
- <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
- <el-table-column label="鍗曚綅" prop="unit" width="70" />
- <!-- <el-table-column label="渚涘簲鍟�" prop="supplierName" width="100" /> -->
- <el-table-column label="閲囪喘鏁伴噺" prop="quantity" width="100" />
- <el-table-column label="寰呭叆搴撴暟閲�" prop="quantity0" width="100" />
- <el-table-column label="鏈鍏ュ簱鏁伴噺" prop="quantityStock" width="150">
- <template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.quantityStock" @change="() => calculateTotalPrice(scope.row)" />
- </template>
- </el-table-column>
- <el-table-column label="绋庣巼(%)" prop="taxRate" width="120" />
- <el-table-column label="鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" width="150">
- <template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.taxInclusiveUnitPrice" @change="() => calculateTotalPrice(scope.row)" :disabled="operationType === 'edit'"/>
- </template>
- </el-table-column>
- <el-table-column
- label="鎬讳环(鍏�)"
- :formatter="formattedNumber"
- prop="taxInclusiveTotalPrice"
- width="150"
- >
- </el-table-column>
- </el-table>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
-</template>
-
-<script setup>
-import { ref, reactive, toRefs, getCurrentInstance } from 'vue'
-import useUserStore from '@/store/modules/user'
-import {
- updateStockIn,
- addSutockIn,
- selectProductRecordListByPuechaserId
-} from "@/api/inventoryManagement/stockIn.js";
-import { purchaseListPage } from "@/api/procurementManagement/procurementLedger.js";
-
-const userStore = useUserStore()
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close', 'success'])
-
-const operationType = ref('')// 鎿嶄綔绫诲瀷: 'add' 鎴� 'edit'
-const dialogFormVisible = ref(false)// 寮规鏄剧ず鐘舵��
-const productList = ref([]);// 浜у搧鍒楄〃鏁版嵁
-const loadingProducts = ref(false);// 浜у搧鍔犺浇鐘舵��
-const selectedRows = ref([]) // 浜у搧琛ㄦ牸閫変腑琛�
-const purchaseOptions = ref([])
-const loadingPurchaseOptions = ref(false)
-const loading = ref(false);
-
-const data = reactive({
- form: {
- id: null,
- purchaseContractNumber: '', // 閲囪喘璁㈠崟鍙�
- supplierId: null, // 渚涘簲鍟咺D
- supplierName: '', // 渚涘簲鍟嗗悕绉�
- inboundTime: '', // 鍏ュ簱鏃堕棿
- inboundBatch: '', // 鍏ュ簱鎵规
- recorderId: userStore.userId, // 褰曞叆浜篒D
- recorderName: userStore.name, // 褰曞叆浜哄鍚�
- entryDate: getCurrentDate(), // 褰曞叆鏃ユ湡
- remark: '', // 澶囨敞
- },
- rules: {
- purchaseContractNumber: [{ required: true, message: "璇疯緭鍏ラ噰璐悎鍚屽彿", trigger: "blur" }],
- supplierId: [{ required: true, message: "璇烽�夋嫨渚涘簲鍟�", trigger: "change" }],
- inboundTime: [{ required: true, message: "璇烽�夋嫨鍏ュ簱鏃堕棿", trigger: "change" }],
- inboundBatch: [{ required: true, message: "璇疯緭鍏ュ叆搴撴壒娆�", trigger: "blur" }]
- }
-})
-const { form, rules } = toRefs(data)
-
-// 鍔ㄦ�佽绠楀璇濇鏍囬
-const getDialogTitle = () => {
- return operationType.value === 'add' ? '鏂板鍏ュ簱' : '缂栬緫鍏ュ簱'
-}
-
-const formatPurchaseOption = (item = {}) => {
- const contract = item.purchaseContractNumber || '--';
- const supplier = item.supplierName ? ` 路 ${item.supplierName}` : '';
- return `${contract}${supplier}`;
-};
-
-const loadPurchaseOptions = async (keyword = '') => {
- try {
- loadingPurchaseOptions.value = true;
- const res = await purchaseListPage({
- current: -1,
- size: -1,
- purchaseContractNumber: keyword,
- });
- const records = res.data?.records || [];
- purchaseOptions.value = records;
- if (
- form.value.purchaseContractNumber &&
- !purchaseOptions.value.find(
- (item) => item.purchaseContractNumber === form.value.purchaseContractNumber
- )
- ) {
- purchaseOptions.value.push({
- purchaseContractNumber: form.value.purchaseContractNumber,
- supplierName: form.value.supplierName,
- supplierId: form.value.supplierId,
- });
- }
- } finally {
- loadingPurchaseOptions.value = false;
- }
-};
-
-const handlePurchaseChange = (value) => {
- form.value.purchaseContractNumber = value || '';
- const matched = purchaseOptions.value.find(
- (item) => item.purchaseContractNumber === value
- );
- if (matched) {
- form.value.supplierName = matched.supplierName || form.value.supplierName;
- form.value.supplierId = matched.supplierId || form.value.supplierId;
- }
- if (!value) {
- productList.value = [];
- return;
- }
- fetchProductsByContract();
-};
-
-const exceedsAddLimit = (product) => {
- const stock = Number(product?.quantityStock ?? 0);
- const waiting = Number(product?.quantity0 ?? 0);
- if (!Number.isFinite(stock) || !Number.isFinite(waiting)) {
- return false;
- }
- return stock > waiting;
-};
-
-const exceedsEditLimit = (product) => {
- const stock = Number(product?.quantityStock ?? 0);
- const waiting = Number(product?.quantity0 ?? 0);
- const original = Number(product?.originalQuantityStock ?? 0);
- if (!Number.isFinite(stock) || !Number.isFinite(waiting) || !Number.isFinite(original)) {
- return false;
- }
- return stock > waiting + original;
-};
-
-const formattedNumber = (row, column, cellValue) => {
- return parseFloat(cellValue).toFixed(2);
-};
-
-// 璁$畻鎬讳环
-const calculateTotalPrice = (row) => {
- const quantityStock = Number(row?.quantityStock ?? 0);
- const taxInclusiveUnitPrice = Number(row?.taxInclusiveUnitPrice ?? 0);
-
- if (Number.isFinite(quantityStock) && Number.isFinite(taxInclusiveUnitPrice)) {
- row.taxInclusiveTotalPrice = quantityStock * taxInclusiveUnitPrice;
- } else {
- row.taxInclusiveTotalPrice = 0;
- }
-};
-
-const fetchProductsByContract = async () => {
- if (!form.value.purchaseContractNumber) {
- proxy.$modal.msgWarning('璇烽�夋嫨鍚堝悓鍙�')
- return
- }
- try {
- loadingProducts.value = true
- const productRes = await selectProductRecordListByPuechaserId({
- purchaseContractNumber: form.value.purchaseContractNumber
- });
- if (!productRes.data || productRes.data.length === 0) {
- proxy.$modal.msgWarning('璇ュ悎鍚屼笅娌℃湁浜у搧璁板綍')
- productList.value = [];
- return
- }
- productList.value = productRes.data.map(item => ({
- ...item,
- quantityStock: 0,
- taxInclusiveUnitPrice: Number(item?.taxInclusiveUnitPrice ?? 0),
- taxInclusiveTotalPrice: 0,
- originalQuantityStock: Number(item.quantityStock ?? item.inboundQuantity ?? 0),
- }))
- } catch (error) {
- console.error('鏌ヨ浜у搧璁板綍澶辫触:', error)
- proxy.$modal.msgError('鏌ヨ浜у搧璁板綍澶辫触')
- productList.value = [];
- } finally {
- loadingProducts.value = false
- }
-}
-
-const updatePro = async () => {
- if (selectedRows.value.length === 0) {
- proxy.$modal.msgWarning('璇峰厛閫夋嫨浜у搧');
- return;
- }
- const target = selectedRows.value[0];
- const stock = Number(target?.quantityStock ?? 0);
- if (!Number.isFinite(stock) || stock <= 0) {
- proxy.$modal.msgWarning('璇峰~鍐欐湁鏁堢殑鍏ュ簱鏁伴噺');
- return;
- }
- if (exceedsEditLimit(target)) {
- proxy.$modal.msgError('鏈鍏ュ簱鏁伴噺涓嶈兘瓒呰繃鍘熷叆搴撴暟閲忎笌寰呭叆搴撴暟閲忎箣鍜�');
- return;
- }
- const stockInData = {
- id: selectedRows.value[0].recordId,
- quantityStock: Number(selectedRows.value[0].quantityStock),
- };
- await updateStockIn(stockInData)
- proxy.$modal.msgSuccess('淇敼鍏ュ簱鎴愬姛')
- closeDia()
- emit('success')
-}
-
-const submitForm = async () => {
- if (selectedRows.value.length === 0) {
- proxy.$modal.msgWarning('璇峰厛閫夋嫨閲囪喘鍚堝悓骞堕�夋嫨浜у搧')
- return
- }
- if(operationType.value !== 'add'){
- await updatePro()
- return
- }
- try {
- await proxy.$refs.formRef.validate()
- const invalidProducts = selectedRows.value.filter((product) => {
- const stock = Number(product?.quantityStock ?? 0);
- if (!Number.isFinite(stock) || stock <= 0) {
- return true;
- }
- return exceedsAddLimit(product);
- })
-
- if (invalidProducts.length > 0) {
- proxy.$modal.msgError('鏈鍏ュ簱鏁伴噺闇�澶т簬0锛屼笖涓嶈兘瓒呰繃寰呭叆搴撴暟閲�')
- return
- }
-
- const stockInData = {
- ...form.value,
- inboundTime: formatDateTime(form.value.inboundTime),
- nickName: userStore.nickName,
- details: selectedRows.value.map(product => ({
- id: product.id,
- inboundQuantity: Number(product.quantityStock),
- unitPrice: Number(product.taxInclusiveUnitPrice),
- taxRate: Number(product.taxRate),
- taxInclusiveTotalPrice: Number(product.taxInclusiveTotalPrice)
- })),
- };
- loading.value = true
- await addSutockIn(stockInData)
-
- proxy.$modal.msgSuccess('鏂板鍏ュ簱鎴愬姛')
- closeDia()
- emit('success')
-
- } catch (error) {
- console.error('鎻愪氦澶辫触:', error)
- if (!error.errors) {
- proxy.$modal.msgError('鎿嶄綔澶辫触锛岃閲嶈瘯')
- }
- } finally {
- loading.value = false
- }
-}
-
-const closeDia = () => {
- proxy.$refs.formRef.resetFields()
- dialogFormVisible.value = false
- emit('close')
-}
-
-const handleSelectionChange = (selection) => {
- selectedRows.value = selection.filter(item => item.id);
-}
-
-function formatDateTime(date = new Date(), includeTime = true) {
- const d = new Date(date);
- const year = d.getFullYear();
- const month = String(d.getMonth() + 1).padStart(2, '0');
- const day = String(d.getDate()).padStart(2, '0');
-
- if (!includeTime) {
- return `${year}-${month}-${day}`;
- }
-
- const hours = String(d.getHours()).padStart(2, '0');
- const minutes = String(d.getMinutes()).padStart(2, '0');
- const seconds = String(d.getSeconds()).padStart(2, '0');
-
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
-}
-
-function getCurrentDate() {
- return formatDateTime(new Date(), false);
-}
-
-const openDialog = async (type, row) => {
- operationType.value = type
- dialogFormVisible.value = true
- selectedRows.value = []
- await loadPurchaseOptions();
-
- if (type === 'add') {
- form.value = {
- id: null,
- purchaseContractNumber: '',
- supplierId: null,
- supplierName: '',
- inboundTime: '',
- inboundBatch: '',
- recorderId: userStore.userId,
- recorderName: userStore.name,
- entryDate: getCurrentDate(),
- remark: ''
- }
- productList.value = []
- } else {
- form.value = JSON.parse(JSON.stringify(row))
- try {
- loadingProducts.value = true
- const res = await selectProductRecordListByPuechaserId({
- purchaseContractNumber: form.value.purchaseContractNumber,
- id: row.id
- });
- productList.value = res.data.map(item => ({
- ...item,
- quantityStock: Number(item.quantityStock ?? item.inboundQuantity ?? row.inboundNum ?? 0),
- taxInclusiveUnitPrice: Number(item?.taxInclusiveUnitPrice ?? 0),
- taxInclusiveTotalPrice: Number(item?.quantityStock ?? 0) * Number(item?.taxInclusiveUnitPrice ?? 0),
- originalQuantityStock: Number(item.quantityStock ?? item.inboundQuantity ?? row.inboundNum ?? 0),
- }))
- selectedRows.value = productList.value
- } catch (error) {
- console.error('鍔犺浇浜у搧澶辫触:', error)
- proxy.$modal.msgError('鍔犺浇浜у搧澶辫触')
- productList.value = []
- } finally {
- loadingProducts.value = false
- }
- }
-}
-
-defineExpose({
- openDialog,
-})
-</script>
-
-<style scoped lang="scss"></style>
-
-
-
diff --git a/src/views/inventoryManagement/receiptManagement/components/formDiaProduct.vue b/src/views/inventoryManagement/receiptManagement/components/formDiaProduct.vue
deleted file mode 100644
index 6048e18..0000000
--- a/src/views/inventoryManagement/receiptManagement/components/formDiaProduct.vue
+++ /dev/null
@@ -1,302 +0,0 @@
-<template>
- <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '鏂板鑷畾涔夊叆搴�' : '缂栬緫鑷畾涔夊叆搴�'" width="70%"
- @close="closeDia">
- <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
- <div style="margin-bottom: 10px;" v-if="operationType === 'add'">
- <el-button type="primary" @click="addProductRow">鏂板</el-button>
- </div>
- <el-table
- :data="productList"
- border
- v-loading="loadingProducts"
- >
- <el-table-column
- align="center"
- label="搴忓彿"
- type="index"
- width="60"
- />
- <el-table-column label="浜у搧澶х被" prop="productCategory" width="200">
- <template #default="scope">
- <el-input v-model="scope.row.productCategory" placeholder="璇疯緭鍏ヤ骇鍝佸ぇ绫�" />
- </template>
- </el-table-column>
- <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" width="200">
- <template #default="scope">
- <el-input v-model="scope.row.specificationModel" placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�" />
- </template>
- </el-table-column>
- <el-table-column label="鍗曚綅" prop="unit" width="100">
- <template #default="scope">
- <el-input v-model="scope.row.unit" placeholder="璇疯緭鍏ュ崟浣�" />
- </template>
- </el-table-column>
- <el-table-column label="鍏ュ簱鏁伴噺" prop="inboundNum" width="150">
- <template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.inboundNum" @change="() => calculateTotalPrice(scope.row)" />
- </template>
- </el-table-column>
- <el-table-column label="鍏ュ簱鏃ユ湡" prop="inboundDate" width="180">
- <template #default="scope">
- <el-date-picker
- v-model="scope.row.inboundDate"
- type="date"
- placeholder="璇烽�夋嫨鍏ュ簱鏃ユ湡"
- value-format="YYYY-MM-DD"
- format="YYYY-MM-DD"
- style="width: 100%"
- />
- </template>
- </el-table-column>
- <el-table-column label="鍗曚环(鍏�)" prop="unitPrice" width="150">
- <template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="scope.row.unitPrice" @change="() => calculateTotalPrice(scope.row)" />
- </template>
- </el-table-column>
- <el-table-column
- label="鎬讳环(鍏�)"
- prop="totalPrice"
- width="150"
- >
- </el-table-column>
- <el-table-column label="鎿嶄綔" width="80" v-if="operationType === 'add'">
- <template #default="scope">
- <el-button type="danger" size="small" @click="removeProductRow(scope.$index)">鍒犻櫎</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
-</template>
-
-<script setup>
-import { ref, reactive, toRefs, getCurrentInstance } from 'vue'
-import useUserStore from '@/store/modules/user'
-import {
- addStockInCustom, updateProduct
-} from "@/api/inventoryManagement/stockIn.js";
-
-const userStore = useUserStore()
-const { proxy } = getCurrentInstance()
-const emit = defineEmits(['close', 'success'])
-
-const operationType = ref('')// 鎿嶄綔绫诲瀷: 'add' 鎴� 'edit'
-const dialogFormVisible = ref(false)// 寮规鏄剧ず鐘舵��
-const productList = ref([]);// 浜у搧鍒楄〃鏁版嵁
-const loadingProducts = ref(false);// 浜у搧鍔犺浇鐘舵��
-const loading = ref(false);
-
-function formatDateTime(date = new Date(), includeTime = true) {
- const d = new Date(date);
- const year = d.getFullYear();
- const month = String(d.getMonth() + 1).padStart(2, '0');
- const day = String(d.getDate()).padStart(2, '0');
-
- if (!includeTime) {
- return `${year}-${month}-${day}`;
- }
-
- const hours = String(d.getHours()).padStart(2, '0');
- const minutes = String(d.getMinutes()).padStart(2, '0');
- const seconds = String(d.getSeconds()).padStart(2, '0');
-
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
-}
-
-function getCurrentDate() {
- return formatDateTime(new Date(), false);
-}
-
-const itemTypeOptions = [
- { label: '鐗╂枡', value: '鐗╂枡' },
- { label: '鍘熸枡', value: '鍘熸枡' },
- { label: '鎴愬搧', value: '鎴愬搧' },
- { label: '鍏朵粬', value: '鍏朵粬' },
-]
-
-const taxRateOptions = [
- { label: '1', value: 1 },
- { label: '6', value: 6 },
- { label: '13', value: 13 },
-]
-
-const data = reactive({
- form: {
- id: null,
- supplierId: null, // 渚涘簲鍟咺D
- supplierName: '', // 渚涘簲鍟嗗悕绉�
- recorderId: userStore.userId, // 褰曞叆浜篒D
- recorderName: userStore.name, // 褰曞叆浜哄鍚�
- entryDate: getCurrentDate(), // 褰曞叆鏃ユ湡
- remark: '', // 澶囨敞
- },
- rules: {
- supplierName: [{ required: true, message: "璇疯緭鍏ヤ緵搴斿晢鍚嶇О", trigger: "blur" }]
- }
-})
-const { form, rules } = toRefs(data)
-
-// 鏂板浜у搧琛�
-const addProductRow = () => {
- productList.value.push({
- id: null,
- productCategory: '',
- specificationModel: '',
- unit: '',
- supplierName: form.value.supplierName || '',
- itemType: '',
- inboundNum: 0,
- inboundDate: '',
- quantityStock: 0,
- unitPrice: 0,
- totalPrice: 0,
- taxRate: null,
- taxExclusiveTotalPrice: 0,
- });
-};
-
-// 鍒犻櫎浜у搧琛�
-const removeProductRow = (index) => {
- productList.value.splice(index, 1);
-};
-
-// 璁$畻鎬讳环锛堟牴鎹暟閲忋�佸崟浠峰拰鍚◣鍗曚环锛�
-const calculateTotalPrice = (row) => {
- // 璁$畻鏅�氭�讳环锛歩nboundNum * unitPrice
- const quantity = Number(row.inboundNum || 0);
- const unitPrice = Number(row.unitPrice || 0);
- row.totalPrice = quantity * unitPrice;
- calculateExclusivePrice(row);
-};
-
-// 璁$畻涓嶅惈绋庢�讳环锛堟牴鎹惈绋庢�讳环鍜岀◣鐜囷級
-const calculateExclusivePrice = (row) => {
- const totalPrice = Number(row.totalPrice || 0);
- const taxRate = Number(row.taxRate || 0);
- row.taxExclusiveTotalPrice = totalPrice / (1 + taxRate / 100);
-};
-
-const submitForm = async () => {
- try {
- await proxy.$refs.formRef.validate()
-
- if (!productList.value.length) {
- proxy.$modal.msgError('璇疯嚦灏戞坊鍔犱竴鏉′骇鍝佹暟鎹�')
- return
- }
-
- // 楠岃瘉鑷畾涔夋坊鍔犵殑鏁版嵁蹇呭~瀛楁
- for (let i = 0; i < productList.value.length; i++) {
- const product = productList.value[i];
- if (!product.productCategory || !product.specificationModel || !product.unit) {
- proxy.$modal.msgError(`绗�${i + 1}琛屼骇鍝佹暟鎹湭濉啓瀹屾暣锛堜骇鍝佸ぇ绫汇�佽鏍煎瀷鍙枫�佸崟浣嶄负蹇呭~锛塦)
- return
- }
- if (!product.inboundDate) {
- proxy.$modal.msgError(`绗�${i + 1}琛岃閫夋嫨鍏ュ簱鏃ユ湡`)
- return
- }
- const stock = Number(product?.inboundNum ?? 0);
- if (!Number.isFinite(stock) || stock <= 0) {
- proxy.$modal.msgError(`绗�${i + 1}琛屾湰娆″叆搴撴暟閲忛渶澶т簬0`)
- return
- }
- }
-
- const payloadList = productList.value.map(product => ({
- id: product.id ?? null,
- inboundNum: Number(product.inboundNum),
- productCategory: product.productCategory,
- specificationModel: product.specificationModel,
- unit: product.unit,
- supplierName: product.supplierName || form.value.supplierName,
- itemType: product.itemType,
- inboundDate: formatDateTime(product.inboundDate, false),
- taxRate: Number(product.taxRate || 0),
- taxExclusiveTotalPrice: Number(product.taxExclusiveTotalPrice || 0),
- unitPrice: Number(product.unitPrice || 0),
- }));
- loading.value = true
- if (operationType.value === 'edit') {
- const editPayload = payloadList[0]
- await updateProduct(editPayload)
- } else {
- await addStockInCustom(payloadList)
- }
-
- proxy.$modal.msgSuccess(operationType.value === 'edit' ? '缂栬緫鑷畾涔夊叆搴撴垚鍔�' : '鏂板鑷畾涔夊叆搴撴垚鍔�')
- closeDia()
- emit('success')
-
- } catch (error) {
- console.error('鎻愪氦澶辫触:', error)
- if (!error.errors) {
- proxy.$modal.msgError('鎿嶄綔澶辫触锛岃閲嶈瘯')
- }
- } finally {
- loading.value = false
- }
-}
-
-const closeDia = () => {
- proxy.$refs.formRef.resetFields()
- dialogFormVisible.value = false
- productList.value = []
- emit('close')
-}
-
-const openDialog = async (type, row) => {
- operationType.value = type
- dialogFormVisible.value = true
-
- if (type === 'add') {
- form.value = {
- id: null,
- supplierId: null,
- supplierName: '',
- recorderId: userStore.userId,
- recorderName: userStore.name,
- entryDate: getCurrentDate(),
- remark: ''
- }
- productList.value = []
- } else {
- // 缂栬緫妯″紡锛氬皢琛屾暟鎹~鍏呭埌琛ㄦ牸涓互鏀寔淇敼
- form.value = {
- id: row?.id ?? null,
- supplierId: row?.supplierId ?? null,
- supplierName: row?.supplierName ?? '',
- recorderId: userStore.userId,
- recorderName: userStore.name,
- entryDate: getCurrentDate(),
- remark: row?.remark ?? ''
- }
- productList.value = [{
- id: row?.id ?? null,
- productCategory: row?.productCategory ?? '',
- specificationModel: row?.specificationModel ?? '',
- unit: row?.unit ?? '',
- supplierName: row?.supplierName ?? '',
- itemType: row?.itemType ?? '',
- inboundNum: Number(row?.inboundNum ?? row?.inboundQuantity ?? 0),
- inboundDate: row?.inboundDate ?? row?.createTime ?? '',
- taxRate: Number(row?.taxRate ?? 0),
- unitPrice: Number(row?.unitPrice ?? 0),
- taxExclusiveTotalPrice: Number(row?.taxExclusiveTotalPrice ?? 0),
- }]
- }
-}
-
-defineExpose({
- openDialog,
-})
-</script>
-
-<style scoped lang="scss"></style>
-
diff --git a/src/views/inventoryManagement/receiptManagement/index.vue b/src/views/inventoryManagement/receiptManagement/index.vue
index 9aebae4..8ca110f 100644
--- a/src/views/inventoryManagement/receiptManagement/index.vue
+++ b/src/views/inventoryManagement/receiptManagement/index.vue
@@ -1,538 +1,36 @@
<template>
<div class="app-container">
- <el-tabs v-model="activeTab"
- @tab-change="handleTabChange">
- <el-tab-pane label="鎴愬搧鍏ュ簱"
- name="production">
- <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.productCategory"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- clearable/>
- <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="table_list">
- <el-table :data="tableData"
- border
- v-loading="tableLoading"
- @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys"
- :row-key="row => row.id"
- show-summary
- style="width: 100%"
- :summary-method="summarizeMainTable"
- height="calc(100vh - 18.5em)">
- <el-table-column align="center"
- type="selection"
- width="55"/>
- <el-table-column align="center"
- label="搴忓彿"
- type="index"
- width="60"/>
- <el-table-column label="鍏ュ簱鏃堕棿"
- prop="createTime"
- show-overflow-tooltip/>
- <el-table-column label="閿�鍞悎鍚屽彿"
- prop="salesContractNo"
- width="180"
- show-overflow-tooltip/>
- <el-table-column label="浜у搧澶х被"
- prop="productCategory"
- show-overflow-tooltip/>
- <el-table-column label="瑙勬牸鍨嬪彿"
- prop="specificationModel"
- show-overflow-tooltip/>
- <el-table-column label="鍗曚綅"
- prop="unit"
- width="70"
- show-overflow-tooltip/>
- <el-table-column label="鍏ュ簱鏁伴噺"
- prop="inboundNum"
- width="100"
- show-overflow-tooltip/>
- <el-table-column label="鍗曚环(鍏�)"
- prop="unitPrice"
- width="150"></el-table-column>
- <el-table-column label="鎬讳环(鍏�)"
- prop="totalPrice"
- width="150"></el-table-column>
- <!-- <el-table-column fixed="right"
- label="鎿嶄綔"
- min-width="60"
- align="center">
- <template #default="scope">
- <el-button link
- type="primary"
- size="small"
- @click="openForm('edit', scope.row, 'production');">缂栬緫</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"/>
- </div>
- </el-tab-pane>
- <el-tab-pane label="鍘熸枡鍏ュ簱"
- name="purchase">
- <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.productCategory"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- clearable/>
- <el-button type="primary"
- @click="handleQuery"
- style="margin-left: 10px">鎼滅储
- </el-button>
- </div>
- <div>
- <el-button type="primary"
- @click="openForm('add', 'purchase')">鏂板鍏ュ簱
- </el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger"
- plain
- @click="handleDelete">鍒犻櫎
- </el-button>
- </div>
- </div>
- <div class="table_list">
- <el-table :data="tableData"
- border
- v-loading="tableLoading"
- @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys"
- :row-key="row => row.id"
- show-summary
- style="width: 100%"
- :summary-method="summarizeMainTable"
- height="calc(100vh - 18.5em)">
- <el-table-column align="center"
- type="selection"
- width="55"/>
- <el-table-column align="center"
- label="搴忓彿"
- type="index"
- width="60"/>
- <el-table-column label="鍏ュ簱鏃堕棿"
- prop="createTime"
- width="100"
- show-overflow-tooltip/>
- <el-table-column label="閲囪喘鍚堝悓鍙�"
- prop="purchaseContractNumber"
- width="180"
- show-overflow-tooltip/>
- <el-table-column label="渚涘簲鍟嗗悕绉�"
- prop="supplierName"
- width="240"
- show-overflow-tooltip/>
- <el-table-column label="浜у搧澶х被"
- prop="productCategory"
- show-overflow-tooltip/>
- <el-table-column label="瑙勬牸鍨嬪彿"
- prop="specificationModel"
- show-overflow-tooltip/>
- <el-table-column label="鍗曚綅"
- prop="unit"
- width="70"
- show-overflow-tooltip/>
- <el-table-column label="鍏ュ簱鏁伴噺"
- prop="inboundNum"
- width="100"
- show-overflow-tooltip/>
- <el-table-column label="鍚◣鍗曚环(鍏�)"
- prop="taxInclusiveUnitPrice"
- width="150"></el-table-column>
- <el-table-column label="鍚◣鎬讳环(鍏�)"
- prop="taxInclusiveTotalPrice"
- width="150"></el-table-column>
- <el-table-column label="鍏ュ簱浜�"
- prop="createBy"
- width="80"
- show-overflow-tooltip/>
- <el-table-column fixed="right"
- label="鎿嶄綔"
- min-width="60"
- align="center">
- <template #default="scope">
- <el-button link
- :disabled="scope.row.type == 1"
- type="primary"
- size="small"
- @click="openForm('edit', scope.row, 'purchase');">缂栬緫
- </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"/>
- </div>
- </el-tab-pane>
- <el-tab-pane label="鐢熶骇鍏ュ簱"
- name="product">
- <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.productCategory"
- style="width: 240px"
- placeholder="璇疯緭鍏�"
- clearable/>
- <el-button type="primary"
- @click="handleQuery"
- style="margin-left: 10px">鎼滅储
- </el-button>
- </div>
- <div>
- <el-button type="primary"
- @click="openForm('add', 'purchase')">鏂板鍏ュ簱
- </el-button>
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger"
- plain
- @click="handleDelete">鍒犻櫎
- </el-button>
- </div>
- </div>
- <div class="table_list">
- <el-table :data="tableData"
- border
- v-loading="tableLoading"
- @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys"
- :row-key="row => row.id"
- show-summary
- style="width: 100%"
- :summary-method="summarizeMainTable"
- height="calc(100vh - 18.5em)">
- <el-table-column align="center"
- type="selection"
- width="55"/>
- <el-table-column align="center"
- label="搴忓彿"
- type="index"
- width="60"/>
- <el-table-column label="鍏ュ簱鏃堕棿"
- prop="createTime"
- width="100"
- show-overflow-tooltip/>
- <el-table-column label="浜у搧澶х被"
- prop="productCategory"
- show-overflow-tooltip/>
- <el-table-column label="瑙勬牸鍨嬪彿"
- prop="specificationModel"
- show-overflow-tooltip/>
- <el-table-column label="鍗曚綅"
- prop="unit"
- width="220"
- show-overflow-tooltip/>
- <el-table-column label="鍏ュ簱鏁伴噺"
- prop="inboundNum"
- width="220"
- show-overflow-tooltip/>
- <el-table-column label="鍏ュ簱浜�"
- prop="createBy"
- width="220"
- show-overflow-tooltip/>
- </el-table>
- <pagination v-show="total > 0"
- :total="total"
- layout="total, sizes, prev, pager, next, jumper"
- :page="page.current"
- :limit="page.size"
- @pagination="pageProductChange"/>
- </div>
+ <el-tabs v-model="activeTab" @tab-change="handleTabChange">
+ <el-tab-pane v-for="tab in tabs"
+ :label="tab.label"
+ :name="tab.name"
+ :key="tab.name">
+ <record :type="tab.type" v-if="activeTab === tab.name" />
</el-tab-pane>
</el-tabs>
- <form-dia ref="formDia"
- @close="handleQuery"
- @success="handleQuery"></form-dia>
- <form-dia-product ref="formDiaProduct"
- @close="handleQuery"
- @success="handleQuery"></form-dia-product>
</div>
</template>
<script setup>
-import pagination from "@/components/PIMTable/Pagination.vue";
-import {
- ref,
- reactive,
- toRefs,
- onMounted,
- getCurrentInstance,
- nextTick,
-} from "vue";
-import {ElMessageBox} from "element-plus";
-import useUserStore from "@/store/modules/user";
-import dayjs from "dayjs";
-import {
- getStockInPage,
- getStockInPageByProduction,
- getStockInPageByProductProduction,
- delStockIn,
-} from "@/api/inventoryManagement/stockIn.js";
-import FormDia from "./components/formDia.vue";
-import FormDiaProduct from "./components/formDiaProduct.vue";
+import Record from "@/views/inventoryManagement/receiptManagement/Record.vue";
-// 鑾峰彇褰撳墠鏃ユ湡
-function getCurrentDate() {
- return dayjs().format("YYYY-MM-DD");
-}
-
-const {proxy} = getCurrentInstance();
-
-const tableData = ref([]);
-const selectedRows = ref([]);
-const tableLoading = ref(false);
-const formDia = ref();
-const formDiaProduct = ref();
-const activeTab = ref("production"); // 褰撳墠婵�娲荤殑 tab
-
-const page = reactive({
- current: 1,
- size: 100,
-});
-const total = ref(0);
-
-const data = reactive({
- searchForm: {
- supplierName: "",
- customerName: "",
- productCategory: "",
- timeStr: "",
+const activeTab = ref('qualified')
+const type = ref(0)
+const tabs = ref([
+ {
+ label: '鍚堟牸鍏ュ簱',
+ name: 'qualified',
+ type: '0'
},
-});
-const {searchForm} = toRefs(data);
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1;
- getList();
-};
-const paginationChange = obj => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const pageProductChange = obj => {
- page.current = obj.page;
- page.size = obj.limit;
- getList();
-};
-const getList = () => {
- tableLoading.value = true;
- const params = {...page};
-
- // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷浼犻�掍笉鍚岀殑鏌ヨ鍙傛暟
- if (activeTab.value === "production") {
- params.customerName = searchForm.value.customerName;
- params.timeStr = searchForm.value.timeStr;
- } else {
- params.supplierName = searchForm.value.supplierName;
- params.timeStr = searchForm.value.timeStr;
+ {
+ label: '涓嶅悎鏍煎叆搴�',
+ name: 'unqualified',
+ type: '1'
}
- params.productCategory = searchForm.value.productCategory;
- if (activeTab.value === "product") {
- getStockInPageByProductProduction(params)
- .then(res => {
- tableLoading.value = false;
- tableData.value = res.data.records;
- });
+])
- }else {
- // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勬帴鍙�
- const apiCall =
- activeTab.value === "production"
- ? getStockInPageByProduction(params)
- : getStockInPage(params);
-
- apiCall
- .then(res => {
- tableLoading.value = false;
- tableData.value = res.data.records;
-
- // 鍓嶇璁$畻鎬讳环锛氭�讳环 = unitPrice * inboundNum
- tableData.value = tableData.value.map(item => {
- // 浣跨敤鍏ュ簱鏁伴噺璁$畻鎬讳环
- const inboundNum = Number(item.inboundNum) || 0;
- const unitPrice = Number(item.unitPrice) || 0;
- const taxInclusiveUnitPrice = Number(item.taxInclusiveUnitPrice) || 0;
-
- // 鏍规嵁鏍囩椤电被鍨嬭绠椾笉鍚岀殑鎬讳环
- if (activeTab.value === "production") {
- // 鎴愬搧搴撳瓨锛氭�讳环 = unitPrice * 鍏ュ簱鏁伴噺
- item.totalPrice = (unitPrice * inboundNum).toFixed(2);
- } else {
- // 鍘熸枡鍜屾潗鏂欏簱瀛橈細鍚◣鎬讳环 = taxInclusiveUnitPrice * 鍏ュ簱鏁伴噺
- item.taxInclusiveTotalPrice = (
- taxInclusiveUnitPrice * inboundNum
- ).toFixed(2);
- }
-
- return item;
- });
-
- total.value = res.data.total;
- })
- .catch(() => {
- tableLoading.value = false;
- });
- }
-
-};
-
-// 鍒囨崲 tab
-const handleTabChange = tabName => {
- page.current = 1;
- // 鍒囨崲 tab 鏃舵竻绌烘悳绱㈡潯浠�
- searchForm.value.supplierName = "";
- searchForm.value.customerName = "";
- searchForm.value.timeStr = "";
- searchForm.value.productCategory = "";
- getList();
-};
-
-// 鎵撳紑寮规
-const openForm = async (type, row, tabType) => {
- const currentTab = tabType || activeTab.value;
- await nextTick(() => {
- if (currentTab === "production") {
- formDiaProduct.value?.openDialog(type, row);
- } else {
- formDia.value?.openDialog(type, row);
- }
- });
-};
-
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = selection => {
- selectedRows.value = selection.filter(item => item.id);
-};
-
-const expandedRowKeys = ref([]);
-
-// 涓昏〃鍚堣鏂规硶
-const summarizeMainTable = param => {
- return proxy.summarizeTable(param, [
- "contractAmount",
- "taxInclusiveTotalPrice",
- "taxExclusiveTotalPrice",
- ]);
-};
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm("鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
- confirmButtonText: "纭",
- cancelButtonText: "鍙栨秷",
- type: "warning",
- })
- .then(() => {
- // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
- let exportUrl = "/stockin/export";
- if (activeTab.value === "production") {
- exportUrl = "/stockin/exportOne";
- }
- proxy.download(exportUrl, {}, "鍏ュ簱鍙拌处.xlsx");
- })
- .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",
- })
- .then(() => {
- // 鏍规嵁褰撳墠 tab 绫诲瀷閫夋嫨涓嶅悓鐨勫垹闄ゆ帴鍙e拰type鍙傛暟
- let deleteApi, deleteParams;
-
- if (activeTab.value === "production") {
- // 鎴愬搧鍒犻櫎锛宼ype浼�2
- deleteApi = delStockIn;
- deleteParams = {ids, type: 2};
- } else {
- // 鍘熸枡鍒犻櫎锛宼ype浼�1
- deleteApi = delStockIn;
- deleteParams = {ids, type: 1};
- }
-
- deleteApi(deleteParams)
- .then(() => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- getList();
- })
- .catch(() => {
- proxy.$modal.msgError("鍒犻櫎澶辫触");
- });
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
-};
-
-onMounted(() => {
- getList();
-});
+const handleTabChange = (tabName) => {
+ activeTab.value = tabName;
+ type.value = tabName === 'qualified' ? 0 : 1
+}
</script>
-
-<style scoped lang="scss"></style>
-
-
-
diff --git a/src/views/inventoryManagement/stockManagement/New.vue b/src/views/inventoryManagement/stockManagement/New.vue
new file mode 100644
index 0000000..751c639
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/New.vue
@@ -0,0 +1,180 @@
+<template>
+ <div>
+ <el-dialog
+ v-model="isShow"
+ title="鏂板搴撳瓨"
+ width="800"
+ @close="closeModal"
+ >
+ <el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
+ <el-form-item
+ label="浜у搧鍚嶇О"
+ prop="productModelId"
+ :rules="[
+ {
+ required: true,
+ message: '璇烽�夋嫨浜у搧',
+ trigger: 'change',
+ }
+ ]"
+ >
+ <el-button type="primary" @click="showProductSelectDialog = true">
+ {{ formState.productName ? formState.productName : '閫夋嫨浜у搧' }}
+ </el-button>
+ </el-form-item>
+
+ <el-form-item
+ label="瑙勬牸"
+ prop="productModelName"
+ >
+ <el-input v-model="formState.productModelName" disabled />
+ </el-form-item>
+
+ <el-form-item
+ label="鍗曚綅"
+ prop="unit"
+ >
+ <el-input v-model="formState.unit" disabled />
+ </el-form-item>
+
+ <el-form-item
+ label="鏁伴噺"
+ prop="qualitity"
+ >
+ <el-input-number v-model="formState.qualitity" :step="1" :min="0" style="width: 100%" />
+ </el-form-item>
+
+ <el-form-item label="澶囨敞" prop="remark">
+ <el-input v-model="formState.remark" type="textarea" />
+ </el-form-item>
+ </el-form>
+
+ <!-- 浜у搧閫夋嫨寮圭獥 -->
+ <ProductSelectDialog
+ v-model="showProductSelectDialog"
+ @confirm="handleProductSelect"
+ single
+ />
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="handleSubmit">纭</el-button>
+ <el-button @click="closeModal">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+import {ref, computed, getCurrentInstance} from "vue";
+import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
+import {createStockInventory} from "@/api/inventoryManagement/stockInventory.js";
+import {createStockUnInventory} from "@/api/inventoryManagement/stockUninventory.js";
+
+const props = defineProps({
+ visible: {
+ type: Boolean,
+ required: true,
+ },
+
+ type: {
+ type: String,
+ required: true,
+ default: 'qualified',
+ },
+});
+
+const emit = defineEmits(['update:visible', 'completed']);
+
+// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
+const formState = ref({
+ productId: undefined,
+ productModelId: undefined,
+ productName: "",
+ productModelName: "",
+ unit: "",
+ qualitity: 0,
+ remark: '',
+});
+
+const isShow = computed({
+ get() {
+ return props.visible;
+ },
+ set(val) {
+ emit('update:visible', val);
+ },
+});
+
+const showProductSelectDialog = ref(false);
+
+let { proxy } = getCurrentInstance()
+
+const closeModal = () => {
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ formState.value = {
+ productId: undefined,
+ productModelId: undefined,
+ productName: "",
+ productModelName: "",
+ description: '',
+ };
+ isShow.value = false;
+};
+
+// 浜у搧閫夋嫨澶勭悊
+const handleProductSelect = async (products) => {
+ if (products && products.length > 0) {
+ const product = products[0];
+ formState.value.productId = product.productId;
+ formState.value.productName = product.productName;
+ formState.value.productModelName = product.model;
+ formState.value.productModelId = product.id;
+ formState.value.unit = product.unit;
+ showProductSelectDialog.value = false;
+ // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ proxy.$refs["formRef"]?.validateField('productModelId');
+ }
+};
+
+const handleSubmit = () => {
+ proxy.$refs["formRef"].validate(valid => {
+ if (valid) {
+ // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佸拰瑙勬牸
+ if (!formState.value.productModelId) {
+ proxy.$modal.msgError("璇烽�夋嫨浜у搧");
+ return;
+ }
+ if (!formState.value.productModelId) {
+ proxy.$modal.msgError("璇烽�夋嫨瑙勬牸");
+ return;
+ }
+ if (props.type === 'qualified') {
+ createStockInventory(formState.value).then(res => {
+ // 鍏抽棴妯℃�佹
+ isShow.value = false;
+ // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+ emit('completed');
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ })
+ } else {
+ createStockUnInventory(formState.value).then(res => {
+ // 鍏抽棴妯℃�佹
+ isShow.value = false;
+ // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+ emit('completed');
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ })
+ }
+
+ }
+ })
+};
+
+
+defineExpose({
+ closeModal,
+ handleSubmit,
+ isShow,
+});
+</script>
diff --git a/src/views/inventoryManagement/stockManagement/Qualified.vue b/src/views/inventoryManagement/stockManagement/Qualified.vue
new file mode 100644
index 0000000..6a0ba17
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/Qualified.vue
@@ -0,0 +1,158 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title ml10">浜у搧澶х被锛�</span>
+ <el-input v-model="searchForm.productName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable/>
+ <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
+ </div>
+ <div>
+ <el-button type="primary" @click="isShowNewModal = true">鏂板搴撳瓨</el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys" :row-key="row => row.id" style="width: 100%"
+ :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
+ <el-table-column align="center" type="selection" width="55" />
+ <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+ <el-table-column label="浜у搧澶х被" prop="productName" show-overflow-tooltip />
+ <el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
+ <el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨鏁伴噺" prop="qualitity" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" show-overflow-tooltip />
+ <el-table-column label="澶囨敞" prop="remark" show-overflow-tooltip />
+ <el-table-column label="鏈�杩戞洿鏂版椂闂�" prop="updateTime" show-overflow-tooltip />
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
+ <template #default="scope">
+ <el-button link type="primary" size="small" @click="showSubtractModal(scope.row)" :disabled="scope.row.qualitity === 0">棰嗙敤</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" />
+ </div>
+ <new-stock-inventory v-if="isShowNewModal"
+ v-model:visible="isShowNewModal"
+ type="qualified"
+ @completed="handleQuery" />
+
+ <subtract-stock-inventory v-if="isShowSubtractModal"
+ v-model:visible="isShowSubtractModal"
+ :record="record"
+ @completed="handleQuery" />
+ </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 { getStockInventoryListPage } from "@/api/inventoryManagement/stockInventory.js";
+const NewStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/New.vue"));
+const SubtractStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Subtract.vue"));
+
+const { proxy } = getCurrentInstance()
+const tableData = ref([])
+const selectedRows = ref([])
+const record = ref({})
+const tableLoading = ref(false)
+const page = reactive({
+ current: 1,
+ size: 100,
+})
+const total = ref(0)
+// 鏄惁鏄剧ず鏂板寮规
+const isShowNewModal = ref(false)
+// 鏄惁鏄剧ず棰嗙敤寮规
+const isShowSubtractModal = ref(false)
+const data = reactive({
+ searchForm: {
+ productName: '',
+ }
+})
+const { searchForm } = toRefs(data)
+
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1
+ getList()
+}
+const paginationChange = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList()
+}
+const getList = () => {
+ tableLoading.value = true
+ getStockInventoryListPage({ ...searchForm.value, ...page }).then(res => {
+ tableLoading.value = false
+ tableData.value = res.data.records
+ total.value = res.data.total
+ // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
+ // checkStockAndCreatePurchase();
+ }).catch(() => {
+ tableLoading.value = false
+ })
+}
+
+// 鐐瑰嚮棰嗙敤
+const showSubtractModal = (row) => {
+ record.value = row
+ isShowSubtractModal.value = true
+}
+
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ // 杩囨护鎺夊瓙鏁版嵁
+ selectedRows.value = selection.filter(item => item.id);
+ console.log('selection', selectedRows.value)
+}
+const expandedRowKeys = ref([])
+
+// 琛ㄦ牸琛岀被鍚�
+const tableRowClassName = ({ row }) => {
+ const stock = Number(row?.inboundNum0 ?? 0);
+ const warn = Number(row?.warnNum ?? 0);
+ if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
+ return '';
+ }
+ return stock < warn ? 'row-low-stock' : '';
+};
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm(
+ '鏄惁纭瀵煎嚭锛�',
+ '瀵煎嚭', {
+ confirmButtonText: '纭',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }
+ ).then(() => {
+ proxy.download("/stockInventory/exportStockInventory", {}, '搴撳瓨淇℃伅.xlsx')
+ }).catch(() => {
+ proxy.$modal.msg("宸插彇娑�")
+ })
+}
+
+onMounted(() => {
+ getList()
+})
+</script>
+
+<style scoped lang="scss">
+:deep(.row-low-stock td) {
+ background-color: #fde2e2;
+ color: #c45656;
+}
+
+:deep(.row-low-stock:hover > td) {
+ background-color: #fcd4d4;
+}
+</style>
diff --git a/src/views/inventoryManagement/stockManagement/Subtract.vue b/src/views/inventoryManagement/stockManagement/Subtract.vue
new file mode 100644
index 0000000..082153c
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/Subtract.vue
@@ -0,0 +1,199 @@
+<template>
+ <div>
+ <el-dialog
+ v-model="isShow"
+ title="棰嗙敤"
+ width="800"
+ @close="closeModal"
+ >
+ <el-form label-width="140px" :model="formState" label-position="top" ref="formRef">
+ <el-form-item
+ label="浜у搧鍚嶇О"
+ prop="productModelId"
+ :rules="[
+ {
+ required: true,
+ message: '璇烽�夋嫨浜у搧',
+ trigger: 'change',
+ }
+ ]"
+ >
+ <el-button type="primary" @click="showProductSelectDialog = true" disabled>
+ {{ formState.productName ? formState.productName : '閫夋嫨浜у搧' }}
+ </el-button>
+ </el-form-item>
+
+ <el-form-item
+ label="瑙勬牸"
+ prop="productModelName"
+ >
+ <el-input v-model="formState.model" disabled />
+ </el-form-item>
+
+ <el-form-item
+ label="鍗曚綅"
+ prop="unit"
+ >
+ <el-input v-model="formState.unit" disabled />
+ </el-form-item>
+
+ <el-form-item
+ label="鏁伴噺"
+ prop="qualitity"
+ >
+ <el-input-number v-model="formState.qualitity" :step="1" :min="1" :max="maxQuality" style="width: 100%" />
+ </el-form-item>
+
+ <el-form-item label="澶囨敞" prop="remark">
+ <el-input v-model="formState.remark" type="textarea" />
+ </el-form-item>
+ </el-form>
+
+ <!-- 浜у搧閫夋嫨寮圭獥 -->
+ <ProductSelectDialog
+ v-model="showProductSelectDialog"
+ @confirm="handleProductSelect"
+ single
+ />
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" @click="handleSubmit">纭</el-button>
+ <el-button @click="closeModal">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+import {ref, computed, getCurrentInstance} from "vue";
+import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
+import {subtractStockInventory} from "@/api/inventoryManagement/stockInventory.js";
+import {subtractStockUnInventory} from "@/api/inventoryManagement/stockUninventory.js";
+
+const props = defineProps({
+ visible: {
+ type: Boolean,
+ required: true,
+ },
+ record: {
+ type: Object,
+ default: () => {},
+ },
+ type: {
+ type: String,
+ required: true,
+ default: 'qualified',
+ },
+});
+
+const emit = defineEmits(['update:visible', 'completed']);
+
+onMounted(() => {
+ initFormData()
+})
+
+const maxQuality = computed(() => {
+ return props.record.qualitity ? props.record.qualitity : 0;
+})
+
+const initFormData = () => {
+ if (props.record) {
+ formState.value = {
+ ...props.record,
+ }
+ }
+}
+
+// 鍝嶅簲寮忔暟鎹紙鏇夸唬閫夐」寮忕殑 data锛�
+const formState = ref({
+ productId: undefined,
+ productModelId: undefined,
+ productName: "",
+ model: "",
+ unit: "",
+ qualitity: 0,
+ remark: '',
+});
+
+const isShow = computed({
+ get() {
+ return props.visible;
+ },
+ set(val) {
+ emit('update:visible', val);
+ },
+});
+
+const showProductSelectDialog = ref(false);
+
+let { proxy } = getCurrentInstance()
+
+const closeModal = () => {
+ // 閲嶇疆琛ㄥ崟鏁版嵁
+ formState.value = {
+ productId: undefined,
+ productModelId: undefined,
+ productName: "",
+ productModelName: "",
+ description: '',
+ };
+ isShow.value = false;
+};
+
+// 浜у搧閫夋嫨澶勭悊
+const handleProductSelect = async (products) => {
+ if (products && products.length > 0) {
+ const product = products[0];
+ console.log(product)
+ formState.value.productId = product.productId;
+ formState.value.productName = product.productName;
+ formState.value.productModelName = product.model;
+ formState.value.productModelId = product.id;
+ formState.value.unit = product.unit;
+ showProductSelectDialog.value = false;
+ // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+ proxy.$refs["formRef"]?.validateField('productModelId');
+ }
+};
+
+const handleSubmit = () => {
+ proxy.$refs["formRef"].validate(valid => {
+ if (valid) {
+ // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佸拰瑙勬牸
+ if (!formState.value.productModelId) {
+ proxy.$modal.msgError("璇烽�夋嫨浜у搧");
+ return;
+ }
+ if (!formState.value.productModelId) {
+ proxy.$modal.msgError("璇烽�夋嫨瑙勬牸");
+ return;
+ }
+ if (props.type === 'qualified') {
+ subtractStockInventory(formState.value).then(res => {
+ // 鍏抽棴妯℃�佹
+ isShow.value = false;
+ // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+ emit('completed');
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ })
+ } else {
+ subtractStockUnInventory(formState.value).then(res => {
+ // 鍏抽棴妯℃�佹
+ isShow.value = false;
+ // 鍛婄煡鐖剁粍浠跺凡瀹屾垚
+ emit('completed');
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ })
+ }
+ }
+ })
+};
+
+
+defineExpose({
+ closeModal,
+ handleSubmit,
+ isShow,
+});
+</script>
diff --git a/src/views/inventoryManagement/stockManagement/Unqualified.vue b/src/views/inventoryManagement/stockManagement/Unqualified.vue
new file mode 100644
index 0000000..afc6700
--- /dev/null
+++ b/src/views/inventoryManagement/stockManagement/Unqualified.vue
@@ -0,0 +1,158 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title ml10">浜у搧澶х被锛�</span>
+ <el-input v-model="searchForm.productName"
+ style="width: 240px"
+ placeholder="璇疯緭鍏�"
+ clearable/>
+ <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
+ </div>
+ <div>
+ <el-button type="primary" @click="isShowNewModal = true">鏂板搴撳瓨</el-button>
+ <el-button @click="handleOut">瀵煎嚭</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
+ :expand-row-keys="expandedRowKeys" :row-key="row => row.id" style="width: 100%"
+ :row-class-name="tableRowClassName" height="calc(100vh - 18.5em)">
+ <el-table-column align="center" type="selection" width="55" />
+ <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+ <el-table-column label="浜у搧澶х被" prop="productName" show-overflow-tooltip />
+ <el-table-column label="瑙勬牸鍨嬪彿" prop="model" show-overflow-tooltip />
+ <el-table-column label="鍗曚綅" prop="unit" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨鏁伴噺" prop="qualitity" show-overflow-tooltip />
+ <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" show-overflow-tooltip />
+ <el-table-column label="澶囨敞" prop="remark" show-overflow-tooltip />
+ <el-table-column label="鏈�杩戞洿鏂版椂闂�" prop="updateTime" show-overflow-tooltip />
+ <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
+ <template #default="scope">
+ <el-button link type="primary" size="small" @click="showSubtractModal(scope.row)" :disabled="scope.row.qualitity === 0">棰嗙敤</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" />
+ </div>
+ <new-stock-inventory v-if="isShowNewModal"
+ v-model:visible="isShowNewModal"
+ type="unqualified"
+ @completed="handleQuery" />
+
+ <subtract-stock-inventory v-if="isShowSubtractModal"
+ v-model:visible="isShowSubtractModal"
+ :record="record"
+ @completed="handleQuery" />
+ </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 { getStockUninventoryListPage } from "@/api/inventoryManagement/stockUninventory.js";
+const NewStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/New.vue"));
+const SubtractStockInventory = defineAsyncComponent(() => import("@/views/inventoryManagement/stockManagement/Subtract.vue"));
+
+const { proxy } = getCurrentInstance()
+const tableData = ref([])
+const selectedRows = ref([])
+const record = ref({})
+const tableLoading = ref(false)
+const page = reactive({
+ current: 1,
+ size: 100,
+})
+const total = ref(0)
+// 鏄惁鏄剧ず鏂板寮规
+const isShowNewModal = ref(false)
+// 鏄惁鏄剧ず棰嗙敤寮规
+const isShowSubtractModal = ref(false)
+const data = reactive({
+ searchForm: {
+ productName: '',
+ }
+})
+const { searchForm } = toRefs(data)
+
+// 鏌ヨ鍒楄〃
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ page.current = 1
+ getList()
+}
+const paginationChange = (obj) => {
+ page.current = obj.page;
+ page.size = obj.limit;
+ getList()
+}
+const getList = () => {
+ tableLoading.value = true
+ getStockUninventoryListPage({ ...searchForm.value, ...page }).then(res => {
+ tableLoading.value = false
+ tableData.value = res.data.records
+ total.value = res.data.total
+ // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
+ // checkStockAndCreatePurchase();
+ }).catch(() => {
+ tableLoading.value = false
+ })
+}
+
+// 鐐瑰嚮棰嗙敤
+const showSubtractModal = (row) => {
+ record.value = row
+ isShowSubtractModal.value = true
+}
+
+// 琛ㄦ牸閫夋嫨鏁版嵁
+const handleSelectionChange = (selection) => {
+ // 杩囨护鎺夊瓙鏁版嵁
+ selectedRows.value = selection.filter(item => item.id);
+ console.log('selection', selectedRows.value)
+}
+const expandedRowKeys = ref([])
+
+// 琛ㄦ牸琛岀被鍚�
+const tableRowClassName = ({ row }) => {
+ const stock = Number(row?.inboundNum0 ?? 0);
+ const warn = Number(row?.warnNum ?? 0);
+ if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
+ return '';
+ }
+ return stock < warn ? 'row-low-stock' : '';
+};
+
+// 瀵煎嚭
+const handleOut = () => {
+ ElMessageBox.confirm(
+ '鏄惁纭瀵煎嚭锛�',
+ '瀵煎嚭', {
+ confirmButtonText: '纭',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }
+ ).then(() => {
+ proxy.download("/stockin/exportCopy", {}, '搴撳瓨淇℃伅.xlsx')
+ }).catch(() => {
+ proxy.$modal.msg("宸插彇娑�")
+ })
+}
+
+onMounted(() => {
+ getList()
+})
+</script>
+
+<style scoped lang="scss">
+:deep(.row-low-stock td) {
+ background-color: #fde2e2;
+ color: #c45656;
+}
+
+:deep(.row-low-stock:hover > td) {
+ background-color: #fcd4d4;
+}
+</style>
diff --git a/src/views/inventoryManagement/stockManagement/index.vue b/src/views/inventoryManagement/stockManagement/index.vue
index 52b0184..347de38 100644
--- a/src/views/inventoryManagement/stockManagement/index.vue
+++ b/src/views/inventoryManagement/stockManagement/index.vue
@@ -1,419 +1,33 @@
<template>
<div class="app-container">
- <div class="search_form">
- <div>
- <span class="search_title">渚涘簲鍟嗗悕绉帮細</span>
- <el-input v-model="searchForm.supplierName" style="width: 240px" placeholder="璇疯緭鍏�" @change="handleQuery"
- clearable prefix-icon="Search" />
- <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"
- />
- <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
- </div>
- <div>
- <!-- <el-button type="primary" @click="openForm('add')">鏂板</el-button> -->
- <el-button @click="handleOut">瀵煎嚭</el-button>
- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
- </div>
- </div>
- <div class="table_list">
- <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
- :expand-row-keys="expandedRowKeys" :row-key="row => row.id" show-summary style="width: 100%"
- :row-class-name="tableRowClassName"
- :summary-method="summarizeMainTable" height="calc(100vh - 18.5em)">
- <el-table-column align="center" type="selection" width="55" />
- <el-table-column align="center" label="搴忓彿" type="index" width="60" />
- <el-table-column label="鍏ュ簱鏃ユ湡" prop="createTime" width="100" show-overflow-tooltip />
- <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" width="240" show-overflow-tooltip />
- <el-table-column label="浜у搧澶х被" prop="productCategory" width="100" show-overflow-tooltip />
- <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" width="200" show-overflow-tooltip />
- <el-table-column label="鍗曚綅" prop="unit" width="80" show-overflow-tooltip />
- <el-table-column label="搴撳瓨鏁伴噺" prop="inboundNum0" width="100" show-overflow-tooltip />
- <el-table-column label="搴撳瓨棰勮鏁伴噺" prop="warnNum" width="130" show-overflow-tooltip />
- <el-table-column label="鍚◣鍗曚环" prop="taxInclusiveUnitPrice" width="100" show-overflow-tooltip />
- <el-table-column label="鍚◣鎬讳环" prop="taxInclusiveTotalPrice" width="100" show-overflow-tooltip />
- <el-table-column label="绋庣巼(%)" prop="taxRate" width="100" show-overflow-tooltip />
- <el-table-column label="涓嶅惈绋庢�讳环" prop="taxExclusiveTotalPrice" width="100" show-overflow-tooltip />
- <el-table-column label="鍏ュ簱浜�" prop="createBy" width="80" show-overflow-tooltip />
- <el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center">
- <template #default="scope">
- <el-button link type="primary" size="small" @click="openForm('edit', 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" />
- </div>
- <el-dialog v-model="dialogFormVisible" :title="operationType === 'add' ? '鏂板搴撳瓨' : '缂栬緫搴撳瓨'" width="70%"
- @close="closeDia">
- <el-form :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="supplierName">
- <el-input disabled v-model="form.supplierName" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="浜у搧澶х被锛�" prop="productId">
- <el-select disabled v-model="form.productCategory" placeholder="璇烽�夋嫨" clearable filterable>
- <el-option v-for="item in productList" :key="item.id" :label="item.productName"
- :value="item.productName" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productManageId">
- <el-select disabled v-model="form.specificationModel" placeholder="璇峰厛閫夋嫨浜у搧澶х被" clearable filterable :disabled="!form.productCategory">
- <el-option v-for="item in productModelList" :key="item.id" :label="item.model"
- :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鍗曚綅锛�" prop="customerId">
- <el-input disabled v-model="form.unit" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="搴撳瓨鏃堕棿锛�" prop="projectName">
- <el-date-picker style="width: 100%" v-model="form.updateTime" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
- type="date" placeholder="璇烽�夋嫨" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鍏ュ簱鏃堕棿锛�" prop="projectName">
- <el-date-picker style="width: 100%" v-model="form.createTime" 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="customerId">
- <el-input disabled v-model="form.taxInclusiveUnitPrice" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="鍚◣鎬讳环锛�" prop="customerContractNo">
- <el-input disabled v-model="form.taxInclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
-
- <el-col :span="12">
- <el-form-item label="绋庣巼锛�" prop="customerId">
- <el-input disabled v-model="form.taxRate" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="涓嶅惈绋庢�讳环锛�" prop="entryDate">
- <el-input disabled v-model="form.taxExclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="30">
- <el-col :span="12">
- <el-form-item label="鍑哄簱浜猴細" prop="entryPerson">
- <el-select v-model="form.createUser" placeholder="璇烽�夋嫨" clearable>
- <el-option v-for="item in userList" :key="item.userId" :label="item.nickName" :value="item.userId" />
- </el-select>
- </el-form-item>
- </el-col>
-<!-- <el-col :span="12">-->
-<!-- <el-form-item label="搴撳瓨棰勮鏁伴噺锛�" prop="warnNum">-->
-<!-- <el-input v-model="form.warnNum" placeholder="璇疯緭鍏ユ渶浣庡簱瀛�" clearable />-->
-<!-- </el-form-item>-->
-<!-- </el-col>-->
- </el-row>
- </el-form>
- <template #footer>
- <div class="dialog-footer">
- <el-button type="primary" @click="submitForm">纭</el-button>
- <el-button @click="closeDia">鍙栨秷</el-button>
- </div>
- </template>
- </el-dialog>
+ <el-tabs v-model="activeTab" @tab-change="handleTabChange">
+ <el-tab-pane v-for="tab in tabs"
+ :label="tab.label"
+ :name="tab.name"
+ :key="tab.name">
+ <component :is="tab.name === 'qualified' ? QualifiedRecord : UnqualifiedRecord" />
+ </el-tab-pane>
+ </el-tabs>
</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 useUserStore from '@/store/modules/user'
-import { userListNoPageByTenantId } from "@/api/system/user.js";
-import { productTreeList,modelList } from "@/api/basicData/product.js"
-import { getCurrentDate } from "@/utils/index.js";
-import {
- getStockManagePage,
- delStockManage,
-} from "@/api/inventoryManagement/stockManage.js";
-import {
- updateManagement,updateStockIn
-} from "@/api/inventoryManagement/stockIn.js";
+import QualifiedRecord from "@/views/inventoryManagement/stockManagement/Qualified.vue";
+import UnqualifiedRecord from "@/views/inventoryManagement/stockManagement/Unqualified.vue";
-
-
-const userStore = useUserStore()
-const { proxy } = getCurrentInstance()
-const tableData = ref([])
-const productData = ref([])
-const selectedRows = ref([])
-const userList = ref([])
-const productList = ref([])
-const productModelList = ref([])
-// const customerOption = ref([])
-const tableLoading = ref(false)
-const page = reactive({
- current: 1,
- size: 100,
-})
-const total = ref(0)
-const fileList = ref([])
-const loading = ref(false);
-// 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
-const operationType = ref('')
-const dialogFormVisible = ref(false)
-const data = reactive({
- searchForm: {
- supplierName: '',
- timeStr: '',
+const activeTab = ref('qualified')
+const tabs = ref([
+ {
+ label: '鍚堟牸搴撳瓨',
+ name: 'qualified'
},
- form: {
- supplierId: null,
- supplierName: '',
- productId: null,
- productName: '',
- userId: userStore.userId,
- nickName: '',
- productModelId: null,
- model: '',
- unit: '',
- productrecordId: null,
- taxInclusiveUnitPrice: '',
- taxInclusiveTotalPrice: '',
- taxRate: '',
- taxExclusiveTotalPrice: '',
- inboundTime: '',
- inboundBatch: '',
- stockQuantity: '',
- boundTime: '',
- warnNum: '', // 鏂板鏈�浣庡簱瀛樺瓧娈�
- salesLedgerProductId: null,
- },
- rules: {
- supplierName: [{ required: true, message: '璇疯緭鍏ヤ緵搴斿晢鍚嶇О', trigger: 'blur' }],
- productCategory: [{ required: true, message: '璇烽�夋嫨浜у搧澶х被', trigger: 'change' }],
- specificationModel: [{ required: true, message: '璇疯緭鍏ヨ鏍煎瀷鍙�', trigger: 'blur' }],
- unit: [{ required: true, message: '璇疯緭鍏ュ崟浣�', trigger: 'blur' }],
- stockQuantity: [{ required: true, message: '璇疯緭鍏ュ嚭搴撴暟閲�', trigger: 'blur' }],
- taxInclusiveUnitPrice: [{ required: true, message: '璇疯緭鍏ュ惈绋庡崟浠�', trigger: 'blur' }],
- taxInclusiveTotalPrice: [{ required: true, message: '璇疯緭鍏ュ惈绋庢�讳环', trigger: 'blur' }],
- taxRate: [{ required: true, message: '璇疯緭鍏ョ◣鐜�', trigger: 'blur' }],
- taxExclusiveTotalPrice: [{ required: true, message: '璇疯緭鍏ヤ笉鍚◣鎬讳环', trigger: 'blur' }],
- boundTime: [{ required: true, message: '璇烽�夋嫨搴撳瓨鏃堕棿', trigger: 'change' }],
- inboundTime: [{ required: true, message: '璇烽�夋嫨鍏ュ簱鏃堕棿', trigger: 'change' }],
- inboundPerson: [{ required: true, message: '璇烽�夋嫨鍑哄簱浜�', trigger: 'change' }],
- warnNum: [{ required: true, message: '璇疯緭鍏ユ渶浣庡簱瀛�', trigger: 'blur' }],
+ {
+ label: '涓嶅悎鏍煎簱瀛�',
+ name: 'unqualified'
}
-})
-const { searchForm, form, rules } = toRefs(data)
+])
-// 鏌ヨ鍒楄〃
-/** 鎼滅储鎸夐挳鎿嶄綔 */
-const handleQuery = () => {
- page.current = 1
- getList()
+const handleTabChange = (tabName) => {
+ activeTab.value = tabName;
}
-const paginationChange = (obj) => {
- page.current = obj.page;
- page.size = obj.limit;
- getList()
-}
-const getList = () => {
- tableLoading.value = true
- getStockManagePage({ ...searchForm.value, ...page }).then(res => {
- tableLoading.value = false
- tableData.value = res.data.records
- total.value = res.data.total
- // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
- // checkStockAndCreatePurchase();
- }).catch(() => {
- tableLoading.value = false
- })
-}
-
-// 琛ㄦ牸閫夋嫨鏁版嵁
-const handleSelectionChange = (selection) => {
-
- // 杩囨护鎺夊瓙鏁版嵁
- selectedRows.value = selection.filter(item => item.id);
- console.log('selection', selectedRows.value)
-}
-const expandedRowKeys = ref([])
-
-// 涓昏〃鍚堣鏂规硶
-const summarizeMainTable = (param) => {
- return proxy.summarizeTable(param, ['contractAmount', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice']);
-};
-
-// 琛ㄦ牸琛岀被鍚�
-const tableRowClassName = ({ row }) => {
- const stock = Number(row?.inboundNum0 ?? 0);
- const warn = Number(row?.warnNum ?? 0);
- if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
- return '';
- }
- return stock < warn ? 'row-low-stock' : '';
-};
-
-// 鎵撳紑寮规
-const openForm = async (type, row) => {
- operationType.value = type
- form.value = {}
- productData.value = []
- let userLists = await userListNoPageByTenantId()
- userList.value = userLists.data
- if (type === 'edit') {
- form.value = { ...row }
- productTreeList().then(res =>{
- productList.value = res
- productList.value.forEach(i =>{
- if (i.label === row.productCategory) {
- modelList({ id: i.id }).then((res) => {
- productModelList.value = res;
- });
- }
- })
- })
- }
- form.value.entryDate = getCurrentDate() // 璁剧疆榛樿褰曞叆鏃ユ湡涓哄綋鍓嶆棩鏈�
- dialogFormVisible.value = true
-}
-
-// 鎻愪氦琛ㄥ崟
-const submitForm = () => {
- console.log(form.value)
- proxy.$refs["formRef"].validate(valid => {
- if (valid) {
-
- updateManagement(form.value).then(res => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛")
- closeDia()
- getList()
- // 鎻愪氦鍚庢鏌ュ簱瀛樺苟灏濊瘯鍒涘缓璇疯喘鍗�
- // checkStockAndCreatePurchase();
- })
- }
- })
-}
-// 妫�鏌ュ簱瀛樺苟鍒涘缓璇疯喘鍗�
-// const checkStockAndCreatePurchase = async () => {
-// const stockList = tableData.value;
-// // handList()
-// for (const item of stockList) {
-// if (item.inboundNum0 < item.warnNum) {
-// try {
-// const stockInData = {
-// id: item.id,
-// quantityStock: item.warnNum + item.totalInboundNum,// 浣跨敤鏂版牸寮忓寲鍑芥暟
-// };
-// loading.value = true
-// await updateStockIn(stockInData)
-// proxy.$modal.msgSuccess(`浜у搧 ${item.productCategory} 淇敼鍏ュ簱鎴愬姛`)
-// loading.value = false
-// } catch (error) {
-// proxy.$modal.msgError(`浜у搧 ${item.productCategory} 鐢熸垚璇疯喘鍗曞け璐ワ紝璇锋墜鍔ㄥ鐞哷);
-//
-// }
-// }
-// }
-// };
-// 鍏抽棴寮规
-const closeDia = () => {
- proxy.resetForm("formRef")
- dialogFormVisible.value = false
-}
-
-// 瀵煎嚭
-const handleOut = () => {
- ElMessageBox.confirm(
- '鏄惁纭瀵煎嚭锛�',
- '瀵煎嚭', {
- confirmButtonText: '纭',
- cancelButtonText: '鍙栨秷',
- type: 'warning',
- }
- ).then(() => {
- proxy.download("/stockin/exportCopy", {}, '搴撳瓨淇℃伅.xlsx')
- }).catch(() => {
- proxy.$modal.msg("宸插彇娑�")
- })
-}
-// 鍒犻櫎
-const handleDelete = () => {
- let ids = []
- if (selectedRows.value.length > 0) {
- // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
- const unauthorizedData = selectedRows.value.filter(item => item.createUser !== userStore.id);
- if (unauthorizedData.length > 0) {
- proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
- return;
- }
- ids = selectedRows.value.map(item => item.id);
- } else {
- proxy.$modal.msgWarning('璇烽�夋嫨鏁版嵁')
- return
- }
- ElMessageBox.confirm(
- '閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�',
- '瀵煎嚭', {
- confirmButtonText: '纭',
- cancelButtonText: '鍙栨秷',
- type: 'warning',
- }
- ).then(() => {
- delStockManage({ids:ids}).then(res => {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛")
- getList()
- })
- }).catch(() => {
- proxy.$modal.msg("宸插彇娑�")
- })
-}
-onMounted(() => {
- getList()
- // checkStockAndCreatePurchase();
- // 姣忓皬鏃舵鏌ヤ竴娆″簱瀛�
- // const intervalId = setInterval(checkStockAndCreatePurchase, 60 * 60 * 1000);
-
-// onUnmounted(() => {
-// // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
-// clearInterval(intervalId);
-// });
-})
</script>
-
-<style scoped lang="scss">
-:deep(.row-low-stock td) {
- background-color: #fde2e2;
- color: #c45656;
-}
-
-:deep(.row-low-stock:hover > td) {
- background-color: #fcd4d4;
-}
-</style>
diff --git a/src/views/productionManagement/productStructure/Detail/index.vue b/src/views/productionManagement/productStructure/Detail/index.vue
index 20a472b..360a124 100644
--- a/src/views/productionManagement/productStructure/Detail/index.vue
+++ b/src/views/productionManagement/productStructure/Detail/index.vue
@@ -2,133 +2,85 @@
<div class="app-container">
<PageHeader content="浜у搧缁撴瀯璇︽儏">
<template #right-button>
- <el-button v-if="dataValue.isEdit && !isOrderPage"
- type="primary"
- @click="addItem">娣诲姞
+ <el-button v-if="!dataValue.isEdit && !isOrderPage" type="primary" @click="dataValue.isEdit = true">缂栬緫
</el-button>
- <el-button v-if="!dataValue.isEdit && !isOrderPage"
- type="primary"
- @click="dataValue.isEdit = true">缂栬緫
+ <el-button v-if="dataValue.isEdit && !isOrderPage" type="primary" @click="cancelEdit">鍙栨秷
</el-button>
- <el-button v-if="dataValue.isEdit && !isOrderPage"
- type="primary"
- @click="cancelEdit">鍙栨秷
- </el-button>
- <el-button v-if="!isOrderPage"
- type="primary"
- :loading="dataValue.loading"
- @click="submit"
- :disabled="!dataValue.isEdit">纭
+ <el-button v-if="!isOrderPage" type="primary" :loading="dataValue.loading" @click="submit"
+ :disabled="!dataValue.isEdit">纭
</el-button>
</template>
</PageHeader>
- <el-table
- :data="tableData"
- border
- :preserve-expanded-content="false"
- :default-expand-all="true"
- style="width: 100%"
- >
+ <el-table :data="tableData" border :preserve-expanded-content="false" :default-expand-all="true"
+ style="width: 100%">
<el-table-column type="expand">
<template #default="props">
- <el-form ref="form"
- :model="dataValue">
- <el-table :data="dataValue.dataList"
- style="width: 100%">
- <el-table-column prop="productName"
- label="浜у搧"/>
- <el-table-column prop="model"
- label="瑙勬牸">
+ <el-form ref="form" :model="dataValue">
+ <el-table :data="dataValue.dataList" row-key="tempId" default-expand-all
+ :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" style="width: 100%">
+ <el-table-column prop="productName" label="浜у搧" />
+ <el-table-column prop="model" label="瑙勬牸">
<template #default="{ row, $index }">
<el-form-item v-if="dataValue.isEdit"
- :prop="`dataList.${$index}.model`"
- :rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur','change'] }]"
- style="margin: 0">
- <el-select v-model="row.model"
- placeholder="璇烽�夋嫨瑙勬牸"
- clearable
- :disabled="!dataValue.isEdit"
- style="width: 100%"
- @visible-change="(v) => { if (v) openDialog($index) }">
- <el-option v-if="row.model"
- :label="row.model"
- :value="row.model" />
+ :rules="[{ required: true, message: '璇烽�夋嫨瑙勬牸', trigger: ['blur', 'change'] }]" style="margin: 0">
+ <el-select v-model="row.model" placeholder="璇烽�夋嫨瑙勬牸" clearable
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+ style="width: 100%" @visible-change="(v) => { if (v) openDialog(row.tempId) }">
+ <el-option v-if="row.model" :label="row.model" :value="row.model" />
</el-select>
</el-form-item>
</template>
</el-table-column>
- <el-table-column prop="processId"
- label="娑堣�楀伐搴�">
+ <el-table-column prop="processName" label="娑堣�楀伐搴�">
<template #default="{ row, $index }">
- <el-form-item :prop="`dataList.${$index}.processId`"
- :rules="[{ required: true, message: '璇烽�夋嫨娑堣�楀伐搴�', trigger: 'change' }]"
- style="margin: 0">
- <el-select v-model="row.processId"
- placeholder="璇烽�夋嫨"
- filterable
- clearable
- style="width: 100%"
- :disabled="!dataValue.isEdit">
- <el-option v-for="item in dataValue.processOptions"
- :key="item.id"
- :label="item.name"
- :value="item.id" />
+ <el-form-item v-if="dataValue.isEdit"
+ :rules="dataValue.dataList.some(item => (item as any).tempId === row.tempId) ? [] : [{ required: true, message: '璇烽�夋嫨娑堣�楀伐搴�', trigger: 'change' }]"
+ style="margin: 0">
+ <el-select v-model="row.processId" placeholder="璇烽�夋嫨" filterable clearable style="width: 100%"
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)">
+ <el-option v-for="item in dataValue.processOptions" :key="item.id" :label="item.name"
+ :value="item.id" />
</el-select>
</el-form-item>
</template>
</el-table-column>
- <el-table-column prop="unitQuantity"
- label="鍗曚綅浜у嚭鎵�闇�鏁伴噺">
+ <el-table-column prop="unitQuantity" label="鍗曚綅浜у嚭鎵�闇�鏁伴噺">
<template #default="{ row, $index }">
- <el-form-item :prop="`dataList.${$index}.unitQuantity`"
- :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺', trigger: ['blur','change'] }]"
- style="margin: 0">
- <el-input-number v-model="row.unitQuantity"
- :min="0"
- :precision="2"
- :step="1"
- controls-position="right"
- style="width: 100%"
- :disabled="!dataValue.isEdit" />
+ <el-form-item v-if="dataValue.isEdit"
+ :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺', trigger: ['blur', 'change'] }]"
+ style="margin: 0">
+ <el-input-number v-model="row.unitQuantity" :min="0" :precision="2" :step="1"
+ controls-position="right" style="width: 100%"
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
</el-table-column>
- <el-table-column v-if="isOrderPage"
- prop="demandedQuantity"
- label="闇�姹傛�婚噺">
+ <el-table-column v-if="isOrderPage" prop="demandedQuantity" label="闇�姹傛�婚噺">
<template #default="{ row, $index }">
- <el-form-item :prop="`dataList.${$index}.demandedQuantity`"
- :rules="[{ required: true, message: '璇疯緭鍏ラ渶姹傛�婚噺', trigger: ['blur','change'] }]"
- style="margin: 0">
- <el-input-number v-model="row.demandedQuantity"
- :min="0"
- :precision="2"
- :step="1"
- controls-position="right"
- style="width: 100%"
- :disabled="!dataValue.isEdit" />
+ <el-form-item v-if="dataValue.isEdit"
+ :rules="[{ required: true, message: '璇疯緭鍏ラ渶姹傛�婚噺', trigger: ['blur', 'change'] }]" style="margin: 0">
+ <el-input-number v-model="row.demandedQuantity" :min="0" :precision="2" :step="1"
+ controls-position="right" style="width: 100%"
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
</el-table-column>
- <el-table-column prop="unit"
- label="鍗曚綅">
+ <el-table-column prop="unit" label="鍗曚綅">
<template #default="{ row, $index }">
- <el-form-item :prop="`dataList.${$index}.unit`"
- :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣�', trigger: ['blur','change'] }]"
- style="margin: 0">
- <el-input v-model="row.unit"
- placeholder="璇疯緭鍏ュ崟浣�"
- clearable
- :disabled="!dataValue.isEdit" />
+ <el-form-item v-if="dataValue.isEdit"
+ :rules="[{ required: true, message: '璇疯緭鍏ュ崟浣�', trigger: ['blur', 'change'] }]" style="margin: 0">
+ <el-input v-model="row.unit" placeholder="璇疯緭鍏ュ崟浣�" clearable
+ :disabled="!dataValue.isEdit || dataValue.dataList.some(item => (item as any).tempId === row.tempId)" />
</el-form-item>
</template>
</el-table-column>
- <el-table-column label="鎿嶄綔" fixed="right" width="100">
+ <el-table-column label="鎿嶄綔" fixed="right" width="200">
<template #default="{ row, $index }">
- <el-button v-if="dataValue.isEdit"
- type="danger"
- text
- @click="dataValue.dataList.splice($index, 1)">鍒犻櫎
+ <el-button
+ v-if="dataValue.isEdit && !dataValue.dataList.some(item => (item as any).tempId === row.tempId)"
+ type="danger" text @click="removeItem(row.tempId)">鍒犻櫎
+ </el-button>
+ <el-button v-if="dataValue.isEdit" type="primary" text @click="addItem2(row.tempId)">娣诲姞
</el-button>
</template>
</el-table-column>
@@ -140,10 +92,8 @@
<el-table-column label="浜у搧鍚嶇О" prop="productName" />
<el-table-column label="瑙勬牸鍨嬪彿" prop="model" />
</el-table>
-
- <product-select-dialog v-if="dataValue.showProductDialog"
- v-model:model-value="dataValue.showProductDialog"
- @confirm="handleProduct" />
+ <product-select-dialog v-if="dataValue.showProductDialog" v-model:model-value="dataValue.showProductDialog"
+ @confirm="handleProduct" />
</div>
</template>
@@ -160,36 +110,41 @@
import { listProcessBom } from "@/api/productionManagement/productionOrder.js";
import { list } from "@/api/productionManagement/productionProcess";
import { ElMessage } from "element-plus";
-import {useRoute, useRouter} from "vue-router";
+import { useRoute, useRouter } from "vue-router";
defineComponent({
name: "StructureEdit",
});
const ProductSelectDialog = defineAsyncComponent(
- () => import("@/views/basicData/product/ProductSelectDialog.vue")
+ () => import("@/views/basicData/product/ProductSelectDialog.vue")
);
+const emit = defineEmits(["update:router"]);
const form = ref();
-const route = useRoute()
-const router = useRouter()
+const route = useRoute();
+const router = useRouter();
const routeId = computed({
get() {
return route.query.id;
},
set(val) {
- emit('update:router', val)
- }
+ emit("update:router", val);
+ },
});
// 浠庤矾鐢卞弬鏁拌幏鍙栦骇鍝佷俊鎭�
-const routeBomNo = computed(() => route.query.bomNo || '');
-const routeProductName = computed(() => route.query.productName || '');
-const routeProductModelName = computed(() => route.query.productModelName || '');
+const routeBomNo = computed(() => route.query.bomNo || "");
+const routeProductName = computed(() => route.query.productName || "");
+const routeProductModelName = computed(
+ () => route.query.productModelName || ""
+);
const routeOrderId = computed(() => route.query.orderId);
const pageType = computed(() => route.query.type);
-const isOrderPage = computed(() => pageType.value === 'order' && routeOrderId.value);
+const isOrderPage = computed(
+ () => pageType.value === "order" && routeOrderId.value
+);
const dataValue = reactive({
dataList: [],
@@ -197,6 +152,7 @@
processOptions: [],
showProductDialog: false,
currentRowIndex: null,
+ currentRowName: null,
loading: false,
isEdit: false,
});
@@ -206,11 +162,12 @@
productName: "",
model: "",
bomNo: "",
- }
-])
+ },
+]);
-const openDialog = index => {
- dataValue.currentRowIndex = index;
+const openDialog = (tempId: any) => {
+ console.log(tempId, "tempId");
+ dataValue.currentRowName = tempId;
dataValue.showProductDialog = true;
};
@@ -218,83 +175,275 @@
if (isOrderPage.value) {
// 璁㈠崟鎯呭喌锛氫娇鐢ㄨ鍗曠殑浜у搧缁撴瀯鎺ュ彛
const { data } = await listProcessBom({ orderId: routeOrderId.value });
- dataValue.dataList = data || [];
+ dataValue.dataList = (data as any) || [];
} else {
// 闈炶鍗曟儏鍐碉細浣跨敤鍘熸潵鐨勬帴鍙�
const { data } = await queryList(routeId.value);
- dataValue.dataList = data || [];
+ dataValue.dataList = (data as any) || [];
+ // 涓烘墍鏈夐」鍙婂叾瀛愰」璁剧疆name灞炴��
+ const setNameRecursively = (items: any[]) => {
+ items.forEach((item: any) => {
+ item.tempId = item.id;
+ item.processName =
+ dataValue.processOptions.find(option => option.id === item.processId)
+ ?.name || "";
+ if (item.children && item.children.length > 0) {
+ setNameRecursively(item.children);
+ }
+ });
+ };
+ setNameRecursively(dataValue.dataList);
+ console.log(dataValue.dataList, "dataValue.dataList");
}
};
const fetchProcessOptions = async () => {
- const { data } = await list(routeId.value);
- dataValue.processOptions = data;
+ const { data } = await list();
+ dataValue.processOptions = data as any;
};
-const handleProduct = row => {
+const handleProduct = (row: any) => {
if (row?.length > 1) {
ElMessage.error("鍙兘閫夋嫨涓�涓骇鍝�");
}
- dataValue.dataList[dataValue.currentRowIndex].productName =
- row[0].productName;
- dataValue.dataList[dataValue.currentRowIndex].model = row[0].model;
- dataValue.dataList[dataValue.currentRowIndex].productModelId = row[0].id;
- dataValue.dataList[dataValue.currentRowIndex].unit = row[0].unit || "";
+ const productData = row[0];
+
+ // 鏈�澶栧眰缁勪欢涓紝涓庡綋鍓嶄骇鍝佺浉鍚岀殑浜у搧鍙兘鏈変竴涓�
+ const isTopLevel = dataValue.dataList.some(item => (item as any).tempId === dataValue.currentRowName);
+ if (isTopLevel) {
+ if (productData.productName === tableData[0].productName &&
+ productData.model === tableData[0].model) {
+ // 鏌ユ壘鏄惁宸茬粡鏈夊叾浠栭《灞傝宸茬粡鏄繖涓骇鍝�
+ const hasOther = dataValue.dataList.some(item =>
+ (item as any).tempId !== dataValue.currentRowName &&
+ (item as any).productName === tableData[0].productName &&
+ (item as any).model === tableData[0].model
+ );
+ if (hasOther) {
+ ElMessage.warning("鏈�澶栧眰鍜屽綋鍓嶄骇鍝佷竴鏍风殑涓�绾у彧鑳芥湁涓�涓�");
+ return;
+ }
+ }
+ }
+ // dataValue.dataList[dataValue.currentRowIndex].productName =
+ // row[0].productName;
+ // dataValue.dataList[dataValue.currentRowIndex].model = row[0].model;
+ // dataValue.dataList[dataValue.currentRowIndex].productModelId = row[0].id;
+ // dataValue.dataList[dataValue.currentRowIndex].unit = row[0].unit || "";
+ dataValue.dataList.map(item => {
+ if (item.tempId === dataValue.currentRowName) {
+ item.productName = productData.productName;
+ item.model = productData.model;
+ item.productModelId = productData.id;
+ item.unit = productData.unit || "";
+ return;
+ }
+ childItem(item, dataValue.currentRowName, productData);
+ });
dataValue.showProductDialog = false;
+};
+const childItem = (item: any, tempId: any, productData: any) => {
+ if (item.tempId === tempId) {
+ item.productName = productData.productName;
+ item.model = productData.model;
+ item.productModelId = productData.id;
+ item.unit = productData.unit || "";
+ return true;
+ }
+ if (item.children && item.children.length > 0) {
+ for (let child of item.children) {
+ if (childItem(child, tempId, productData)) {
+ return true;
+ }
+ }
+ }
+ return false;
+};
+
+// 閫掑綊鏍¢獙鎵�鏈夊眰绾х殑琛ㄥ崟鏁版嵁
+const validateAll = () => {
+ let isValid = true;
+
+ // 鏍¢獙鍑芥暟
+ const validateItem = (item: any, isTopLevel = false) => {
+ // 鏍¢獙褰撳墠椤圭殑蹇呭~瀛楁
+ if (!item.model) {
+ ElMessage.error("璇烽�夋嫨瑙勬牸");
+ isValid = false;
+ return;
+ }
+ if (!isTopLevel && !item.processId) {
+ ElMessage.error("璇烽�夋嫨娑堣�楀伐搴�");
+ isValid = false;
+ return;
+ }
+ if (!item.unitQuantity) {
+ ElMessage.error("璇疯緭鍏ュ崟浣嶄骇鍑烘墍闇�鏁伴噺");
+ isValid = false;
+ return;
+ }
+ if (isOrderPage.value && !item.demandedQuantity) {
+ ElMessage.error("璇疯緭鍏ラ渶姹傛�婚噺");
+ isValid = false;
+ return;
+ }
+ if (!item.unit) {
+ ElMessage.error("璇疯緭鍏ュ崟浣�");
+ isValid = false;
+ return;
+ }
+
+ // 閫掑綊鏍¢獙瀛愰」
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(child => {
+ validateItem(child, false);
+ });
+ }
+ };
+
+ // 閬嶅巻鎵�鏈夐《灞傞」
+ dataValue.dataList.forEach(item => {
+ validateItem(item, true);
+ });
+
+ return isValid;
};
const submit = () => {
- form.value
- .validate(valid => {
- dataValue.loading = true;
- if (valid) {
- add({
- bomId: routeId.value,
- productStructureList: dataValue.dataList || [],
- }).then(res => {
- router.push({
- path: '/productionManagement/productionManagement/productStructure/index',
- })
- ElMessage.success("淇濆瓨鎴愬姛");
- dataValue.loading = false;
- });
- }
+ dataValue.loading = true;
+
+ // 鍏堣繘琛岃〃鍗曟牎楠�
+ const valid = validateAll();
+ console.log(dataValue.dataList, "dataValue.dataList");
+ if (valid) {
+ add({
+ bomId: routeId.value,
+ children: dataValue.dataList || [],
+ })
+ .then(res => {
+ router.push({
+ path: "/productionManagement/productionManagement/productStructure/index",
+ });
+ ElMessage.success("淇濆瓨鎴愬姛");
+ dataValue.loading = false;
})
- .finally(() => {
+ .catch(() => {
dataValue.loading = false;
});
+ } else {
+ dataValue.loading = false;
+ }
};
-const addItem = () => {
- dataValue.dataList.push({
- productName: "",
- productId: "",
- model: undefined,
- productModelId: undefined,
- processId: "",
- unitQuantity: 0,
- demandedQuantity: 0,
- unit: "",
+const removeItem = (tempId: string) => {
+ // 鍏堝皾璇曚粠椤跺眰鍒犻櫎
+ const topIndex = dataValue.dataList.findIndex(item => item.tempId === tempId);
+ if (topIndex !== -1) {
+ dataValue.dataList.splice(topIndex, 1);
+ return;
+ }
+
+ // 閫掑綊鍒犻櫎瀛愰」
+ const delchildItem = (items: any[], tempId: any) => {
+ for (let i = 0; i < items.length; i++) {
+ const item = items[i];
+ if (item.tempId === tempId) {
+ items.splice(i, 1);
+ return true;
+ }
+ if (item.children && item.children.length > 0) {
+ if (delchildItem(item.children, tempId)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
+
+ dataValue.dataList.forEach(item => {
+ if (item.children && item.children.length > 0) {
+ delchildItem(item.children, tempId);
+ }
});
+};
+const addItem2 = tempId => {
+ dataValue.dataList.map(item => {
+ if (item.tempId === tempId) {
+ if (!item.children) {
+ item.children = [];
+ }
+ item.children.push({
+ parentId: item.id || "",
+ parentTempId: item.tempId || "",
+ productName: "",
+ productId: "",
+ model: undefined,
+ productModelId: undefined,
+ processId: "",
+ processName: "",
+ unitQuantity: 0,
+ demandedQuantity: 0,
+ unit: "",
+ children: [],
+
+ tempId: new Date().getTime(),
+ });
+ return;
+ }
+ addchildItem(item, tempId);
+ });
+};
+const addchildItem = (item: any, tempId: any) => {
+ if (item.tempId === tempId) {
+ console.log(item, "item");
+ if (!item.children) {
+ item.children = [];
+ }
+ item.children.push({
+ parentId: item.id || "",
+ parentTempId: item.tempId || "",
+ productName: "",
+ productId: "",
+ model: undefined,
+ productModelId: undefined,
+ processId: "",
+ unitQuantity: 0,
+ demandedQuantity: 0,
+ children: [],
+ unit: "",
+ tempId: new Date().getTime(),
+ });
+ return true;
+ }
+ if (item.children && item.children.length > 0) {
+ for (let child of item.children) {
+ if (addchildItem(child, tempId)) {
+ return true;
+ }
+ }
+ }
+ return false;
};
const cancelEdit = () => {
dataValue.isEdit = false;
- dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined);
+ // dataValue.dataList = dataValue.dataList.filter(item => item.id !== undefined);
+ fetchData();
};
-onMounted(() => {
+onMounted(async () => {
// 浠庤矾鐢卞弬鏁板洖鏄炬暟鎹�
- tableData[0].productName = routeProductName.value;
- tableData[0].model = routeProductModelName.value;
- tableData[0].bomNo = routeBomNo.value;
-
+ tableData[0].productName = routeProductName.value as string;
+ tableData[0].model = routeProductModelName.value as string;
+ tableData[0].bomNo = routeBomNo.value as string;
+
// 璁㈠崟鎯呭喌涓嬬鐢ㄧ紪杈�
if (isOrderPage.value) {
dataValue.isEdit = false;
}
-
- fetchData();
- fetchProcessOptions();
+
+ // 鍏堝姞杞藉伐搴忛�夐」锛屽啀鍔犺浇鏁版嵁锛岀‘淇漞l-select鑳藉姝g‘鍥炴樉
+ await fetchProcessOptions();
+ await fetchData();
});
</script>
\ No newline at end of file
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 54114f1..2d7bbd3 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -554,6 +554,7 @@
import { modelList, productTreeList } from "@/api/basicData/product.js";
import useFormData from "@/hooks/useFormData.js";
import dayjs from "dayjs";
+import FileListDialog from "@/components/Dialog/FileListDialog.vue";
const userStore = useUserStore();
const { proxy } = getCurrentInstance();
@@ -1675,6 +1676,7 @@
* @param row 涓嬭浇鏂囦欢鐨勭浉鍏充俊鎭璞�
*/
const fileListRef = ref(null)
+const fileListDialogVisible = ref(false);
const downLoadFile = (row) => {
getSalesLedgerWithProducts({ id: row.id, type: 1 }).then((res) => {
fileListRef.value.open(res.salesLedgerFiles)
--
Gitblit v1.9.3