fix: 🧩 修复bug
This commit is contained in:
10
src/main.ts
10
src/main.ts
@@ -32,6 +32,16 @@ import pinia from "@/stores";
|
|||||||
import errorHandler from "@/utils/errorHandler";
|
import errorHandler from "@/utils/errorHandler";
|
||||||
import VXETable from "vxe-table";
|
import VXETable from "vxe-table";
|
||||||
import "vxe-table/lib/style.css";
|
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);
|
localStorage.setItem("baseUrl", import.meta.env.VITE_SINGLE_URL);
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|||||||
@@ -268,6 +268,3 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.el-message {
|
|
||||||
z-index: 888;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ const handleButtonClickCallback = (item: any) => {
|
|||||||
if (type === "preview") {
|
if (type === "preview") {
|
||||||
if (!dataStore.id) {
|
if (!dataStore.id) {
|
||||||
useMsg("warning", "请先保存数据 !");
|
useMsg("warning", "请先保存数据 !");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
$router.push({
|
$router.push({
|
||||||
path: "/foundation/set/goods/preview",
|
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
|
//仓库列表 /foundation/set/goods/preview
|
||||||
const getWarehousesList = async () => {
|
const getWarehousesList = async () => {
|
||||||
const result = await getWarehousesListApi({ use_org_number: dataStore.ruleForm.use_org_number });
|
const result = await getWarehousesListApi({ use_org_number: dataStore.ruleForm.use_org_number });
|
||||||
@@ -133,26 +158,46 @@ const getWarehousesList = async () => {
|
|||||||
let options: any = [];
|
let options: any = [];
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
options.push({
|
options.push({
|
||||||
id: item.id,
|
// id: item.id,
|
||||||
value: item.warehouse_number,
|
value: item.warehouse_number,
|
||||||
label: item.warehouse_name
|
label: item.warehouse_name
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
dataStore.formData[1].options = options;
|
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) => {
|
const handleChange = (item: any) => {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
getGoodsCheckExistsw();
|
if (item.prop === "warehouse_number") {
|
||||||
|
if (!dataStore.ruleForm.use_org_number || !dataStore.ruleForm.warehouse_number) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getGoodsCheckExistsw();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//监听当前组织
|
//监听当前组织
|
||||||
watch(
|
watch(
|
||||||
() => dataStore.ruleForm.use_org_number,
|
() => dataStore.ruleForm.use_org_number,
|
||||||
(newVal: any) => {
|
(newVal: any) => {
|
||||||
if (newVal) {
|
if (!newVal) {
|
||||||
getWarehousesList();
|
dataStore.ruleForm.warehouse_number = "";
|
||||||
|
dataStore.formData[1].options = [];
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
getWarehousesList();
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: true,
|
deep: true,
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ const getShopAdd = async () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dataStore.dialogVisible = false;
|
dataStore.dialogVisible = false;
|
||||||
detailsRef?.value?.formElement?.resetFields();
|
detailsRef?.value?.formElement?.resetFields();
|
||||||
|
dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM);
|
||||||
|
dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA);
|
||||||
proTableRef?.value!.getTableList();
|
proTableRef?.value!.getTableList();
|
||||||
}, 600);
|
}, 600);
|
||||||
}
|
}
|
||||||
@@ -137,6 +139,8 @@ const getShopUp = async () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dataStore.dialogVisible = false;
|
dataStore.dialogVisible = false;
|
||||||
detailsRef?.value?.formElement?.resetFields();
|
detailsRef?.value?.formElement?.resetFields();
|
||||||
|
dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM);
|
||||||
|
dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA);
|
||||||
proTableRef?.value!.getTableList();
|
proTableRef?.value!.getTableList();
|
||||||
}, 600);
|
}, 600);
|
||||||
}
|
}
|
||||||
@@ -152,9 +156,10 @@ const getShopDetails = async (id: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 表格row点击事件
|
// 表格row点击事件
|
||||||
const handleOpen = (row: any) => {
|
const handleOpen = async (row: any) => {
|
||||||
dataStore.rowId = row.id;
|
dataStore.rowId = row.id;
|
||||||
getShopDetails(row.id);
|
await getShopAccessSystem();
|
||||||
|
await getShopDetails(row.id);
|
||||||
};
|
};
|
||||||
// 獲取接入系統列表數據
|
// 獲取接入系統列表數據
|
||||||
const getShopAccessSystem = async () => {
|
const getShopAccessSystem = async () => {
|
||||||
@@ -171,7 +176,7 @@ const getShopAccessSystem = async () => {
|
|||||||
dataStore.detailsFormData[2].options = options;
|
dataStore.detailsFormData[2].options = options;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getShopAccessSystem();
|
|
||||||
// 导出
|
// 导出
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
const result = await getShopListExportApi(dataStore.initParam);
|
const result = await getShopListExportApi(dataStore.initParam);
|
||||||
@@ -191,11 +196,13 @@ const handleButtonClickCallback = (item: any) => {
|
|||||||
if (type === "add") {
|
if (type === "add") {
|
||||||
dataStore.title = "新增店铺";
|
dataStore.title = "新增店铺";
|
||||||
dataStore.dialogVisible = true;
|
dataStore.dialogVisible = true;
|
||||||
|
getShopAccessSystem();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 弹窗取消
|
// 弹窗取消
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM);
|
dataStore.detailsRuleForm = cloneDeep(DETAILS_RULE_FORM);
|
||||||
|
dataStore.detailsFormData = cloneDeep(DETAILS_FORM_DATA);
|
||||||
detailsRef?.value?.formElement?.resetFields();
|
detailsRef?.value?.formElement?.resetFields();
|
||||||
dataStore.dialogVisible = false;
|
dataStore.dialogVisible = false;
|
||||||
};
|
};
|
||||||
@@ -243,7 +250,6 @@ const handleCommit = () => {
|
|||||||
};
|
};
|
||||||
// 搜索
|
// 搜索
|
||||||
const handleSearch = async (params: any) => {
|
const handleSearch = async (params: any) => {
|
||||||
console.log(params, "==============>");
|
|
||||||
dataStore.initParam = cloneDeep(params);
|
dataStore.initParam = cloneDeep(params);
|
||||||
//这里需要等到表格刷新以后才去请求
|
//这里需要等到表格刷新以后才去请求
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ProTable
|
<ProTable
|
||||||
ref="proTable"
|
ref="proTableRef"
|
||||||
:formData="dataStore.formData"
|
:formData="dataStore.formData"
|
||||||
:columns="dataStore.columns"
|
:columns="dataStore.columns"
|
||||||
:request-api="getMaterialListApi"
|
:request-api="getMaterialListApi"
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
{{ scope.row.boxBillNo }}
|
{{ scope.row.boxBillNo }}
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
<!-- <template v-slot:search>
|
<template v-slot:search>
|
||||||
<SearchForm
|
<SearchForm
|
||||||
@search="handleSearch"
|
@search="handleSearch"
|
||||||
@reset="handleReset"
|
@reset="handleReset"
|
||||||
:searchParams="dataStore.initParam"
|
:searchParams="dataStore.initParam"
|
||||||
:formData="dataStore.formData"
|
:formData="dataStore.formData"
|
||||||
/>
|
/>
|
||||||
</template> -->
|
</template>
|
||||||
</ProTable>
|
</ProTable>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -40,21 +40,19 @@ import ProTable from "@/components/ProTable/index.vue";
|
|||||||
// import { useMsg } from "@/hooks/useMsg";
|
// import { useMsg } from "@/hooks/useMsg";
|
||||||
import PermissionButton from "@/components/PermissionButton/index.vue";
|
import PermissionButton from "@/components/PermissionButton/index.vue";
|
||||||
import { getMaterialListApi } from "@/api/modules/foundationMaterial";
|
import { getMaterialListApi } from "@/api/modules/foundationMaterial";
|
||||||
// import { useAuthStore } from "@/stores/modules/auth";
|
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { RULE_FORM, FORM_DATA, COLUMNS, BUTTON } from "./constant/list/index";
|
import { RULE_FORM, FORM_DATA, COLUMNS, BUTTON } from "./constant/list/index";
|
||||||
//表格TS
|
//表格TS
|
||||||
import { ProTableInstance } from "@/components/ProTable/interface";
|
import { ProTableInstance } from "@/components/ProTable/interface";
|
||||||
import { useUserStore } from "@/stores/modules/user";
|
|
||||||
import { btnClick } from "./init";
|
import { btnClick } from "./init";
|
||||||
//深拷贝方法
|
//深拷贝方法
|
||||||
import { cloneDeep } from "lodash-es";
|
import { cloneDeep } from "lodash-es";
|
||||||
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
|
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
|
||||||
const proTable = ref<ProTableInstance>();
|
const proTableRef = ref<ProTableInstance>();
|
||||||
|
|
||||||
const $router = useRouter();
|
const $router = useRouter();
|
||||||
// 获取用户信息(组织id)
|
|
||||||
const userStore = useUserStore();
|
|
||||||
// 数据源
|
// 数据源
|
||||||
const dataStore = reactive<any>({
|
const dataStore = reactive<any>({
|
||||||
columns: COLUMNS, //列表配置项
|
columns: COLUMNS, //列表配置项
|
||||||
@@ -78,17 +76,23 @@ const handleButtonClickCallback = (item: any) => {
|
|||||||
const handleOpen = (row: any) => {
|
const handleOpen = (row: any) => {
|
||||||
console.log(row);
|
console.log(row);
|
||||||
};
|
};
|
||||||
watch(
|
|
||||||
() => userStore.orgCode,
|
// 搜索
|
||||||
newVal => {
|
const handleSearch = async (params: any) => {
|
||||||
dataStore.ruleForm.orgCode = newVal;
|
dataStore.initParam = cloneDeep(params);
|
||||||
dataStore.initParam.orgCode = newVal;
|
//这里需要等到表格刷新以后才去请求
|
||||||
},
|
nextTick(() => {
|
||||||
{
|
proTableRef?.value!.getTableList();
|
||||||
immediate: true,
|
});
|
||||||
deep: true
|
};
|
||||||
}
|
// 重置
|
||||||
);
|
const handleReset = () => {
|
||||||
|
dataStore.initParam = cloneDeep(RULE_FORM);
|
||||||
|
//这里需要等到表格刷新以后才去请求
|
||||||
|
nextTick(() => {
|
||||||
|
proTableRef?.value!.getTableList();
|
||||||
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scope lang="scss">
|
<style scope lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user