Ver código fonte

违法模板

Luka 21 horas atrás
pai
commit
4bcac9eaea
3 arquivos alterados com 216 adições e 216 exclusões
  1. BIN
      public/assets/address-book.xlsx
  2. 113 111
      src/permission.ts
  3. 103 105
      src/views/addressBook/index.vue

BIN
public/assets/address-book.xlsx


+ 113 - 111
src/permission.ts

@@ -15,119 +15,121 @@ NProgress.configure({ showSpinner: false });
 const whiteList = ['/login', '/register'];
 
 router.beforeEach((to, from, next) => {
-    NProgress.start();
-    if (getToken()) {
-        //  重置筛选项
-        const systemStore = useSystemStore();
-        const { searchObj, pageInfo } = storeToRefs(systemStore);
-        searchObj.value = {};
-        pageInfo.value = {
-            pageNum: 1,
-            pageSize: 10,
-        };
+	NProgress.start();
+	if (getToken()) {
+		//  重置筛选项
+		const systemStore = useSystemStore();
+		const { searchObj, pageInfo } = storeToRefs(systemStore);
+		searchObj.value = {};
+		pageInfo.value = {
+			pageNum: 1,
+			pageSize: 10,
+		};
 
-        to.meta.title && useSettingsStore().setTitle(to.meta.title);
-        /* has token*/
-        if (to.path === '/login') {
-            next({ path: '/' });
-            NProgress.done();
-        } else {
-            /* TODO 暂时隐藏登陆逻辑 */
-            // if (useUserStore().roles.length === 0) {
-            //     isRelogin.show = true;
-            //     // 判断当前用户是否已拉取完user_info信息
-            //     useUserStore()
-            //         .getInfo()
-            //         .then(() => {
-            //             isRelogin.show = false;
-            //             usePermissionStore()
-            //                 .generateRoutes()
-            //                 .then(accessRoutes => {
-            //                     // 根据roles权限生成可访问的路由表
-            //                     accessRoutes.forEach(route => {
-            //                         if (!isHttp(route.path)) {
-            //                             router.addRoute(route); // 动态添加可访问路由表
-            //                         }
-            //                     });
-            //                     next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
-            //                 });
-            //         })
-            //         .catch(err => {
-            //             useUserStore()
-            //                 .logOut()
-            //                 .then(() => {
-            //                     ElMessage.error(err);
-            //                     next({ path: '/' });
-            //                 });
-            //         });
-            // } else {
-            //     next();
-            // }
-            next();
-        }
-    } else {
-        // 没有token
-        if (whiteList.indexOf(to.path) !== -1) {
-            // 在免登录白名单,直接进入
-            next();
-        } else if (to.fullPath.includes('code=')) {
-            const codeFromUrl = to.fullPath.split('=')[1];
-            callback(codeFromUrl).then((res: any) => {
-                setToken(res.token);
-                to.meta.title && useSettingsStore().setTitle(to.meta.title);
-                /* has token*/
-                if (to.path === '/login') {
-                    next({ path: '/' });
-                    NProgress.done();
-                } else {
-                    if (useUserStore().roles.length === 0) {
-                        isRelogin.show = true;
-                        // 判断当前用户是否已拉取完user_info信息
-                        useUserStore()
-                            .getInfo()
-                            .then(() => {
-                                isRelogin.show = false;
-                                usePermissionStore()
-                                    .generateRoutes()
-                                    .then(accessRoutes => {
-                                        // 根据roles权限生成可访问的路由表
-                                        accessRoutes.forEach(route => {
-                                            if (!isHttp(route.path)) {
-                                                router.addRoute(route); // 动态添加可访问路由表
-                                            }
-                                        });
-                                        next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
-                                    });
-                            })
-                            .catch(err => {
-                                useUserStore()
-                                    .logOut()
-                                    .then(() => {
-                                        ElMessage.error(err);
-                                        next({ path: '/' });
-                                    });
-                            });
-                    } else {
-                        next();
-                    }
-                }
-                next();
-            });
-        } else if (process.env.NODE_ENV === 'production') {
-            // 单点登录
-            if (to.fullPath.includes('manage')) {
-                next('/login');
-            } else {
-                location.href = `${import.meta.env.VITE_APP_BASE_API}/thirdPartyLogin`;
-            }
-        } else {
-            // next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
-            next('/login');
-            NProgress.done();
-        }
-    }
+		to.meta.title && useSettingsStore().setTitle(to.meta.title);
+		/* has token*/
+		if (to.path === '/login') {
+			next({ path: '/' });
+			NProgress.done();
+		} else {
+			/* TODO 暂时隐藏登陆逻辑 */
+			// if (useUserStore().roles.length === 0) {
+			//     isRelogin.show = true;
+			//     // 判断当前用户是否已拉取完user_info信息
+			//     useUserStore()
+			//         .getInfo()
+			//         .then(() => {
+			//             isRelogin.show = false;
+			//             usePermissionStore()
+			//                 .generateRoutes()
+			//                 .then(accessRoutes => {
+			//                     // 根据roles权限生成可访问的路由表
+			//                     accessRoutes.forEach(route => {
+			//                         if (!isHttp(route.path)) {
+			//                             router.addRoute(route); // 动态添加可访问路由表
+			//                         }
+			//                     });
+			//                     next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
+			//                 });
+			//         })
+			//         .catch(err => {
+			//             useUserStore()
+			//                 .logOut()
+			//                 .then(() => {
+			//                     ElMessage.error(err);
+			//                     next({ path: '/' });
+			//                 });
+			//         });
+			// } else {
+			//     next();
+			// }
+			next();
+		}
+	}
+	next();
+	// else {
+	//     // 没有token
+	//     if (whiteList.indexOf(to.path) !== -1) {
+	//         // 在免登录白名单,直接进入
+	//         next();
+	//     } else if (to.fullPath.includes('code=')) {
+	//         const codeFromUrl = to.fullPath.split('=')[1];
+	//         callback(codeFromUrl).then((res: any) => {
+	//             setToken(res.token);
+	//             to.meta.title && useSettingsStore().setTitle(to.meta.title);
+	//             /* has token*/
+	//             if (to.path === '/login') {
+	//                 next({ path: '/' });
+	//                 NProgress.done();
+	//             } else {
+	//                 if (useUserStore().roles.length === 0) {
+	//                     isRelogin.show = true;
+	//                     // 判断当前用户是否已拉取完user_info信息
+	//                     useUserStore()
+	//                         .getInfo()
+	//                         .then(() => {
+	//                             isRelogin.show = false;
+	//                             usePermissionStore()
+	//                                 .generateRoutes()
+	//                                 .then(accessRoutes => {
+	//                                     // 根据roles权限生成可访问的路由表
+	//                                     accessRoutes.forEach(route => {
+	//                                         if (!isHttp(route.path)) {
+	//                                             router.addRoute(route); // 动态添加可访问路由表
+	//                                         }
+	//                                     });
+	//                                     next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
+	//                                 });
+	//                         })
+	//                         .catch(err => {
+	//                             useUserStore()
+	//                                 .logOut()
+	//                                 .then(() => {
+	//                                     ElMessage.error(err);
+	//                                     next({ path: '/' });
+	//                                 });
+	//                         });
+	//                 } else {
+	//                     next();
+	//                 }
+	//             }
+	//             next();
+	//         });
+	//     } else if (process.env.NODE_ENV === 'production') {
+	//         // 单点登录
+	//         if (to.fullPath.includes('manage')) {
+	//             next('/login');
+	//         } else {
+	//             location.href = `${import.meta.env.VITE_APP_BASE_API}/thirdPartyLogin`;
+	//         }
+	//     } else {
+	//         // next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
+	//         next('/login');
+	//         NProgress.done();
+	//     }
+	// }
 });
 
 router.afterEach(() => {
-    NProgress.done();
+	NProgress.done();
 });

