This commit is contained in:
xuyucheng 2022-11-11 16:36:03 +08:00
parent cc1ff88578
commit fce38d7d43
8 changed files with 116 additions and 18 deletions

3
.env.development Normal file
View File

@ -0,0 +1,3 @@
NODE_ENV = 'development'
VUE_APP_MODE = 'development'
VUE_APP_URL = 'http://localhost:8082/webapp/rating_manager/'

3
.env.production Normal file
View File

@ -0,0 +1,3 @@
NODE_ENV = 'production'
VUE_APP_MODE = 'production'
VUE_APP_URL = 'http://test.fecribd.com/webapp/rating_manager/'

View File

@ -3,8 +3,10 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"serve": "vue-cli-service serve --mode development",
"build": "vue-cli-service build --mode development",
"serve-prod": "vue-cli-service serve --mode production",
"build-prod": "vue-cli-service build --mode production",
"lint": "vue-cli-service lint"
},
"dependencies": {

View File

@ -1,4 +1,5 @@
import axios from 'axios'
import router from "@/router/index"
import { rsaKey } from "@/utils/rsaKey.js";
//创建axios实例
@ -31,7 +32,7 @@ axios.interceptors.response.use(response => {
case 400:
break;
case 401:
window.location.href = "http://test.fecribd.com/webapp/entry_system/login"
router.push("/webapp/entry_system/login")
break;
case 500:
break

View File

@ -5,7 +5,13 @@
<el-table
ref="table"
:data="data"
:border="border"
:row-key="checkKey"
:span-method="spanMethod"
:cell-style="cellStyle"
:header-cell-style="headerCellStyle"
@cell-click="cellClick"
@sort-change="sortChange"
@selection-change="handleSelectChange"
>
<!-- 多选 -->
@ -19,8 +25,10 @@
<el-table-column
v-for="(item, index) in column"
:key="index"
:sortable="sortable"
:prop="item.prop"
:label="item.label"
:align="align"
>
<template slot-scope="scope">
<!-- 单元格 - 默认文本展示内容 -->
@ -51,11 +59,31 @@
<script>
export default {
props: {
// -
border: {
type: Boolean,
default: true,
},
// -
align: {
type: String,
default: "center",
},
// -
sortable: {
type: Boolean,
default: true,
},
// - ? true - : false -
selection: {
type: Boolean,
default: false,
},
// ,id
checkKey: {
type: String,
default: "id",
},
//
checkValue: [Array],
// -
@ -66,10 +94,27 @@ export default {
default: null,
},
//
data: [Array],
data: {
type: Array,
default: () => {
return [];
},
},
//
column: [Array],
column: {
type: Array,
default: () => {
return [];
},
},
//
spanMethod: [Function],
// style
cellStyle: [Function, Object],
// style
headerCellStyle: [Function, Object],
},
data() {
return {};
},
@ -99,12 +144,46 @@ export default {
cellClick(row, column) {
this.$emit("cellClick", { row, column: column.property });
},
//
toggleSelect() {
this.$refs.table.clearSelection();
this.$nextTick(() => {
this.data.forEach((row) => {
this.checkValue.forEach((item) => {
row[this.checkKey] === item[this.checkKey]
? this.$refs.table.toggleRowSelection(row, true)
: null;
});
});
});
},
sortChange({ prop, order }) {
this.$emit("sortChange", { prop, order });
},
},
watch: {
data: {},
immediate: true,
deep: true,
data: {
handle(newVal) {
this.data = newVal;
//
if (this.selection) {
this.toggleSelect();
}
},
immediate: true,
deep: true,
},
checkValue: {
handle(newVal) {
this.checkValue = newVal;
if (this.selection) {
this.toggleSelect();
}
},
},
},
};
</script>

View File

@ -16,8 +16,25 @@ const router = new VueRouter({
}, {
path: "/webapp/entry_system/detail/:id",
name: "detail",
meta: {
requireAuth: true
},
component: () => import("@/view/user/detail/index")
}]
})
router.beforeEach((to, from, next) => {
if (to.matched.some(r => r.meta.requireAuth)) {
if (localStorage.getItem("token")) {
next();
} else {
next({
path: '/webapp/entry_system/login',
})
}
} else {
next();
}
})
export default router

View File

@ -114,6 +114,7 @@ export default {
},
logOut() {
localStorage.removeItem("token")
this.$router.push("/webapp/entry_system/login");
},
},

View File

@ -167,18 +167,10 @@ export default {
verify_code: this.form.vcode,
})
.then((res) => {
document.cookie = "uid=";
document.cookie = "token=";
document.cookie = "refresh_token=";
localStorage.setItem("role", res.role);
localStorage.setItem("token", res.token);
localStorage.setItem("refresh_token", res.refresh_token);
document.cookie = "uid=" + res.uid;
document.cookie = "token=" + res.token;
document.cookie = "refresh_token=" + res.refresh_token;
if (res.uid) {
window.location.href =
"http://test.fecribd.com/webapp/rating_manager/";
window.location.href = process.env.VUE_APP_URL;
}
});
} else {