From 6cc81f9de0c87c40a9f1181ab35e8dff792a1884 Mon Sep 17 00:00:00 2001 From: Fixiaobai <fixiaobai@163.com> Date: 星期一, 28 八月 2023 09:17:21 +0800 Subject: [PATCH] 动态路由 --- src/utils/request.js | 17 .env.development | 2 src/views/home/index.vue | 2 src/views/laboratory/measure/index.vue | 17 src/api/laboratory/role.js | 17 src/views/login/index.vue | 54 - src/layout/components/Navbar.vue | 18 src/views/laboratory/role/index.vue | 483 ++++++++++++++++ src/layout/components/Sidebar/Item.vue | 3 src/router/index.js | 1017 ++++++++++++++++++++--------------- src/components/Breadcrumb/index.vue | 4 11 files changed, 1,121 insertions(+), 513 deletions(-) diff --git a/.env.development b/.env.development index 6ec8b12..ab9be2d 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,4 @@ ENV = 'development' # base api -VUE_APP_BASE_API = 'http://192.168.110.87:1234/' +VUE_APP_BASE_API = 'http://localhost:1234/' diff --git a/src/api/laboratory/role.js b/src/api/laboratory/role.js index 9744850..eba1b01 100644 --- a/src/api/laboratory/role.js +++ b/src/api/laboratory/role.js @@ -31,4 +31,21 @@ method: 'get', params }) + } + + export function deleteRole(params) { + return request({ + url: '/role-manager/deleteRole', + method: 'get', + params + }) + } + + //updateRoleMenu + export function updateRoleMenu(data) { + return request({ + url: '/role-manager/updateRoleMenu', + method: 'post', + data + }) } \ No newline at end of file diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 3c4c407..ed6144a 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -11,8 +11,8 @@ </el-breadcrumb> </el-col> <el-col :span="12" style="background-color: #fff;display: flex;justify-content: end; align-items: center;"> - <el-button v-if="backPlan" type="primary" icon="el-icon-refresh-left" size="mini" plain @click="backPlanUp">杩斿洖</el-button> - <el-button v-if="add" size="mini" @click="breadd" style="width: 60px;" type="primary">淇濆瓨</el-button> + <!-- <el-button v-if="backPlan" type="primary" icon="el-icon-refresh-left" size="mini" plain @click="backPlanUp">杩斿洖</el-button> --> + <!-- <el-button v-if="add" size="mini" @click="breadd" style="width: 60px;" type="primary">淇濆瓨</el-button> --> <el-col :span="1"></el-col> </el-col> </div> diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 5d90276..905c4ac 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -64,6 +64,10 @@ newPwd: '', confirmPwd: '' }, + user: { + id: null, + name: 'value' + }, dialogFormVisible: false, formLabelWidth: '120px' } @@ -78,14 +82,6 @@ 'avatar' ]) }, - data() { - return { - user: { - id: null, - name: 'value' - } - } - }, mounted() { this.getUser() }, @@ -107,11 +103,15 @@ }, async logout() { // await this.$store.dispatch('user/logout') - this.$router.push(`/login?redirect=${this.$route.fullPath}`) + localStorage.removeItem("user") + this.$router.push(`/login?redirect=${this.$route.fullPath}`) + this.$router.replace({path: '/login'}); + location.reload(); }, getUser(){ get(this.$url.info).then(res=>{ this.user = res.data + localStorage.setItem("user",JSON.stringify(res.data)) }) } } diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue index 454e81b..effef3c 100644 --- a/src/layout/components/Sidebar/Item.vue +++ b/src/layout/components/Sidebar/Item.vue @@ -16,6 +16,9 @@ default: '' } }, + created(){ + + }, render(h, context) { const { icon, title } = context.props const vnodes = [] diff --git a/src/router/index.js b/src/router/index.js index cc9b8b5..285386b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -30,465 +30,588 @@ * a base page that does not have permission requirements * all roles can be accessed */ -export const constantRoutes = [ - { - path: '/login', - component: () => import('@/views/login/index'), - hidden: true - }, - { - path: '/404', - component: () => import('@/views/404'), - hidden: true - }, - { - path: '/addCommision', - component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), - hidden:true - }, - { - path: '/', - component: Layout, - redirect: '/home', - // meta: { title: '涓婚〉', icon: 'el-icon-s-home' }, - children: [{ - path: 'home', - name: 'Home', - component: () => import('@/views/home/index'), - meta: { title: '涓婚〉', icon: 'el-icon-s-home' } - }] - }, - { - path: '/addCommision/:viewId', - hidden: true, - component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), - }, - { - path: '/standardLibrary', - component: Layout, - redirect: '/standardLibrary/index', - meta: { title: '鏍囧噯搴�', icon: 'el-icon-s-help' }, - children: [ - { - path: 'index', - name: 'StandardLibrary', - component: () => import('@/views/standardLibrary/index'), - meta: { title: '鏍囧噯搴�', icon: 'form' } - }, - { - path: 'specificationDetails/:id', - name: 'SpecificationDetails', - // hidden: true, - component: () => import('@/views/standardLibrary/SpecificationDetails'), - meta: { title: '浜у搧瑙勬牸璇︽儏', icon: 'form', show: false } - } - ] - }, - // { - // path: '/rawMaterials', - // component: Layout, - // redirect: '/rawMaterials/reportForInspection', - // name: 'rawMaterials', - // meta: { title: '妫�楠�', icon: 'el-icon-s-help' }, - // children: [ - // { - // path: 'reportForInspection', - // name: 'ReportForInspection', - // component: () => import('@/views/rawMaterials/reportForInspection/index'), - // meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'table' }, - // children: [ - // // { - // // path: 'index', - // // name: 'ReportForInspectionIndex', - // // // hidden: true, - // // component: () => import('@/views/rawMaterials/reportForInspection/index'), - // // meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'table' } - // // }, - // { - // path: 'forInspectionDetail', - // name: 'ForInspectionDetail', - // hidden: true, - // component: () => import('@/views/rawMaterials/reportForInspection/forInspectionDetail'), - // meta: { title: '鏂板妫�楠屽崟璇︽儏', icon: 'table' } - // } - // ] - // }, - // { - // path: 'print', - // name: 'Print', - // component: () => import('@/views/rawMaterials/print/index'), - // meta: { title: '鏉$爜鎵撳嵃', icon: 'tree' } - // }, - // { - // path: 'planAssignments', - // name: 'PlanAssignments', - // component: () => import('@/views/rawMaterials/planAssignments/index'), - // meta: { title: '妫�楠岃鍒掑垎閰�', icon: 'tree' } - // }, - // { - // path: 'rawMaterialInspection', - // name: 'RawMaterialInspection', - // component: () => import('@/views/rawMaterials/rawMaterialInspection/index'), - // meta: { title: '鍘熸潗鏂欐楠�', icon: 'tree' } - // }, - // { - // path: 'checkTheReport', - // name: 'CheckTheReport', - // component: () => import('@/views/rawMaterials/checkTheReport/index'), - // meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } - // }, - // { - // path: 'reportAuditing', - // name: 'ReportAuditing', - // component: () => import('@/views/rawMaterials/reportAuditing/index'), - // meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } - // }, - // { - // path: 'nonConformanceReview', - // name: 'NonConformanceReview', - // component: () => import('@/views/rawMaterials/nonConformanceReview/index'), - // meta: { title: '涓嶅悎鏍煎弽棣�', icon: 'tree' } - // }, - // { - // path: 'nonConformingFeedback', - // name: 'NonConformingFeedback', - // component: () => import('@/views/rawMaterials/nonConformingFeedback/index'), - // meta: { title: '涓嶅悎鏍艰瘎瀹�', icon: 'tree' } - // }, - // { - // path: 'passRateStatistics', - // name: 'PassRateStatistics', - // component: () => import('@/views/rawMaterials/passRateStatistics/index'), - // meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } - // } - // ] - // }, - { - path: '/inspectionManagement', - component: Layout, - redirect: '/inspectionManagement/commissionInspection', - name: 'InspectionManagement', - meta: { title: '鎶ユ绠$悊', icon: 'el-icon-s-help' }, - children: [ - { - path: 'commissionInspection', - name: 'CommissionInspection', - component: () => import('@/views/inspectionManagement/commissionInspection/index'), - meta: { title: '濮旀墭妫�楠�', icon: 'table' } - }, - { - path: 'reportForInspection', - name: 'ReportForInspection', - component: () => import('@/views/inspectionManagement/reportForInspection/index'), - meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'tree' } - } - ] - }, - { - path: '/experiment', - component: Layout, - redirect: '/experiment/inspectionApplication', - name: 'Experiment', - meta: { title: '璇曢獙绠$悊', icon: 'el-icon-s-help' }, - children: [ - { - path: 'inspectionApplication', - name: 'inspectionApplication', - component: () => import('@/views/experiment/inspectionApplication/index'), - meta: { title: '鏂板妫�楠�', icon: 'tree' } - }, +function getRoutes() { + let constantRoutes = [ + { + path: '/login', + component: () => import('@/views/login/index'), + hidden: true + }, + { + path: '/404', + component: () => import('@/views/404'), + hidden: true + }, + { + path: '/addCommision', + component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), + hidden: true + }, + { + path: '/', + component: Layout, + redirect: '/home', + // meta: { title: '涓婚〉', icon: 'el-icon-s-home' }, + children: [{ + path: 'home', + name: 'Home', + component: () => import('@/views/home/index'), + meta: { title: '涓婚〉', icon: 'el-icon-s-home' } + }] + }, + { + path: '/addCommision/:viewId', + hidden: true, + component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), + }, + { + path: '/standardLibrary', + component: Layout, + redirect: '/standardLibrary/index', + meta: { title: '鏍囧噯搴�', icon: 'el-icon-s-help' }, + children: [ + { + path: 'index', + name: 'StandardLibrary', + component: () => import('@/views/standardLibrary/index'), + meta: { title: '鏍囧噯搴�', icon: 'form' } + }, + { + path: 'specificationDetails/:id', + name: 'SpecificationDetails', + // hidden: true, + component: () => import('@/views/standardLibrary/SpecificationDetails'), + meta: { title: '浜у搧瑙勬牸璇︽儏', icon: 'form', show: false } + } + ] + }, + // { + // path: '/rawMaterials', + // component: Layout, + // redirect: '/rawMaterials/reportForInspection', + // name: 'rawMaterials', + // meta: { title: '妫�楠�', icon: 'el-icon-s-help' }, + // children: [ + // { + // path: 'reportForInspection', + // name: 'ReportForInspection', + // component: () => import('@/views/rawMaterials/reportForInspection/index'), + // meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'table' }, + // children: [ + // // { + // // path: 'index', + // // name: 'ReportForInspectionIndex', + // // // hidden: true, + // // component: () => import('@/views/rawMaterials/reportForInspection/index'), + // // meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'table' } + // // }, + // { + // path: 'forInspectionDetail', + // name: 'ForInspectionDetail', + // hidden: true, + // component: () => import('@/views/rawMaterials/reportForInspection/forInspectionDetail'), + // meta: { title: '鏂板妫�楠屽崟璇︽儏', icon: 'table' } + // } + // ] + // }, + // { + // path: 'print', + // name: 'Print', + // component: () => import('@/views/rawMaterials/print/index'), + // meta: { title: '鏉$爜鎵撳嵃', icon: 'tree' } + // }, + // { + // path: 'planAssignments', + // name: 'PlanAssignments', + // component: () => import('@/views/rawMaterials/planAssignments/index'), + // meta: { title: '妫�楠岃鍒掑垎閰�', icon: 'tree' } + // }, + // { + // path: 'rawMaterialInspection', + // name: 'RawMaterialInspection', + // component: () => import('@/views/rawMaterials/rawMaterialInspection/index'), + // meta: { title: '鍘熸潗鏂欐楠�', icon: 'tree' } + // }, + // { + // path: 'checkTheReport', + // name: 'CheckTheReport', + // component: () => import('@/views/rawMaterials/checkTheReport/index'), + // meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } + // }, + // { + // path: 'reportAuditing', + // name: 'ReportAuditing', + // component: () => import('@/views/rawMaterials/reportAuditing/index'), + // meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } + // }, + // { + // path: 'nonConformanceReview', + // name: 'NonConformanceReview', + // component: () => import('@/views/rawMaterials/nonConformanceReview/index'), + // meta: { title: '涓嶅悎鏍煎弽棣�', icon: 'tree' } + // }, + // { + // path: 'nonConformingFeedback', + // name: 'NonConformingFeedback', + // component: () => import('@/views/rawMaterials/nonConformingFeedback/index'), + // meta: { title: '涓嶅悎鏍艰瘎瀹�', icon: 'tree' } + // }, + // { + // path: 'passRateStatistics', + // name: 'PassRateStatistics', + // component: () => import('@/views/rawMaterials/passRateStatistics/index'), + // meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } + // } + // ] + // }, + { + path: '/inspectionManagement', + component: Layout, + redirect: '/inspectionManagement/commissionInspection', + name: 'InspectionManagement', + meta: { title: '鎶ユ绠$悊', icon: 'el-icon-s-help' }, + children: [ + { + path: 'commissionInspection', + name: 'CommissionInspection', + component: () => import('@/views/inspectionManagement/commissionInspection/index'), + meta: { title: '濮旀墭妫�楠�', icon: 'table' } + }, + { + path: 'reportForInspection', + name: 'ReportForInspection', + component: () => import('@/views/inspectionManagement/reportForInspection/index'), + meta: { title: '鍘熸潗鏂欐姤妫�', icon: 'tree' } + } + ] + }, + { + path: '/experiment', + component: Layout, + redirect: '/experiment/inspectionApplication', + name: 'Experiment', + meta: { title: '璇曢獙绠$悊', icon: 'el-icon-s-help' }, + children: [ + { + path: 'inspectionApplication', + name: 'inspectionApplication', + component: () => import('@/views/experiment/inspectionApplication/index'), + meta: { title: '鏂板妫�楠�', icon: 'tree' } + }, { path: 'Viewdetails', name: 'Viewdetails', - hidden: true , + hidden: true, component: () => import('@/views/experiment/inspectionApplication/Viewdetails/index'), meta: { title: '璇︽儏椤�', icon: 'tree' } }, - { - path: 'planAssignments', - name: 'PlanAssignments', - component: () => import('@/views/experiment/planAssignments/plan'), - meta: { title: '妫�楠岃鍒�', icon: 'tree' } - }, - { - path: 'checkTheReport', - name: 'CheckTheReport', - component: () => import('@/views/experiment/checkTheReport/index'), - meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } - }, - { - path: 'reportAuditing', - name: 'ReportAuditing', - component: () => import('@/views/experiment/reportAuditing/index'), - meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } - }, - { - path: 'nonConformanceReview', - name: 'NonConformanceReview', - component: () => import('@/views/experiment/nonConformanceReview/index'), - meta: { title: '涓嶅悎鏍煎搧鍙嶉', icon: 'tree' } - }, - { - path: 'nonConformingFeedback', - name: 'NonConformingFeedback', - component: () => import('@/views/experiment/nonConformingFeedback/index'), - meta: { title: '涓嶅悎鏍煎搧璇勫', icon: 'tree' } - }, - { - path: 'passRateStatistics', - name: 'PassRateStatistics', - component: () => import('@/views/experiment/passRateStatistics/index'), - meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } - } - ] - }, - // { - // path: '/finishedProduct', - // component: Layout, - // redirect: '/finishedProduct/reportForInspection', - // name: 'FinishedProduct', - // meta: { title: '鎴愬搧妫�楠�', icon: 'el-icon-s-help' }, - // children: [ - // { - // path: 'reportForInspection', - // name: 'ReportForInspection', - // component: () => import('@/views/rawMaterials/reportForInspection/index'), - // meta: { title: '鎴愬搧閫佹鐧昏', icon: 'table' } - // }, - // { - // path: 'print', - // name: 'Print', - // component: () => import('@/views/rawMaterials/print/index'), - // meta: { title: '鏉$爜鎵撳嵃', icon: 'tree' } - // }, - // { - // path: 'planAssignments', - // name: 'PlanAssignments', - // component: () => import('@/views/rawMaterials/planAssignments/index'), - // meta: { title: '妫�楠岃鍒掑垎閰�', icon: 'tree' } - // }, - // { - // path: 'rawMaterialInspection', - // name: 'RawMaterialInspection', - // component: () => import('@/views/rawMaterials/rawMaterialInspection/index'), - // meta: { title: '鎴愬搧妫�楠�', icon: 'tree' } - // }, - // { - // path: 'checkTheReport', - // name: 'CheckTheReport', - // component: () => import('@/views/rawMaterials/checkTheReport/index'), - // meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } - // }, - // { - // path: 'reportAuditing', - // name: 'ReportAuditing', - // component: () => import('@/views/rawMaterials/reportAuditing/index'), - // meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } - // }, - // { - // path: 'nonConformanceReview', - // name: 'NonConformanceReview', - // component: () => import('@/views/rawMaterials/nonConformanceReview/index'), - // meta: { title: '涓嶅悎鏍煎弽棣�', icon: 'tree' } - // }, - // { - // path: 'nonConformingFeedback', - // name: 'NonConformingFeedback', - // component: () => import('@/views/rawMaterials/nonConformingFeedback/index'), - // meta: { title: '涓嶅悎鏍艰瘎瀹�', icon: 'tree' } - // }, - // { - // path: 'passRateStatistics', - // name: 'PassRateStatistics', - // component: () => import('@/views/rawMaterials/passRateStatistics/index'), - // meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } - // } - // ] - // }, - { - path: '/laboratory', - component: Layout, - redirect: '/laboratory/ledger', - name: 'Laboratory', - meta: { title: '瀹為獙瀹ょ鐞�', icon: 'el-icon-s-help' }, - children: [ - { - path: 'ledger', - name: 'Ledger', - component: () => import('@/views/laboratory/ledger/index'), - meta: { title: '璁惧鍙拌处', icon: 'table' } - }, - { - path: 'measure', - name: 'Measure', - component: () => import('@/views/laboratory/measure/index'), - meta: { title: '璁¢噺绠$悊', icon: 'tree' } - }, - { - path: 'gather', - name: 'Gather', - component: () => import('@/views/laboratory/gather/index'), - meta: { title: '璁惧閲囬泦', icon: 'tree' } - }, - { - path: 'personnel', - name: 'Personnel', - component: () => import('@/views/laboratory/personnel/index'), - meta: { title: '浜哄憳绠$悊', icon: 'tree' } - }, - { - path: 'org', - name: 'Organizational', - component: () => import('@/views/laboratory/organizational/index.vue'), - meta: { title: '缁勭粐鏋舵瀯', icon: 'tree'} - }, - { - path: 'role', - name: 'Role', - component: () => import('@/views/laboratory/role/index'), - meta: { title: '瑙掕壊绠$悊', icon: 'tree' } - } - ] - }, - { - path: '/CNAS', - component: Layout, - redirect: '/CNAS/reviewAnnualPlan', - name: 'CNAS', - meta: { title: 'CNAS绠$悊', icon: 'el-icon-s-help' }, - children: [ - { - path: 'reviewAnnualPlan', - name: 'ReviewAnnualPlan', - component: () => import('@/views/CNAS/reviewAnnualPlan/index'), - meta: { title: '瀹℃牳骞村害璁″垝', icon: 'table' } - }, - { - path: 'nonConformanceManage', - name: 'NonConformanceManage', - component: () => import('@/views/CNAS/nonConformanceManage/index'), - meta: { title: '涓嶇鍚堥」绠$悊', icon: 'tree' } - }, - { - path: 'nonConformanceStatistics', - name: 'NonConformanceStatistics', - component: () => import('@/views/CNAS/nonConformanceStatistics/index'), - meta: { title: '涓嶇鍚堥」缁熻', icon: 'tree' } - }, - { - path: 'satisfactionSurveys', - name: 'SatisfactionSurveys', - component: () => import('@/views/CNAS/satisfactionSurveys/index'), - meta: { title: '婊℃剰搴﹁皟鏌�', icon: 'tree' } - } - ] - }, - { - path: '/chart', - component: Layout, - redirect: '/chart/center', - name: 'Chart', - meta: { title: '鏅鸿兘鍥捐〃', icon: 'el-icon-s-help' }, - children: [ - { - path: 'center', - name: 'center', - component: () => import('@/views/chart/center/index'), - meta: { title: '瀹為獙涓績', icon: 'table' } - }, - { - path: 'spc', - name: 'Spc', - component: () => import('@/views/chart/spc/index'), - meta: { title: 'SPC鎺у埗鍥�', icon: 'tree' } - }, - { - path: 'shota', - name: 'Shota', - component: () => import('@/views/chart/shota/index'), - meta: { title: '姝eお鍒嗗竷鍥�', icon: 'tree' } - }, - { - path: 'work', - name: 'Work', - component: () => import('@/views/chart/work/index'), - meta: { title: '宸ヤ綔缁熻', icon: 'tree' } - } - ] - }, - { - path: '/message', - component: Layout, - redirect: '/message/toDo', - name: 'Message', - meta: { title: '娑堟伅寰呭姙', icon: 'el-icon-s-help' }, - children: [ + { + path: 'planAssignments', + name: 'PlanAssignments', + component: () => import('@/views/experiment/planAssignments/plan'), + meta: { title: '妫�楠岃鍒�', icon: 'tree' } + }, + { + path: 'checkTheReport', + name: 'CheckTheReport', + component: () => import('@/views/experiment/checkTheReport/index'), + meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } + }, + { + path: 'reportAuditing', + name: 'ReportAuditing', + component: () => import('@/views/experiment/reportAuditing/index'), + meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } + }, + { + path: 'nonConformanceReview', + name: 'NonConformanceReview', + component: () => import('@/views/experiment/nonConformanceReview/index'), + meta: { title: '涓嶅悎鏍煎搧鍙嶉', icon: 'tree' } + }, + { + path: 'nonConformingFeedback', + name: 'NonConformingFeedback', + component: () => import('@/views/experiment/nonConformingFeedback/index'), + meta: { title: '涓嶅悎鏍煎搧璇勫', icon: 'tree' } + }, + { + path: 'passRateStatistics', + name: 'PassRateStatistics', + component: () => import('@/views/experiment/passRateStatistics/index'), + meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } + } + ] + }, + // { + // path: '/finishedProduct', + // component: Layout, + // redirect: '/finishedProduct/reportForInspection', + // name: 'FinishedProduct', + // meta: { title: '鎴愬搧妫�楠�', icon: 'el-icon-s-help' }, + // children: [ + // { + // path: 'reportForInspection', + // name: 'ReportForInspection', + // component: () => import('@/views/rawMaterials/reportForInspection/index'), + // meta: { title: '鎴愬搧閫佹鐧昏', icon: 'table' } + // }, + // { + // path: 'print', + // name: 'Print', + // component: () => import('@/views/rawMaterials/print/index'), + // meta: { title: '鏉$爜鎵撳嵃', icon: 'tree' } + // }, + // { + // path: 'planAssignments', + // name: 'PlanAssignments', + // component: () => import('@/views/rawMaterials/planAssignments/index'), + // meta: { title: '妫�楠岃鍒掑垎閰�', icon: 'tree' } + // }, + // { + // path: 'rawMaterialInspection', + // name: 'RawMaterialInspection', + // component: () => import('@/views/rawMaterials/rawMaterialInspection/index'), + // meta: { title: '鎴愬搧妫�楠�', icon: 'tree' } + // }, + // { + // path: 'checkTheReport', + // name: 'CheckTheReport', + // component: () => import('@/views/rawMaterials/checkTheReport/index'), + // meta: { title: '妫�楠屾姤鍛�', icon: 'tree' } + // }, + // { + // path: 'reportAuditing', + // name: 'ReportAuditing', + // component: () => import('@/views/rawMaterials/reportAuditing/index'), + // meta: { title: '鎶ュ憡瀹℃牳', icon: 'tree' } + // }, + // { + // path: 'nonConformanceReview', + // name: 'NonConformanceReview', + // component: () => import('@/views/rawMaterials/nonConformanceReview/index'), + // meta: { title: '涓嶅悎鏍煎弽棣�', icon: 'tree' } + // }, + // { + // path: 'nonConformingFeedback', + // name: 'NonConformingFeedback', + // component: () => import('@/views/rawMaterials/nonConformingFeedback/index'), + // meta: { title: '涓嶅悎鏍艰瘎瀹�', icon: 'tree' } + // }, + // { + // path: 'passRateStatistics', + // name: 'PassRateStatistics', + // component: () => import('@/views/rawMaterials/passRateStatistics/index'), + // meta: { title: '鍚堟牸鐜囩粺璁�', icon: 'tree' } + // } + // ] + // }, + { + path: '/laboratory', + component: Layout, + redirect: '/laboratory/ledger', + name: 'Laboratory', + meta: { title: '瀹為獙瀹ょ鐞�', icon: 'el-icon-s-help' }, + children: [ + { + path: 'ledger', + name: 'Ledger', + component: () => import('@/views/laboratory/ledger/index'), + meta: { title: '璁惧鍙拌处', icon: 'table' } + }, + { + path: 'measure', + name: 'Measure', + component: () => import('@/views/laboratory/measure/index'), + meta: { title: '璁¢噺绠$悊', icon: 'tree' } + }, + { + path: 'gather', + name: 'Gather', + component: () => import('@/views/laboratory/gather/index'), + meta: { title: '璁惧閲囬泦', icon: 'tree' } + }, + { + path: 'personnel', + name: 'Personnel', + component: () => import('@/views/laboratory/personnel/index'), + meta: { title: '浜哄憳绠$悊', icon: 'tree' } + }, + { + path: 'org', + name: 'Organizational', + component: () => import('@/views/laboratory/organizational/index.vue'), + meta: { title: '缁勭粐鏋舵瀯', icon: 'tree' } + }, + { + path: 'role', + name: 'Role', + component: () => import('@/views/laboratory/role/index'), + meta: { title: '瑙掕壊绠$悊', icon: 'tree' } + } + ] + }, + { + path: '/CNAS', + component: Layout, + redirect: '/CNAS/reviewAnnualPlan', + name: 'CNAS', + meta: { title: 'CNAS绠$悊', icon: 'el-icon-s-help' }, + children: [ + { + path: 'reviewAnnualPlan', + name: 'ReviewAnnualPlan', + component: () => import('@/views/CNAS/reviewAnnualPlan/index'), + meta: { title: '瀹℃牳骞村害璁″垝', icon: 'table' } + }, + { + path: 'nonConformanceManage', + name: 'NonConformanceManage', + component: () => import('@/views/CNAS/nonConformanceManage/index'), + meta: { title: '涓嶇鍚堥」绠$悊', icon: 'tree' } + }, + { + path: 'nonConformanceStatistics', + name: 'NonConformanceStatistics', + component: () => import('@/views/CNAS/nonConformanceStatistics/index'), + meta: { title: '涓嶇鍚堥」缁熻', icon: 'tree' } + }, + { + path: 'satisfactionSurveys', + name: 'SatisfactionSurveys', + component: () => import('@/views/CNAS/satisfactionSurveys/index'), + meta: { title: '婊℃剰搴﹁皟鏌�', icon: 'tree' } + } + ] + }, + { + path: '/chart', + component: Layout, + redirect: '/chart/center', + name: 'Chart', + meta: { title: '鏅鸿兘鍥捐〃', icon: 'el-icon-s-help' }, + children: [ + { + path: 'center', + name: 'center', + component: () => import('@/views/chart/center/index'), + meta: { title: '瀹為獙涓績', icon: 'table' } + }, + { + path: 'spc', + name: 'Spc', + component: () => import('@/views/chart/spc/index'), + meta: { title: 'SPC鎺у埗鍥�', icon: 'tree' } + }, + { + path: 'shota', + name: 'Shota', + component: () => import('@/views/chart/shota/index'), + meta: { title: '姝eお鍒嗗竷鍥�', icon: 'tree' } + }, + { + path: 'work', + name: 'Work', + component: () => import('@/views/chart/work/index'), + meta: { title: '宸ヤ綔缁熻', icon: 'tree' } + } + ] + }, + { + path: '/message', + component: Layout, + redirect: '/message/toDo', + name: 'Message', + meta: { title: '娑堟伅寰呭姙', icon: 'el-icon-s-help' }, + children: [ { path: 'toDo', name: 'ToDo', component: () => import('@/views/message/toDo/index'), meta: { title: '鎴戠殑寰呭姙', icon: 'tree' } }, - { - path: 'message', - name: 'Message', - // hidden: true, - component: () => import('@/views/message/message/index'), - // meta: { title: '鎴戠殑娑堟伅', icon: 'table' } - }, - ] - }, - { - path: '/personal', - component: Layout, - redirect: '/personal/myInformation', - name: 'Personal', - meta: { title: '涓汉绠$悊', icon: 'el-icon-s-help' }, - children: [ - { - path: 'myInformation', - name: 'MyInformation', - component: () => import('@/views/personal/myInformation/index'), - meta: { title: '鎴戠殑淇℃伅', icon: 'table' } - }, - { - path: 'myBusiness', - name: 'MyBusiness', - component: () => import('@/views/personal/myBusiness/index'), - meta: { title: '鎴戠殑浼佷笟', icon: 'tree', show: false } - } - ] - }, - { - path: '/baseData', - component: Layout, - redirect: '/baseData/basicDataMessage', - meta: { title: '鍩虹鏁版嵁', icon: 'el-icon-s-tools' }, - children: [ - { - path: '/basicDataMessage', - name: 'BasicDataMessage', - component: () => import('@/views/basicData/index'), - meta: { title: '鍩虹鏁版嵁', icon: 'el-icon-s-tools' } - } - ] - }, - // 404 page must be placed at the end !!! - { path: '*', redirect: '/404', hidden: true } -] - -const createRouter = () => new Router({ - // mode: 'history', // require service support - scrollBehavior: () => ({ y: 0 }), - routes: constantRoutes -}) - -const router = createRouter() - -// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 -export function resetRouter() { - const newRouter = createRouter() - router.matcher = newRouter.matcher // reset router + { + path: 'message', + name: 'Message', + // hidden: true, + component: () => import('@/views/message/message/index'), + // meta: { title: '鎴戠殑娑堟伅', icon: 'table' } + }, + ] + }, + { + path: '/personal', + component: Layout, + redirect: '/personal/myInformation', + name: 'Personal', + meta: { title: '涓汉绠$悊', icon: 'el-icon-s-help' }, + children: [ + { + path: 'myInformation', + name: 'MyInformation', + component: () => import('@/views/personal/myInformation/index'), + meta: { title: '鎴戠殑淇℃伅', icon: 'table' } + }, + { + path: 'myBusiness', + name: 'MyBusiness', + component: () => import('@/views/personal/myBusiness/index'), + meta: { title: '鎴戠殑浼佷笟', icon: 'tree', show: false } + } + ] + }, + { + path: '/baseData', + component: Layout, + redirect: '/baseData/basicDataMessage', + name: 'BaseData', + meta: { title: '鍩虹鏁版嵁', icon: 'el-icon-s-tools' }, + children: [ + { + path: 'basicDataMessage', + name: 'BasicDataMessage', + component: () => import('@/views/basicData/index'), + meta: { title: '鍩虹鏁版嵁', icon: 'el-icon-s-tools' } + } + ] + }, + { path: '*', redirect: '/404', hidden: true } + ] + return constantRoutes } +const baseRouter = [{ + path: '/login', + component: () => import('@/views/login/index'), + hidden: true +}, +{ + path: '/404', + component: () => import('@/views/404'), + hidden: true +}, +{ + path: '/addCommision', + component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), + hidden: true +}, +{ + path: '/', + component: Layout, + redirect: '/home', + // meta: { title: '涓婚〉', icon: 'el-icon-s-home' }, + children: [{ + path: 'home', + name: 'Home', + component: () => import('@/views/home/index'), + meta: { title: '涓婚〉', icon: 'el-icon-s-home' } + }] +}, { + path: '/addCommision/:viewId', + hidden: true, + component: () => import('@/views/inspectionManagement/commissionInspection/addCommision'), +}] + +function fn3(tempArr) { + let result = []; + let obj = {}; + for (let i = 0; i < tempArr.length; i++) { + if (!obj[tempArr[i].path]) { + result.push(tempArr[i]); + obj[tempArr[i].path] = true; + }; + }; + return result; +}; + + +function createRouter(Routees) { + if (JSON.parse(localStorage.getItem("user")) != undefined && JSON.parse(localStorage.getItem("user")) != null) { + let role = JSON.parse(localStorage.getItem("user")).role + let menuFather = baseRouter + const dataMenuFather = fn3(menuFather) + role.roleMenuList.forEach((r) => { + dataMenuFather.push(Routees.filter(item => { + return item.path === r.menuUrl + })[0]) + }) + let eqChildren = []; + role.roleMenuList.forEach((r) => { + dataMenuFather.forEach(m => { + if (r.menuUrl === m.path) { + r.children.forEach(rc => { + m.children.forEach(mc => { + if (mc.meta != undefined) { + eqChildren.push({ "path": mc.path, "meta": JSON.parse(JSON.stringify(mc.meta)) }) + delete mc["meta"] + } + }) + }) + } + }) + }) + let once = [] + role.roleMenuList.forEach((r) => { + r.children.forEach(rc => { + eqChildren.forEach(eq => { + if (eq != undefined) { + if (eq.path == rc.menuUrl.split("/")[1]) { + once.push(eq) + } + } + }) + }) + }) + dataMenuFather.forEach(m => { + let i = 0 + if (m.children != undefined) { + m.children.forEach(mc => { + once.forEach(eq => { + if (eq != undefined) { + if (mc.path == eq.path) { + if (i === 0) { + m.redirect = m.path + "/" + eq.path + } + i++; + mc.meta = eq.meta + } + } + }) + }) + } + }) + dataMenuFather.push({path: '*', redirect: '/404', hidden: true}) + dataMenuFather.push() + Routees = dataMenuFather + } else { + Routees = baseRouter + } + return new Router({ + // mode: 'history', // require service support + scrollBehavior: () => ({ y: 0 }), + routes: Routees + }) +} +let router = createRouter(getRoutes()) + +// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 +export async function resetRouter() { + let newRouter = createRouter(getRoutes()) + router.matcher = newRouter.matcher +} +router.beforeEach(async (to, from, next) => { + // 1. 鍒ゆ柇鏄笉鏄櫥褰曢〉闈� + // 鏄櫥褰曢〉闈� + if (to.path === '/login') { + next() + } else { + // 涓嶆槸鐧诲綍椤甸潰 + // 2. 鍒ゆ柇 鏄惁鐧诲綍杩� + let token = localStorage.getItem('user') + if(token!=null&&token!=undefined){ + await resetRouter() + } + token ? next() : next('/login') + } +}) export default router diff --git a/src/utils/request.js b/src/utils/request.js index 2b822e9..aef5813 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -48,7 +48,22 @@ // if the custom code is not 20000, it is judged as an error. if (res.code !== 200) { - console.log(res.message || 'Error') + if(res.code===400){ + Message({ + message: res.message, + type: 'warning', + duration: 5 * 1000 + }) + } + if(res.code===401){ + Message({ + message: res.message, + type: 'warning', + duration: 5 * 1000 + }) + localStorage.removeItem("user") + this.$router.push({ path: '/login' }) + } // Message({ // message: res.message || 'Error', // type: 'error', diff --git a/src/views/home/index.vue b/src/views/home/index.vue index d7201cd..aeecc96 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -124,7 +124,7 @@ this.getcheckProjectNum(); this.getVerifiedData(); this.getUncheckedData(); - this.getPieChart(); + this.getPieChart(); }, methods: { cell({ row, column, rowIndex, columnIndex }) { diff --git a/src/views/laboratory/measure/index.vue b/src/views/laboratory/measure/index.vue index 0e01e41..18e0146 100644 --- a/src/views/laboratory/measure/index.vue +++ b/src/views/laboratory/measure/index.vue @@ -117,6 +117,13 @@ </div> </div> </div> + <div> + <el-button v-if="selectInfoBtn" @click="combackLookPlan" style="position: fixed;top: 43px;right: 14px; z-index: 1000;" type="primary" icon="el-icon-refresh-left" size="mini" plain >杩斿洖</el-button> + <div v-if="addBtn" style="display: flex;justify-content: center;width: 10%;position: fixed;top: 43px;right: 14px; z-index: 1000;"> + <el-button @click="addTop = -82;addBtn=false" size="mini" style="width: 60px;" >杩斿洖</el-button> + <el-button size="mini" @click="measureAdd" style="width: 60px;" type="primary">淇濆瓨</el-button> + </div> + </div> <div :style="`position: absolute;top:${addTop}vh;left: 9px;transition: 1s;width: 99%;height: 82vh;background-color: #fff;z-index: 21;`"> <Add ref="add" /> @@ -276,6 +283,8 @@ return { dialogVisible: false, tableIndex: null, + selectInfoBtn: false, + addBtn: false, measureUpInfo: { id: null, code: null, @@ -370,15 +379,12 @@ this.measureUpInfo.termValidity = scope.row.termValidity }, measureAdd() { - let add = this.$refs.add.add() - if (add) { - this.addTop = -82 + this.addTop = -82 this.$message({ message: '鎿嶄綔鎴愬姛锛�', type: 'success' }); this.lookVisible = false - } }, async handleSizeChangePlan(num) { this.pageSizePlan = num @@ -392,6 +398,7 @@ this.addTop = 2 this.lookVisible = true this.$parent.mainShowAdd() + this.addBtn=true }, async limitGetPlanMeasureInstrument() { let param = { @@ -408,6 +415,7 @@ this.getPlanAndInfoAndIns(id) this.lookVisible = true this.mymodelTop = 2 + this.selectInfoBtn=true this.$parent.triggerMainBtnPlan() }, async getPlanAndInfoAndIns(id) { @@ -429,6 +437,7 @@ combackLookPlan() { this.lookVisible = false this.mymodelTop = -85 + this.selectInfoBtn=false }, blurSearch() { if (this.radioValue === 1) { diff --git a/src/views/laboratory/role/index.vue b/src/views/laboratory/role/index.vue index a56cda7..c4f696c 100644 --- a/src/views/laboratory/role/index.vue +++ b/src/views/laboratory/role/index.vue @@ -8,7 +8,7 @@ </el-input> </el-form-item> <el-form-item class="rightBtn"> - <el-button type="primary">鏌ヨ</el-button> + <el-button type="primary" @click="searchRole">鏌ヨ</el-button> <el-button type="primary" plain>閲嶇疆</el-button> </el-form-item> </el-form> @@ -16,7 +16,6 @@ <el-form-item class="rightBtn"> <el-button type="primary" @click="addClickRole" icon="el-icon-plus">鏂板瑙掕壊</el-button> </el-form-item> - </el-form> </el-form> </div> <div class="library-table"> @@ -30,8 +29,9 @@ <el-table-column prop="updateTime" label="鏇存柊鏃堕棿" min-width="20%" /> <el-table-column label="鎿嶄綔" min-width="12%"> <template slot-scope="scope"> - <el-button type="text" size="small">缂栬緫</el-button> - <el-button type="text" size="small">鍒犻櫎</el-button> + <el-button type="text" @click="selectRoleInfo(scope)" size="small">鏌ョ湅</el-button> + <el-button type="text" @click="upRole(scope)" size="small">缂栬緫</el-button> + <el-button type="text" @click="removeRole(scope)" size="small">鍒犻櫎</el-button> </template> </el-table-column> </el-table> @@ -67,10 +67,10 @@ :default-expand-all="false" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> <el-table-column highlight-current-row prop="parentId" label="鑿滃崟绫诲瀷" sortable width="180"> <template slot-scope="scope"> - <span v-if="scope.row.parentId == 0 && scope.row.children != undefined" style="color: #409eff;">涓昏彍鍗�</span> - <span v-if="scope.row.parentId == 0 && scope.row.children === undefined" style="color: #409eff;"> + <span v-if="scope.row.parentId == 0" style="color: #409eff;">涓昏彍鍗�</span> + <!-- <span v-if="scope.row.parentId == 0 && scope.row.children === undefined" style="color: #409eff;"> 涓昏彍鍗� - </span> + </span> --> </template> </el-table-column> <el-table-column prop="name" label="鑿滃崟鍚�" sortable width="180"> @@ -103,11 +103,125 @@ <el-button type="primary" @click="addRole">纭� 瀹�</el-button> </span> </el-dialog> + + <el-dialog top="5vh" title="缂栬緫瑙掕壊" :visible.sync="dialogTableVisibleUpdate" width="50%"> + <el-form :model="updateRole" ref="updateRole" label-position="right" label-width="100px"> + <el-col :span="24" style="display: flex;justify-content: space-between;"> + <el-form-item :rules="nameaRules" label="瑙掕壊鍚�:"> + <el-input @blur="assertUpName" style="width: 300px" v-model="updateRole.roleName" placeholder="璇疯緭鍏ヨ鑹插悕"> + </el-input> + </el-form-item> + <!-- <el-form-item label="鑿滃崟閫夋嫨:"> + <el-cascader style="width: 300px" collapse-tags size="medium " filterable :props="props" + v-model="roleAdd.menuData" :options="menuInfo"> + <template slot-scope="{ data }"> + <span>{{ data.label }}</span> + </template> + </el-cascader> + </el-form-item> --> + </el-col> + </el-form> + <el-col :span="24"> + <el-table height="500" :data="menuUpdateInfo" style="width: 100%;margin-bottom: 20px;" row-key="id" + :default-expand-all="true" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> + <el-table-column highlight-current-row prop="parentId" label="鑿滃崟绫诲瀷" sortable width="180"> + <template slot-scope="scope"> + <span v-if="scope.row.parentId == 0" style="color: #409eff;">涓昏彍鍗�</span> + <!-- <span v-if="scope.row.parentId == 0 && scope.row.children === undefined" style="color: #409eff;"> + 涓昏彍鍗� + </span> --> + </template> + </el-table-column> + <el-table-column prop="name" label="鑿滃崟鍚�" sortable width="180"> + <template slot-scope="scope"> + <el-col v-if="scope.row.parentId == 0"> + <span style="color: #409eff;">{{ scope.row.name }}</span> + </el-col> + <el-col v-else> + <span style="color: #40b815;">{{ scope.row.name }}</span> + </el-col> + </template> + </el-table-column> + <el-table-column prop="id" label="鎿嶄綔鏉冮檺"> + <template slot-scope="scope"> + <el-col v-if="scope.row.parentId == 0 && scope.row.children != undefined"> + <!-- <el-checkbox v-model="scope.row.select">鏌ヨ</el-checkbox> --> + </el-col> + <el-col v-else> + <el-checkbox size="medium" v-model="scope.row.selected" @change="chekSelect(scope)">鏌ヨ</el-checkbox> + <el-checkbox size="medium" v-model="scope.row.added" @change="chekAdd(scope)">娣诲姞</el-checkbox> + <el-checkbox size="medium" v-model="scope.row.updated" @change="chekUpdate(scope)">淇敼</el-checkbox> + <el-checkbox size="medium" v-model="scope.row.deleted" @change="chekDelet(scope)">鍒犻櫎</el-checkbox> + </el-col> + </template> + </el-table-column> + </el-table> + </el-col> + <span slot="footer" class="dialog-footer"> + <el-button @click="clearUPAll">鍙� 娑�</el-button> + <el-button type="primary" @click="cilckUP">纭� 瀹�</el-button> + </span> + </el-dialog> + + <el-dialog top="5vh" title="瑙掕壊瀵熺湅" :visible.sync="dialogTableSelectVisible" width="50%"> + <el-form :model="selectMenuInfo" ref="selectMenuInfo" label-position="right" label-width="100px"> + <el-col :span="24" style="display: flex;justify-content: space-between;"> + <el-form-item label="瑙掕壊鍚�:"> + <el-input style="width: 300px" v-model="selectMenuInfo.roleName" readonly> + </el-input> + </el-form-item> + <!-- <el-form-item label="鑿滃崟閫夋嫨:"> + <el-cascader style="width: 300px" collapse-tags size="medium " filterable :props="props" + v-model="roleAdd.menuData" :options="menuInfo"> + <template slot-scope="{ data }"> + <span>{{ data.label }}</span> + </template> + </el-cascader> + </el-form-item> --> + </el-col> + </el-form> + <el-col :span="24"> + <el-table height="500" :data="selectMenuInfo.menuData" style="width: 100%;margin-bottom: 20px;" row-key="menuId" + :default-expand-all="true" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> + <el-table-column highlight-current-row prop="parentId" label="鑿滃崟绫诲瀷" sortable width="180"> + <template slot-scope="scope"> + <span v-if="scope.row.parentId == 0" style="color: #409eff;">涓昏彍鍗�</span> + <!-- <span v-if="scope.row.parentId == 0 && scope.row.children === undefined" style="color: #409eff;"> + 涓昏彍鍗� + </span> --> + </template> + </el-table-column> + <el-table-column prop="menuName" label="鑿滃崟鍚�" sortable width="180"> + <template slot-scope="scope"> + <el-col v-if="scope.row.parentId == 0"> + <span style="color: #409eff;">{{ scope.row.menuName }}</span> + </el-col> + <el-col v-else> + <span style="color: #40b815;">{{ scope.row.menuName }}</span> + </el-col> + </template> + </el-table-column> + <el-table-column prop="menuId" label="鎿嶄綔鏉冮檺"> + <template slot-scope="scope"> + <el-col v-if="scope.row.parentId == 0 && scope.row.children.length > 0"> + <!-- <el-checkbox v-model="scope.row.select">鏌ヨ</el-checkbox> --> + </el-col> + <el-col id="selectRoleCheck" class="selectRoleCheck" v-else> + <el-checkbox size="medium" disabled v-model="scope.row.selected">鏌ヨ</el-checkbox> + <el-checkbox size="medium" disabled v-model="scope.row.added">娣诲姞</el-checkbox> + <el-checkbox size="medium" disabled v-model="scope.row.updated">淇敼</el-checkbox> + <el-checkbox size="medium" disabled v-model="scope.row.deleted">鍒犻櫎</el-checkbox> + </el-col> + </template> + </el-table-column> + </el-table> + </el-col> + </el-dialog> </div> </template> <script> -import { getMenusTree, addRoleInfo, assertRepeat, getAllRoleAndMenuInfo } from '@/api/laboratory/role' +import { getMenusTree, addRoleInfo, assertRepeat, getAllRoleAndMenuInfo, deleteRole, updateRoleMenu } from '@/api/laboratory/role' import { default as menuPower } from './menuPower.vue' export default { components: { @@ -116,6 +230,15 @@ data() { return { props: { multiple: true }, + dialogTableVisibleUpdate: false, + updateRole: { + roleId: null, + roleName: null, + lastName: null, + menuData: null, + lastMenuSelect: null + }, + selectRole: [], roleAdd: { roleName: null, menuData: null @@ -124,10 +247,14 @@ menuTableTree: null, searchData: { roleName: '', - permission: '' }, assertRepeatName: true, menuInfo: [], + menuUpdateInfo: [], + selectMenuInfo: { + roleName: null, + menuData: null + }, roleTable: [], updateData: { oldPassWord: '', @@ -135,6 +262,8 @@ confirmPassWord: '' }, dialogTableVisible: false, + dialogTableSelectVisible: false, + addOrUp: false, currentPage: 1, pageSize: 5, total: 20 @@ -147,13 +276,169 @@ this.start() }, methods: { - chekSelect(scope) { + selectRoleInfo(scope) { + this.selectMenuInfo.roleName = scope.row.roleName + this.selectMenuInfo.menuData = scope.row.roleMenuList + console.log(this.selectMenuInfo.menuData); + this.dialogTableSelectVisible = true + }, + searchRole() { + this.start() + }, + clearUPAll() { + this.updateRole = { + roleId: null, + roleName: null, + lastName: null, + menuData: null, + lastMenuSelect: null + } + this.menuUpdateInfo = [] + this.dialogTableVisibleUpdate = false + }, + async cilckUP() { + if (this.updateRole.roleName == null || this.updateRole.roleName == '') { + this.$message({ + message: '璇疯緭鍏ヨ鑹插悕', + type: 'warning' + }); + return + } + if (!this.assertRepeatName) { + this.$message({ + message: '瑙掕壊鍚嶉噸澶嶏紝璇烽噸鏂拌緭鍏�', + type: 'warning' + }); + return + } + this.menuUpdateInfo.forEach(item => { + if (item.children != undefined) { + item.children.forEach(c => { + if (c.added) { + item.selected = true + } + if (c.selected) { + item.selected = true + } + if (c.updated) { + item.selected = true + } + if (c.deleted) { + item.selected = true + } + }) + } + }) + console.log(this.menuUpdateInfo); + this.updateRole.menuData = JSON.parse(JSON.stringify(this.menuUpdateInfo)); + this.updateRole.menuData.forEach(item => { + if (item.children != undefined) { + let child = item.children.filter(c => { + return c.added == true || c.selected == true || c.deleted == true || c.updated === true + }) + item.children = child + } + }) + this.updateRole.menuData = this.updateRole.menuData.filter(item => { + return item.selected == true + }) + this.assertDeleteOrUp() + console.log(this.updateRole); + let up = await updateRoleMenu(this.updateRole) + if (up.data) { + this.$message({ + type: 'success', + message: '缂栬緫鎴愬姛!' + }); + this.start() + this.clearUPAll() + } else { + this.$message.error('缂栬緫澶辫触锛佽閲嶆柊鎿嶄綔'); + } }, + async upRole(scope) { + console.log(scope); + this.updateRole.roleId = scope.row.roleId + this.updateRole.roleName = scope.row.roleName + this.updateRole.lastName = scope.row.roleName + let menuSelect = scope.row.roleMenuList + this.updateRole.lastMenuSelect = scope.row.roleMenuList + console.log(menuSelect); + let res = await getMenusTree(); + this.menuUpdateInfo = res.data + this.menuUpdateInfo.forEach(item => { + this.$set(item, 'added', false); + this.$set(item, 'updated', false); + this.$set(item, 'deleted', false); + this.$set(item, 'selected', false); + if (item.children.length == 0) { + delete item['children'] + } else { + item.children.forEach(c => { + this.$set(c, 'selected', false); + this.$set(c, 'added', false); + this.$set(c, 'updated', false); + this.$set(c, 'deleted', false); + if (c.children.length == 0) { + delete c['children'] + } + }) + } + }) + console.log(this.menuUpdateInfo); + menuSelect.forEach(ms => { + this.menuUpdateInfo.forEach(item => { + if (ms.menuName === item.name) { + item.selected = ms.selected + item.added = ms.added + item.deleted = ms.deleted + item.updated = ms.updated + ms.children.forEach(msc => { + if (item.children != undefined) { + item.children.forEach(itemc => { + if (itemc.name === msc.menuName) { + itemc.selected = msc.selected + itemc.added = msc.added + itemc.deleted = msc.deleted + itemc.updated = msc.updated + } + }) + } + }) + } + }) + }) + this.dialogTableVisibleUpdate = true + }, + removeRole(scope) { + this.$confirm('姝ゆ搷浣滃皢鍒犻櫎璇ヨ鑹�, 鏄惁缁х画?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(async () => { + this.roleTable = this.roleTable.filter(item => { + return item.roleId != scope.row.roleId + }); + this.$message({ + type: 'success', + message: '鍒犻櫎鎴愬姛!' + }); + await deleteRole({ id: scope.row.roleId }) + }).catch(() => { + this.$message({ + type: 'info', + message: '宸插彇娑堝垹闄�' + }); + }); + }, async start() { - let res = await getAllRoleAndMenuInfo() - this.roleTable = res.data - console.log(res); + let res = await getAllRoleAndMenuInfo({ currentPage: this.currentPage, pageSize: this.pageSize, name: this.searchData.roleName }) + res.data.list.forEach(item => { + item.roleId = String(item.roleId) + }) + this.roleTable = res.data.list + this.total = res.data.total }, async assertName() { if (this.roleAdd.roleName == null || this.roleAdd.roleName == '') { @@ -175,13 +460,81 @@ } }, chekAdd(scope) { - scope.row.selected = true + if (scope.row.added) { + scope.row.selected = true + } + this.updateFatherState(scope) }, chekUpdate(scope) { - scope.row.selected = true + if (scope.row.updated) { + scope.row.selected = true + } + this.updateFatherState(scope) }, chekDelet(scope) { - scope.row.selected = true + if (scope.row.deleted) { + scope.row.selected = true + } + this.updateFatherState(scope) + }, + chekSelect(scope) { + this.updateFatherState(scope) + }, + updateFatherState(scope) { + if (this.menuUpdateInfo != []) { + this.menuUpdateInfo.forEach(item => { + if (item.id == scope.row.parentId) { + if (item.children != undefined) { + let childrenFalse = item.children.length * 4; + let countFalse = 0; + item.children.forEach(c => { + if (c.added == false) { + countFalse++; + } + if (c.deleted == false) { + countFalse++; + } + if (c.updated == false) { + countFalse++; + } + if (c.selected == false) { + countFalse++; + } + }) + if (childrenFalse === countFalse) { + item.selected = false + } + } + } + }) + } + if (this.menuInfo != []) { + this.menuInfo.forEach(item => { + if (item.id == scope.row.parentId) { + if (item.children != undefined) { + let childrenFalse = item.children.length * 4; + let countFalse = 0; + item.children.forEach(c => { + if (c.added == false) { + countFalse++; + } + if (c.deleted == false) { + countFalse++; + } + if (c.updated == false) { + countFalse++; + } + if (c.selected == false) { + countFalse++; + } + }) + if (childrenFalse === countFalse) { + item.selected = false + } + } + } + }) + } }, async addClickRole() { let res = await getMenusTree(); @@ -254,6 +607,7 @@ return item.selected == true }) let res = await addRoleInfo(this.roleAdd); + this.start() if (res.data) { this.$message({ message: '娣诲姞瑙掕壊鎴愬姛', @@ -287,6 +641,92 @@ this.menuInfo = [] this.assertRepeatName = true this.dialogTableVisible = false + }, + assertDeleteOrUp() { + console.log("---------"); + console.log(this.updateRole.menuData); + this.updateRole.lastMenuSelect + this.updateRole.menuData + let newTree = [] + let oldTree = [] + this.updateRole.menuData.forEach(item => { + const obj = { + menuId: item.id, + menuName: item.name, + added: item.added, + parentId: item.parentId, + deleted: item.deleted, + updated: item.updated, + selected: item.selected + } + newTree.push(obj) + if (item.children != undefined && obj.selected != false) { + item.children.forEach(c => { + const objc = { + menuId: c.id, + menuName: c.name, + parentId: c.parentId, + added: c.added, + deleted: c.deleted, + updated: c.updated, + selected: c.selected + } + newTree.push(objc) + }) + } + }) + console.log(newTree); + // this.updateRole.lastMenuSelect.forEach(item => { + // const obj = { + // menuId: item.menuId, + // menuName: item.menuName, + // added: item.added, + // deleted: item.deleted, + // updated: item.updated, + // selected: item.selected + // } + // if (obj.selected) { + // oldTree.push(obj) + // } + // if (item.children != [] && obj.selected != false) { + // item.children.forEach(c => { + // const objc = { + // menuId: c.menuId, + // menuName: c.menuName, + // added: c.added, + // deleted: c.deleted, + // updated: c.updated, + // selected: c.selected + // } + // oldTree.push(objc) + // }) + // } + // }) + console.log(oldTree); + // this.updateRole.lastMenuSelect = oldTree + this.updateRole.menuData = newTree + }, + async assertUpName() { + if (this.updateRole.roleName == null || this.updateRole.roleName == '') { + this.$message({ + message: '璇疯緭鍏ヨ鑹插悕绉帮紒', + type: 'warning' + }); + return + } + if (this.updateRole.roleName === this.updateRole.lastName) { + return + } + let res = await assertRepeat({ roleName: this.updateRole.roleName }) + if (!res.data) { + this.assertRepeatName = false + this.$message({ + message: '瑙掕壊鍚嶉噸澶嶏紝璇烽噸鏂拌緭鍏ワ紒', + type: 'warning' + }); + } else { + this.assertRepeatName = true + } } } } @@ -336,5 +776,16 @@ justify-content: end; margin-top: 20px } + } </style> + +<style> +#selectRolecheck .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after { + border-color: #fff !important; +} +#selectRoleCheck .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner { + background-color: #409EFF; + border-color: #409EFF; +} +</style> \ No newline at end of file diff --git a/src/views/login/index.vue b/src/views/login/index.vue index d753b3b..d381e08 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -11,38 +11,23 @@ <span class="svg-container"> <svg-icon icon-class="user" /> </span> - <el-input - ref="username" - v-model="loginForm.username" - placeholder="Username" - name="username" - type="text" - tabindex="1" - auto-complete="on" - /> + <el-input ref="username" v-model="loginForm.username" placeholder="Username" name="username" type="text" + tabindex="1" auto-complete="on" /> </el-form-item> <el-form-item prop="password"> <span class="svg-container"> <svg-icon icon-class="password" /> </span> - <el-input - :key="passwordType" - ref="password" - v-model="loginForm.password" - :type="passwordType" - placeholder="Password" - name="password" - tabindex="2" - auto-complete="on" - @keyup.enter.native="handleLogin" - /> + <el-input :key="passwordType" ref="password" v-model="loginForm.password" :type="passwordType" + placeholder="Password" name="password" tabindex="2" auto-complete="on" @keyup.enter.native="handleLogin" /> <span class="show-pwd" @click="showPwd"> <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> </span> </el-form-item> - <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">Login</el-button> + <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" + @click.native.prevent="handleLogin">Login</el-button> <!-- <div class="tips"> <span style="margin-right:20px;">username: admin</span> <span> password: any</span> @@ -53,7 +38,7 @@ <script> import { validUsername } from '@/utils/validate' - +import { get } from "@/api/util/requestUtil.js" export default { name: 'Login', data() { @@ -87,7 +72,7 @@ }, watch: { $route: { - handler: function(route) { + handler: function (route) { this.redirect = route.query && route.query.redirect }, immediate: true @@ -108,7 +93,11 @@ this.$refs.loginForm.validate(valid => { if (valid) { this.loading = true - this.$store.dispatch('user/login', this.loginForm).then(() => { + this.$store.dispatch('user/login', this.loginForm).then(async () => { + await get(this.$url.info).then(res => { + this.user = res.data + localStorage.setItem("user", JSON.stringify(res.data)) + }) this.$router.push({ path: this.redirect || '/' }) this.loading = false }).catch(() => { @@ -128,8 +117,8 @@ /* 淇input 鑳屾櫙涓嶅崗璋� 鍜屽厜鏍囧彉鑹� */ /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */ -$bg:#283443; -$light_gray:#fff; +$bg: #283443; +$light_gray: #fff; $cursor: #fff; @supports (-webkit-mask: none) and (not (cater-color: $cursor)) { @@ -172,27 +161,28 @@ </style> <style lang="scss" scoped> -$bg:#2d3a4b; -$dark_gray:#889aa4; -$light_gray:#eee; +$bg: #2d3a4b; +$dark_gray: #889aa4; +$light_gray: #eee; .login-container { min-height: 100%; width: 100%; - background:url('../../assets/404_images/backgroud.png') no-repeat; + background: url('../../assets/404_images/backgroud.png') no-repeat; background-size: 100vw 100vh; overflow: hidden; + .login-form { position: relative; width: 520px; max-width: 100%; - padding: 0 35px ; + padding: 0 35px; margin: 0 auto; overflow: hidden; position: absolute; top: 50%; left: 50%; - transform: translate(-50%,-50%); + transform: translate(-50%, -50%); } -- Gitblit v1.9.3