+ 103 - 105
src/views/addressBook/index.vue

@@ -1,49 +1,39 @@
 <template>
-    <el-tabs type="card" v-model="activeTab" style="height: 100%">
-        <el-tab-pane 
-            v-for="tab in tabs" 
-            :key="tab.key"
-            :label="tab.label"
-            :name="tab.key"
-        >
-            <div class="sensitive-words flex">
-                <TreeSelect class="mr20"></TreeSelect>
-                <div class="table-box">
-                    <pageSearch
-                        ref="searchTableRef"
-                        :searchConfig="activeTab === 'industry' ? searchConfig : searchNonIndustryConfig"
-                        />
-                    <pageContent
-                        ref="tableListRef"
-                        :total="total"
-                        :contentConfig="activeTab === 'industry' ? contentConfig : contentNonIndustryConfig" :pageList="tableData"
-                        >
-                        <template #button>
-                            <el-button type="primary" @click="onImport()">导入</el-button>
-                            <el-button type="primary" @click="onImport()">下载模版</el-button>
-                            <el-button type="primary" @click="onAdd()">新增</el-button>
-                            <el-button type="primary" @click="onExport()">导出</el-button>
-                        </template>
-                        <template #operate="scope">
-                            <el-button type="primary" link @click="handleEdit(scope.row.rentalCompanyId)">
-                                编辑
-                            </el-button>
-                            <el-button type="primary" link @click="handleCheck(scope.row.rentalCompanyId)">
-                                查看
-                            </el-button>
-                            <el-button type="primary" link @click="onDelete(scope.row.rentalCompanyId)">
-                                删除
-                            </el-button>
-                        </template>
-                    </pageContent>
-                </div>
-            </div>
-        </el-tab-pane>
-    </el-tabs>
-    <pageDetail
-        :modalConfig="activeTab === 'industry' ? detailConfig : detailNonIndustryConfig"
-        ref="modalRef">
-    </pageDetail>
+	<el-tabs type="card" v-model="activeTab" style="height: 100%">
+		<el-tab-pane v-for="tab in tabs" :key="tab.key" :label="tab.label" :name="tab.key">
+			<div class="sensitive-words flex">
+				<TreeSelect class="mr20"></TreeSelect>
+				<div class="table-box">
+					<pageSearch
+						ref="searchTableRef"
+						:searchConfig="activeTab === 'industry' ? searchConfig : searchNonIndustryConfig"
+					/>
+					<pageContent
+						ref="tableListRef"
+						:total="total"
+						:contentConfig="activeTab === 'industry' ? contentConfig : contentNonIndustryConfig"
+						:pageList="tableData"
+					>
+						<template #button>
+							<el-button type="primary" @click="onImport()">导入</el-button>
+							<el-button type="primary" @click="onImport()">下载模版</el-button>
+							<el-button type="primary" @click="onAdd()">新增</el-button>
+							<el-button type="primary" @click="onExport()">导出</el-button>
+						</template>
+						<template #operate="scope">
+							<el-button type="primary" link @click="handleEdit(scope.row.rentalCompanyId)"> 编辑 </el-button>
+							<el-button type="primary" link @click="handleCheck(scope.row.rentalCompanyId)">
+								查看
+							</el-button>
+							<el-button type="primary" link @click="onDelete(scope.row.rentalCompanyId)"> 删除 </el-button>
+						</template>
+					</pageContent>
+				</div>
+			</div>
+		</el-tab-pane>
+	</el-tabs>
+	<pageDetail :modalConfig="activeTab === 'industry' ? detailConfig : detailNonIndustryConfig" ref="modalRef">
+	</pageDetail>
 </template>
 
 <script setup lang="ts">
