Compare commits
6 Commits
f057f07ce7
...
7efeb8faf0
| Author | SHA1 | Date | |
|---|---|---|---|
| 7efeb8faf0 | |||
| 8a064cf1b9 | |||
| f08b094efc | |||
| 9aa3782667 | |||
| 574c46580f | |||
| 3c72a248fa |
2
.env
2
.env
@@ -1,5 +1,5 @@
|
||||
# title
|
||||
VITE_GLOB_APP_TITLE = OPS供应链系统
|
||||
VITE_GLOB_APP_TITLE = WMS系统
|
||||
|
||||
# 本地运行端口号
|
||||
VITE_PORT = 8080
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
export const usePathUrl = () => {
|
||||
const PATH_URL = `${import.meta.env.VITE_APP_SSO_LOGINURL}?client_id=${
|
||||
import.meta.env.VITE_APP_SSO_APPID
|
||||
}&redirect_uri=${encodeURIComponent(import.meta.env.VITE_REDIRECT_URL)}&response_type=code`;
|
||||
return PATH_URL;
|
||||
export const usePathUrl = (redirect_path?: any) => {
|
||||
let PATH_URL: any = "";
|
||||
if (redirect_path) {
|
||||
PATH_URL = `${import.meta.env.VITE_APP_SSO_LOGINURL}?client_id=${
|
||||
import.meta.env.VITE_APP_SSO_APPID
|
||||
}&redirect_uri=${encodeURIComponent(
|
||||
import.meta.env.VITE_REDIRECT_URL + "?redirect_path=" + redirect_path
|
||||
)}&response_type=code`;
|
||||
return PATH_URL;
|
||||
} else {
|
||||
PATH_URL = `${import.meta.env.VITE_APP_SSO_LOGINURL}?client_id=${
|
||||
import.meta.env.VITE_APP_SSO_APPID
|
||||
}&redirect_uri=${encodeURIComponent(import.meta.env.VITE_REDIRECT_URL)}&response_type=code`;
|
||||
return PATH_URL;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -90,14 +90,15 @@ export const useTable = (
|
||||
try {
|
||||
await initSubscribeData();
|
||||
await deleteParams();
|
||||
// await initData();
|
||||
state.tableData = [];
|
||||
let params = {
|
||||
...state.totalParam,
|
||||
...pageParam.value
|
||||
};
|
||||
|
||||
const { data } = await api(params);
|
||||
state.tableData = data.data || [];
|
||||
|
||||
state.tableData = Array.isArray(data.data) && data.data.length ? data.data : [];
|
||||
clearSelection && clearSelection();
|
||||
if (isPageable && data.total_size !== undefined) {
|
||||
updatePageable({
|
||||
|
||||
@@ -107,13 +107,12 @@ const tabClick = (tabItem: TabsPaneContext) => {
|
||||
|
||||
// Remove Tab
|
||||
const tabRemove = (fullPath: TabPaneName) => {
|
||||
if (fullPath === "/index") {
|
||||
const name = tabStore.tabsMenuList.filter(item => item.path == fullPath)[0].name || "";
|
||||
|
||||
if (fullPath === "/index" || name === "home") {
|
||||
return;
|
||||
}
|
||||
// const name = tabStore.tabsMenuList.filter(item => item.path == fullPath)[0].name || "";
|
||||
// keepAliveStore.removeKeepAliveName(name);
|
||||
// tabStore.removeTabs(fullPath as string, fullPath == route.fullPath);
|
||||
const name = tabStore.tabsMenuList.filter(item => item.path == fullPath)[0].name || "";
|
||||
|
||||
tabStore.removeTabs(fullPath as string, fullPath == route.fullPath);
|
||||
let isKeepAlive = tabStore.tabsMenuList.some((item: any) => {
|
||||
return item.name === name;
|
||||
|
||||
@@ -38,7 +38,8 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
// 1.NProgress 开始
|
||||
NProgress.start();
|
||||
|
||||
const currentPath = window.location.pathname;
|
||||
console.log(currentPath, "=currentPath=");
|
||||
// 2.动态设置标题
|
||||
const title = import.meta.env.VITE_GLOB_APP_TITLE;
|
||||
document.title = to.meta.title ? `${to.meta.title} - ${title}` : title;
|
||||
@@ -51,6 +52,17 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
// 4.判断访问页面是否在路由白名单地址(静态路由)中,如果存在直接放行
|
||||
if (ROUTER_WHITE_LIST.includes(to.path)) return next();
|
||||
// 4.判断访问页面是否在路由白名单地址(静态路由)中,如果存在直接放行
|
||||
if (ROUTER_WHITE_LIST.includes(to.path)) return next();
|
||||
|
||||
// 如果没有token但是有订阅路由就将订阅路由当参数携带
|
||||
if (!userStore.newUserToken && currentPath === "/foundation/subscribe/warehousing/index") {
|
||||
return next({
|
||||
path: LOGIN_URL,
|
||||
replace: true,
|
||||
query: { redirect_path: currentPath } // 通过query传递参数
|
||||
});
|
||||
}
|
||||
|
||||
// 5.判断是否有 Token,没有重定向到 login 页面
|
||||
if (!userStore.newUserToken) return next({ path: LOGIN_URL, replace: true });
|
||||
|
||||
@@ -6,16 +6,46 @@ import piniaPersistConfig from "@/config/piniaPersist";
|
||||
export const useTabsStore = defineStore({
|
||||
id: "wms-tabs",
|
||||
state: (): TabsState => ({
|
||||
tabsMenuList: []
|
||||
tabsMenuList: [
|
||||
{
|
||||
icon: "", // 首页的icon,按实际路由meta.icon填写(如"Home")
|
||||
title: "首页", // 固定首页标题
|
||||
path: "/index", // 首页的基础路径(无参数版本,避免初始参数冗余)
|
||||
name: "home", // 必须与首页路由的name一致(如路由定义中name: "home")
|
||||
close: true // 首页是否可关闭,按业务需求设置(通常true,若禁止关闭设为false)
|
||||
}
|
||||
]
|
||||
}),
|
||||
actions: {
|
||||
// Add Tabs
|
||||
// Add Tabs:按 name 去重,首页始终在最前
|
||||
async addTabs(tabItem: any) {
|
||||
if (this.tabsMenuList.every(item => item.path !== tabItem.path)) {
|
||||
this.tabsMenuList.push(tabItem);
|
||||
// 1. 校验参数:确保 tabItem 有 name(避免异常数据)
|
||||
if (!tabItem.name) return;
|
||||
|
||||
// 2. 去重逻辑:按 name 判断是否已存在
|
||||
const isExist = this.tabsMenuList.some(item => item.name === tabItem.name);
|
||||
|
||||
if (!isExist) {
|
||||
// 3. 首页(name: "home")添加到数组开头,其他标签添加到末尾
|
||||
if (tabItem.name === "home") {
|
||||
// 先移除旧的首页(防止极端情况残留),再添加新首页到最前
|
||||
this.tabsMenuList = this.tabsMenuList.filter(item => item.name !== "home");
|
||||
this.tabsMenuList.unshift(tabItem); // 首页放第一位
|
||||
} else {
|
||||
this.tabsMenuList.push(tabItem); // 非首页放末尾
|
||||
}
|
||||
} else {
|
||||
// 4. 可选优化:若标签已存在,同步更新其 path(如首页参数变化时)
|
||||
this.tabsMenuList = this.tabsMenuList.map(item => {
|
||||
if (item.name === tabItem.name) {
|
||||
return { ...item, path: tabItem.path }; // 仅更新 path,保留其他属性
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
},
|
||||
// Remove Tabs
|
||||
|
||||
// Remove Tabs(原有逻辑不变,无需修改)
|
||||
async removeTabs(tabPath: string, isCurrent: boolean = true) {
|
||||
const tabsMenuList = this.tabsMenuList;
|
||||
if (isCurrent) {
|
||||
@@ -28,17 +58,36 @@ export const useTabsStore = defineStore({
|
||||
}
|
||||
this.tabsMenuList = tabsMenuList.filter(item => item.path !== tabPath);
|
||||
},
|
||||
// Close MultipleTab
|
||||
|
||||
// Close MultipleTab(原有逻辑不变)
|
||||
async closeMultipleTab(tabsMenuValue?: string) {
|
||||
this.tabsMenuList = this.tabsMenuList.filter(item => {
|
||||
return item.path === tabsMenuValue || !item.close;
|
||||
});
|
||||
},
|
||||
// Set Tabs
|
||||
|
||||
// Set Tabs(原有逻辑不变)
|
||||
async setTabs(tabsMenuList: any[]) {
|
||||
this.tabsMenuList = tabsMenuList;
|
||||
// 补充:设置 tabs 时也需去重,避免批量设置时带入重复首页
|
||||
const uniqueTabs = [];
|
||||
const nameSet = new Set();
|
||||
// 先处理首页,确保在最前
|
||||
const homeTab = tabsMenuList.find(item => item.name === "home");
|
||||
if (homeTab) {
|
||||
uniqueTabs.push(homeTab);
|
||||
nameSet.add("home");
|
||||
}
|
||||
// 再处理其他标签,去重
|
||||
tabsMenuList.forEach(tab => {
|
||||
if (!nameSet.has(tab.name)) {
|
||||
nameSet.add(tab.name);
|
||||
uniqueTabs.push(tab);
|
||||
}
|
||||
});
|
||||
this.tabsMenuList = uniqueTabs;
|
||||
},
|
||||
// Set Tabs Title
|
||||
|
||||
// Set Tabs Title(原有逻辑不变)
|
||||
async setTabsTitle(title: string) {
|
||||
const nowFullPath = location.hash.substring(1);
|
||||
this.tabsMenuList.forEach(item => {
|
||||
|
||||
@@ -79,7 +79,7 @@ const handleSearch = async (params: any) => {
|
||||
dataStore.initParam = cloneDeep(params);
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTableRef.value!.getTableList();
|
||||
proTableRef?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
//重置
|
||||
@@ -87,7 +87,7 @@ const handleReset = () => {
|
||||
dataStore.initParam = cloneDeep(RULE_FORM);
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTableRef.value!.getTableList();
|
||||
proTableRef?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
import PermissionButton from "@/components/PermissionButton/index.vue";
|
||||
import DetailsSearch from "@/components/DetailsSearch/index.vue";
|
||||
import { FORM_DATA, RULE_FORM } from "./constant/add";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import { getSubscribeDetailsApi, getSubscribeAddApi, getSubscribeUpdateApi } from "@/api/modules/subscribe";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { getSubscribeDetailsApi, getSubscribeUpdateApi, getSubscribeAddApi } from "@/api/modules/subscribe";
|
||||
import { setDetailsData } from "./init/setDetailsData";
|
||||
import { useMsg } from "@/hooks/useMsg";
|
||||
import { BUTTON } from "./constant/add/button";
|
||||
@@ -42,7 +41,7 @@ const dataStore = reactive({
|
||||
});
|
||||
const userStore = useUserStore();
|
||||
const $route = useRoute();
|
||||
|
||||
const $router = useRouter();
|
||||
dataStore.formData[0].options = userStore.orgIdArr;
|
||||
const init = () => {
|
||||
//$route.query.title === "新增订阅" ? org_number: ["101"],
|
||||
@@ -54,7 +53,7 @@ init();
|
||||
//新增
|
||||
const handleAdd = () => {
|
||||
if (
|
||||
dataStore.ruleForm?.customer_number.length ||
|
||||
dataStore.ruleForm?.customer_number?.length ||
|
||||
dataStore.ruleForm?.org_number ||
|
||||
dataStore.ruleForm?.product_lines ||
|
||||
dataStore.ruleForm?.subscriber_dduid
|
||||
@@ -74,9 +73,15 @@ const handleAdd = () => {
|
||||
|
||||
//添加
|
||||
const getSubscribeAdd = async (params: any) => {
|
||||
console.log(params);
|
||||
const result = await getSubscribeAddApi(params);
|
||||
if (result?.code === 0) {
|
||||
useMsg("success", "新增成功 !");
|
||||
dataStore.ruleForm = cloneDeep(RULE_FORM);
|
||||
init();
|
||||
setTimeout(() => {
|
||||
$router.replace({ path: "/foundation/subscribe/list/index" });
|
||||
}, 300);
|
||||
}
|
||||
};
|
||||
//更新
|
||||
|
||||
@@ -91,7 +91,7 @@ const handleSearch = async (params: any) => {
|
||||
dataStore.initParam = cloneDeep(params);
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTableRef.value!.getTableList();
|
||||
proTableRef?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
//重置
|
||||
@@ -99,7 +99,7 @@ const handleReset = () => {
|
||||
dataStore.initParam = cloneDeep(RULE_FORM);
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTableRef.value!.getTableList();
|
||||
proTableRef?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const handleDel = (params: any) => {
|
||||
});
|
||||
const result = await getSubscribeDelApi(ids.join(","));
|
||||
if (result?.code === 0) {
|
||||
proTable.value!.getTableList();
|
||||
proTable?.value!.getTableList();
|
||||
useMsg("success", "删除成功 !");
|
||||
}
|
||||
})
|
||||
|
||||
@@ -101,7 +101,7 @@ const handleSearch = async (params: any) => {
|
||||
dataStore.initParam = cloneDeep(params);
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTable.value!.getTableList();
|
||||
proTable?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
//重置
|
||||
@@ -110,7 +110,7 @@ const handleReset = () => {
|
||||
init();
|
||||
//这里需要等到表格刷新以后才去请求
|
||||
nextTick(() => {
|
||||
proTable.value!.getTableList();
|
||||
proTable?.value!.getTableList();
|
||||
});
|
||||
};
|
||||
const handleClickSuccess = (row: any) => {
|
||||
|
||||
@@ -9,11 +9,11 @@ export const handleExport = async (params: any) => {
|
||||
}
|
||||
};
|
||||
// proTable: any
|
||||
export const handleReSet = async (item: any, selectionList: any[], proTable: any) => {
|
||||
console.log("刷新操作", item);
|
||||
export const handleReSet = async (params: any) => {
|
||||
const { proTable, selectionList } = params;
|
||||
let length = selectionList.length;
|
||||
if (length && length > 100) {
|
||||
useMsg("warning", "选中刷新数据最大100条!");
|
||||
useMsg("warning", "选中刷新数据最大100条 !");
|
||||
return;
|
||||
}
|
||||
let ids: any = [];
|
||||
@@ -25,7 +25,7 @@ export const handleReSet = async (item: any, selectionList: any[], proTable: any
|
||||
const result = await getSubscribeResetListApi({ id });
|
||||
if (result?.code === 0) {
|
||||
useMsg("success", "数据刷新成功 !");
|
||||
proTable.value!.getTableList();
|
||||
proTable?.value!.getTableList();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,48 +6,61 @@
|
||||
|
||||
<script setup lang="ts" name="home">
|
||||
//登录请求接口
|
||||
import { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";
|
||||
|
||||
// import { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
//用户信息存储
|
||||
import { useUserStore } from "@/stores/modules/user";
|
||||
const userStore = useUserStore();
|
||||
//获取组织
|
||||
const getOrgs = async () => {
|
||||
const result = await getOrgsApi();
|
||||
if (result?.code === 0) {
|
||||
const { data } = result;
|
||||
if (data?.length) {
|
||||
let options: any = [];
|
||||
data.forEach((item: any) => {
|
||||
options.push({
|
||||
id: item.id,
|
||||
value: item.org_number,
|
||||
label: item.org_name
|
||||
});
|
||||
});
|
||||
userStore.setOrgIdArr(options);
|
||||
}
|
||||
// import { useUserStore } from "@/stores/modules/user";
|
||||
// const userStore = useUserStore();
|
||||
//路由;
|
||||
const $route = useRoute();
|
||||
const $router = useRouter();
|
||||
// //获取组织
|
||||
// const getOrgs = async () => {
|
||||
// const result = await getOrgsApi();
|
||||
// if (result?.code === 0) {
|
||||
// const { data } = result;
|
||||
// if (data?.length) {
|
||||
// let options: any = [];
|
||||
// data.forEach((item: any) => {
|
||||
// options.push({
|
||||
// id: item.id,
|
||||
// value: item.org_number,
|
||||
// label: item.org_name
|
||||
// });
|
||||
// });
|
||||
// userStore.setOrgIdArr(options);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// getOrgs();
|
||||
// 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_name,
|
||||
// label: item.warehouse_name
|
||||
// });
|
||||
// });
|
||||
// userStore.setWarehouse(options);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// getWarehousesList();
|
||||
|
||||
const init = () => {
|
||||
let redirect_path: any = $route.query.redirect_path;
|
||||
if (redirect_path) {
|
||||
setTimeout(() => {
|
||||
$router.push({ path: redirect_path });
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
getOrgs();
|
||||
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_name,
|
||||
label: item.warehouse_name
|
||||
});
|
||||
});
|
||||
userStore.setWarehouse(options);
|
||||
}
|
||||
}
|
||||
};
|
||||
getWarehousesList();
|
||||
init();
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<script setup lang="ts">
|
||||
//useRouter
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";
|
||||
// import { useMsg } from "@/hooks/useMsg";
|
||||
//重定向
|
||||
import { usePathUrl } from "@/hooks/usePathUrl";
|
||||
@@ -18,18 +19,66 @@ const userStore = useUserStore();
|
||||
const $route = useRoute();
|
||||
const $router = useRouter();
|
||||
|
||||
//获取组织
|
||||
const getOrgs = async () => {
|
||||
const result = await getOrgsApi();
|
||||
if (result?.code === 0) {
|
||||
const { data } = result;
|
||||
if (data?.length) {
|
||||
let options: any = [];
|
||||
data.forEach((item: any) => {
|
||||
options.push({
|
||||
id: item.id,
|
||||
value: item.org_number,
|
||||
label: item.org_name
|
||||
});
|
||||
});
|
||||
userStore.setOrgIdArr(options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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_name,
|
||||
label: item.warehouse_name
|
||||
});
|
||||
});
|
||||
userStore.setWarehouse(options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 登录
|
||||
const loginHttp = async (code: any) => {
|
||||
const result: Record<string, any> = await loginApi(code);
|
||||
if (result.code === 0) {
|
||||
userStore.setToken(result?.data?.access_token);
|
||||
console.log(result?.data?.access_token, "=data.access_token=");
|
||||
// 设置用户信息
|
||||
userStore.setUserInfo(result?.data?.user_data);
|
||||
//设置好了token和用户信息跳转到首页
|
||||
setTimeout(() => {
|
||||
$router.push({ path: "/" });
|
||||
}, 500);
|
||||
|
||||
let redirect_path: any = $route.query.redirect_path;
|
||||
|
||||
if (result?.data?.access_token) {
|
||||
getWarehousesList();
|
||||
getOrgs();
|
||||
}
|
||||
if (redirect_path) {
|
||||
setTimeout(() => {
|
||||
$router.replace({ path: redirect_path });
|
||||
}, 500);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
$router.replace({ path: "/" });
|
||||
}, 500);
|
||||
}
|
||||
} else {
|
||||
location.href = usePathUrl();
|
||||
}
|
||||
@@ -37,14 +86,20 @@ const loginHttp = async (code: any) => {
|
||||
|
||||
// 登录前的判断
|
||||
const login = () => {
|
||||
const { code } = $route.query;
|
||||
const { code, redirect_path } = $route.query;
|
||||
// 没有code直接跳转到登录页
|
||||
if (!code && redirect_path) {
|
||||
location.href = usePathUrl(redirect_path);
|
||||
return;
|
||||
}
|
||||
if (!code) {
|
||||
location.href = usePathUrl();
|
||||
return;
|
||||
}
|
||||
// 有code就登录请求
|
||||
loginHttp(code);
|
||||
if (code) {
|
||||
loginHttp(code);
|
||||
}
|
||||
};
|
||||
login();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user