From 4168871fd4c9525df5be9fc933f268f8766e9804 Mon Sep 17 00:00:00 2001 From: yangchunlong <292345300@qq.com> Date: Mon, 17 Nov 2025 15:53:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=A7=A9=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 10 ++++ src/styles/element.scss | 3 -- src/views/foundation/set/goods/add.vue | 53 +++++++++++++++++-- src/views/foundation/set/shop/index.vue | 14 +++-- .../shipment/outbound/shipmentOrder/index.vue | 42 ++++++++------- 5 files changed, 92 insertions(+), 30 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8b20db6..d99e383 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,6 +32,16 @@ import pinia from "@/stores"; import errorHandler from "@/utils/errorHandler"; import VXETable from "vxe-table"; import "vxe-table/lib/style.css"; + +// 全局添加 ElMessage 的高层级样式(不用再单独写 CSS 文件) +const style = document.createElement("style"); +style.textContent = ` + .el-message { + z-index: 3000 !important; + } +`; +document.head.appendChild(style); + localStorage.setItem("baseUrl", import.meta.env.VITE_SINGLE_URL); const app = createApp(App); diff --git a/src/styles/element.scss b/src/styles/element.scss index 40397b0..d5e98a7 100644 --- a/src/styles/element.scss +++ b/src/styles/element.scss @@ -268,6 +268,3 @@ text-overflow: ellipsis; white-space: nowrap; } -.el-message { - z-index: 888; -} diff --git a/src/views/foundation/set/goods/add.vue b/src/views/foundation/set/goods/add.vue index 1c3aac1..df50b3a 100644 --- a/src/views/foundation/set/goods/add.vue +++ b/src/views/foundation/set/goods/add.vue @@ -112,6 +112,7 @@ const handleButtonClickCallback = (item: any) => { if (type === "preview") { if (!dataStore.id) { useMsg("warning", "请先保存数据 !"); + return; } $router.push({ path: "/foundation/set/goods/preview", @@ -124,6 +125,30 @@ const handleButtonClickCallback = (item: any) => { }); } }; + +//去重 +const uniqueArrayObject = (arr: any[], uniqueKey: any = "value") => { + // 边界处理:如果传入的不是数组,直接返回空数组 + if (!Array.isArray(arr)) { + console.warn("传入的参数不是数组,返回空数组"); + return []; + } + // 方法1:Map 实现(高效,保留顺序) + const uniqueMap = new Map(); + arr.forEach(item => { + // 确保对象存在该字段,避免报错 + if (item.hasOwnProperty(uniqueKey)) { + // 以 uniqueKey 的值为键,重复键会自动覆盖(保留最后一次出现?不,forEach 顺序遍历,后出现的会覆盖前面的,如需保留首次出现,用下面的逻辑) + // 如需保留首次出现:只有 Map 中没有该键时才添加 + if (!uniqueMap.has(item[uniqueKey])) { + uniqueMap.set(item[uniqueKey], item); + } + } + }); + // 转换为数组返回 + return Array.from(uniqueMap.values()); +}; + //仓库列表 /foundation/set/goods/preview const getWarehousesList = async () => { const result = await getWarehousesListApi({ use_org_number: dataStore.ruleForm.use_org_number }); @@ -133,26 +158,46 @@ const getWarehousesList = async () => { let options: any = []; data.forEach((item: any) => { options.push({ - id: item.id, + // id: item.id, value: item.warehouse_number, label: item.warehouse_name }); }); dataStore.formData[1].options = options; + console.log(12121212); + console.log(dataStore.ruleForm); + console.log(dataStore.ruleForm.warehouse_number, "=dataStore.ruleForm="); + if (dataStore.ruleForm.warehouse_name) { + console.log("走到了这里"); + dataStore.formData[1].options.push({ + value: dataStore.ruleForm.warehouse_number, + label: dataStore.ruleForm.warehouse_name + }); + + dataStore.formData[1].options = uniqueArrayObject(dataStore.formData[1].options); + } } } }; const handleChange = (item: any) => { console.log(item); - getGoodsCheckExistsw(); + if (item.prop === "warehouse_number") { + if (!dataStore.ruleForm.use_org_number || !dataStore.ruleForm.warehouse_number) { + return; + } + getGoodsCheckExistsw(); + } }; //监听当前组织 watch( () => dataStore.ruleForm.use_org_number, (newVal: any) => { - if (newVal) { - getWarehousesList(); + if (!newVal) { + dataStore.ruleForm.warehouse_number = ""; + dataStore.formData[1].options = []; + return; } + getWarehousesList(); }, { deep: true, diff --git a/src/views/foundation/set/shop/index.vue b/src/views/foundation/set/shop/index.vue index 6923436..99d808d 100644 --- a/src/views/foundation/set/shop/index.vue +++ b/src/views/foundation/set/shop/index.vue @@ -125,6 +125,8 @@ const getShopAdd = async () => { setTimeout(() => { dataStore.dialogVisible = false; detailsRef?.value?.formElement?.resetFields(); + dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM); + dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA); proTableRef?.value!.getTableList(); }, 600); } @@ -137,6 +139,8 @@ const getShopUp = async () => { setTimeout(() => { dataStore.dialogVisible = false; detailsRef?.value?.formElement?.resetFields(); + dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM); + dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA); proTableRef?.value!.getTableList(); }, 600); } @@ -152,9 +156,10 @@ const getShopDetails = async (id: any) => { } }; // 表格row点击事件 -const handleOpen = (row: any) => { +const handleOpen = async (row: any) => { dataStore.rowId = row.id; - getShopDetails(row.id); + await getShopAccessSystem(); + await getShopDetails(row.id); }; // 獲取接入系統列表數據 const getShopAccessSystem = async () => { @@ -171,7 +176,7 @@ const getShopAccessSystem = async () => { dataStore.detailsFormData[2].options = options; } }; -getShopAccessSystem(); + // 导出 const handleExport = async () => { const result = await getShopListExportApi(dataStore.initParam); @@ -191,11 +196,13 @@ const handleButtonClickCallback = (item: any) => { if (type === "add") { dataStore.title = "新增店铺"; dataStore.dialogVisible = true; + getShopAccessSystem(); } }; // 弹窗取消 const handleClose = () => { dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM); + dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA); detailsRef?.value?.formElement?.resetFields(); dataStore.dialogVisible = false; }; @@ -243,7 +250,6 @@ const handleCommit = () => { }; // 搜索 const handleSearch = async (params: any) => { - console.log(params, "==============>"); dataStore.initParam = cloneDeep(params); //这里需要等到表格刷新以后才去请求 nextTick(() => { diff --git a/src/views/shipment/outbound/shipmentOrder/index.vue b/src/views/shipment/outbound/shipmentOrder/index.vue index 76893a6..ad54872 100644 --- a/src/views/shipment/outbound/shipmentOrder/index.vue +++ b/src/views/shipment/outbound/shipmentOrder/index.vue @@ -9,7 +9,7 @@ - + @@ -40,21 +40,19 @@ import ProTable from "@/components/ProTable/index.vue"; // import { useMsg } from "@/hooks/useMsg"; import PermissionButton from "@/components/PermissionButton/index.vue"; import { getMaterialListApi } from "@/api/modules/foundationMaterial"; -// import { useAuthStore } from "@/stores/modules/auth"; import { useRouter } from "vue-router"; import { RULE_FORM, FORM_DATA, COLUMNS, BUTTON } from "./constant/list/index"; //表格TS import { ProTableInstance } from "@/components/ProTable/interface"; -import { useUserStore } from "@/stores/modules/user"; + import { btnClick } from "./init"; //深拷贝方法 import { cloneDeep } from "lodash-es"; // 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数) -const proTable = ref(); +const proTableRef = ref(); const $router = useRouter(); -// 获取用户信息(组织id) -const userStore = useUserStore(); + // 数据源 const dataStore = reactive({ columns: COLUMNS, //列表配置项 @@ -78,17 +76,23 @@ const handleButtonClickCallback = (item: any) => { const handleOpen = (row: any) => { console.log(row); }; -watch( - () => userStore.orgCode, - newVal => { - dataStore.ruleForm.orgCode = newVal; - dataStore.initParam.orgCode = newVal; - }, - { - immediate: true, - deep: true - } -); + +// 搜索 +const handleSearch = async (params: any) => { + dataStore.initParam = cloneDeep(params); + //这里需要等到表格刷新以后才去请求 + nextTick(() => { + proTableRef?.value!.getTableList(); + }); +}; +// 重置 +const handleReset = () => { + dataStore.initParam = cloneDeep(RULE_FORM); + //这里需要等到表格刷新以后才去请求 + nextTick(() => { + proTableRef?.value!.getTableList(); + }); +};