@@ -57,7 +47,7 @@ import detailConfig from './config/detail.config';
 import detailNonIndustryConfig from './config/detail.nonIndustry.config';
 import pageDetail from './components/detail.vue';
 import useSystemStore from '@/store/main';
-import FileUpload from '@/components/FileUpload/index.vue'
+import FileUpload from '@/components/FileUpload/index.vue';
 import TreeSelect from './components/treeSelect.vue';
 // 使用pinia数据
 const systemStore = useSystemStore();
@@ -69,22 +59,22 @@ const tableData = ref([]);
 const tableListRef = ref();
 
 const tabs = reactive([
-  {
-    key: 'industry',
-    label: '行业内联络员',
-    total: 0,
-    tableData: [],
-    loading: false,
-    showDetail: true
-  },
-  {
-    key: 'nonIndustry',
-    label: '行业外联络员',
-    total: 0,
-    tableData: [],
-    loading: false,
-    showDetail: true
-  }
+	{
+		key: 'industry',
+		label: '行业内联络员',
+		total: 0,
+		tableData: [],
+		loading: false,
+		showDetail: true,
+	},
+	{
+		key: 'nonIndustry',
+		label: '行业外联络员',
+		total: 0,
+		tableData: [],
+		loading: false,
+		showDetail: true,
+	},
 ]);
 
 const activeTab = ref('industry');
