mirror of https://gitee.com/pnoker/dc3-web.git
parent
e6fed5d652
commit
9e9f3fe185
@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
plugins: {
|
|
||||||
autoprefixer: {}
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,25 +0,0 @@
|
|||||||
import request from '@/config/axios'
|
|
||||||
|
|
||||||
export const generateSalt = (name) => request({
|
|
||||||
url: 'user_api/auth/token/salt',
|
|
||||||
method: 'post',
|
|
||||||
data: name
|
|
||||||
});
|
|
||||||
|
|
||||||
export const generateToken = (login) => request({
|
|
||||||
url: 'user_api/auth/token/generate',
|
|
||||||
method: 'post',
|
|
||||||
data: login
|
|
||||||
});
|
|
||||||
|
|
||||||
export const checkTokenValid = (login) => request({
|
|
||||||
url: 'user_api/auth/token/check',
|
|
||||||
method: 'post',
|
|
||||||
data: login
|
|
||||||
});
|
|
||||||
|
|
||||||
export const cancelToken = (name) => request({
|
|
||||||
url: 'user_api/auth/token/cancel',
|
|
||||||
method: 'post',
|
|
||||||
data: name
|
|
||||||
});
|
|
@ -1,6 +0,0 @@
|
|||||||
const getters = {
|
|
||||||
token: state => state.user.token,
|
|
||||||
user: state => state.user.user,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default getters
|
|
@ -1,67 +0,0 @@
|
|||||||
import md5 from 'js-md5';
|
|
||||||
|
|
||||||
import {getStore, removeCookies, removeStore, setCookies, setStore} from '@/util/store'
|
|
||||||
import {cancelToken, generateSalt, generateToken} from '@/api/user'
|
|
||||||
|
|
||||||
import website from "@/config/website";
|
|
||||||
|
|
||||||
const user = {
|
|
||||||
state: {},
|
|
||||||
actions: {
|
|
||||||
GenerateSalt({commit}, name) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
generateSalt(name).then(res => {
|
|
||||||
resolve(res.data);
|
|
||||||
}).catch(error => {
|
|
||||||
reject(error);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
},
|
|
||||||
GenerateToken({commit}, form) {
|
|
||||||
let login = {
|
|
||||||
tenant: form.tenant,
|
|
||||||
name: form.name,
|
|
||||||
salt: form.salt,
|
|
||||||
password: md5(md5(form.password) + form.salt)
|
|
||||||
};
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
generateToken(login).then(res => {
|
|
||||||
const data = res.data;
|
|
||||||
commit('SET_TOKEN',
|
|
||||||
{
|
|
||||||
tenant: login.tenant,
|
|
||||||
name: login.name,
|
|
||||||
salt: login.salt,
|
|
||||||
token: data
|
|
||||||
}
|
|
||||||
);
|
|
||||||
resolve();
|
|
||||||
}).catch(error => {
|
|
||||||
reject(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
ClearToken({commit}) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
let token = getStore(website.token_header);
|
|
||||||
if (token && token.name) {
|
|
||||||
cancelToken(token.name);
|
|
||||||
}
|
|
||||||
commit('REMOVE_TOKEN');
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
SET_TOKEN: (state, token) => {
|
|
||||||
setCookies(website.token_header, token);
|
|
||||||
setStore(website.token_header, token);
|
|
||||||
},
|
|
||||||
REMOVE_TOKEN: () => {
|
|
||||||
removeCookies(website.token_header);
|
|
||||||
removeStore(website.token_header);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default user
|
|
@ -1,16 +1,11 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import user from './modules/user'
|
|
||||||
import common from './modules/common'
|
import common from './modules/common'
|
||||||
import getters from './getters'
|
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {common}
|
||||||
common, user
|
|
||||||
},
|
|
||||||
getters
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default store
|
export default store
|
||||||
|
@ -1,136 +0,0 @@
|
|||||||
import {isNull} from './validate';
|
|
||||||
import website from '@/config/website';
|
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import {decode, encode} from 'js-base64'
|
|
||||||
|
|
||||||
const keyName = website.key + '-';
|
|
||||||
|
|
||||||
export function getCookies(key) {
|
|
||||||
return JSON.parse(decode(Cookies.get(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setCookies(key, value) {
|
|
||||||
return Cookies.set(key, encode(JSON.stringify(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeCookies(key) {
|
|
||||||
return Cookies.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储 localStorage
|
|
||||||
* @param params
|
|
||||||
*/
|
|
||||||
export const setStore = (params = {}) => {
|
|
||||||
let {
|
|
||||||
name,
|
|
||||||
content,
|
|
||||||
type,
|
|
||||||
} = params;
|
|
||||||
name = keyName + name;
|
|
||||||
let obj = {
|
|
||||||
dataType: typeof (content),
|
|
||||||
content: content,
|
|
||||||
type: type,
|
|
||||||
datetime: new Date().getTime()
|
|
||||||
};
|
|
||||||
if (type) window.sessionStorage.setItem(name, JSON.stringify(obj));
|
|
||||||
else window.localStorage.setItem(name, JSON.stringify(obj));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 localStorage
|
|
||||||
* @param params
|
|
||||||
*/
|
|
||||||
export const getStore = (params = {}) => {
|
|
||||||
let {
|
|
||||||
name,
|
|
||||||
debug
|
|
||||||
} = params;
|
|
||||||
name = keyName + name;
|
|
||||||
let obj = {}, content;
|
|
||||||
obj = window.sessionStorage.getItem(name);
|
|
||||||
if (isNull(obj)) obj = window.localStorage.getItem(name);
|
|
||||||
if (isNull(obj)) return;
|
|
||||||
try {
|
|
||||||
obj = JSON.parse(obj);
|
|
||||||
} catch {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
if (debug) {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
if (obj.dataType === 'string') {
|
|
||||||
content = obj.content;
|
|
||||||
} else if (obj.dataType === 'number') {
|
|
||||||
content = Number(obj.content);
|
|
||||||
} else if (obj.dataType === 'boolean') {
|
|
||||||
content = eval(obj.content);
|
|
||||||
} else if (obj.dataType === 'object') {
|
|
||||||
content = obj.content;
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除 localStorage
|
|
||||||
* @param params
|
|
||||||
*/
|
|
||||||
export const removeStore = (params = {}) => {
|
|
||||||
let {
|
|
||||||
name,
|
|
||||||
type
|
|
||||||
} = params;
|
|
||||||
name = keyName + name;
|
|
||||||
if (type) {
|
|
||||||
window.sessionStorage.removeItem(name);
|
|
||||||
} else {
|
|
||||||
window.localStorage.removeItem(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取全部 localStorage
|
|
||||||
* @param params
|
|
||||||
*/
|
|
||||||
export const getAllStore = (params = {}) => {
|
|
||||||
let list = [];
|
|
||||||
let {
|
|
||||||
type
|
|
||||||
} = params;
|
|
||||||
if (type) {
|
|
||||||
for (let i = 0; i <= window.sessionStorage.length; i++) {
|
|
||||||
list.push({
|
|
||||||
name: window.sessionStorage.key(i),
|
|
||||||
content: getStore({
|
|
||||||
name: window.sessionStorage.key(i),
|
|
||||||
type: 'session'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i <= window.localStorage.length; i++) {
|
|
||||||
list.push({
|
|
||||||
name: window.localStorage.key(i),
|
|
||||||
content: getStore({
|
|
||||||
name: window.localStorage.key(i),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空全部 localStorage
|
|
||||||
* @param params
|
|
||||||
*/
|
|
||||||
export const clearStore = (params = {}) => {
|
|
||||||
let {type} = params;
|
|
||||||
if (type) {
|
|
||||||
window.sessionStorage.clear();
|
|
||||||
} else {
|
|
||||||
window.localStorage.clear()
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,177 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-col :span="24">
|
|
||||||
<base-card>
|
|
||||||
<avue-crud :option="listOption"
|
|
||||||
:data="listData"
|
|
||||||
:page="page"
|
|
||||||
:table-loading="loading"
|
|
||||||
ref="crud"
|
|
||||||
v-model="listForm"
|
|
||||||
@on-load="list"
|
|
||||||
@row-save="listAdd"
|
|
||||||
@row-del="listDelete"
|
|
||||||
@row-update="listUpdate"
|
|
||||||
@search-reset="searchReset"
|
|
||||||
@search-change="searchChange"
|
|
||||||
@refresh-change="refreshChange"
|
|
||||||
@size-change="sizeChange"
|
|
||||||
@current-change="currentChange"
|
|
||||||
>
|
|
||||||
</avue-crud>
|
|
||||||
</base-card>
|
|
||||||
</el-col>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {groupApi} from '@/api/manager'
|
|
||||||
import {successMessage} from "@/util/util";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
query: {},
|
|
||||||
listForm: {},
|
|
||||||
listData: [],
|
|
||||||
listOption: {
|
|
||||||
tip: false,
|
|
||||||
index: true,
|
|
||||||
stripe: true,
|
|
||||||
border: true,
|
|
||||||
height: 664,
|
|
||||||
align: 'center',
|
|
||||||
column: [
|
|
||||||
{
|
|
||||||
label: '分组',
|
|
||||||
prop: 'name',
|
|
||||||
span: 24,
|
|
||||||
search: true,
|
|
||||||
searchSpan: 24,
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: '请输入 分组名称',
|
|
||||||
trigger: 'blur'
|
|
||||||
}, {
|
|
||||||
min: 2,
|
|
||||||
max: 32,
|
|
||||||
message: '请输入 2~32 位字长的分组名称',
|
|
||||||
trigger: 'blur'
|
|
||||||
}, {
|
|
||||||
pattern: /^[A-Za-z0-9\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5-_]*$/,
|
|
||||||
message: '请输入 正确格式的分组名称'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}, {
|
|
||||||
label: '备注',
|
|
||||||
prop: 'description',
|
|
||||||
span: 24,
|
|
||||||
type: 'textarea',
|
|
||||||
overHidden: true,
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
max: 380,
|
|
||||||
message: '最多输入380个字符',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}, {
|
|
||||||
label: '修改日期',
|
|
||||||
prop: 'updateTime',
|
|
||||||
span: 12,
|
|
||||||
disabled: true,
|
|
||||||
type: 'date',
|
|
||||||
format: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
valueFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
||||||
}, {
|
|
||||||
label: '创建日期',
|
|
||||||
prop: 'createTime',
|
|
||||||
span: 12,
|
|
||||||
disabled: true,
|
|
||||||
type: 'date',
|
|
||||||
format: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
valueFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
loading: true,
|
|
||||||
page: {
|
|
||||||
total: 0,
|
|
||||||
pageSize: 20,
|
|
||||||
currentPage: 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods:
|
|
||||||
{
|
|
||||||
list(page) {
|
|
||||||
this.loading = true;
|
|
||||||
groupApi.list(Object.assign({
|
|
||||||
page: {
|
|
||||||
current: page.currentPage,
|
|
||||||
size: page.pageSize
|
|
||||||
}
|
|
||||||
}, this.query)).then(res => {
|
|
||||||
const data = res.data;
|
|
||||||
this.page.total = data.total;
|
|
||||||
this.listData = data.records;
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
listAdd(row, done, loading) {
|
|
||||||
groupApi.add(row).then(() => {
|
|
||||||
loading();
|
|
||||||
this.list(this.page);
|
|
||||||
successMessage();
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
listDelete(row) {
|
|
||||||
this.$confirm('是否删除该条数据?', '提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
return groupApi.delete(row.id);
|
|
||||||
}).then(() => {
|
|
||||||
this.list(this.page);
|
|
||||||
successMessage();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
listUpdate(row, index, done, loading) {
|
|
||||||
groupApi.update(row).then(() => {
|
|
||||||
loading();
|
|
||||||
this.list(this.page);
|
|
||||||
successMessage();
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
refreshChange() {
|
|
||||||
this.list(this.page);
|
|
||||||
},
|
|
||||||
currentChange(page) {
|
|
||||||
this.page.currentPage = page;
|
|
||||||
},
|
|
||||||
sizeChange(pageSize) {
|
|
||||||
this.page.pageSize = pageSize;
|
|
||||||
},
|
|
||||||
searchChange(params, done) {
|
|
||||||
this.query = params;
|
|
||||||
this.list(this.page);
|
|
||||||
done();
|
|
||||||
},
|
|
||||||
searchReset() {
|
|
||||||
this.query = {};
|
|
||||||
this.list(this.page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
</style>
|
|
@ -1,124 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="login-container">
|
|
||||||
<div class="login-wrapper-left animated bounceInDown">
|
|
||||||
<div class="login-left">
|
|
||||||
<img class="img" src="images/logo/logo-white.png">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<particles/>
|
|
||||||
<div class="login-wrapper-right animated bounceInDown">
|
|
||||||
<div class="login-border">
|
|
||||||
<div class="login-main">
|
|
||||||
<h4 class="login-title">
|
|
||||||
Demo Application
|
|
||||||
</h4>
|
|
||||||
<p style="text-align: center;">基于 DC3 1.2.3.SR 接口开发的 demo 应用<br/>仅供演示和测试用途!</p>
|
|
||||||
<el-form class="login-form"
|
|
||||||
status-icon
|
|
||||||
:rules="loginRules"
|
|
||||||
ref="loginForm"
|
|
||||||
:model="loginForm"
|
|
||||||
label-width="0">
|
|
||||||
<el-form-item prop="tenant">
|
|
||||||
<el-input size="small"
|
|
||||||
@keyup.enter.native="handleLogin"
|
|
||||||
v-model="loginForm.tenant"
|
|
||||||
auto-complete="off"
|
|
||||||
placeholder="请输入租户名">
|
|
||||||
<i slot="prefix" class="el-icon-suitcase"/>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item prop="name">
|
|
||||||
<el-input size="small"
|
|
||||||
@keyup.enter.native="handleLogin"
|
|
||||||
v-model="loginForm.name"
|
|
||||||
auto-complete="off"
|
|
||||||
placeholder="请输入用户名">
|
|
||||||
<i slot="prefix" class="el-icon-user"/>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item prop="password">
|
|
||||||
<el-input size="small"
|
|
||||||
@keyup.enter.native="handleLogin"
|
|
||||||
:type="passwordType"
|
|
||||||
v-model="loginForm.password"
|
|
||||||
auto-complete="off"
|
|
||||||
placeholder="请输入密码">
|
|
||||||
<i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword"/>
|
|
||||||
<i slot="prefix" class="el-icon-lock"/>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary"
|
|
||||||
size="small"
|
|
||||||
@click.native.prevent="handleLogin"
|
|
||||||
class="login-submit">登录
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import particles from "@/components/particles/particles";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "login",
|
|
||||||
components: {particles},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loginForm: {
|
|
||||||
tenant: "default",
|
|
||||||
name: "pnoker",
|
|
||||||
password: "dc3dc3dc3"
|
|
||||||
},
|
|
||||||
loginRules: {
|
|
||||||
tenant: [
|
|
||||||
{required: true, message: "请输入租户名", trigger: "blur"}
|
|
||||||
],
|
|
||||||
name: [
|
|
||||||
{required: true, message: "请输入用户名", trigger: "blur"}
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{required: true, message: "请输入密码", trigger: "blur"},
|
|
||||||
{min: 1, message: "密码长度最少为6位", trigger: "blur"}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
passwordType: "password"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showPassword() {
|
|
||||||
this.passwordType === ""
|
|
||||||
? (this.passwordType = "password")
|
|
||||||
: (this.passwordType = "");
|
|
||||||
},
|
|
||||||
handleLogin() {
|
|
||||||
this.$refs.loginForm.validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
let loading = this.$loading({
|
|
||||||
lock: true,
|
|
||||||
text: '登录中,请稍后。。。',
|
|
||||||
spinner: "el-icon-loading"
|
|
||||||
});
|
|
||||||
this.$store.dispatch("GenerateSalt", this.loginForm.name).then((salt) => {
|
|
||||||
this.$store.dispatch("GenerateToken", {salt, ...this.loginForm}).then(() => {
|
|
||||||
this.$router.push({path: '/'}).then(() => loading.close());
|
|
||||||
}).catch(() => {
|
|
||||||
loading.close();
|
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
loading.close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
@import "~@/assets/styles/login.scss";
|
|
||||||
</style>
|
|
Loading…
Reference in new issue