fix: 🧩 修复bug
This commit is contained in:
3
src/components.d.ts
vendored
3
src/components.d.ts
vendored
@@ -16,6 +16,7 @@ declare module "vue" {
|
||||
ElBreadcrumb: typeof import("element-plus/es")["ElBreadcrumb"];
|
||||
ElBreadcrumbItem: typeof import("element-plus/es")["ElBreadcrumbItem"];
|
||||
ElButton: typeof import("element-plus/es")["ElButton"];
|
||||
ElCheckbox: typeof import("element-plus/es")["ElCheckbox"];
|
||||
ElContainer: typeof import("element-plus/es")["ElContainer"];
|
||||
ElDatePicker: typeof import("element-plus/es")["ElDatePicker"];
|
||||
ElDialog: typeof import("element-plus/es")["ElDialog"];
|
||||
@@ -28,6 +29,7 @@ declare module "vue" {
|
||||
ElHeader: typeof import("element-plus/es")["ElHeader"];
|
||||
ElIcon: typeof import("element-plus/es")["ElIcon"];
|
||||
ElInput: typeof import("element-plus/es")["ElInput"];
|
||||
ElInputNumber: typeof import("element-plus/es")["ElInputNumber"];
|
||||
ElMain: typeof import("element-plus/es")["ElMain"];
|
||||
ElMenu: typeof import("element-plus/es")["ElMenu"];
|
||||
ElMenuItem: typeof import("element-plus/es")["ElMenuItem"];
|
||||
@@ -42,6 +44,7 @@ declare module "vue" {
|
||||
ElTabPane: typeof import("element-plus/es")["ElTabPane"];
|
||||
ElTabs: typeof import("element-plus/es")["ElTabs"];
|
||||
ElTag: typeof import("element-plus/es")["ElTag"];
|
||||
ElTooltip: typeof import("element-plus/es")["ElTooltip"];
|
||||
Empty: typeof import("./components/ProTable/components/Empty.vue")["default"];
|
||||
Form: typeof import("./components/Form/index.vue")["default"];
|
||||
FormItem: typeof import("./components/Form/components/FormItem.vue")["default"];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div v-if="formData.length" class="table-search" style="display: flex">
|
||||
<div v-if="_formData.length" class="table-search" style="display: flex">
|
||||
<div style="flex: 2">
|
||||
<el-form ref="formRef" :model="_searchParams" :inline="true">
|
||||
<template v-for="item in formData" :key="item.prop">
|
||||
<template v-for="item in _formData" :key="item.prop">
|
||||
<el-form-item
|
||||
:prop="item.prop"
|
||||
:label-width="item.labelWidth ? item.labelWidth : '120px'"
|
||||
@@ -115,7 +115,7 @@
|
||||
}
|
||||
"
|
||||
:disabled="item.disabled"
|
||||
style="width: 224px"
|
||||
style="width: 224px; max-height: 80px; overflow-y: auto"
|
||||
>
|
||||
<el-option
|
||||
:label="option.label"
|
||||
@@ -136,7 +136,7 @@
|
||||
:placeholder="item.placeholder"
|
||||
class="m-2 select"
|
||||
:reserve-keyword="false"
|
||||
style="width: 224px"
|
||||
style="width: 224px; max-height: 80px; overflow-y: auto"
|
||||
@remove-tag="handleTagRemove1(item)"
|
||||
ref="remoteRef"
|
||||
>
|
||||
@@ -190,8 +190,7 @@ import {
|
||||
getWarehousesKingdeeListApi,
|
||||
getSubwarehouseskingdeeListApi
|
||||
} from "@/api/modules/global";
|
||||
// // getWarehousesKingdeeListApi getSubwarehouseskingdeeListApi getWarehousesJushuitanListApi getWarehousesLingXingListApi
|
||||
// import { getWarehousesKingdeeListApi, getSubwarehouseskingdeeListApi } from "@/api/modules/setWarehouse";
|
||||
|
||||
const props = defineProps<{
|
||||
formData: any[];
|
||||
searchParams: Record<string, any>;
|
||||
@@ -203,13 +202,16 @@ const emits = defineEmits<{
|
||||
(e: "reset", result: Record<string, any>): void;
|
||||
(e: "selectMultipleRemoveTag", result: Record<string, any>): void;
|
||||
}>();
|
||||
|
||||
const $router = useRouter();
|
||||
const routeName: any = ref($router.currentRoute.value.name);
|
||||
let loading = ref(false);
|
||||
const remoteRef = ref(null);
|
||||
const _searchParams: any = computed(() => {
|
||||
return props.searchParams;
|
||||
});
|
||||
|
||||
const _formData: any = computed(() => {
|
||||
return props.formData;
|
||||
});
|
||||
//日期选择后重选赋值
|
||||
const handlePicker = (item: any) => {
|
||||
const { prop } = item;
|
||||
@@ -274,15 +276,15 @@ const getProductLines = async (keywords: any, item: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
//金蝶仓库
|
||||
const getSetWarehouseKingdeeList = async (keywords: any, item: any) => {
|
||||
//金蝶仓库 keywords: any, item: any
|
||||
const getSetWarehouseKingdeeList = async () => {
|
||||
const useOrgNumber: any[] = _searchParams?.value?.use_org_number;
|
||||
if (Array.isArray(useOrgNumber) && useOrgNumber?.length > 0) {
|
||||
item.options = [];
|
||||
_formData.value[1].options = [];
|
||||
let use_org_number = "";
|
||||
use_org_number = _searchParams.value.use_org_number.join(",");
|
||||
const result = await getWarehousesKingdeeListApi({
|
||||
keywords: keywords,
|
||||
// keywords: keywords,
|
||||
use_org_number
|
||||
});
|
||||
if (result?.code === 0) {
|
||||
@@ -294,20 +296,19 @@ const getSetWarehouseKingdeeList = async (keywords: any, item: any) => {
|
||||
use_org_number: it.use_org_number
|
||||
});
|
||||
});
|
||||
item.options = options;
|
||||
_formData.value[1].options = options;
|
||||
}
|
||||
}
|
||||
};
|
||||
//获取金蝶子仓库
|
||||
const getSetWarehouseSubwarehousesList = async (keywords: any, item: any) => {
|
||||
const getSetWarehouseSubwarehousesList = async () => {
|
||||
const kdWarehouseNumber: any[] = _searchParams?.value?.kd_warehouse_number;
|
||||
if (Array.isArray(kdWarehouseNumber) && kdWarehouseNumber?.length > 0) {
|
||||
//先清空一下
|
||||
item.options = [];
|
||||
_formData.value[2].options = [];
|
||||
let kd_warehouse_number = "";
|
||||
kd_warehouse_number = _searchParams.value.kd_warehouse_number.join(",");
|
||||
const result = await getSubwarehouseskingdeeListApi({
|
||||
keywords,
|
||||
warehouse_number: kd_warehouse_number
|
||||
});
|
||||
if (result?.code === 0) {
|
||||
@@ -319,7 +320,7 @@ const getSetWarehouseSubwarehousesList = async (keywords: any, item: any) => {
|
||||
warehouse_number: it.warehouse_number
|
||||
});
|
||||
});
|
||||
item.options = options;
|
||||
_formData.value[2].options = options;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -345,11 +346,12 @@ const handleSelectMultipleRemote = async (query: any, item: any) => {
|
||||
} else if (item.type === "selectProductLinesRemote") {
|
||||
//品线
|
||||
getProductLines(valClone, item);
|
||||
} else if (item.type === "selectRemoteKD") {
|
||||
getSetWarehouseKingdeeList(valClone, item);
|
||||
} else if (item.type === "selectRemoteKDSubwarehouse") {
|
||||
getSetWarehouseSubwarehousesList(valClone, item);
|
||||
}
|
||||
// else if (item.type === "selectRemoteKD") {
|
||||
// getSetWarehouseKingdeeList(valClone, item);
|
||||
// } else if (item.type === "selectRemoteKDSubwarehouse") {
|
||||
// getSetWarehouseSubwarehousesList(valClone, item);
|
||||
// }
|
||||
loading.value = false;
|
||||
};
|
||||
const handleTagRemove = (item: any) => {
|
||||
@@ -408,6 +410,37 @@ const handleFormSearch = () => {
|
||||
const handleFormReset = () => {
|
||||
emits("reset", _searchParams.value);
|
||||
};
|
||||
watch(
|
||||
() => _searchParams?.value?.use_org_number,
|
||||
newVal => {
|
||||
if (routeName.value === "foundationSetWarehouse") {
|
||||
if (!newVal || !newVal.length) {
|
||||
_formData.value[1].options = [];
|
||||
_formData.value[2].options = [];
|
||||
}
|
||||
getSetWarehouseKingdeeList();
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => _searchParams?.value?.kd_warehouse_number,
|
||||
newVal => {
|
||||
if (routeName.value === "foundationSetWarehouse") {
|
||||
if (!newVal || !newVal.length) {
|
||||
_formData.value[2].options = [];
|
||||
}
|
||||
getSetWarehouseSubwarehousesList();
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="scss" scope>
|
||||
@use "./index.scss";
|
||||
|
||||
@@ -124,6 +124,7 @@ const getShopAdd = async () => {
|
||||
useMsg("success", "新增成功 !");
|
||||
setTimeout(() => {
|
||||
dataStore.dialogVisible = false;
|
||||
detailsRef?.value?.formElement?.resetFields();
|
||||
proTableRef?.value!.getTableList();
|
||||
}, 600);
|
||||
}
|
||||
@@ -135,6 +136,7 @@ const getShopUp = async () => {
|
||||
useMsg("success", "更新成功 !");
|
||||
setTimeout(() => {
|
||||
dataStore.dialogVisible = false;
|
||||
detailsRef?.value?.formElement?.resetFields();
|
||||
proTableRef?.value!.getTableList();
|
||||
}, 600);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export const FORM_DATA: FormItem[] = [
|
||||
{
|
||||
prop: "kd_warehouse_number",
|
||||
placeholder: "请输入金蝶仓库",
|
||||
type: "selectRemoteKD",
|
||||
type: "selectMultiple",
|
||||
label: "金蝶仓库: ",
|
||||
options: []
|
||||
},
|
||||
@@ -34,7 +34,7 @@ export const FORM_DATA: FormItem[] = [
|
||||
{
|
||||
prop: "kd_subwarehouse_number",
|
||||
placeholder: "请输入金蝶子仓库",
|
||||
type: "selectRemoteKDSubwarehouse",
|
||||
type: "selectMultiple",
|
||||
label: "金蝶子仓库: ",
|
||||
options: []
|
||||
},
|
||||
|
||||
@@ -139,6 +139,7 @@ const getWarehouseAdd = async (params: any) => {
|
||||
useMsg("success", "新增成功 !");
|
||||
setTimeout(() => {
|
||||
dataStore.dialogVisible = false;
|
||||
detailsRef?.value?.formElement?.resetFields();
|
||||
proTableRef?.value!.getTableList();
|
||||
}, 600);
|
||||
}
|
||||
@@ -150,6 +151,7 @@ const getWarehouseUp = async (params: any) => {
|
||||
useMsg("success", "更新成功 !");
|
||||
setTimeout(() => {
|
||||
dataStore.dialogVisible = false;
|
||||
detailsRef?.value?.formElement?.resetFields();
|
||||
proTableRef?.value!.getTableList();
|
||||
}, 600);
|
||||
}
|
||||
@@ -161,6 +163,7 @@ const getWarehouseDetails = async (id: any) => {
|
||||
dataStore.dialogVisible = true;
|
||||
dataStore.title = "编辑金蝶子仓与各系统仓库关系";
|
||||
dataStore.detailsRuleForm = result?.data;
|
||||
|
||||
//临时变量存储金蝶和金蝶子仓库
|
||||
let kd_warehouse_number = dataStore?.detailsRuleForm?.kd_warehouse_number;
|
||||
let kd_subwarehouse = dataStore?.detailsRuleForm?.kd_subwarehouse;
|
||||
@@ -177,7 +180,7 @@ const getWarehouseDetails = async (id: any) => {
|
||||
}
|
||||
};
|
||||
//获取金蝶仓库
|
||||
const getSetWarehouseKingdeeList = async () => {
|
||||
const getSetWarehouseKingdeeList = async (type: any) => {
|
||||
dataStore.detailsFormData[1].options = [];
|
||||
const result = await getWarehousesKingdeeListApi({ use_org_number: dataStore.detailsRuleForm.use_org_number });
|
||||
if (result?.code === 0) {
|
||||
@@ -188,11 +191,45 @@ const getSetWarehouseKingdeeList = async () => {
|
||||
value: item.warehouse_number
|
||||
});
|
||||
});
|
||||
dataStore.detailsFormData[1].options = options;
|
||||
if (type === "details") {
|
||||
dataStore.detailsFormData[1].options = options;
|
||||
if (dataStore.detailsRuleForm.kd_warehouse_number) {
|
||||
dataStore.detailsFormData[1].options.push({
|
||||
label: dataStore.detailsRuleForm.kd_warehouse_number,
|
||||
value: dataStore.detailsRuleForm.kd_warehouse_number
|
||||
});
|
||||
dataStore.detailsFormData[1].options = uniqueArrayObject(dataStore.detailsFormData[1].options);
|
||||
}
|
||||
} else {
|
||||
dataStore.formData[1].options = options;
|
||||
}
|
||||
}
|
||||
};
|
||||
//去重
|
||||
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());
|
||||
};
|
||||
|
||||
//获取金蝶子仓库
|
||||
const getSetWarehouseSubwarehousesList = async () => {
|
||||
const getSetWarehouseSubwarehousesList = async (type: any) => {
|
||||
//先清空一下
|
||||
dataStore.detailsFormData[2].options = [];
|
||||
const result = await getSubwarehouseskingdeeListApi({
|
||||
@@ -206,7 +243,19 @@ const getSetWarehouseSubwarehousesList = async () => {
|
||||
value: item.sub_warehouse_number
|
||||
});
|
||||
});
|
||||
dataStore.detailsFormData[2].options = options;
|
||||
if (type === "details") {
|
||||
dataStore.detailsFormData[2].options = options;
|
||||
if (dataStore.detailsRuleForm.kd_subwarehouse.length) {
|
||||
let options: any = [];
|
||||
dataStore.detailsRuleForm.kd_subwarehouse.forEach((item: any) => {
|
||||
options.push({ label: item.subwarehouse_name, value: item.subwarehouse_number });
|
||||
});
|
||||
dataStore.detailsFormData[2].options = [...dataStore.detailsFormData[2].options, ...options];
|
||||
dataStore.detailsFormData[2].options = uniqueArrayObject(dataStore.detailsFormData[2].options);
|
||||
}
|
||||
} else {
|
||||
dataStore.formData[2].options = options;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -222,6 +271,14 @@ const getSetWarehouseSubwarehousesLingXingList = async () => {
|
||||
});
|
||||
});
|
||||
dataStore.detailsFormData[4].options = options;
|
||||
//领星
|
||||
if (dataStore.detailsRuleForm.lx_warehouse_number) {
|
||||
dataStore.detailsFormData[4].options.push({
|
||||
label: dataStore.detailsRuleForm.lx_warehouse_name,
|
||||
value: dataStore.detailsRuleForm.lx_warehouse_number
|
||||
});
|
||||
dataStore.detailsFormData[4].options = uniqueArrayObject(dataStore.detailsFormData[4].options);
|
||||
}
|
||||
}
|
||||
};
|
||||
//获取聚水潭仓库
|
||||
@@ -236,6 +293,13 @@ const getSetWarehouseSubwarehousesJushuitanList = async () => {
|
||||
});
|
||||
});
|
||||
dataStore.detailsFormData[3].options = options;
|
||||
if (dataStore.detailsRuleForm.lx_warehouse_number) {
|
||||
dataStore.detailsFormData[3].options.push({
|
||||
label: dataStore.detailsRuleForm.lx_warehouse_name,
|
||||
value: dataStore.detailsRuleForm.lx_warehouse_number
|
||||
});
|
||||
dataStore.detailsFormData[3].options = uniqueArrayObject(dataStore.detailsFormData[3].options);
|
||||
}
|
||||
}
|
||||
};
|
||||
// 表格row点击事件
|
||||
@@ -250,9 +314,6 @@ const handleButtonClickCallback = (item: any) => {
|
||||
if (type === "del") {
|
||||
handleDel();
|
||||
}
|
||||
// if (type === "export") {
|
||||
// handleExport();
|
||||
// }
|
||||
if (type === "add") {
|
||||
dataStore.title = "新增金蝶子仓与各系统仓库关系";
|
||||
dataStore.dialogVisible = true;
|
||||
@@ -396,7 +457,7 @@ watch(
|
||||
(newVal: any) => {
|
||||
if (newVal) {
|
||||
//金蝶倉庫
|
||||
getSetWarehouseKingdeeList();
|
||||
getSetWarehouseKingdeeList("details");
|
||||
//领星仓库
|
||||
getSetWarehouseSubwarehousesLingXingList();
|
||||
//聚水潭仓库
|
||||
@@ -414,7 +475,7 @@ watch(
|
||||
if (newVal) {
|
||||
dataStore.detailsRuleForm.kd_warehouse_number = "";
|
||||
dataStore.detailsRuleForm.kd_subwarehouse_number = "";
|
||||
getSetWarehouseKingdeeList();
|
||||
getSetWarehouseKingdeeList("details");
|
||||
} else {
|
||||
dataStore.detailsRuleForm.kd_warehouse_number = "";
|
||||
dataStore.detailsRuleForm.kd_subwarehouse_number = "";
|
||||
@@ -429,7 +490,7 @@ watch(
|
||||
(newVal: any) => {
|
||||
if (newVal) {
|
||||
dataStore.detailsRuleForm.kd_subwarehouse_number = "";
|
||||
getSetWarehouseSubwarehousesList();
|
||||
getSetWarehouseSubwarehousesList("details");
|
||||
} else {
|
||||
dataStore.detailsRuleForm.kd_subwarehouse_number = "";
|
||||
dataStore.detailsFormData[2].options = [];
|
||||
|
||||
@@ -22,6 +22,14 @@
|
||||
{{ scope.row.boxBillNo }}
|
||||
</a>
|
||||
</template>
|
||||
<!-- <template v-slot:search>
|
||||
<SearchForm
|
||||
@search="handleSearch"
|
||||
@reset="handleReset"
|
||||
:searchParams="dataStore.initParam"
|
||||
:formData="dataStore.formData"
|
||||
/>
|
||||
</template> -->
|
||||
</ProTable>
|
||||
</div>
|
||||
</template>
|
||||
@@ -66,25 +74,7 @@ const selectionChange = (selection: any) => {
|
||||
const handleButtonClickCallback = (item: any) => {
|
||||
btnClick[item?.type](item, $router);
|
||||
};
|
||||
// // 规格型号
|
||||
// const remoteMethod1 = async (query: any) => {
|
||||
// datas.loading = true;
|
||||
// if (!query) {
|
||||
// datas.loading = false;
|
||||
// return;
|
||||
// }
|
||||
// let valClone = query.replace(/^\s*|\s*$/g, "");
|
||||
// if (!valClone.length) {
|
||||
// datas.loading = false;
|
||||
// return;
|
||||
// }
|
||||
// const result = await getMaterialListApi(valClone);
|
||||
// if (result.status === 200) {
|
||||
// const { data } = result;
|
||||
// datas.options = data;
|
||||
// }
|
||||
// datas.loading = false;
|
||||
// };
|
||||
|
||||
const handleOpen = (row: any) => {
|
||||
console.log(row);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user