@@ -92,83 +82,91 @@ const activeTab = ref('industry');
 // 操作弹框
 import usePageModal from '@/components/components/hooks/usePageDetails';
 const { modalRef, handleNewDataClick, handleEditDataClick, handleCheckDataClick, handlePageDetail } =
-    usePageModal();
+	usePageModal();
 
 const handleEdit = async (id: string) => {
-    await handlePageDetail(id);
-    await handleEditDataClick();
+	await handlePageDetail(id);
+	await handleEditDataClick();
 };
 
 const handleCheck = async (id: string) => {
-    await handlePageDetail(id);
-    await handleCheckDataClick();
-}
+	await handlePageDetail(id);
+	await handleCheckDataClick();
+};
 
 // 新增按钮
 const onAdd = () => {
-    handleNewDataClick();
+	handleNewDataClick();
+};
+const onImport = () => {
+	const link = document.createElement('a');
+	link.href = `/assets/address-book.xlsx`;
+	link.download = '违法信息通报通讯录人员导入模板.xlsx'; // 指定下载后的文件名
+	link.style.display = 'none';
+	document.body.appendChild(link);
+	link.click();
+	document.body.removeChild(link);
 };
-const onImport = () => {}
-const onExport = () => {}
+const onExport = () => {};
 const searchTableRef = ref();
 // 删除按钮
 function onDelete(value: any) {
-    ElMessageBox.confirm('确定删除该条违法信息通报通讯录吗?', '删除提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-    })
-        .then(() => {
-            systemStore.deletePageDataAction(contentConfig.pageName, value);
-        })
-        .catch(() => {
-            ElMessage({
-                type: 'info',
-                message: '取消删除',
-            });
-        });
+	ElMessageBox.confirm('确定删除该条违法信息通报通讯录吗?', '删除提示', {
+		confirmButtonText: '确定',
+		cancelButtonText: '取消',
+		type: 'warning',
+	})
+		.then(() => {
+			systemStore.deletePageDataAction(contentConfig.pageName, value);
+		})
+		.catch(() => {
+			ElMessage({
+				type: 'info',
+				message: '取消删除',
+			});
+		});
 }
 
 // 筛选-状态赋值
 async function searchItem() {
-    searchConfig.formItems.forEach(item => {
-        if (item.prop === 'status') {
-            // item.options = searchList.value;
-        }
-    });
+	searchConfig.formItems.forEach(item => {
+		if (item.prop === 'status') {
+			// item.options = searchList.value;
+		}
+	});
 }
 searchItem();
 </script>
 
 <style scoped lang="scss">
 .sensitive-words {
-    margin: 20px;
-    height: calc(100vh - 130px);
+	margin: 20px;
+	height: calc(100vh - 130px);
 }
 
 .status {
-    cursor: pointer;
-    position: relative;
+	cursor: pointer;
+	position: relative;
 
-    .status-tip {
-        position: absolute;
-        top: 2px;
-        left: 60px;
-    }
+	.status-tip {
+		position: absolute;
+		top: 2px;
+		left: 60px;
+	}
 }
 
 .dialog-tip {
-    text-align: center;
+	text-align: center;
 }
 
 .table-box {
-    width: 70%;
-    display: flex;
-    flex-direction: column;
+	width: 70%;
+	display: flex;
+	flex-direction: column;
 }
 
 :deep .el-tabs__item.is-active {
-    color: #fff;
-    background-color: #409EFF;
+	color: #fff;
+	background-color: #409eff;
 }
 </style>