feat: 🚀 物料列表刷新
This commit is contained in:
@@ -8,3 +8,7 @@ import http from "@/api";
|
||||
export const getMaterialListApi = (params: any) => {
|
||||
return http.get<any>(`material`, params);
|
||||
};
|
||||
//刷新 /admapi/material/reload
|
||||
export const getMaterialListReloadApi = (params: any) => {
|
||||
return http.get<any>(`material/reload`, params);
|
||||
};
|
||||
|
||||
@@ -24,3 +24,8 @@ export const getUsersApi = (params: any) => {
|
||||
export const getProductLinesApi = (params: any) => {
|
||||
return http.get<any>(`basicinfo/productlines`, params);
|
||||
};
|
||||
|
||||
//仓库
|
||||
export const getWarehousesListApi = () => {
|
||||
return http.get<any>(`basicinfo/warehouses`);
|
||||
};
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
||||
export const useFilter = (datas: any) => {
|
||||
const target = cloneDeep(datas);
|
||||
const returnTarget = target.filter((item: any) => {
|
||||
return !item.disable;
|
||||
});
|
||||
return returnTarget;
|
||||
};
|
||||
@@ -31,7 +31,7 @@ export const useTable = (
|
||||
}
|
||||
});
|
||||
|
||||
//订阅列表数据处理
|
||||
//数据处理
|
||||
const initSubscribeData = () => {
|
||||
if (routeName === "foundationSubscribeList") {
|
||||
if (Array.isArray(state.totalParam?.org_number) && state.totalParam?.org_number?.length) {
|
||||
|
||||
@@ -2,7 +2,7 @@ export const BUTTON = [
|
||||
{
|
||||
text: "导出",
|
||||
permission: "foundationSetMaterialBtnExport",
|
||||
type: "add",
|
||||
type: "export",
|
||||
props: {
|
||||
type: "primary"
|
||||
}
|
||||
@@ -10,6 +10,6 @@ export const BUTTON = [
|
||||
{
|
||||
text: "刷新",
|
||||
permission: "foundationSetMaterialBtnRefresh",
|
||||
type: "del"
|
||||
type: "reset"
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { getMaterialListReloadApi } from "@/api/modules/foundationMaterial";
|
||||
import { useMsg } from "@/hooks/useMsg";
|
||||
//getMaterialListResetApi
|
||||
// 直接导出函数,无需额外包装对象
|
||||
export const handleDel = (item: any, selectionList: any[], proTable: any) => {
|
||||
export const handleExport = (item: any, selectionList: any[], proTable: any) => {
|
||||
console.log("导出操作", item);
|
||||
console.log(selectionList, "=selectionList=");
|
||||
let length = selectionList.length;
|
||||
@@ -24,8 +26,8 @@ export const handleDel = (item: any, selectionList: any[], proTable: any) => {
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
// proTable: any
|
||||
export const handleAdd = (item: any, selectionList: any[]) => {
|
||||
// proTable: any getMaterialListReloadApi
|
||||
export const handleReload = async (item: any, selectionList: any[], proTable: any) => {
|
||||
console.log("刷新操作", item);
|
||||
let length = selectionList.length;
|
||||
let ids: any = [];
|
||||
@@ -36,9 +38,15 @@ export const handleAdd = (item: any, selectionList: any[]) => {
|
||||
selectionList.forEach((item: any) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
let id = ids.join(",");
|
||||
const result = await getMaterialListReloadApi({ id });
|
||||
if (result?.code === 0) {
|
||||
useMsg("success", "数据刷新成功 !");
|
||||
proTable.value!.getTableList();
|
||||
}
|
||||
};
|
||||
|
||||
export const btnClick: any = {
|
||||
del: handleDel,
|
||||
add: handleAdd
|
||||
export: handleExport,
|
||||
reset: handleReload
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@ const dataStore = reactive({
|
||||
});
|
||||
const userStore = useUserStore();
|
||||
const $route = useRoute();
|
||||
|
||||
dataStore.formData[0].options = userStore.orgIdArr;
|
||||
//新增
|
||||
const handleAdd = () => {
|
||||
|
||||
@@ -72,7 +72,7 @@ export const FORM_DATA: FormItem[] = [
|
||||
options: []
|
||||
},
|
||||
{
|
||||
prop: "sub_warehouse",
|
||||
prop: "sub_warehouse_name",
|
||||
placeholder: "请输入子仓库",
|
||||
type: "input",
|
||||
label: "子仓库: "
|
||||
|
||||
@@ -57,12 +57,16 @@ const dataStore = reactive<any>({
|
||||
selectionList: [], //选中表格的行
|
||||
loading: false
|
||||
});
|
||||
|
||||
const init = () => {
|
||||
//设置组织数组
|
||||
dataStore.formData[5].options = userStore.orgIdArr;
|
||||
|
||||
//设置仓库数据
|
||||
dataStore.formData[6].options = userStore.warehouse;
|
||||
//订阅人
|
||||
dataStore.initParam.subscriber_name = userStore.userInfo.nickname;
|
||||
|
||||
};
|
||||
init();
|
||||
// 表格选择事件
|
||||
const selectionChange = (selection: any) => {
|
||||
dataStore.selectionList = selection;
|
||||
@@ -82,6 +86,7 @@ const handleSearch = async (params: any) => {
|
||||
//重置
|
||||
const handleReset = () => {
|
||||
dataStore.initParam = cloneDeep(RULE_FORM);
|
||||
init();
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTable.value!.getTableList();
|
||||
|
||||
@@ -37,7 +37,9 @@ export const handleReSet = async (item: any, selectionList: any[], proTable: any
|
||||
selectionList.forEach((item: any) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
const result = await getSubscribeResetListApi(ids);
|
||||
|
||||
let id = ids.join(",");
|
||||
const result = await getSubscribeResetListApi({ id });
|
||||
if (result?.code === 0) {
|
||||
useMsg("success", "数据刷新成功 !");
|
||||
proTable.value!.getTableList();
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
<script setup lang="ts" name="home">
|
||||
//登录请求接口
|
||||
import { getOrgsApi } from "@/api/modules/global";
|
||||
import { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";
|
||||
|
||||
//用户信息存储
|
||||
import { useUserStore } from "@/stores/modules/user";
|
||||
//setOrgIdArr
|
||||
const userStore = useUserStore();
|
||||
//获取组织
|
||||
const getOrgs = async () => {
|
||||
@@ -30,16 +30,24 @@ const getOrgs = async () => {
|
||||
}
|
||||
};
|
||||
getOrgs();
|
||||
|
||||
// //获取供应商
|
||||
// const getSupplier = async () => {
|
||||
// const result = await getSupplierApi();
|
||||
// if (result?.code === 0) {
|
||||
// const { data } = result;
|
||||
// console.log(data, "=============>");
|
||||
// }
|
||||
// };
|
||||
// getSupplier();
|
||||
const getWarehousesList = async () => {
|
||||
const result = await getWarehousesListApi();
|
||||
if (result?.code === 0) {
|
||||
const { data } = result;
|
||||
if (data?.length) {
|
||||
let options: any = [];
|
||||
data.forEach((item: any) => {
|
||||
options.push({
|
||||
id: item.id,
|
||||
value: item.warehouse_number,
|
||||
label: item.warehouse_name
|
||||
});
|
||||
});
|
||||
userStore.setWarehouse(options);
|
||||
}
|
||||
}
|
||||
};
|
||||
getWarehousesList();
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user