init
This commit is contained in:
177
src/router/avue-router.js
Executable file
177
src/router/avue-router.js
Executable file
@@ -0,0 +1,177 @@
|
|||||||
|
import website from '@/config/website';
|
||||||
|
import { getToken } from '@/utils/auth';
|
||||||
|
const modules = import.meta.glob('../**/**/*.vue');
|
||||||
|
|
||||||
|
function isURL(s) {
|
||||||
|
return /^http[s]?:\/\/.*/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
let RouterPlugin = function () {
|
||||||
|
this.$router = null;
|
||||||
|
this.$store = null;
|
||||||
|
};
|
||||||
|
RouterPlugin.install = function (option = {}) {
|
||||||
|
this.$router = option.router;
|
||||||
|
this.$store = option.store;
|
||||||
|
let i18n = option.i18n.global;
|
||||||
|
this.$router.$avueRouter = {
|
||||||
|
safe: this,
|
||||||
|
// 设置标题
|
||||||
|
setTitle: title => {
|
||||||
|
const defaultTitle = i18n.t('title');
|
||||||
|
title = title ? `${title} | ${defaultTitle}` : defaultTitle;
|
||||||
|
document.title = title;
|
||||||
|
},
|
||||||
|
closeTag: value => {
|
||||||
|
let tag = value || this.$store.getters.tag;
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
tag = this.$store.getters.tagList.find(ele => ele.fullPath === value);
|
||||||
|
}
|
||||||
|
this.$store.commit('DEL_TAG', tag);
|
||||||
|
},
|
||||||
|
generateTitle: (item, props = {}) => {
|
||||||
|
let query = item[props.query || 'query'] || {};
|
||||||
|
let title = query.name || item[props.label || 'label'];
|
||||||
|
let meta = item[props.meta || 'meta'] || {};
|
||||||
|
let key = meta.i18n;
|
||||||
|
if (key) {
|
||||||
|
const hasKey = i18n.te('route.' + key);
|
||||||
|
if (hasKey) return i18n.t('route.' + key);
|
||||||
|
}
|
||||||
|
return title ? title.split(',')[0] : title;
|
||||||
|
},
|
||||||
|
//动态路由
|
||||||
|
formatRoutes: function (aMenu = [], first) {
|
||||||
|
const aRouter = [];
|
||||||
|
const propsDefault = website.menu;
|
||||||
|
|
||||||
|
if (aMenu && aMenu.length === 0) return;
|
||||||
|
for (let i = 0; i < aMenu.length; i++) {
|
||||||
|
const oMenu = aMenu[i];
|
||||||
|
let path = oMenu[propsDefault.path],
|
||||||
|
isComponent = true,
|
||||||
|
component = oMenu.component,
|
||||||
|
name = oMenu[propsDefault.label] + ',' + oMenu.id,
|
||||||
|
icon = oMenu[propsDefault.icon],
|
||||||
|
children = oMenu[propsDefault.children],
|
||||||
|
query = oMenu[propsDefault.query],
|
||||||
|
meta = oMenu[propsDefault.meta];
|
||||||
|
if (option.keepAlive) {
|
||||||
|
meta.keepAlive = option.keepAlive;
|
||||||
|
}
|
||||||
|
const isChild = !!(children && children.length !== 0);
|
||||||
|
const oRouter = {
|
||||||
|
path: path,
|
||||||
|
component: (() => {
|
||||||
|
// 判断是否为首路由
|
||||||
|
if (first) {
|
||||||
|
return modules[
|
||||||
|
option.store.getters.isMacOs || !website.setting.menu
|
||||||
|
? '../page/index/layout.vue'
|
||||||
|
: '../page/index/index.vue'
|
||||||
|
];
|
||||||
|
// 判断是否为多层路由
|
||||||
|
} else if (isChild && !first) {
|
||||||
|
return modules['../page/index/layout.vue'];
|
||||||
|
// 判断是否为最终的页面视图
|
||||||
|
} else {
|
||||||
|
let result = modules[`../${component}.vue`];
|
||||||
|
if (!result) {
|
||||||
|
isComponent = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
})(),
|
||||||
|
name,
|
||||||
|
icon,
|
||||||
|
meta,
|
||||||
|
query,
|
||||||
|
redirect: (() => {
|
||||||
|
if (!isChild && first) return `${path}`;
|
||||||
|
else return '';
|
||||||
|
})(),
|
||||||
|
// 处理是否为一级路由
|
||||||
|
children: !isChild
|
||||||
|
? (() => {
|
||||||
|
if (first) {
|
||||||
|
oMenu[propsDefault.path] = `${path}`;
|
||||||
|
let result = modules[`../${component}.vue`];
|
||||||
|
if (!result) {
|
||||||
|
isComponent = false;
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
component: result,
|
||||||
|
icon: icon,
|
||||||
|
name: name,
|
||||||
|
meta: meta,
|
||||||
|
query: query,
|
||||||
|
path: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
})()
|
||||||
|
: (() => {
|
||||||
|
return this.formatRoutes(children, false);
|
||||||
|
})(),
|
||||||
|
};
|
||||||
|
if (!isURL(path) && isComponent) aRouter.push(oRouter);
|
||||||
|
}
|
||||||
|
if (first) {
|
||||||
|
aRouter.forEach(ele => this.safe.$router.addRoute(ele));
|
||||||
|
} else {
|
||||||
|
return aRouter;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export const formatPath = (ele, first) => {
|
||||||
|
const propsDefault = website.menu;
|
||||||
|
const icon = ele[propsDefault.icon];
|
||||||
|
ele[propsDefault.icon] = !icon ? propsDefault.iconDefault : icon;
|
||||||
|
ele.meta = {
|
||||||
|
keepAlive: ele.isOpen === 2,
|
||||||
|
};
|
||||||
|
const iframeComponent = 'components/iframe/main';
|
||||||
|
const iframeSrc = href => {
|
||||||
|
// 替换&为#
|
||||||
|
let processedHref = href.replace(/&/g, '#');
|
||||||
|
|
||||||
|
// 检查URL中是否包含${token},如果有则使用getToken()替换
|
||||||
|
if (processedHref.includes('${token}')) {
|
||||||
|
const token = getToken();
|
||||||
|
processedHref = processedHref.replace(/\${token}/g, token);
|
||||||
|
}
|
||||||
|
return processedHref;
|
||||||
|
};
|
||||||
|
const isChild = !!(ele[propsDefault.children] && ele[propsDefault.children].length !== 0);
|
||||||
|
if (!isChild && first) {
|
||||||
|
ele.component = 'views' + ele[propsDefault.path];
|
||||||
|
if (isURL(ele[propsDefault.href])) {
|
||||||
|
let href = ele[propsDefault.href];
|
||||||
|
ele.component = iframeComponent;
|
||||||
|
ele[propsDefault.query] = {
|
||||||
|
url: iframeSrc(href),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ele[propsDefault.children] &&
|
||||||
|
ele[propsDefault.children].forEach(child => {
|
||||||
|
child.component = 'views' + child[propsDefault.path];
|
||||||
|
child.meta = {
|
||||||
|
keepAlive: child.isOpen === 2,
|
||||||
|
};
|
||||||
|
if (isURL(child[propsDefault.href])) {
|
||||||
|
let href = child[propsDefault.href];
|
||||||
|
child[propsDefault.path] = ele[propsDefault.path] + '/' + child.code;
|
||||||
|
child.component = iframeComponent;
|
||||||
|
child[propsDefault.query] = {
|
||||||
|
url: iframeSrc(href),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
formatPath(child);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export default RouterPlugin;
|
||||||
1
src/router/ext/index.js
Executable file
1
src/router/ext/index.js
Executable file
@@ -0,0 +1 @@
|
|||||||
|
export default [];
|
||||||
33
src/router/index.js
Executable file
33
src/router/index.js
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
|
import ExtRouter from './ext/';
|
||||||
|
import PageRouter from './page/';
|
||||||
|
import ViewsRouter from './views/';
|
||||||
|
import AvueRouter from './avue-router';
|
||||||
|
import i18n from '@/lang';
|
||||||
|
import Store from '@/store/';
|
||||||
|
//创建路由
|
||||||
|
const Router = createRouter({
|
||||||
|
base: import.meta.env.VITE_APP_BASE,
|
||||||
|
history: createWebHistory(import.meta.env.VITE_APP_BASE),
|
||||||
|
routes: [...ExtRouter, ...PageRouter, ...ViewsRouter],
|
||||||
|
});
|
||||||
|
AvueRouter.install({
|
||||||
|
store: Store,
|
||||||
|
router: Router,
|
||||||
|
i18n: i18n,
|
||||||
|
});
|
||||||
|
|
||||||
|
Router.$avueRouter.formatRoutes(Store.getters.menuAll, true);
|
||||||
|
|
||||||
|
export function resetRouter() {
|
||||||
|
// 重置路由 比如用于身份验证失败,需要重新登录时 先清空当前的路有权限
|
||||||
|
const newRouter = createRouter();
|
||||||
|
Router.matcher = newRouter.matcher; // reset router
|
||||||
|
AvueRouter.install(Vue, {
|
||||||
|
router: Router,
|
||||||
|
store: Store,
|
||||||
|
i18n: i18n,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Router;
|
||||||
72
src/router/page/index.js
Executable file
72
src/router/page/index.js
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
import Store from '@/store/';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/login',
|
||||||
|
name: 'Login Page',
|
||||||
|
component: () =>
|
||||||
|
Store.getters.isMacOs ? import('@/mac/login.vue') : import('@/page/login/index.vue'),
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/oauth/redirect/:source',
|
||||||
|
name: '第三方登录',
|
||||||
|
component: () =>
|
||||||
|
Store.getters.isMacOs ? import('@/mac/login.vue') : import('@/page/login/index.vue'),
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/lock',
|
||||||
|
name: '锁屏页',
|
||||||
|
component: () =>
|
||||||
|
Store.getters.isMacOs ? import('@/mac/lock.vue') : import('@/page/lock/index.vue'),
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/404',
|
||||||
|
component: () => import(/* webpackChunkName: "page" */ '@/components/error-page/404.vue'),
|
||||||
|
name: '404',
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/403',
|
||||||
|
component: () => import(/* webpackChunkName: "page" */ '@/components/error-page/403.vue'),
|
||||||
|
name: '403',
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/500',
|
||||||
|
component: () => import(/* webpackChunkName: "page" */ '@/components/error-page/500.vue'),
|
||||||
|
name: '500',
|
||||||
|
meta: {
|
||||||
|
keepAlive: true,
|
||||||
|
isTab: false,
|
||||||
|
isAuth: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
name: '主页',
|
||||||
|
redirect: '/wel',
|
||||||
|
},
|
||||||
|
];
|
||||||
92
src/router/views/index.js
Executable file
92
src/router/views/index.js
Executable file
@@ -0,0 +1,92 @@
|
|||||||
|
import Layout from '@/page/index/index.vue';
|
||||||
|
import Store from '@/store/';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/wel',
|
||||||
|
component: () =>
|
||||||
|
Store.getters.isMacOs ? import('@/mac/index.vue') : import('@/page/index/index.vue'),
|
||||||
|
redirect: '/wel/index',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Index',
|
||||||
|
meta: {
|
||||||
|
i18n: 'dashboard',
|
||||||
|
},
|
||||||
|
component: () => import(/* webpackChunkName: "views" */ '@/views/wel/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'dashboard',
|
||||||
|
name: '控制台',
|
||||||
|
meta: {
|
||||||
|
i18n: 'dashboard',
|
||||||
|
menu: false,
|
||||||
|
},
|
||||||
|
component: () => import(/* webpackChunkName: "views" */ '@/views/wel/dashboard.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/test',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/test/index',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: '测试页',
|
||||||
|
meta: {
|
||||||
|
i18n: 'test',
|
||||||
|
},
|
||||||
|
component: () => import(/* webpackChunkName: "views" */ '@/views/util/test.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/dict-horizontal',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/dict-horizontal/index',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: '字典管理',
|
||||||
|
meta: {
|
||||||
|
i18n: 'dict',
|
||||||
|
},
|
||||||
|
component: () =>
|
||||||
|
import(/* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/dict-vertical',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/dict-vertical/index',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: '字典管理',
|
||||||
|
meta: {
|
||||||
|
i18n: 'dict',
|
||||||
|
},
|
||||||
|
component: () =>
|
||||||
|
import(/* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/info',
|
||||||
|
component: Layout,
|
||||||
|
redirect: '/info/index',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'index',
|
||||||
|
name: 'Info',
|
||||||
|
meta: {
|
||||||
|
i18n: 'info',
|
||||||
|
},
|
||||||
|
component: () => import(/* webpackChunkName: "views" */ '@/views/system/userinfo.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
37
src/store/getters.js
Executable file
37
src/store/getters.js
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
const getters = {
|
||||||
|
tag: state => state.tags.tag,
|
||||||
|
language: state => state.common.language,
|
||||||
|
setting: state => state.common.setting,
|
||||||
|
userInfo: state => state.user.userInfo,
|
||||||
|
colorName: state => state.common.colorName,
|
||||||
|
themeName: state => state.common.themeName,
|
||||||
|
isMacOs: (state, getters) => getters.themeName === 'mac-os',
|
||||||
|
isRefresh: state => state.common.isRefresh,
|
||||||
|
isSearch: state => state.common.isSearch,
|
||||||
|
isHorizontal: state => state.common.setting.sidebar === 'horizontal',
|
||||||
|
isCollapse: state => state.common.isCollapse,
|
||||||
|
isLock: state => state.common.isLock,
|
||||||
|
isFullScren: state => state.common.isFullScren,
|
||||||
|
isMenu: state => state.common.isMenu,
|
||||||
|
lockPasswd: state => state.common.lockPasswd,
|
||||||
|
tagList: state => state.tags.tagList,
|
||||||
|
tagsKeep: (state, getters) => {
|
||||||
|
return getters.tagList
|
||||||
|
.filter(ele => {
|
||||||
|
return (ele.meta || {}).keepAlive;
|
||||||
|
})
|
||||||
|
.map(ele => ele.fullPath);
|
||||||
|
},
|
||||||
|
tagWel: state => state.tags.tagWel,
|
||||||
|
token: state => state.user.token,
|
||||||
|
roles: state => state.user.roles,
|
||||||
|
permission: state => state.user.permission,
|
||||||
|
menuId: state => state.user.menuId,
|
||||||
|
menu: state => state.user.menu,
|
||||||
|
menuAll: state => state.user.menuAll,
|
||||||
|
logsList: state => state.logs.logsList,
|
||||||
|
logsLen: state => state.logs.logsList.length || 0,
|
||||||
|
logsFlag: (state, getters) => getters.logsLen === 0,
|
||||||
|
flowRoutes: state => state.dict.flowRoutes,
|
||||||
|
};
|
||||||
|
export default getters;
|
||||||
20
src/store/index.js
Executable file
20
src/store/index.js
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
import { createStore } from 'vuex';
|
||||||
|
import user from './modules/user';
|
||||||
|
import common from './modules/common';
|
||||||
|
import tags from './modules/tags';
|
||||||
|
import logs from './modules/logs';
|
||||||
|
import dict from './modules/dict';
|
||||||
|
import getters from './getters';
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
modules: {
|
||||||
|
user,
|
||||||
|
common,
|
||||||
|
logs,
|
||||||
|
tags,
|
||||||
|
dict,
|
||||||
|
},
|
||||||
|
getters,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default store;
|
||||||
86
src/store/modules/common.js
Executable file
86
src/store/modules/common.js
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
import { setStore, getStore, removeStore } from 'utils/store';
|
||||||
|
import website from '@/config/website';
|
||||||
|
|
||||||
|
const common = {
|
||||||
|
state: {
|
||||||
|
language: getStore({ name: 'language' }) || 'zh-cn',
|
||||||
|
isCollapse: false,
|
||||||
|
isFullScren: false,
|
||||||
|
isMenu: true,
|
||||||
|
isSearch: false,
|
||||||
|
isRefresh: true,
|
||||||
|
isLock: getStore({ name: 'isLock' }),
|
||||||
|
colorName: getStore({ name: 'colorName' }) || '#2C77F1',
|
||||||
|
themeName: getStore({ name: 'themeName' }) || 'theme-go',
|
||||||
|
lockPasswd: getStore({ name: 'lockPasswd' }) || '',
|
||||||
|
website: website,
|
||||||
|
setting: website.setting,
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
SET_LANGUAGE: (state, language) => {
|
||||||
|
state.language = language;
|
||||||
|
setStore({
|
||||||
|
name: 'language',
|
||||||
|
content: state.language,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SET_COLLAPSE: state => {
|
||||||
|
state.isCollapse = !state.isCollapse;
|
||||||
|
},
|
||||||
|
SET_IS_MENU: (state, menu) => {
|
||||||
|
state.isMenu = menu;
|
||||||
|
},
|
||||||
|
SET_IS_REFRESH: (state, refresh) => {
|
||||||
|
state.isRefresh = refresh;
|
||||||
|
},
|
||||||
|
SET_IS_SEARCH: (state, search) => {
|
||||||
|
state.isSearch = search;
|
||||||
|
},
|
||||||
|
SET_FULLSCREN: state => {
|
||||||
|
state.isFullScren = !state.isFullScren;
|
||||||
|
},
|
||||||
|
SET_LOCK: state => {
|
||||||
|
state.isLock = true;
|
||||||
|
setStore({
|
||||||
|
name: 'isLock',
|
||||||
|
content: state.isLock,
|
||||||
|
type: 'session',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SET_COLOR_NAME: (state, colorName) => {
|
||||||
|
state.colorName = colorName;
|
||||||
|
setStore({
|
||||||
|
name: 'colorName',
|
||||||
|
content: state.colorName,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SET_THEME_NAME: (state, themeName) => {
|
||||||
|
state.themeName = themeName;
|
||||||
|
setStore({
|
||||||
|
name: 'themeName',
|
||||||
|
content: state.themeName,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
SET_LOCK_PASSWD: (state, lockPasswd) => {
|
||||||
|
state.lockPasswd = lockPasswd;
|
||||||
|
setStore({
|
||||||
|
name: 'lockPasswd',
|
||||||
|
content: state.lockPasswd,
|
||||||
|
type: 'session',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
CLEAR_LOCK: state => {
|
||||||
|
state.isLock = false;
|
||||||
|
state.lockPasswd = '';
|
||||||
|
removeStore({
|
||||||
|
name: 'lockPasswd',
|
||||||
|
type: 'session',
|
||||||
|
});
|
||||||
|
removeStore({
|
||||||
|
name: 'isLock',
|
||||||
|
type: 'session',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default common;
|
||||||
36
src/store/modules/dict.js
Normal file
36
src/store/modules/dict.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { getStore, setStore } from '@/utils/store';
|
||||||
|
|
||||||
|
import { getDictionary } from '@/api/system/dict';
|
||||||
|
|
||||||
|
const dict = {
|
||||||
|
state: {
|
||||||
|
flowRoutes: getStore({ name: 'flowRoutes' }) || {},
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
FlowRoutes({ commit }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
getDictionary({ code: 'flow' })
|
||||||
|
.then(res => {
|
||||||
|
commit('SET_FLOW_ROUTES', res.data.data);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
SET_FLOW_ROUTES: (state, data) => {
|
||||||
|
state.flowRoutes = data.map(item => {
|
||||||
|
return {
|
||||||
|
routeKey: `${item.code}_${item.dictKey}`,
|
||||||
|
routeValue: item.remark,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
setStore({ name: 'flowRoutes', content: state.flowRoutes });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default dict;
|
||||||
49
src/store/modules/logs.js
Executable file
49
src/store/modules/logs.js
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
import { setStore, getStore } from 'utils/store';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import { sendLogs } from '@/api/user';
|
||||||
|
|
||||||
|
const logs = {
|
||||||
|
state: {
|
||||||
|
logsList: getStore({ name: 'logsList' }) || [],
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
//发送错误日志
|
||||||
|
SendLogs({ state, commit }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
sendLogs(state.logsList)
|
||||||
|
.then(() => {
|
||||||
|
commit('CLEAR_LOGS');
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
ADD_LOGS: (state, { type, message, stack, info }) => {
|
||||||
|
state.logsList.push(
|
||||||
|
Object.assign(
|
||||||
|
{
|
||||||
|
url: window.location.href,
|
||||||
|
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type,
|
||||||
|
message,
|
||||||
|
stack,
|
||||||
|
info: info.toString(),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
setStore({ name: 'logsList', content: state.logsList });
|
||||||
|
},
|
||||||
|
CLEAR_LOGS: state => {
|
||||||
|
state.logsList = [];
|
||||||
|
setStore({ name: 'logsList', content: state.logsList });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default logs;
|
||||||
38
src/store/modules/tags.js
Executable file
38
src/store/modules/tags.js
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
import { setStore, getStore } from 'utils/store';
|
||||||
|
import website from '@/config/website';
|
||||||
|
|
||||||
|
const tagWel = website.fistPage;
|
||||||
|
const navs = {
|
||||||
|
state: {
|
||||||
|
tagList: getStore({ name: 'tagList' }) || [],
|
||||||
|
tag: getStore({ name: 'tag' }) || {},
|
||||||
|
tagWel: tagWel,
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
ADD_TAG: (state, action) => {
|
||||||
|
if (typeof action.name == 'function') action.name = action.name(action.query);
|
||||||
|
state.tag = action;
|
||||||
|
setStore({ name: 'tag', content: state.tag });
|
||||||
|
if (state.tagList.some(ele => ele.fullPath == action.fullPath)) return;
|
||||||
|
state.tagList.push(action);
|
||||||
|
setStore({ name: 'tagList', content: state.tagList });
|
||||||
|
},
|
||||||
|
DEL_TAG: (state, action) => {
|
||||||
|
state.tagList = state.tagList.filter(item => {
|
||||||
|
return item.fullPath !== action.fullPath;
|
||||||
|
});
|
||||||
|
setStore({ name: 'tagList', content: state.tagList });
|
||||||
|
},
|
||||||
|
DEL_ALL_TAG: (state, tagList = []) => {
|
||||||
|
state.tagList = tagList;
|
||||||
|
setStore({ name: 'tagList', content: state.tagList });
|
||||||
|
},
|
||||||
|
DEL_TAG_OTHER: state => {
|
||||||
|
state.tagList = state.tagList.filter(item => {
|
||||||
|
return [state.tag.fullPath, website.fistPage.path].includes(item.fullPath);
|
||||||
|
});
|
||||||
|
setStore({ name: 'tagList', content: state.tagList });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default navs;
|
||||||
390
src/store/modules/user.js
Normal file
390
src/store/modules/user.js
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
import {
|
||||||
|
setToken,
|
||||||
|
setRefreshToken,
|
||||||
|
removeToken,
|
||||||
|
removeRefreshToken,
|
||||||
|
getRefreshToken,
|
||||||
|
} from '@/utils/auth';
|
||||||
|
import { setStore, getStore } from '@/utils/store';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
import { deepClone } from '@/utils/util';
|
||||||
|
import {
|
||||||
|
loginByUsername,
|
||||||
|
loginBySocial,
|
||||||
|
loginBySso,
|
||||||
|
loginByPhone,
|
||||||
|
getUserInfo,
|
||||||
|
logout,
|
||||||
|
refreshToken,
|
||||||
|
getButtons,
|
||||||
|
registerUser,
|
||||||
|
} from '@/api/user';
|
||||||
|
import { getRoutes, getTopMenu } from '@/api/system/menu';
|
||||||
|
import { formatPath } from '@/router/avue-router';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
import { encrypt } from '@/utils/sm2';
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
state: {
|
||||||
|
tenantId: getStore({ name: 'tenantId' }) || '',
|
||||||
|
userInfo: getStore({ name: 'userInfo' }) || [],
|
||||||
|
permission: getStore({ name: 'permission' }) || {},
|
||||||
|
roles: [],
|
||||||
|
menuId: {},
|
||||||
|
menu: getStore({ name: 'menu' }) || [],
|
||||||
|
menuAll: getStore({ name: 'menuAll' }) || [],
|
||||||
|
token: getStore({ name: 'token' }) || '',
|
||||||
|
refreshToken: getStore({ name: 'refreshToken' }) || '',
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
//根据用户名登录
|
||||||
|
LoginByUsername({ commit }, userInfo = {}) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
loginByUsername(
|
||||||
|
userInfo.tenantId,
|
||||||
|
userInfo.deptId,
|
||||||
|
userInfo.roleId,
|
||||||
|
userInfo.username,
|
||||||
|
encrypt(userInfo.password),
|
||||||
|
userInfo.type,
|
||||||
|
userInfo.key,
|
||||||
|
userInfo.code
|
||||||
|
)
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.error_description) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.error_description,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_TENANT_ID', data.tenant_id);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
commit('DEL_ALL_TAG');
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//根据第三方信息登录
|
||||||
|
LoginBySocial({ commit }, userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
loginBySocial(userInfo.tenantId, userInfo.source, userInfo.code, userInfo.state)
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.error_description) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.error_description,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
commit('SET_TENANT_ID', data.tenant_id);
|
||||||
|
commit('DEL_ALL_TAG');
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//根据单点信息登录
|
||||||
|
LoginBySso({ commit }, userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
loginBySso(userInfo.state, userInfo.code)
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.error_description) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.error_description,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
commit('SET_TENANT_ID', data.tenant_id);
|
||||||
|
commit('DEL_ALL_TAG');
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//根据手机信息登录
|
||||||
|
LoginByPhone({ commit }, userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
loginByPhone(
|
||||||
|
userInfo.tenantId,
|
||||||
|
encrypt(userInfo.phone),
|
||||||
|
userInfo.codeId,
|
||||||
|
userInfo.codeValue
|
||||||
|
)
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.error_description) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.error_description,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
commit('SET_TENANT_ID', data.tenant_id);
|
||||||
|
commit('DEL_ALL_TAG');
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//用户注册
|
||||||
|
RegisterUser({ commit }, userInfo = {}) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
registerUser(
|
||||||
|
userInfo.tenantId,
|
||||||
|
userInfo.name,
|
||||||
|
userInfo.account,
|
||||||
|
encrypt(userInfo.password),
|
||||||
|
userInfo.phone,
|
||||||
|
userInfo.email
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
if (data.error_description) {
|
||||||
|
ElMessage({
|
||||||
|
message: data.error_description,
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
|
reject(data.error_description);
|
||||||
|
} else {
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
commit('SET_TENANT_ID', data.tenant_id);
|
||||||
|
commit('DEL_ALL_TAG');
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetUserInfo({ commit }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
getUserInfo()
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
commit('SET_ROLES', data.roles);
|
||||||
|
resolve(data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//刷新token
|
||||||
|
RefreshToken({ state, commit }, userInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
refreshToken(
|
||||||
|
getRefreshToken(),
|
||||||
|
state.tenantId,
|
||||||
|
!validatenull(userInfo) ? userInfo.deptId : state.userInfo.dept_id,
|
||||||
|
!validatenull(userInfo) ? userInfo.roleId : state.userInfo.role_id
|
||||||
|
)
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data;
|
||||||
|
commit('SET_TOKEN', data.access_token);
|
||||||
|
commit('SET_REFRESH_TOKEN', data.refresh_token);
|
||||||
|
commit('SET_USER_INFO', data);
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 登出
|
||||||
|
LogOut({ commit }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
logout()
|
||||||
|
.then(() => {
|
||||||
|
commit('SET_TOKEN', '');
|
||||||
|
commit('SET_MENU_ALL_NULL', []);
|
||||||
|
commit('SET_MENU', []);
|
||||||
|
commit('SET_ROLES', []);
|
||||||
|
commit('DEL_ALL_TAG', []);
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
removeToken();
|
||||||
|
removeRefreshToken();
|
||||||
|
removeToken();
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
//注销session
|
||||||
|
FedLogOut({ commit }) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
commit('SET_TOKEN', '');
|
||||||
|
commit('SET_MENU_ALL_NULL', []);
|
||||||
|
commit('SET_MENU', []);
|
||||||
|
commit('SET_ROLES', []);
|
||||||
|
commit('DEL_ALL_TAG', []);
|
||||||
|
commit('CLEAR_LOCK');
|
||||||
|
removeToken();
|
||||||
|
removeRefreshToken();
|
||||||
|
removeToken();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetTopMenu() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
getTopMenu().then(res => {
|
||||||
|
const data = res.data.data || [];
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetMenu({ commit, dispatch }, tenantId) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
getRoutes(tenantId).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
let menu = deepClone(data);
|
||||||
|
menu.forEach(ele => formatPath(ele, true));
|
||||||
|
commit('SET_MENU', menu);
|
||||||
|
commit('SET_MENU_ALL', menu);
|
||||||
|
dispatch('GetButtons');
|
||||||
|
resolve(menu);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetButtons({ commit }) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
getButtons().then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
commit('SET_PERMISSION', data);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
SET_TOKEN: (state, token) => {
|
||||||
|
setToken(token);
|
||||||
|
state.token = token;
|
||||||
|
setStore({ name: 'token', content: state.token });
|
||||||
|
},
|
||||||
|
SET_REFRESH_TOKEN: (state, refreshToken) => {
|
||||||
|
setRefreshToken(refreshToken);
|
||||||
|
state.refreshToken = refreshToken;
|
||||||
|
setStore({ name: 'refreshToken', content: state.refreshToken });
|
||||||
|
},
|
||||||
|
SET_MENU_ID(state, menuId) {
|
||||||
|
state.menuId = menuId;
|
||||||
|
},
|
||||||
|
SET_TENANT_ID: (state, tenantId) => {
|
||||||
|
state.tenantId = tenantId;
|
||||||
|
setStore({ name: 'tenantId', content: state.tenantId });
|
||||||
|
},
|
||||||
|
SET_USER_INFO: (state, userInfo) => {
|
||||||
|
if (validatenull(userInfo.user_id) && validatenull(userInfo.account)) {
|
||||||
|
state.userInfo = { user_name: 'unauth', role_name: 'unauth', authority: 'unauth' };
|
||||||
|
} else {
|
||||||
|
if (validatenull(userInfo.avatar)) {
|
||||||
|
userInfo.avatar = '/img/bg/img-logo.png';
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.role_name)) {
|
||||||
|
userInfo.roleName = userInfo.role_name;
|
||||||
|
userInfo.authority = userInfo.role_name;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.user_id)) {
|
||||||
|
userInfo.userId = userInfo.user_id;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.user_name)) {
|
||||||
|
userInfo.userName = userInfo.user_name;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.tenant_id)) {
|
||||||
|
userInfo.tenantId = userInfo.tenant_id;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.dept_id)) {
|
||||||
|
userInfo.deptId = userInfo.dept_id;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.role_id)) {
|
||||||
|
userInfo.roleId = userInfo.role_id;
|
||||||
|
}
|
||||||
|
if (!validatenull(userInfo.oauth_id)) {
|
||||||
|
userInfo.oauthId = userInfo.oauth_id;
|
||||||
|
}
|
||||||
|
state.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
setStore({ name: 'userInfo', content: state.userInfo });
|
||||||
|
},
|
||||||
|
SET_MENU_ALL: (state, menuAll) => {
|
||||||
|
let menu = state.menuAll;
|
||||||
|
menuAll.forEach(ele => {
|
||||||
|
let index = menu.findIndex(item => item.path === ele.path);
|
||||||
|
if (index === -1) {
|
||||||
|
menu.push(ele);
|
||||||
|
} else {
|
||||||
|
menu[index] = ele;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
state.menuAll = menu;
|
||||||
|
setStore({ name: 'menuAll', content: state.menuAll });
|
||||||
|
},
|
||||||
|
SET_MENU_ALL_NULL: state => {
|
||||||
|
state.menuAll = [];
|
||||||
|
setStore({ name: 'menuAll', content: state.menuAll });
|
||||||
|
},
|
||||||
|
SET_MENU: (state, menu) => {
|
||||||
|
state.menu = menu;
|
||||||
|
setStore({ name: 'menu', content: state.menu });
|
||||||
|
},
|
||||||
|
SET_ROLES: (state, roles) => {
|
||||||
|
state.roles = roles;
|
||||||
|
},
|
||||||
|
SET_PERMISSION: (state, permission) => {
|
||||||
|
let result = [];
|
||||||
|
|
||||||
|
function getCode(list) {
|
||||||
|
list.forEach(ele => {
|
||||||
|
if (typeof ele === 'object') {
|
||||||
|
const children = ele.children;
|
||||||
|
const code = ele.code;
|
||||||
|
if (children && children.length > 0) {
|
||||||
|
getCode(children);
|
||||||
|
} else {
|
||||||
|
result.push(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getCode(permission);
|
||||||
|
state.permission = {};
|
||||||
|
result.forEach(ele => {
|
||||||
|
state.permission[ele] = true;
|
||||||
|
});
|
||||||
|
setStore({ name: 'permission', content: state.permission, type: 'session' });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default user;
|
||||||
133
src/styles/common.scss
Executable file
133
src/styles/common.scss
Executable file
@@ -0,0 +1,133 @@
|
|||||||
|
// 全局变量
|
||||||
|
@use './variables.scss' as variables;
|
||||||
|
@use './mixin.scss' as *;
|
||||||
|
|
||||||
|
// ele样式覆盖
|
||||||
|
@use './element-ui.scss';
|
||||||
|
// 顶部右侧显示
|
||||||
|
@use './top.scss';
|
||||||
|
// 导航标签
|
||||||
|
@use './tags.scss';
|
||||||
|
// 工具类函数
|
||||||
|
@use './mixin.scss';
|
||||||
|
// 侧面导航栏
|
||||||
|
@use './sidebar.scss';
|
||||||
|
//主题
|
||||||
|
@use './theme/index.scss';
|
||||||
|
//通用配置
|
||||||
|
@use './normalize.scss';
|
||||||
|
//图标配置
|
||||||
|
@use './iconfont.scss';
|
||||||
|
//登录样式
|
||||||
|
@use "./login.scss";
|
||||||
|
//适配
|
||||||
|
@use './media.scss';
|
||||||
|
//滚动条样式
|
||||||
|
@include scrollBar;
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar,
|
||||||
|
.avue-top,
|
||||||
|
.avue-logo,
|
||||||
|
.avue-layout,
|
||||||
|
.login-logo,
|
||||||
|
.avue-main {
|
||||||
|
transition: all .3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-layout {
|
||||||
|
display: flex;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&--horizontal {
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
width: 100%;
|
||||||
|
height: variables.$top_height;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.avue-menu, .el-menu-item, .el-sub-menu__title {
|
||||||
|
height: variables.$top_height;
|
||||||
|
line-height: variables.$top_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active:before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
width: variables.$sidebar_width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-contail {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: #f0f2f5;
|
||||||
|
background-size: 100%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue--collapse {
|
||||||
|
.avue-sidebar,
|
||||||
|
.avue-logo {
|
||||||
|
width: variables.$sidebar_collapse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-main {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
flex: 1;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f0f2f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
#avue-view {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-view {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-footer {
|
||||||
|
width: 100%;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.copyright {
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mac_bg {
|
||||||
|
background-image: url("/img/bg.jpg");
|
||||||
|
background-color: #000;
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
69
src/styles/element-ui.scss
Executable file
69
src/styles/element-ui.scss
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
.el-card.is-always-shadow {
|
||||||
|
box-shadow: none;
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-message__icon,
|
||||||
|
.el-message__content {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-date-editor .el-range-input,
|
||||||
|
.el-date-editor .el-range-separator {
|
||||||
|
height: auto;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dialog__wrapper {
|
||||||
|
z-index: 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.el-col {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-main {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown-menu__item--divided:before, .el-menu, .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus, .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover, .el-menu--horizontal > .el-sub-menu .el-sub-menu__title:hover {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.el-dropdown-menu__item--divided:before, .el-menu, .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus, .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover, .el-menu--horizontal > .el-sub-menu .el-sub-menu__title:hover {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-collapse-item__header {
|
||||||
|
height: auto;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-button.is-text:not(.is-disabled):active {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-button.is-text:not(.is-disabled):focus, .el-button.is-text:not(.is-disabled):hover {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
.el-dropdown{
|
||||||
|
display: inline-block;
|
||||||
|
line-height: inherit;
|
||||||
|
.el-button.is-text:not(.is-disabled):focus-visible{
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-icon i, .avue-icon svg {
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue--detail .el-form-item {
|
||||||
|
background-color: #fafafa;
|
||||||
|
}
|
||||||
24
src/styles/iconfont.scss
Normal file
24
src/styles/iconfont.scss
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
[class^="icon-"] {
|
||||||
|
font-family: "iconfont" !important;
|
||||||
|
font-size: 18px !important;
|
||||||
|
font-style: normal;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item [class^=icon-] {
|
||||||
|
margin-right: 5px;
|
||||||
|
width: 24px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-sub-menu [class^=icon-] {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 5px;
|
||||||
|
width: 24px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
177
src/styles/login.scss
Executable file
177
src/styles/login.scss
Executable file
@@ -0,0 +1,177 @@
|
|||||||
|
.login-container {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
// background-color: #fff;
|
||||||
|
background: linear-gradient(110deg, rgb(2, 40, 85) 0%, rgb(44, 119, 241) 50%, rgb(255,255,255) 50%, rgb(240,240,240) 100%);
|
||||||
|
overflow: hidden;
|
||||||
|
&::before{
|
||||||
|
// content:' ';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin-left: -48%;
|
||||||
|
background-image: url(/img/login-bg.svg);
|
||||||
|
background-position: 100%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: auto 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.login-weaper {
|
||||||
|
margin: 0 auto;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-left,
|
||||||
|
.login-border {
|
||||||
|
position: relative;
|
||||||
|
min-height: 500px;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.login-left {
|
||||||
|
padding-top: 100px;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
color: #fff;
|
||||||
|
float: left;
|
||||||
|
width: 50%;
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.login-left .img {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
.login-time {
|
||||||
|
position: absolute;
|
||||||
|
left: 25px;
|
||||||
|
top: 25px;
|
||||||
|
width: 100%;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 200;
|
||||||
|
opacity: 0.9;
|
||||||
|
font-size: 18px;
|
||||||
|
overflow: hidden;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.login-left .title {
|
||||||
|
margin-top: 60px;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 300;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-border {
|
||||||
|
border-left: none;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
color: #fff;
|
||||||
|
width: 50%;
|
||||||
|
float: left;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.login-main {
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 30px 50px;
|
||||||
|
width: 70%;
|
||||||
|
//box-shadow: -4px 5px 10px rgba(255, 255, 255, 0.4);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.login-main > h3 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.login-title {
|
||||||
|
color: #000;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 28px;
|
||||||
|
text-align: center;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
}
|
||||||
|
.login-menu {
|
||||||
|
margin-top: 40px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
a {
|
||||||
|
color: #999;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 0px 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.login-submit {
|
||||||
|
width: 100%;
|
||||||
|
height: 45px;
|
||||||
|
font-size: 18px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
font-weight: 300;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 30px;
|
||||||
|
transition: 0.25s;
|
||||||
|
background-color: #2C77F1;
|
||||||
|
}
|
||||||
|
.register-submit {
|
||||||
|
width: 100%;
|
||||||
|
height: 45px;
|
||||||
|
font-size: 18px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
font-weight: 300;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 30px;
|
||||||
|
margin-left: 0!important;
|
||||||
|
transition: 0.25s;
|
||||||
|
}
|
||||||
|
.login-form {
|
||||||
|
margin: 10px 0;
|
||||||
|
i {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.el-input {
|
||||||
|
input {
|
||||||
|
text-indent: 5px;
|
||||||
|
}
|
||||||
|
.el-input__wrapper{
|
||||||
|
padding:5px 10px;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.el-input__suffix,.el-input__prefix{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.el-input__prefix{
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.login-code {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
.el-input-group__append{
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.login-code-box{
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.login-code-img {
|
||||||
|
cursor: pointer;
|
||||||
|
min-width: 100px;
|
||||||
|
padding: 0 5px;
|
||||||
|
height: 30px;
|
||||||
|
color: #333;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
letter-spacing: 3px;
|
||||||
|
line-height: 38px;
|
||||||
|
text-indent: 5px;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
68
src/styles/media.scss
Executable file
68
src/styles/media.scss
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
@use './variables.scss' as variables;
|
||||||
|
|
||||||
|
@media screen and (max-width: 992px) {
|
||||||
|
.avue-sidebar {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: -265px;
|
||||||
|
z-index: 1024;
|
||||||
|
}
|
||||||
|
.avue--collapse {
|
||||||
|
.avue-sidebar {
|
||||||
|
left: 0;
|
||||||
|
width: variables.$sidebar_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
width: variables.$sidebar_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-main {
|
||||||
|
margin-left: variables.$sidebar_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ele的自适应
|
||||||
|
.el-dialog,
|
||||||
|
.el-message-box {
|
||||||
|
width: 98%;
|
||||||
|
}
|
||||||
|
//登录页面
|
||||||
|
.login-left {
|
||||||
|
width: 100%;
|
||||||
|
min-height: auto;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-top: 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
text-shadow: #000 1px 0 0, #000 0 1px 0, #000 -1px 0 0, #000 0 -1px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.img {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.login-logo {
|
||||||
|
padding-top: 30px;
|
||||||
|
margin-left: -30px;
|
||||||
|
}
|
||||||
|
.login-border {
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 20px;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.login-main {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 10px 20px;
|
||||||
|
box-shadow: none
|
||||||
|
}
|
||||||
|
.login-container {
|
||||||
|
&::before {
|
||||||
|
margin-left: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.top-bar__item {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/styles/mixin.scss
Executable file
70
src/styles/mixin.scss
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
@mixin clearfix {
|
||||||
|
&:after {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin scrollBar {
|
||||||
|
::-webkit-scrollbar-track-piece {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: hsla(220, 4%, 58%, .3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin radius($width, $size, $color) {
|
||||||
|
width: $width;
|
||||||
|
height: $width;
|
||||||
|
line-height: $width;
|
||||||
|
border-radius: $width;
|
||||||
|
text-align: center;
|
||||||
|
border-width: $size;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin relative {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin pct($pct) {
|
||||||
|
width: #{$pct};
|
||||||
|
position: relative;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin triangle($width, $height, $color, $direction) {
|
||||||
|
$width: $width/2;
|
||||||
|
$color-border-style: $height solid $color;
|
||||||
|
$transparent-border-style: $width solid transparent;
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
@if $direction==up {
|
||||||
|
border-bottom: $color-border-style;
|
||||||
|
border-left: $transparent-border-style;
|
||||||
|
border-right: $transparent-border-style;
|
||||||
|
} @else if $direction==right {
|
||||||
|
border-left: $color-border-style;
|
||||||
|
border-top: $transparent-border-style;
|
||||||
|
border-bottom: $transparent-border-style;
|
||||||
|
} @else if $direction==down {
|
||||||
|
border-top: $color-border-style;
|
||||||
|
border-left: $transparent-border-style;
|
||||||
|
border-right: $transparent-border-style;
|
||||||
|
} @else if $direction==left {
|
||||||
|
border-right: $color-border-style;
|
||||||
|
border-top: $transparent-border-style;
|
||||||
|
border-bottom: $transparent-border-style;
|
||||||
|
}
|
||||||
|
}
|
||||||
501
src/styles/normalize.scss
vendored
Executable file
501
src/styles/normalize.scss
vendored
Executable file
@@ -0,0 +1,501 @@
|
|||||||
|
/*! normalize.css v2.1.2 | MIT License | git.io/normalize */
|
||||||
|
/*
|
||||||
|
/*! 我就是自己看看,然后翻译下下,让大家看看 */
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
HTML5 display definitions
|
||||||
|
|
||||||
|
HTML5 新增元素定义
|
||||||
|
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct `block` display not defined in IE 8/9.
|
||||||
|
*
|
||||||
|
* 修正IE 8/9 中未定义的块级元素。
|
||||||
|
*/
|
||||||
|
|
||||||
|
article,
|
||||||
|
aside,
|
||||||
|
details,
|
||||||
|
figcaption,
|
||||||
|
figure,
|
||||||
|
footer,
|
||||||
|
header,
|
||||||
|
hgroup,
|
||||||
|
main,
|
||||||
|
nav,
|
||||||
|
section,
|
||||||
|
summary {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct `inline-block` display not defined in IE 8/9.
|
||||||
|
*
|
||||||
|
* 修正在 IE 8/9 中未定义的 'inline-block' 元素。
|
||||||
|
*/
|
||||||
|
|
||||||
|
audio,
|
||||||
|
canvas,
|
||||||
|
video {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent modern browsers from displaying `audio` without controls.
|
||||||
|
* Remove excess height in iOS 5 devices.
|
||||||
|
*
|
||||||
|
* 阻止现在浏览器显示未定义 control 播放控件的 'audio' 声音元素。
|
||||||
|
* 删除 IOS 5 设备中显示的多余的高度。
|
||||||
|
*/
|
||||||
|
|
||||||
|
audio:not([controls]) {
|
||||||
|
display: none;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address styling not present in IE 8/9.
|
||||||
|
*
|
||||||
|
* 处理 IE 8/9 中不存在的样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Base
|
||||||
|
|
||||||
|
基本设置
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Set default font family to sans-serif.
|
||||||
|
* 2. Prevent iOS text size adjust after orientation change, without disabling
|
||||||
|
* user zoom.
|
||||||
|
*
|
||||||
|
* 1. 设置默认字体类型为 sans-serif.
|
||||||
|
* 2. 当用户放大或缩小页面时不改变字体大小。
|
||||||
|
*/
|
||||||
|
|
||||||
|
html {
|
||||||
|
font-family: sans-serif; /* 1 */
|
||||||
|
-ms-text-size-adjust: 100%; /* 2 */
|
||||||
|
-webkit-text-size-adjust: 100%; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove default margin.
|
||||||
|
*
|
||||||
|
* 删除默认边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Links
|
||||||
|
|
||||||
|
链接
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address `outline` inconsistency between Chrome and other browsers.
|
||||||
|
*
|
||||||
|
* 处理 Chrome 与其它浏览器中关于 'outline' 的不一致性。
|
||||||
|
*/
|
||||||
|
|
||||||
|
a:focus {
|
||||||
|
outline: thin dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Improve readability when focused and also mouse hovered in all browsers.
|
||||||
|
*
|
||||||
|
* 为所有浏览器改善当激活或悬停在元素上时元素内容的可读性。
|
||||||
|
*/
|
||||||
|
|
||||||
|
a:active,
|
||||||
|
a:hover {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Typography
|
||||||
|
|
||||||
|
排版
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address variable `h1` font-size and margin within `section` and `article`
|
||||||
|
* contexts in Firefox 4+, Safari 5, and Chrome.
|
||||||
|
*
|
||||||
|
* 处理多变的 'h1' 字体大小及其在 Firefox 4+, Safari 5, 及 Chrome时浏览器中的
|
||||||
|
* 'section' 与 'article' 元素中的边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 2em;
|
||||||
|
margin: 0.67em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address styling not present in IE 8/9, Safari 5, and Chrome.
|
||||||
|
*
|
||||||
|
* 处理在 IE 8/9, Safari 5, 及 Chrome 没有的样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
abbr[title] {
|
||||||
|
border-bottom: 1px dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome.
|
||||||
|
*
|
||||||
|
* 处理 Firefox 4+, Safari 5, 及 Chrome 中默认的 'bolder' 样式为 'bold'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
b,
|
||||||
|
strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address styling not present in Safari 5 and Chrome.
|
||||||
|
*
|
||||||
|
* 处理在 Safari 5 和 Chrome 没有的样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
dfn {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address differences between Firefox and other browsers.
|
||||||
|
*
|
||||||
|
* 处理 Firefox 与其它浏览器的差异。
|
||||||
|
*/
|
||||||
|
|
||||||
|
hr {
|
||||||
|
-moz-box-sizing: content-box;
|
||||||
|
box-sizing: content-box;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address styling not present in IE 8/9.
|
||||||
|
*
|
||||||
|
* 处理在 IE 8/9 中没有的样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
mark {
|
||||||
|
background: #ff0;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct font family set oddly in Safari 5 and Chrome.
|
||||||
|
*
|
||||||
|
* 修正确 Safari 5 和 Chrome 中古怪的默认字体。
|
||||||
|
*/
|
||||||
|
|
||||||
|
code,
|
||||||
|
kbd,
|
||||||
|
pre,
|
||||||
|
samp {
|
||||||
|
font-family: monospace, serif;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Improve readability of pre-formatted text in all browsers.
|
||||||
|
*
|
||||||
|
* 为所有浏览器改善预格式化文本的可读性。
|
||||||
|
*/
|
||||||
|
|
||||||
|
pre {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set consistent quote types.
|
||||||
|
*
|
||||||
|
* 设置一致的引用格式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
q {
|
||||||
|
quotes: "\201C" "\201D" "\2018" "\2019";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address inconsistent and variable font size in all browsers.
|
||||||
|
*
|
||||||
|
* 处理所有浏览器中字体大小的不一致性[译者注:原文直译为:处理所有
|
||||||
|
* 浏览器中的不一致和多变的字体大小]。
|
||||||
|
*/
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
|
||||||
|
*
|
||||||
|
* 阻止所有浏览器中 'sub' 和 'sup' 元素影响 'line-height'.
|
||||||
|
* [译者注:就是不让上标与下标影响行高。]
|
||||||
|
*/
|
||||||
|
|
||||||
|
sub,
|
||||||
|
sup {
|
||||||
|
font-size: 75%;
|
||||||
|
line-height: 0;
|
||||||
|
position: relative;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup {
|
||||||
|
top: -0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
bottom: -0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Embedded content
|
||||||
|
|
||||||
|
嵌入的内容
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove border when inside `a` element in IE 8/9.
|
||||||
|
*
|
||||||
|
* 删除 IE 8/9 中当内容位于 'a' 中出现的边框。
|
||||||
|
*/
|
||||||
|
|
||||||
|
img {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct overflow displayed oddly in IE 9.
|
||||||
|
*
|
||||||
|
* 修正 IE 9 中显示古怪的溢出内容。
|
||||||
|
*/
|
||||||
|
|
||||||
|
svg:not(:root) {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Figures
|
||||||
|
|
||||||
|
Figure 图像/图表/代码等
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address margin not present in IE 8/9 and Safari 5.
|
||||||
|
*
|
||||||
|
* 处理在 IE 8/9 和 Safari 5 没有的边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
figure {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Forms
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define consistent border, margin, and padding.
|
||||||
|
*
|
||||||
|
* 定义一致的边框、外边距及内边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
border: 1px solid #c0c0c0;
|
||||||
|
margin: 0 2px;
|
||||||
|
padding: 0.35em 0.625em 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Correct `color` not being inherited in IE 8/9.
|
||||||
|
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
|
||||||
|
* 1. 修正在 IE 8/9 中没有继承的 'color'.
|
||||||
|
*
|
||||||
|
* [译者注:说是修正颜色嘛,可下面没有关于颜色的呀,这也行?求大神解释!]
|
||||||
|
* 2. 去掉内边距,避免当用户清空表单组时认为出错了。
|
||||||
|
*/
|
||||||
|
|
||||||
|
legend {
|
||||||
|
border: 0; /* 1 */
|
||||||
|
padding: 0; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Correct font family not being inherited in all browsers.
|
||||||
|
* 2. Correct font size not being inherited in all browsers.
|
||||||
|
* 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome.
|
||||||
|
*
|
||||||
|
* 1. 修正所有浏览器中未被继承的字体类型。
|
||||||
|
* 2. 修正所有浏览器中未被继承的字体大小。
|
||||||
|
* 3. 处理 Firefox 4+, Safari 5, 及 Chrome 中默认设置不同的外边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font-family: inherit; /* 1 */
|
||||||
|
font-size: 100%; /* 2 */
|
||||||
|
margin: 0; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
|
||||||
|
* the UA stylesheet.
|
||||||
|
*
|
||||||
|
* 处理 Firefox 4+ 中的客户端样式表里使用 '!important' 设置的 'line-height'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
input {
|
||||||
|
line-height: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address inconsistent `text-transform` inheritance for `button` and `select`.
|
||||||
|
* All other form control elements do not inherit `text-transform` values.
|
||||||
|
* Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+.
|
||||||
|
* Correct `select` style inheritance in Firefox 4+ and Opera.
|
||||||
|
*
|
||||||
|
* 处理 'button' 和 'select' 的 'text-transform' 继承的不一致性。
|
||||||
|
* 所有其它表单控件元素不继承 'text-transform' 的值。
|
||||||
|
* 修正 Chrome, Safari 5+, 及 IE 8+ 中 'button' 的继承样式。
|
||||||
|
* 修正 Firefox 4+ 和 Opera 中 'select' 的继承样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
select {
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
|
||||||
|
* and `video` controls.
|
||||||
|
* 2. Correct inability to style clickable `input` types in iOS.
|
||||||
|
* 3. Improve usability and consistency of cursor style between image-type
|
||||||
|
* `input` and others.
|
||||||
|
*
|
||||||
|
* 1. 避免 Android 4.0.* 中 WebKit 的一个bug, 防止 'audio' 与 'video' 的播放控件失效。
|
||||||
|
* 2. 修正 iOS 中不可点击的 'input' 样式。
|
||||||
|
* 3. 改善图片类型的 'input' 等光标样式的可用性与一致性。
|
||||||
|
*/
|
||||||
|
|
||||||
|
button,
|
||||||
|
html input[type="button"], /* 1 */
|
||||||
|
input[type="reset"],
|
||||||
|
input[type="submit"] {
|
||||||
|
-webkit-appearance: button; /* 2 */
|
||||||
|
cursor: pointer; /* 3 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-set default cursor for disabled elements.
|
||||||
|
*
|
||||||
|
* 重置不可用元素的默认光标样式。
|
||||||
|
*/
|
||||||
|
|
||||||
|
button[disabled],
|
||||||
|
html input[disabled] {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Address box sizing set to `content-box` in IE 8/9.
|
||||||
|
* 2. Remove excess padding in IE 8/9.
|
||||||
|
*
|
||||||
|
* 1. 处理 IE 8/9 中设置为 'content-box' 的盒子模型。
|
||||||
|
* 2. 删除 IE 8/9 中多余的内边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="checkbox"],
|
||||||
|
input[type="radio"] {
|
||||||
|
box-sizing: border-box; /* 1 */
|
||||||
|
padding: 0; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome.
|
||||||
|
* 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome
|
||||||
|
* (include `-moz` to future-proof).
|
||||||
|
*
|
||||||
|
* 1. 处理 Safari 5 和 Chrome 中默认设置为 'appearance' 的 'searchfield'.
|
||||||
|
* 2. 处理 Safari 5 和 Chrome 中默认设置为 'box-sizing' 的 'border-box'
|
||||||
|
* (包括不会过时的 '-moz').
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="search"] {
|
||||||
|
-webkit-appearance: textfield; /* 1 */
|
||||||
|
-moz-box-sizing: content-box;
|
||||||
|
-webkit-box-sizing: content-box; /* 2 */
|
||||||
|
box-sizing: content-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove inner padding and search cancel button in Safari 5 and Chrome
|
||||||
|
* on OS X.
|
||||||
|
*
|
||||||
|
* 删除 Safari 5 和 OS X 上的 Chrome 中的输入框上的内边距和搜索取消按钮。
|
||||||
|
*/
|
||||||
|
|
||||||
|
input[type="search"]::-webkit-search-cancel-button,
|
||||||
|
input[type="search"]::-webkit-search-decoration {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove inner padding and border in Firefox 4+.
|
||||||
|
*
|
||||||
|
* 删除 Firefox 4+ button 与 input 上的内边距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
button::-moz-focus-inner,
|
||||||
|
input::-moz-focus-inner {
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. Remove default vertical scrollbar in IE 8/9.
|
||||||
|
* 2. Improve readability and alignment in all browsers.
|
||||||
|
*
|
||||||
|
* 1. 删除 IE8/9 中默认的垂直滚动条。
|
||||||
|
* 2. 改善所有浏览器中的可读性并使文本垂直对齐。
|
||||||
|
*/
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
overflow: auto; /* 1 */
|
||||||
|
vertical-align: top; /* 2 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Tables
|
||||||
|
|
||||||
|
表格
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove most spacing between table cells.
|
||||||
|
*
|
||||||
|
* 删除表格里单元格间的间距。
|
||||||
|
*/
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
74
src/styles/sidebar.scss
Executable file
74
src/styles/sidebar.scss
Executable file
@@ -0,0 +1,74 @@
|
|||||||
|
@use './variables.scss' as variables;
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
width: variables.$sidebar_width;
|
||||||
|
height: 100%;
|
||||||
|
user-select: none;
|
||||||
|
position: relative;
|
||||||
|
background-color: #031527;
|
||||||
|
transition: width .2s;
|
||||||
|
box-sizing: border-box;
|
||||||
|
box-shadow: 2px 0 6px rgba(0, 21, 41, .35);
|
||||||
|
|
||||||
|
.el-scrollbar__wrap {
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-menu {
|
||||||
|
height: calc(100% - #{variables.$top_height});
|
||||||
|
}
|
||||||
|
|
||||||
|
&--tip {
|
||||||
|
width: 90%;
|
||||||
|
height: 140px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
left: 5%;
|
||||||
|
color: #ccc;
|
||||||
|
z-index: 2;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
background-color: rgba(0, 0, 0, .4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: hsla(0, 0%, 100%, .7);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 4px;
|
||||||
|
background: var(--el-color-primary);
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
background-color: rgba(0, 0, 0, .8);
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
101
src/styles/tags.scss
Executable file
101
src/styles/tags.scss
Executable file
@@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
user-select: none;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-top: 1px solid #f6f6f6;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
|
||||||
|
|
||||||
|
.el-tabs--card > .el-tabs__header {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs--card > .el-tabs__header .el-tabs__nav,
|
||||||
|
.el-tabs--card > .el-tabs__header .el-tabs__item,
|
||||||
|
.el-tabs--card > .el-tabs__header {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs--card > .el-tabs__header .el-tabs__item:first-child {
|
||||||
|
border-left-width: 1px
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs--card > .el-tabs__header .el-tabs__item {
|
||||||
|
margin: 0 3px;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #ccc;
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
border-bottom: 3px solid var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__nav-prev,
|
||||||
|
.el-tabs__nav-next {
|
||||||
|
width: 20px;
|
||||||
|
line-height: 40px;
|
||||||
|
font-size: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__box {
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-right: 106px;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
&:first-child {
|
||||||
|
.is-icon-close {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__contentmenu {
|
||||||
|
position: fixed;
|
||||||
|
width: 120px;
|
||||||
|
background-color: #fff;
|
||||||
|
z-index: 1024;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 1px 2px 10px #ccc;
|
||||||
|
|
||||||
|
.item {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 8px 20px 8px 15px;
|
||||||
|
color: #606266;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom-left-radius: 5px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__menu {
|
||||||
|
position: absolute !important;
|
||||||
|
top: 3px;
|
||||||
|
right: 0;
|
||||||
|
padding: 1px 0 0 15px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/styles/theme/beautiful.scss
Executable file
55
src/styles/theme/beautiful.scss
Executable file
@@ -0,0 +1,55 @@
|
|||||||
|
.theme-beautiful {
|
||||||
|
.avue-sidebar {
|
||||||
|
background: linear-gradient(90deg, #006cff, #399efd) !important;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
background: linear-gradient(90deg, #006cff, #399efd) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #fff
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
background: #399efd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover, &.is-active {
|
||||||
|
background: #399efd !important;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
background: #399efd !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
background: linear-gradient(90deg, #006cff, #399efd) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
.el-tabs__item {
|
||||||
|
font-size: 14px !important;
|
||||||
|
color: #303133 !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
border: 1px solid #dcdfe6 !important;
|
||||||
|
border-radius: 3px;
|
||||||
|
height: 35px !important;
|
||||||
|
line-height: 35px !important;
|
||||||
|
margin: 5px 3px 8px 3px !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
border-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
border-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
53
src/styles/theme/bule.scss
Executable file
53
src/styles/theme/bule.scss
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
.theme-bule {
|
||||||
|
|
||||||
|
.avue-top, .avue-logo {
|
||||||
|
background: #004ca7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background: #004ca7;
|
||||||
|
|
||||||
|
.el-menu-item.is-active, .el-sub-menu__title.is-active {
|
||||||
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
.avue-logo_title {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-breadcrumb {
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
175
src/styles/theme/cool.scss
Executable file
175
src/styles/theme/cool.scss
Executable file
@@ -0,0 +1,175 @@
|
|||||||
|
.theme-cool {
|
||||||
|
.el-menu--popup {
|
||||||
|
.el-menu-item {
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i, span {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 4px;
|
||||||
|
background: var(--el-color-primary);
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
background: linear-gradient(120deg, #25aff3, #008ad3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
padding: 0 3px;
|
||||||
|
margin: 8px 0;
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: transparent;
|
||||||
|
|
||||||
|
.el-tabs__header .el-tabs__item {
|
||||||
|
padding: 0 10px !important;
|
||||||
|
background-color: #fff;
|
||||||
|
margin-right: 5px;
|
||||||
|
color: #909399;
|
||||||
|
border-radius: 3px;
|
||||||
|
height: 30px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 30px;
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
border: none;
|
||||||
|
color: #008ad3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar--tip {
|
||||||
|
background-color: transparent;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
font-weight: 400;
|
||||||
|
color: #008ad3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo_title,
|
||||||
|
.avue-breadcrumb {
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
.el-menu-item {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.15);
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: #e5f1fb;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #25aff3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-search {
|
||||||
|
.el-input__inner {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-webkit-input-placeholder,
|
||||||
|
textarea::-webkit-input-placeholder {
|
||||||
|
/* WebKit browsers */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-moz-placeholder,
|
||||||
|
textarea:-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 4 to 18 */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-moz-placeholder,
|
||||||
|
textarea::-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 19+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-ms-input-placeholder,
|
||||||
|
textarea:-ms-input-placeholder {
|
||||||
|
/* Internet Explorer 10+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/styles/theme/d2.scss
Executable file
68
src/styles/theme/d2.scss
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
.theme-d2 {
|
||||||
|
.avue-logo {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
background-color: #ebf1f6;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
background-color: #ebf1f6;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-main {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
margin-left: 6px;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid #e4e7ed;
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #ebf1f6;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
border-left: 1px solid #cfd7e5 !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
background-color: rgba(0, 0, 0, .03) !important;
|
||||||
|
color: #606266 !important;
|
||||||
|
font-size: 14px !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-left: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
border-bottom: 1px solid #fff !important;
|
||||||
|
background-color: #fff !important;
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background-color: #ebf1f6;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #606266
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover, &.is-active {
|
||||||
|
background: hsla(0, 0%, 100%, .5);
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
src/styles/theme/dark.scss
Executable file
70
src/styles/theme/dark.scss
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
.theme-dark {
|
||||||
|
.avue-logo {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #2c3643;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
background-color: #2c3643;
|
||||||
|
box-shadow: none;
|
||||||
|
color: #ccc;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-main {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
padding-left: 0;
|
||||||
|
background-color: #2c3643;
|
||||||
|
border-color: transparent;
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
margin: 0 !important;
|
||||||
|
background-color: #262d37;
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
color: #262d37 !important;
|
||||||
|
background-color: #fff !important;
|
||||||
|
border-color: #262d37 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-main {
|
||||||
|
background-color: #2c3643;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background-color: #2c3643;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover, &.is-active {
|
||||||
|
background: #262d37;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
128
src/styles/theme/go.scss
Normal file
128
src/styles/theme/go.scss
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
.theme-go {
|
||||||
|
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1) !important;
|
||||||
|
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color) !important;
|
||||||
|
.el-table .el-table__row td .cell {
|
||||||
|
line-height: 32px;
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(75 85 99 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
.el-table tr th .cell {
|
||||||
|
line-height: 25px;
|
||||||
|
--tw-text-opacity: 1;
|
||||||
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background:#fff !important;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
&:before {
|
||||||
|
left: auto;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
background-color: #f0f6ff;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
width:100%;
|
||||||
|
height:50px;
|
||||||
|
line-height: 50px;
|
||||||
|
background:#fff;
|
||||||
|
color:#333;
|
||||||
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top{
|
||||||
|
height:50px;
|
||||||
|
line-height: 50px;
|
||||||
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important;
|
||||||
|
.top-bar__left i, .top-bar__right i{
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
.el-menu--horizontal.el-menu{
|
||||||
|
border:none
|
||||||
|
}
|
||||||
|
.el-menu-item{
|
||||||
|
i,span{
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__title{
|
||||||
|
padding-left: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.avue-main{
|
||||||
|
background-color: rgb(249,250,251);
|
||||||
|
}
|
||||||
|
.avue-tags {
|
||||||
|
margin: 5px 6px 8px 6px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
|
||||||
|
.el-tabs__nav-prev,
|
||||||
|
.el-tabs__nav-next {
|
||||||
|
width: 20px;
|
||||||
|
line-height: 50px;
|
||||||
|
font-size: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__box {
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-right: 70px;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
&:first-child {
|
||||||
|
.is-icon-close {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
font-size: 14px !important;
|
||||||
|
color: rgb(75,85,99) !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
border: 1px solid rgb(205,218,214) !important;
|
||||||
|
border-radius: 3px;
|
||||||
|
height: 30px !important;
|
||||||
|
line-height: 35px !important;
|
||||||
|
margin: 8px 3px 8px 3px !important;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
border-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
border-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
71
src/styles/theme/hey.scss
Executable file
71
src/styles/theme/hey.scss
Executable file
@@ -0,0 +1,71 @@
|
|||||||
|
.theme-hey {
|
||||||
|
.avue-sidebar {
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: rgba(49, 58, 70, .8);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
&:before {
|
||||||
|
left: auto;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
background-color: #f0f6ff;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
background: #f3f6f8;
|
||||||
|
|
||||||
|
&__box {
|
||||||
|
position: relative;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding-right: 70px;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
&:first-child {
|
||||||
|
.is-icon-close {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
color: rgba(0, 0, 0, .65) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
background-color: #fff;
|
||||||
|
border-bottom: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/styles/theme/index.scss
Executable file
35
src/styles/theme/index.scss
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
// white
|
||||||
|
@use './white.scss';
|
||||||
|
|
||||||
|
// star
|
||||||
|
@use './star.scss';
|
||||||
|
|
||||||
|
// vip
|
||||||
|
@use './vip.scss';
|
||||||
|
|
||||||
|
// d2
|
||||||
|
@use './d2.scss';
|
||||||
|
|
||||||
|
// bule
|
||||||
|
@use './bule.scss';
|
||||||
|
|
||||||
|
//iview
|
||||||
|
@use './iview.scss';
|
||||||
|
|
||||||
|
//go
|
||||||
|
@use 'go';
|
||||||
|
|
||||||
|
//heyui
|
||||||
|
@use './hey.scss';
|
||||||
|
|
||||||
|
//dark
|
||||||
|
@use './dark.scss';
|
||||||
|
|
||||||
|
//lte
|
||||||
|
@use 'lte';
|
||||||
|
|
||||||
|
//cool
|
||||||
|
@use './cool.scss';
|
||||||
|
|
||||||
|
//beautiful
|
||||||
|
@use './beautiful.scss';
|
||||||
87
src/styles/theme/iview.scss
Executable file
87
src/styles/theme/iview.scss
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
.theme-iview {
|
||||||
|
.avue-logo {
|
||||||
|
background: #001529;
|
||||||
|
box-shadow: none;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
padding: 5px 8px 8px 8px;
|
||||||
|
border-top-left-radius: 5px;
|
||||||
|
border-top-right-radius: 5px;
|
||||||
|
border-bottom-left-radius: 3px;
|
||||||
|
border-bottom-right-radius: 3px;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
display: inline;
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
padding: 3px 5px 5px 0;
|
||||||
|
background: #f0f0f0;
|
||||||
|
box-shadow: inset 0 0 3px 2px hsla(0, 0%, 39.2%, .1);
|
||||||
|
|
||||||
|
.is-active {
|
||||||
|
&:before {
|
||||||
|
background: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-tabs__item {
|
||||||
|
padding: 0 15px !important;
|
||||||
|
position: relative;
|
||||||
|
height: 32px !important;
|
||||||
|
line-height: 32px !important;
|
||||||
|
border: 1px solid #e8eaec !important;
|
||||||
|
color: #515a6e !important;
|
||||||
|
background: #fff !important;
|
||||||
|
border-radius: 3px;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
margin-right: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #e8eaec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background: #001529;
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
&.is-active {
|
||||||
|
background-color: #000c17;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-sub-menu {
|
||||||
|
.el-menu-item {
|
||||||
|
&.is-active {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
src/styles/theme/lte.scss
Executable file
44
src/styles/theme/lte.scss
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
.theme-lte {
|
||||||
|
.avue-logo {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
.el-tabs__item {
|
||||||
|
font-size: 12px !important;
|
||||||
|
font-weight: 500 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
background-color: #263238;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #8a979e;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #2b373d;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
&:before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
background-color: #2b373d;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
116
src/styles/theme/star.scss
Executable file
116
src/styles/theme/star.scss
Executable file
@@ -0,0 +1,116 @@
|
|||||||
|
.theme-star {
|
||||||
|
.avue-main {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-contail {
|
||||||
|
background-image: url("/img/star-squashed.jpg");
|
||||||
|
background-size: 100% 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top,
|
||||||
|
.avue-logo,
|
||||||
|
.tags-container {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-card, .error-page {
|
||||||
|
opacity: .9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tabs {
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
background-color: transparent;
|
||||||
|
border-top: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
.avue-breadcrumb {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: rgba(0, 0, 0, .4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.15);
|
||||||
|
background-color: transparent;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #fff
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: rgba(0, 0, 0, .4);
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-search {
|
||||||
|
.el-input__inner {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-webkit-input-placeholder,
|
||||||
|
textarea::-webkit-input-placeholder {
|
||||||
|
/* WebKit browsers */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-moz-placeholder,
|
||||||
|
textarea:-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 4 to 18 */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-moz-placeholder,
|
||||||
|
textarea::-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 19+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-ms-input-placeholder,
|
||||||
|
textarea:-ms-input-placeholder {
|
||||||
|
/* Internet Explorer 10+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
109
src/styles/theme/vip.scss
Executable file
109
src/styles/theme/vip.scss
Executable file
@@ -0,0 +1,109 @@
|
|||||||
|
.theme-vip {
|
||||||
|
$color: rgba(246, 202, 157, .7);
|
||||||
|
$is_active_color: #f6ca9d;
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
background-color: #20222a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown {
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
.avue-logo_title {
|
||||||
|
background-image: -webkit-gradient(linear, left top, left bottom, from($color), to($is_active_color));
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-breadcrumb {
|
||||||
|
i {
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
.el-menu-item {
|
||||||
|
&.is-active {
|
||||||
|
&:before {
|
||||||
|
background: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: $is_active_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-tags {
|
||||||
|
.el-tabs__item {
|
||||||
|
color: rgba(0, 0, 0, 0.4) !important;
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
color: $is_active_color !important;
|
||||||
|
border-color: $is_active_color !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
background: $is_active_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-search {
|
||||||
|
.el-input__inner {
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-webkit-input-placeholder,
|
||||||
|
textarea::-webkit-input-placeholder {
|
||||||
|
/* WebKit browsers */
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-moz-placeholder,
|
||||||
|
textarea:-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 4 to 18 */
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-moz-placeholder,
|
||||||
|
textarea::-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 19+ */
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-ms-input-placeholder,
|
||||||
|
textarea:-ms-input-placeholder {
|
||||||
|
/* Internet Explorer 10+ */
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
i {
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: $color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: $is_active_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
143
src/styles/theme/white.scss
Executable file
143
src/styles/theme/white.scss
Executable file
@@ -0,0 +1,143 @@
|
|||||||
|
.theme-white {
|
||||||
|
.el-menu--popup {
|
||||||
|
.el-menu-item {
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i, span {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 4px;
|
||||||
|
background: var(--el-color-primary);
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top,
|
||||||
|
.avue-logo,
|
||||||
|
.tags-container {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar--tip {
|
||||||
|
background-color: transparent;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-dropdown {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo_title {
|
||||||
|
font-weight: 400;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo_title,
|
||||||
|
.avue-breadcrumb {
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
.el-menu-item {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
i,
|
||||||
|
span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-sidebar {
|
||||||
|
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.15);
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
.el-menu-item, .el-sub-menu__title {
|
||||||
|
i, span {
|
||||||
|
color: #666
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
|
||||||
|
i, span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-search {
|
||||||
|
.el-input__inner {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-webkit-input-placeholder,
|
||||||
|
textarea::-webkit-input-placeholder {
|
||||||
|
/* WebKit browsers */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-moz-placeholder,
|
||||||
|
textarea:-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 4 to 18 */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::-moz-placeholder,
|
||||||
|
textarea::-moz-placeholder {
|
||||||
|
/* Mozilla Firefox 19+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:-ms-input-placeholder,
|
||||||
|
textarea:-ms-input-placeholder {
|
||||||
|
/* Internet Explorer 10+ */
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
i {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
143
src/styles/top.scss
Executable file
143
src/styles/top.scss
Executable file
@@ -0,0 +1,143 @@
|
|||||||
|
@use './variables.scss' as variables;
|
||||||
|
|
||||||
|
.avue-top {
|
||||||
|
position: relative;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
|
||||||
|
color: rgba(0, 0, 0, .65);
|
||||||
|
font-size: 28px;
|
||||||
|
height: variables.$top_height;
|
||||||
|
line-height: variables.$top_height;
|
||||||
|
box-sizing: border-box;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
i, span {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-breadcrumb {
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 30px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-user {
|
||||||
|
margin-left: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-menu {
|
||||||
|
.el-menu-item {
|
||||||
|
padding: 0 10px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-search {
|
||||||
|
line-height: variables.$top_height;
|
||||||
|
position: absolute !important;
|
||||||
|
right: 200px;
|
||||||
|
top: 0;
|
||||||
|
width: 300px;
|
||||||
|
|
||||||
|
.el-input__wrapper {
|
||||||
|
font-size: 13px;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__img {
|
||||||
|
margin: 0 5px;
|
||||||
|
padding: 2px;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__left,
|
||||||
|
.top-bar__right {
|
||||||
|
height: variables.$top_height;
|
||||||
|
position: absolute;
|
||||||
|
margin-top: 2px;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
|
i {
|
||||||
|
line-height: variables.$top_height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__left {
|
||||||
|
left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__right {
|
||||||
|
right: 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__item {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
height: variables.$top_height;
|
||||||
|
margin: 0 7px;
|
||||||
|
font-size: 16px;
|
||||||
|
|
||||||
|
.el-badge__content.is-fixed {
|
||||||
|
top: 12px;
|
||||||
|
right: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar__title {
|
||||||
|
height: 100%;
|
||||||
|
padding-left: 50px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: inherit;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avue-logo {
|
||||||
|
height: variables.$top_height;
|
||||||
|
line-height: variables.$top_height;
|
||||||
|
background-color: #031527;
|
||||||
|
font-size: 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-sizing: border-box;
|
||||||
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
&_title {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&_subtitle {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
src/styles/variables.scss
Executable file
3
src/styles/variables.scss
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
$sidebar_width: 230px;
|
||||||
|
$sidebar_collapse: 60px;
|
||||||
|
$top_height: 50px;
|
||||||
33
src/utils/auth.js
Executable file
33
src/utils/auth.js
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
import Cookies from 'js-cookie';
|
||||||
|
import website from '@/config/website';
|
||||||
|
|
||||||
|
const TokenKey = website.tokenKey;
|
||||||
|
const RefreshTokenKey = website.refreshTokenKey;
|
||||||
|
const SessionId = 'JSESSIONID';
|
||||||
|
const UserId = 'b-user-id';
|
||||||
|
|
||||||
|
export function getToken() {
|
||||||
|
return Cookies.get(TokenKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setToken(token) {
|
||||||
|
return Cookies.set(TokenKey, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRefreshToken() {
|
||||||
|
return Cookies.get(RefreshTokenKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setRefreshToken(token) {
|
||||||
|
return Cookies.set(RefreshTokenKey, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeToken() {
|
||||||
|
Cookies.remove(SessionId);
|
||||||
|
Cookies.remove(UserId);
|
||||||
|
return Cookies.remove(TokenKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeRefreshToken() {
|
||||||
|
return Cookies.remove(RefreshTokenKey);
|
||||||
|
}
|
||||||
94
src/utils/crypto.js
Normal file
94
src/utils/crypto.js
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
|
export default class crypto {
|
||||||
|
/**
|
||||||
|
* token加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
static cryptoKey = '请配置cryptoKey';
|
||||||
|
/**
|
||||||
|
* 报文加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
static aesKey = '请配置aesKey';
|
||||||
|
/**
|
||||||
|
* 报文加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
static desKey = '请配置desKey';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes 加密方法
|
||||||
|
* @param data
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
static encrypt(data) {
|
||||||
|
return this.encryptAES(data, this.aesKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes 解密方法
|
||||||
|
* @param data
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
static decrypt(data) {
|
||||||
|
return this.decryptAES(data, this.aesKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes 加密方法,同java:AesUtil.encryptToBase64(text, aesKey);
|
||||||
|
*/
|
||||||
|
static encryptAES(data, key) {
|
||||||
|
const dataBytes = CryptoJS.enc.Utf8.parse(data);
|
||||||
|
const keyBytes = CryptoJS.enc.Utf8.parse(key);
|
||||||
|
const encrypted = CryptoJS.AES.encrypt(dataBytes, keyBytes, {
|
||||||
|
iv: keyBytes,
|
||||||
|
mode: CryptoJS.mode.CBC,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
});
|
||||||
|
return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aes 解密方法,同java:AesUtil.decryptFormBase64ToString(encrypt, aesKey);
|
||||||
|
*/
|
||||||
|
static decryptAES(data, key) {
|
||||||
|
const keyBytes = CryptoJS.enc.Utf8.parse(key);
|
||||||
|
const decrypted = CryptoJS.AES.decrypt(data, keyBytes, {
|
||||||
|
iv: keyBytes,
|
||||||
|
mode: CryptoJS.mode.CBC,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
});
|
||||||
|
return CryptoJS.enc.Utf8.stringify(decrypted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* des 加密方法,同java:DesUtil.encryptToBase64(text, desKey)
|
||||||
|
*/
|
||||||
|
static encryptDES(data, key) {
|
||||||
|
const keyHex = CryptoJS.enc.Utf8.parse(key);
|
||||||
|
const encrypted = CryptoJS.DES.encrypt(data, keyHex, {
|
||||||
|
mode: CryptoJS.mode.ECB,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
});
|
||||||
|
return encrypted.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* des 解密方法,同java:DesUtil.decryptFormBase64(encryptBase64, desKey);
|
||||||
|
*/
|
||||||
|
static decryptDES(data, key) {
|
||||||
|
const keyHex = CryptoJS.enc.Utf8.parse(key);
|
||||||
|
const decrypted = CryptoJS.DES.decrypt(
|
||||||
|
{
|
||||||
|
ciphertext: CryptoJS.enc.Base64.parse(data),
|
||||||
|
},
|
||||||
|
keyHex,
|
||||||
|
{
|
||||||
|
mode: CryptoJS.mode.ECB,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/utils/date.js
Normal file
58
src/utils/date.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
export const calcDate = (date1, date2) => {
|
||||||
|
let date3 = date2 - date1;
|
||||||
|
|
||||||
|
let days = Math.floor(date3 / (24 * 3600 * 1000));
|
||||||
|
|
||||||
|
let leave1 = date3 % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
|
||||||
|
let hours = Math.floor(leave1 / (3600 * 1000));
|
||||||
|
|
||||||
|
let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
|
||||||
|
let minutes = Math.floor(leave2 / (60 * 1000));
|
||||||
|
|
||||||
|
let leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
|
||||||
|
let seconds = Math.round(date3 / 1000);
|
||||||
|
return {
|
||||||
|
leave1,
|
||||||
|
leave2,
|
||||||
|
leave3,
|
||||||
|
days: days,
|
||||||
|
hours: hours,
|
||||||
|
minutes: minutes,
|
||||||
|
seconds: seconds,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日期格式化
|
||||||
|
*/
|
||||||
|
export function dateFormat(date, format) {
|
||||||
|
format = format || 'yyyy-MM-dd hh:mm:ss';
|
||||||
|
if (date !== 'Invalid Date') {
|
||||||
|
let o = {
|
||||||
|
'M+': date.getMonth() + 1, //month
|
||||||
|
'd+': date.getDate(), //day
|
||||||
|
'h+': date.getHours(), //hour
|
||||||
|
'm+': date.getMinutes(), //minute
|
||||||
|
's+': date.getSeconds(), //second
|
||||||
|
'q+': Math.floor((date.getMonth() + 3) / 3), //quarter
|
||||||
|
S: date.getMilliseconds(), //millisecond
|
||||||
|
};
|
||||||
|
if (/(y+)/.test(format))
|
||||||
|
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
||||||
|
for (let k in o)
|
||||||
|
if (new RegExp('(' + k + ')').test(format))
|
||||||
|
format = format.replace(
|
||||||
|
RegExp.$1,
|
||||||
|
RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
|
||||||
|
);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前时间戳
|
||||||
|
*/
|
||||||
|
export function dateNow() {
|
||||||
|
return dateFormat(new Date(), 'yyyyMMddhhmmss');
|
||||||
|
}
|
||||||
20
src/utils/flow.js
Normal file
20
src/utils/flow.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* 工作流统一分类格式
|
||||||
|
* @param category 分类字典号
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
export function flowCategory(category) {
|
||||||
|
return `flow_${category}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据key获取流程路由
|
||||||
|
* @param routes
|
||||||
|
* @param key
|
||||||
|
*/
|
||||||
|
export function flowRoute(routes, key) {
|
||||||
|
const data = routes.filter(d => {
|
||||||
|
return d.routeKey === key;
|
||||||
|
});
|
||||||
|
return data.length === 0 ? [] : data[0].routeValue;
|
||||||
|
}
|
||||||
46
src/utils/formatter.js
Normal file
46
src/utils/formatter.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import {validatenull} from "@/utils/validate";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化工具类
|
||||||
|
*/
|
||||||
|
export default class formatter {
|
||||||
|
static prettyCode(str) {
|
||||||
|
try {
|
||||||
|
// 为空则返回空
|
||||||
|
if (validatenull(str)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// 解析并格式化JSON字符串
|
||||||
|
str = JSON.stringify(JSON.parse(str), null, 2);
|
||||||
|
|
||||||
|
// 先处理 < 符号,然后特殊处理 > 符号
|
||||||
|
// 处理所有 < 符号(因为 <- 中的 < 转换不影响显示)
|
||||||
|
str = str.replace(/</g, '<');
|
||||||
|
|
||||||
|
// 只处理不是箭头的 > 符号
|
||||||
|
// 将所有 > 替换,但排除 -> 的情况
|
||||||
|
str = str.replace(/([^-])>/g, '$1>');
|
||||||
|
// 处理行首的 > 符号
|
||||||
|
str = str.replace(/^>/gm, '>');
|
||||||
|
|
||||||
|
// 返回格式化的字符串,并添加样式类
|
||||||
|
return str.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
||||||
|
let cls = 'number';
|
||||||
|
if (/^"/.test(match)) {
|
||||||
|
if (/:$/.test(match)) {
|
||||||
|
cls = 'key';
|
||||||
|
} else {
|
||||||
|
cls = 'string';
|
||||||
|
}
|
||||||
|
} else if (/true|false/.test(match)) {
|
||||||
|
cls = 'boolean';
|
||||||
|
} else if (/null/.test(match)) {
|
||||||
|
cls = 'null';
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
310
src/utils/func.js
Normal file
310
src/utils/func.js
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
/**
|
||||||
|
* 通用工具类
|
||||||
|
*/
|
||||||
|
export default class func {
|
||||||
|
/**
|
||||||
|
* 不为空
|
||||||
|
* @param val
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
static notEmpty(val) {
|
||||||
|
return !this.isEmpty(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为定义
|
||||||
|
* @param val
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
static isUndefined(val) {
|
||||||
|
return val === null || typeof val === 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为空
|
||||||
|
* @param val
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
static isEmpty(val) {
|
||||||
|
if (
|
||||||
|
val === null ||
|
||||||
|
typeof val === 'undefined' ||
|
||||||
|
(typeof val === 'string' && val === '' && val !== 'undefined')
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强转int型
|
||||||
|
* @param val
|
||||||
|
* @param defaultValue
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
static toInt(val, defaultValue) {
|
||||||
|
if (this.isEmpty(val)) {
|
||||||
|
return defaultValue === undefined ? -1 : defaultValue;
|
||||||
|
}
|
||||||
|
const num = parseInt(val, 0);
|
||||||
|
return Number.isNaN(num) ? (defaultValue === undefined ? -1 : defaultValue) : num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转为数字型(转换失败则返回原值)
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
|
static toNumber(val) {
|
||||||
|
if (this.isEmpty(val)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
const num = parseFloat(val);
|
||||||
|
return Number.isNaN(num) ? val : num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Json强转为Form类型
|
||||||
|
* @param obj
|
||||||
|
* @returns {FormData}
|
||||||
|
*/
|
||||||
|
static toFormData(obj) {
|
||||||
|
const data = new FormData();
|
||||||
|
Object.keys(obj).forEach(key => {
|
||||||
|
data.append(key, Array.isArray(obj[key]) ? obj[key].join(',') : obj[key]);
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* date类转为字符串格式
|
||||||
|
* @param date
|
||||||
|
* @param format
|
||||||
|
* @returns {null}
|
||||||
|
*/
|
||||||
|
static format(date, format = 'YYYY-MM-DD HH:mm:ss') {
|
||||||
|
return date ? date.format(format) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data类格式化
|
||||||
|
* @param timestamp
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static formatDateTime(timestamp) {
|
||||||
|
return this.formatDate(new Date(timestamp));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data类格式化
|
||||||
|
* @param date
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static formatDate(date) {
|
||||||
|
const pad = num => (num < 10 ? '0' + num : num);
|
||||||
|
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = pad(date.getMonth() + 1); // 月份从0开始,所以+1
|
||||||
|
const day = pad(date.getDate());
|
||||||
|
const hour = pad(date.getHours());
|
||||||
|
const minute = pad(date.getMinutes());
|
||||||
|
const second = pad(date.getSeconds());
|
||||||
|
|
||||||
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化时区解决时间差问题
|
||||||
|
* @param datetime
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static toLocalISOString(datetime) {
|
||||||
|
let timezoneOffset = datetime.getTimezoneOffset() * 60000; // 获取当前时区与UTC的时间差(以毫秒为单位)
|
||||||
|
let localDatetime = new Date(datetime - timezoneOffset); // 调整时间,得到当前时区时间
|
||||||
|
return localDatetime.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据逗号联合
|
||||||
|
* @param arr
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static join(arr) {
|
||||||
|
return Array.isArray(arr) ? arr.join(',') : arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据逗号分隔
|
||||||
|
* @param str
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static split(str) {
|
||||||
|
return str ? String(str).split(',') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换空字符串
|
||||||
|
* @param str
|
||||||
|
* @returns {string|*}
|
||||||
|
*/
|
||||||
|
static toStr(str) {
|
||||||
|
if (typeof str === 'undefined' || str === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为数组
|
||||||
|
* @param param
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
static isArrayAndNotEmpty(param) {
|
||||||
|
return Array.isArray(param) && param.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化URL
|
||||||
|
* @param url
|
||||||
|
* @returns {*|string}
|
||||||
|
*/
|
||||||
|
static formatUrl(url) {
|
||||||
|
if (!url) return url;
|
||||||
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||||
|
return url;
|
||||||
|
} else {
|
||||||
|
return `http://${url}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bytes转换为kb单位
|
||||||
|
* @param bytes
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static bytesToKB(bytes) {
|
||||||
|
const kb = bytes / 1024;
|
||||||
|
return kb.toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* json数组转换成key value字符串
|
||||||
|
* @param jsonArray "[{enumKey: 'key', enumValue: 'value'}]"
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
static jsonArrayToKeyValue(jsonArray) {
|
||||||
|
if (this.isEmpty(jsonArray)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return jsonArray.map(item => `${item.enumKey}:${item.enumValue}`).join(';');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* key value字符串转换成json数组
|
||||||
|
* @param keyValue key:value;key:value
|
||||||
|
* @returns {*[]}
|
||||||
|
*/
|
||||||
|
static keyValueToJsonArray(keyValue) {
|
||||||
|
if (this.isEmpty(keyValue)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return keyValue.split(';').map((kv, index) => {
|
||||||
|
const [key, value] = kv.split(':');
|
||||||
|
return {
|
||||||
|
id: index,
|
||||||
|
enumKey: key,
|
||||||
|
enumValue: value,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查字符串str中是否包含子字符串val
|
||||||
|
* @param {string} str 要检查的字符串
|
||||||
|
* @param {string} val 要查找的子字符串
|
||||||
|
* @return {boolean} 如果str包含val则返回true,否则返回false
|
||||||
|
*/
|
||||||
|
static contains(str, val) {
|
||||||
|
// 检查str是否为字符串且不为空
|
||||||
|
if (typeof str === 'string' && str.length > 0) {
|
||||||
|
return str.includes(val);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 截取字符串
|
||||||
|
* @param str 字符串
|
||||||
|
* @param len 截取长度
|
||||||
|
* @returns {*|string}
|
||||||
|
*/
|
||||||
|
static truncateString(str, len = 20) {
|
||||||
|
if (str.length > len) {
|
||||||
|
return str.slice(0, len) + '...';
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驼峰转下划线
|
||||||
|
* @param str
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
static camelCaseString(str) {
|
||||||
|
return str.replace(/_([a-z])/g, g => g[1].toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成随机字符串
|
||||||
|
* @param length 长度
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static strGenerate(length) {
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const maxLength = 256;
|
||||||
|
if (length > maxLength) {
|
||||||
|
throw new Error(`长度最大值不能超过 ${maxLength}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from({ length }, () =>
|
||||||
|
characters.charAt(Math.floor(Math.random() * characters.length))
|
||||||
|
).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成UUID
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static generateUUID() {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
|
const r = (Math.random() * 16) | 0,
|
||||||
|
v = c === 'x' ? r : (r & 0x3) | 0x8;
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤空对象
|
||||||
|
* @param obj
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
static filterEmptyObject(obj) {
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(obj).filter(
|
||||||
|
([, value]) => value !== '' && value !== null && value !== undefined
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户租户ID
|
||||||
|
* @param userInfo
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
static getUserTenantId(userInfo) {
|
||||||
|
if (userInfo && userInfo.tenant_id) {
|
||||||
|
return userInfo.tenant_id;
|
||||||
|
} else if (userInfo && userInfo.tenantId) {
|
||||||
|
return userInfo.tenantId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/utils/module.js
Normal file
39
src/utils/module.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
let flowInstance = null;
|
||||||
|
let formInstance = null;
|
||||||
|
let formDesignInstance = null;
|
||||||
|
|
||||||
|
export function loadFlowModule(app) {
|
||||||
|
if (!flowInstance) {
|
||||||
|
flowInstance = import('@saber/nf-design-base-elp')
|
||||||
|
.then(module => {
|
||||||
|
app.use(module.default);
|
||||||
|
return module;
|
||||||
|
})
|
||||||
|
.catch(error => console.error('failed to load module:', error));
|
||||||
|
}
|
||||||
|
return flowInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadFormModule(app) {
|
||||||
|
if (!formInstance) {
|
||||||
|
formInstance = import('@saber/nf-form-elp')
|
||||||
|
.then(module => {
|
||||||
|
app.use(module.default);
|
||||||
|
return module;
|
||||||
|
})
|
||||||
|
.catch(error => console.error('failed to load module:', error));
|
||||||
|
}
|
||||||
|
return formInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadFormDesignModule(app) {
|
||||||
|
if (!formDesignInstance) {
|
||||||
|
formDesignInstance = import('@saber/nf-form-design-elp')
|
||||||
|
.then(module => {
|
||||||
|
app.use(module.default);
|
||||||
|
return module;
|
||||||
|
})
|
||||||
|
.catch(error => console.error('failed to load module:', error));
|
||||||
|
}
|
||||||
|
return formDesignInstance;
|
||||||
|
}
|
||||||
81
src/utils/sensitive.js
Normal file
81
src/utils/sensitive.js
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
export const sensitive = {
|
||||||
|
/**
|
||||||
|
* 初始化敏感数据管理器
|
||||||
|
* @param {Object} config 配置项
|
||||||
|
* @param {Array} config.fields 需要脱敏的字段列表
|
||||||
|
* @returns {Object} 敏感数据管理器实例
|
||||||
|
*/
|
||||||
|
create(config = {}) {
|
||||||
|
const sensitiveFields = config.fields || [];
|
||||||
|
let initialMaskedData = {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* 保存初始的脱敏数据
|
||||||
|
* @param {Object} data 包含脱敏数据的对象
|
||||||
|
*/
|
||||||
|
saveInitialData(data) {
|
||||||
|
initialMaskedData = {};
|
||||||
|
sensitiveFields.forEach(field => {
|
||||||
|
if (data[field]) {
|
||||||
|
initialMaskedData[field] = data[field];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取要提交的数据,过滤掉未修改的敏感字段
|
||||||
|
* @param {Object} formData 表单数据
|
||||||
|
* @returns {Object} 过滤后的提交数据
|
||||||
|
*/
|
||||||
|
getSubmitData(formData) {
|
||||||
|
const submitData = { ...formData };
|
||||||
|
|
||||||
|
sensitiveFields.forEach(field => {
|
||||||
|
// 如果敏感字段的值与初始值相同,删除该字段
|
||||||
|
if (submitData[field] === initialMaskedData[field]) {
|
||||||
|
delete submitData[field];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return submitData;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新脱敏数据
|
||||||
|
* @param {Object} newMaskedData 新的脱敏数据
|
||||||
|
*/
|
||||||
|
updateMaskedData(newMaskedData) {
|
||||||
|
Object.assign(initialMaskedData, newMaskedData);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断敏感数据是否被修改
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isModified(formData) {
|
||||||
|
return sensitiveFields.some(field => formData[field] !== initialMaskedData[field]);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取已修改的敏感字段列表
|
||||||
|
* @returns {Array}
|
||||||
|
*/
|
||||||
|
getModifiedFields(formData) {
|
||||||
|
return sensitiveFields.filter(field => formData[field] !== initialMaskedData[field]);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置为初始状态
|
||||||
|
* @param {Object} formData 表单数据对象
|
||||||
|
*/
|
||||||
|
reset(formData) {
|
||||||
|
sensitiveFields.forEach(field => {
|
||||||
|
if (initialMaskedData[field]) {
|
||||||
|
formData[field] = initialMaskedData[field];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
15
src/utils/sm2.js
Normal file
15
src/utils/sm2.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import website from '@/config/website';
|
||||||
|
import smCrypto from 'sm-crypto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sm2 加密方法
|
||||||
|
* @param data
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export function encrypt(data) {
|
||||||
|
try {
|
||||||
|
return smCrypto.sm2.doEncrypt(data, website.oauth2.publicKey, 0);
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
103
src/utils/store.js
Executable file
103
src/utils/store.js
Executable file
@@ -0,0 +1,103 @@
|
|||||||
|
import { validatenull } from 'utils/validate';
|
||||||
|
import website from '@/config/website';
|
||||||
|
|
||||||
|
const keyName = website.key + '-';
|
||||||
|
/**
|
||||||
|
* 存储localStorage
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const getStore = (params = {}) => {
|
||||||
|
let { name, debug } = params;
|
||||||
|
name = keyName + name;
|
||||||
|
let obj = {},
|
||||||
|
content;
|
||||||
|
obj = window.sessionStorage.getItem(name);
|
||||||
|
if (validatenull(obj)) obj = window.localStorage.getItem(name);
|
||||||
|
if (validatenull(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
|
||||||
|
*/
|
||||||
|
export const removeStore = (params = {}) => {
|
||||||
|
let { name, type } = params;
|
||||||
|
name = keyName + name;
|
||||||
|
if (type) {
|
||||||
|
window.sessionStorage.removeItem(name);
|
||||||
|
} else {
|
||||||
|
window.localStorage.removeItem(name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取全部localStorage
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
export const clearStore = (params = {}) => {
|
||||||
|
let { type } = params;
|
||||||
|
if (type) {
|
||||||
|
window.sessionStorage.clear();
|
||||||
|
} else {
|
||||||
|
window.localStorage.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
434
src/utils/util.js
Executable file
434
src/utils/util.js
Executable file
@@ -0,0 +1,434 @@
|
|||||||
|
import { validatenull } from './validate';
|
||||||
|
import sha256 from 'crypto-js/sha256';
|
||||||
|
import Base64 from 'crypto-js/enc-base64';
|
||||||
|
//表单序列化
|
||||||
|
export const serialize = data => {
|
||||||
|
let list = [];
|
||||||
|
Object.keys(data).forEach(ele => {
|
||||||
|
list.push(`${ele}=${data[ele]}`);
|
||||||
|
});
|
||||||
|
return list.join('&');
|
||||||
|
};
|
||||||
|
export const getObjType = obj => {
|
||||||
|
var toString = Object.prototype.toString;
|
||||||
|
var map = {
|
||||||
|
'[object Boolean]': 'boolean',
|
||||||
|
'[object Number]': 'number',
|
||||||
|
'[object String]': 'string',
|
||||||
|
'[object Function]': 'function',
|
||||||
|
'[object Array]': 'array',
|
||||||
|
'[object Date]': 'date',
|
||||||
|
'[object RegExp]': 'regExp',
|
||||||
|
'[object Undefined]': 'undefined',
|
||||||
|
'[object Null]': 'null',
|
||||||
|
'[object Object]': 'object',
|
||||||
|
};
|
||||||
|
if (obj instanceof Element) {
|
||||||
|
return 'element';
|
||||||
|
}
|
||||||
|
return map[toString.call(obj)];
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 对象深拷贝
|
||||||
|
*/
|
||||||
|
export const deepClone = data => {
|
||||||
|
var type = getObjType(data);
|
||||||
|
var obj;
|
||||||
|
if (type === 'array') {
|
||||||
|
obj = [];
|
||||||
|
} else if (type === 'object') {
|
||||||
|
obj = {};
|
||||||
|
} else {
|
||||||
|
//不再具有下一层次
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
if (type === 'array') {
|
||||||
|
for (var i = 0, len = data.length; i < len; i++) {
|
||||||
|
obj.push(deepClone(data[i]));
|
||||||
|
}
|
||||||
|
} else if (type === 'object') {
|
||||||
|
for (var key in data) {
|
||||||
|
obj[key] = deepClone(data[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 设置灰度模式
|
||||||
|
*/
|
||||||
|
export const toggleGrayMode = status => {
|
||||||
|
if (status) {
|
||||||
|
document.body.className = document.body.className + ' grayMode';
|
||||||
|
} else {
|
||||||
|
document.body.className = document.body.className.replace(' grayMode', '');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 设置主题
|
||||||
|
*/
|
||||||
|
export const setTheme = name => {
|
||||||
|
document.body.className = name;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密处理
|
||||||
|
*/
|
||||||
|
export const encryption = params => {
|
||||||
|
let { data = {}, type, param, key } = params;
|
||||||
|
let result = JSON.parse(JSON.stringify(data));
|
||||||
|
if (type == 'Base64') {
|
||||||
|
param.forEach(ele => {
|
||||||
|
result[ele] = Base64.stringify(result[ele]);
|
||||||
|
});
|
||||||
|
} else if (type == 'Aes') {
|
||||||
|
param.forEach(ele => {
|
||||||
|
result[ele] = sha256(result[ele], key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览器判断是否全屏
|
||||||
|
*/
|
||||||
|
export const fullscreenToggel = () => {
|
||||||
|
if (fullscreenEnable()) {
|
||||||
|
exitFullScreen();
|
||||||
|
} else {
|
||||||
|
reqFullScreen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* esc监听全屏
|
||||||
|
*/
|
||||||
|
export const listenfullscreen = callback => {
|
||||||
|
function listen() {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('fullscreenchange', function () {
|
||||||
|
listen();
|
||||||
|
});
|
||||||
|
document.addEventListener('mozfullscreenchange', function () {
|
||||||
|
listen();
|
||||||
|
});
|
||||||
|
document.addEventListener('webkitfullscreenchange', function () {
|
||||||
|
listen();
|
||||||
|
});
|
||||||
|
document.addEventListener('msfullscreenchange', function () {
|
||||||
|
listen();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 浏览器判断是否全屏
|
||||||
|
*/
|
||||||
|
export const fullscreenEnable = () => {
|
||||||
|
var isFullscreen =
|
||||||
|
document.isFullScreen || document.mozIsFullScreen || document.webkitIsFullScreen;
|
||||||
|
return isFullscreen;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览器全屏
|
||||||
|
*/
|
||||||
|
export const reqFullScreen = () => {
|
||||||
|
if (document.documentElement.requestFullScreen) {
|
||||||
|
document.documentElement.requestFullScreen();
|
||||||
|
} else if (document.documentElement.webkitRequestFullScreen) {
|
||||||
|
document.documentElement.webkitRequestFullScreen();
|
||||||
|
} else if (document.documentElement.mozRequestFullScreen) {
|
||||||
|
document.documentElement.mozRequestFullScreen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 浏览器退出全屏
|
||||||
|
*/
|
||||||
|
export const exitFullScreen = () => {
|
||||||
|
if (document.documentElement.requestFullScreen) {
|
||||||
|
document.exitFullScreen();
|
||||||
|
} else if (document.documentElement.webkitRequestFullScreen) {
|
||||||
|
document.webkitCancelFullScreen();
|
||||||
|
} else if (document.documentElement.mozRequestFullScreen) {
|
||||||
|
document.mozCancelFullScreen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 递归寻找子类的父类
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const findParent = (menu, id) => {
|
||||||
|
for (let i = 0; i < menu.length; i++) {
|
||||||
|
if (menu[i].children.length != 0) {
|
||||||
|
for (let j = 0; j < menu[i].children.length; j++) {
|
||||||
|
if (menu[i].children[j].id == id) {
|
||||||
|
return menu[i];
|
||||||
|
} else {
|
||||||
|
if (menu[i].children[j].children.length != 0) {
|
||||||
|
return findParent(menu[i].children[j].children, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 判断2个对象属性和值是否相等
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动态插入css
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const loadStyle = url => {
|
||||||
|
const link = document.createElement('link');
|
||||||
|
link.type = 'text/css';
|
||||||
|
link.rel = 'stylesheet';
|
||||||
|
link.href = url;
|
||||||
|
const head = document.getElementsByTagName('head')[0];
|
||||||
|
head.appendChild(link);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 判断路由是否相等
|
||||||
|
*/
|
||||||
|
export const diff = (obj1, obj2) => {
|
||||||
|
delete obj1.close;
|
||||||
|
var o1 = obj1 instanceof Object;
|
||||||
|
var o2 = obj2 instanceof Object;
|
||||||
|
if (!o1 || !o2) {
|
||||||
|
/* 判断不是对象 */
|
||||||
|
return obj1 === obj2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
||||||
|
return false;
|
||||||
|
//Object.keys() 返回一个由对象的自身可枚举属性(key值)组成的数组,例如:数组返回下表:let arr = ["a", "b", "c"];console.log(Object.keys(arr))->0,1,2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var attr in obj1) {
|
||||||
|
var t1 = obj1[attr] instanceof Object;
|
||||||
|
var t2 = obj2[attr] instanceof Object;
|
||||||
|
if (t1 && t2) {
|
||||||
|
return diff(obj1[attr], obj2[attr]);
|
||||||
|
} else if (obj1[attr] !== obj2[attr]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 根据字典的value显示label
|
||||||
|
*/
|
||||||
|
export const findByvalue = (dic, value) => {
|
||||||
|
let result = '';
|
||||||
|
if (validatenull(dic)) return value;
|
||||||
|
if (typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean') {
|
||||||
|
let index = 0;
|
||||||
|
index = findArray(dic, value);
|
||||||
|
if (index != -1) {
|
||||||
|
result = dic[index].label;
|
||||||
|
} else {
|
||||||
|
result = value;
|
||||||
|
}
|
||||||
|
} else if (value instanceof Array) {
|
||||||
|
result = [];
|
||||||
|
let index = 0;
|
||||||
|
value.forEach(ele => {
|
||||||
|
index = findArray(dic, ele);
|
||||||
|
if (index != -1) {
|
||||||
|
result.push(dic[index].label);
|
||||||
|
} else {
|
||||||
|
result.push(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result = result.toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 根据字典的value查找对应的index
|
||||||
|
*/
|
||||||
|
export const findArray = (dic, value) => {
|
||||||
|
for (let i = 0; i < dic.length; i++) {
|
||||||
|
if (dic[i].value == value) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 生成随机len位数字
|
||||||
|
*/
|
||||||
|
export const randomLenNum = (len, date) => {
|
||||||
|
let random = '';
|
||||||
|
random = Math.ceil(Math.random() * 100000000000000)
|
||||||
|
.toString()
|
||||||
|
.substr(0, len ? len : 4);
|
||||||
|
if (date) random = random + Date.now();
|
||||||
|
return random;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 打开小窗口
|
||||||
|
*/
|
||||||
|
export const openWindow = (url, title, w, h) => {
|
||||||
|
// Fixes dual-screen position Most browsers Firefox
|
||||||
|
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
|
||||||
|
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
|
||||||
|
|
||||||
|
const width = window.innerWidth
|
||||||
|
? window.innerWidth
|
||||||
|
: document.documentElement.clientWidth
|
||||||
|
? document.documentElement.clientWidth
|
||||||
|
: screen.width;
|
||||||
|
const height = window.innerHeight
|
||||||
|
? window.innerHeight
|
||||||
|
: document.documentElement.clientHeight
|
||||||
|
? document.documentElement.clientHeight
|
||||||
|
: screen.height;
|
||||||
|
|
||||||
|
const left = width / 2 - w / 2 + dualScreenLeft;
|
||||||
|
const top = height / 2 - h / 2 + dualScreenTop;
|
||||||
|
const newWindow = window.open(
|
||||||
|
url,
|
||||||
|
title,
|
||||||
|
'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' +
|
||||||
|
w +
|
||||||
|
', height=' +
|
||||||
|
h +
|
||||||
|
', top=' +
|
||||||
|
top +
|
||||||
|
', left=' +
|
||||||
|
left
|
||||||
|
);
|
||||||
|
|
||||||
|
// Puts focus on the newWindow
|
||||||
|
if (window.focus) {
|
||||||
|
newWindow.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getScreen = isCollapse => {
|
||||||
|
if (document.body.clientWidth <= 768) {
|
||||||
|
return !isCollapse;
|
||||||
|
} else {
|
||||||
|
return isCollapse;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取顶部地址栏地址
|
||||||
|
*/
|
||||||
|
export const getTopUrl = () => {
|
||||||
|
return window.location.origin;
|
||||||
|
// return window.location.href.split('/#/')[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取url参数
|
||||||
|
* @param name 参数名
|
||||||
|
*/
|
||||||
|
export const getQueryString = name => {
|
||||||
|
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
|
||||||
|
let r = window.location.search.substr(1).match(reg);
|
||||||
|
if (r != null) return unescape(decodeURI(r[2]));
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
* @param {String} path - 文件地址
|
||||||
|
* @param {String} name - 文件名,eg: test.png
|
||||||
|
*/
|
||||||
|
export const downloadFileBlob = (path, name) => {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('get', path);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send();
|
||||||
|
xhr.onload = function () {
|
||||||
|
if (this.status === 200 || this.status === 304) {
|
||||||
|
// 如果是IE10及以上,不支持download属性,采用msSaveOrOpenBlob方法,但是IE10以下也不支持msSaveOrOpenBlob
|
||||||
|
if ('msSaveOrOpenBlob' in navigator) {
|
||||||
|
navigator.msSaveOrOpenBlob(this.response, name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const url = URL.createObjectURL(this.response);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = url;
|
||||||
|
a.download = name;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
* @param {String} path - 文件地址
|
||||||
|
* @param {String} name - 文件名,eg: test.png
|
||||||
|
*/
|
||||||
|
export const downloadFileBase64 = (path, name) => {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('get', path);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send();
|
||||||
|
xhr.onload = function () {
|
||||||
|
if (this.status === 200 || this.status === 304) {
|
||||||
|
const fileReader = new FileReader();
|
||||||
|
fileReader.readAsDataURL(this.response);
|
||||||
|
fileReader.onload = function () {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = this.result;
|
||||||
|
a.download = name;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载excel
|
||||||
|
* @param {blob} fileArrayBuffer 文件流
|
||||||
|
* @param {String} filename 文件名称
|
||||||
|
*/
|
||||||
|
export const downloadXls = (fileArrayBuffer, filename) => {
|
||||||
|
downloadFile(fileArrayBuffer, filename, 'application/vnd.ms-excel,charset=utf-8');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载json
|
||||||
|
* @param {blob} fileArrayBuffer 文件流
|
||||||
|
* @param {String} filename 文件名称
|
||||||
|
*/
|
||||||
|
export const downloadJson = (fileArrayBuffer, filename) => {
|
||||||
|
downloadFile(fileArrayBuffer, filename, 'application/json,charset=utf-8');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
* @param fileArrayBuffer 文件流
|
||||||
|
* @param filename 文件名
|
||||||
|
* @param mimeType 文件类型
|
||||||
|
*/
|
||||||
|
export const downloadFile = (fileArrayBuffer, filename, mimeType = 'application/octet-stream') => {
|
||||||
|
let data = new Blob([fileArrayBuffer], { type: mimeType });
|
||||||
|
if (typeof window.chrome !== 'undefined') {
|
||||||
|
// Chrome
|
||||||
|
let link = document.createElement('a');
|
||||||
|
link.href = window.URL.createObjectURL(data);
|
||||||
|
link.download = filename;
|
||||||
|
link.click();
|
||||||
|
} else if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
||||||
|
// IE
|
||||||
|
let blob = new Blob([data], { type: 'application/force-download' });
|
||||||
|
window.navigator.msSaveBlob(blob, filename);
|
||||||
|
} else {
|
||||||
|
// Firefox
|
||||||
|
let file = new File([data], filename, { type: 'application/force-download' });
|
||||||
|
window.open(URL.createObjectURL(file));
|
||||||
|
}
|
||||||
|
};
|
||||||
285
src/utils/validate.js
Executable file
285
src/utils/validate.js
Executable file
@@ -0,0 +1,285 @@
|
|||||||
|
/**
|
||||||
|
* Created by jiachenpan on 16/11/18.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function isvalidUsername(str) {
|
||||||
|
const valid_map = ['admin', 'editor'];
|
||||||
|
return valid_map.indexOf(str.trim()) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 合法uri*/
|
||||||
|
export function validateURL(textval) {
|
||||||
|
const urlregex =
|
||||||
|
/^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
|
||||||
|
return urlregex.test(textval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
* @param {*} s
|
||||||
|
*/
|
||||||
|
export function isEmail(s) {
|
||||||
|
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
* @param {*} s
|
||||||
|
*/
|
||||||
|
export function isMobile(s) {
|
||||||
|
return /^1[0-9]{10}$/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电话号码
|
||||||
|
* @param {*} s
|
||||||
|
*/
|
||||||
|
export function isPhone(s) {
|
||||||
|
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL地址
|
||||||
|
* @param {*} s
|
||||||
|
*/
|
||||||
|
export function isURL(s) {
|
||||||
|
return /^http[s]?:\/\/.*/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 小写字母*/
|
||||||
|
export function validateLowerCase(str) {
|
||||||
|
const reg = /^[a-z]+$/;
|
||||||
|
return reg.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 大写字母*/
|
||||||
|
export function validateUpperCase(str) {
|
||||||
|
const reg = /^[A-Z]+$/;
|
||||||
|
return reg.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 大小写字母*/
|
||||||
|
export function validatAlphabets(str) {
|
||||||
|
const reg = /^[A-Za-z]+$/;
|
||||||
|
return reg.test(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*验证pad还是pc*/
|
||||||
|
export const vaildatePc = function () {
|
||||||
|
const userAgentInfo = navigator.userAgent;
|
||||||
|
const Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
|
||||||
|
let flag = true;
|
||||||
|
for (var v = 0; v < Agents.length; v++) {
|
||||||
|
if (userAgentInfo.indexOf(Agents[v]) > 0) {
|
||||||
|
flag = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validate email
|
||||||
|
* @param email
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
export function validateEmail(email) {
|
||||||
|
const re =
|
||||||
|
/^(([^<>()\\[\]\\.,;:\s@"]+(\.[^<>()\\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
return re.test(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断身份证号码
|
||||||
|
*/
|
||||||
|
export function cardid(code) {
|
||||||
|
let list = [];
|
||||||
|
let result = true;
|
||||||
|
let msg = '';
|
||||||
|
var city = {
|
||||||
|
11: '北京',
|
||||||
|
12: '天津',
|
||||||
|
13: '河北',
|
||||||
|
14: '山西',
|
||||||
|
15: '内蒙古',
|
||||||
|
21: '辽宁',
|
||||||
|
22: '吉林',
|
||||||
|
23: '黑龙江 ',
|
||||||
|
31: '上海',
|
||||||
|
32: '江苏',
|
||||||
|
33: '浙江',
|
||||||
|
34: '安徽',
|
||||||
|
35: '福建',
|
||||||
|
36: '江西',
|
||||||
|
37: '山东',
|
||||||
|
41: '河南',
|
||||||
|
42: '湖北 ',
|
||||||
|
43: '湖南',
|
||||||
|
44: '广东',
|
||||||
|
45: '广西',
|
||||||
|
46: '海南',
|
||||||
|
50: '重庆',
|
||||||
|
51: '四川',
|
||||||
|
52: '贵州',
|
||||||
|
53: '云南',
|
||||||
|
54: '西藏 ',
|
||||||
|
61: '陕西',
|
||||||
|
62: '甘肃',
|
||||||
|
63: '青海',
|
||||||
|
64: '宁夏',
|
||||||
|
65: '新疆',
|
||||||
|
71: '台湾',
|
||||||
|
81: '香港',
|
||||||
|
82: '澳门',
|
||||||
|
91: '国外 ',
|
||||||
|
};
|
||||||
|
if (!validatenull(code)) {
|
||||||
|
if (code.length === 18) {
|
||||||
|
if (!code || !/(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(code)) {
|
||||||
|
msg = '证件号码格式错误';
|
||||||
|
} else if (!city[code.substr(0, 2)]) {
|
||||||
|
msg = '地址编码错误';
|
||||||
|
} else {
|
||||||
|
//18位身份证需要验证最后一位校验位
|
||||||
|
code = code.split('');
|
||||||
|
//∑(ai×Wi)(mod 11)
|
||||||
|
//加权因子
|
||||||
|
var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
|
||||||
|
//校验位
|
||||||
|
var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2, 'x'];
|
||||||
|
var sum = 0;
|
||||||
|
var ai = 0;
|
||||||
|
var wi = 0;
|
||||||
|
for (var i = 0; i < 17; i++) {
|
||||||
|
ai = code[i];
|
||||||
|
wi = factor[i];
|
||||||
|
sum += ai * wi;
|
||||||
|
}
|
||||||
|
if (parity[sum % 11] !== code[17]) {
|
||||||
|
msg = '证件号码校验位错误';
|
||||||
|
} else {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg = '证件号码长度不为18位';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg = '证件号码不能为空';
|
||||||
|
}
|
||||||
|
list.push(result);
|
||||||
|
list.push(msg);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断手机号码是否正确
|
||||||
|
*/
|
||||||
|
export function isvalidatemobile(phone) {
|
||||||
|
let list = [];
|
||||||
|
let result = true;
|
||||||
|
let msg = '';
|
||||||
|
var isPhone = /^0\d{2,3}-?\d{7,8}$/;
|
||||||
|
//增加134 减少|1349[0-9]{7},增加181,增加145,增加17[678]
|
||||||
|
if (!validatenull(phone)) {
|
||||||
|
if (phone.length === 11) {
|
||||||
|
if (isPhone.test(phone)) {
|
||||||
|
msg = '手机号码格式不正确';
|
||||||
|
} else {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg = '手机号码长度不为11位';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
msg = '手机号码不能为空';
|
||||||
|
}
|
||||||
|
list.push(result);
|
||||||
|
list.push(msg);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断姓名是否正确
|
||||||
|
*/
|
||||||
|
export function validatename(name) {
|
||||||
|
var regName = /^[\u4e00-\u9fa5]{2,4}$/;
|
||||||
|
if (!regName.test(name)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为整数
|
||||||
|
*/
|
||||||
|
export function validatenum(num, type) {
|
||||||
|
let regName = /[^\d.]/g;
|
||||||
|
if (type === 1) {
|
||||||
|
if (!regName.test(num)) return false;
|
||||||
|
} else if (type === 2) {
|
||||||
|
regName = /[^\d]/g;
|
||||||
|
if (!regName.test(num)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为小数
|
||||||
|
*/
|
||||||
|
export function validatenumord(num, type) {
|
||||||
|
let regName = /[^\d.]/g;
|
||||||
|
if (type === 1) {
|
||||||
|
if (!regName.test(num)) return false;
|
||||||
|
} else if (type === 2) {
|
||||||
|
regName = /[^\d.]/g;
|
||||||
|
if (!regName.test(num)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否为空
|
||||||
|
*/
|
||||||
|
export function validatenull(val) {
|
||||||
|
if (typeof val == 'boolean') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (typeof val == 'number') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (val instanceof Array) {
|
||||||
|
if (val.length === 0) return true;
|
||||||
|
} else if (val instanceof Object) {
|
||||||
|
if (JSON.stringify(val) === '{}') return true;
|
||||||
|
} else {
|
||||||
|
if (val === 'null' || val == null || val === 'undefined' || val === undefined || val === '')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断输入是否为有效的 JSON 或者 JSON 字符串
|
||||||
|
* @param {any} val - 待判断的值
|
||||||
|
* @returns {boolean} - 如果是对象或可解析的 JSON 字符串,返回 true;否则返回 false
|
||||||
|
*/
|
||||||
|
export function validatejson(val) {
|
||||||
|
// 直接判断是否为对象(排除 null 和数组)
|
||||||
|
if (val !== null && typeof val === 'object') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试解析字符串为 JSON
|
||||||
|
if (typeof val === 'string') {
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(val);
|
||||||
|
// 解析后还需判断是否为对象或数组
|
||||||
|
return obj !== null && typeof obj === 'object';
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非对象、非数组、非字符串,或者字符串不是 JSON
|
||||||
|
return false;
|
||||||
|
}
|
||||||
671
src/views/authority/apiscope.vue
Normal file
671
src/views/authority/apiscope.vue
Normal file
@@ -0,0 +1,671 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
@tree-load="treeLoad"
|
||||||
|
>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
v-if="permission.api_scope_setting"
|
||||||
|
plain
|
||||||
|
style="border: 0; background-color: transparent !important"
|
||||||
|
@click.stop="handleDataScope(row)"
|
||||||
|
>权限配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ row }">
|
||||||
|
<i :class="row.source" style="margin-right: 5px" />
|
||||||
|
<span>{{ row.name }}</span>
|
||||||
|
</template>
|
||||||
|
<template #source="{ row }">
|
||||||
|
<div style="text-align: center">
|
||||||
|
<i :class="row.source" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-drawer
|
||||||
|
:title="`[${scopeMenuName}] 接口权限配置`"
|
||||||
|
v-model="drawerVisible"
|
||||||
|
:direction="direction"
|
||||||
|
append-to-body
|
||||||
|
:before-close="handleDrawerClose"
|
||||||
|
size="1000px"
|
||||||
|
>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="optionScope"
|
||||||
|
:data="dataScope"
|
||||||
|
:page="pageScope"
|
||||||
|
v-model="formScope"
|
||||||
|
:table-loading="scopeLoading"
|
||||||
|
ref="crudScope"
|
||||||
|
@row-del="rowDelScope"
|
||||||
|
@row-update="rowUpdateScope"
|
||||||
|
@row-save="rowSaveScope"
|
||||||
|
:before-open="beforeOpenScope"
|
||||||
|
@search-change="searchChangeScope"
|
||||||
|
@search-reset="searchResetScope"
|
||||||
|
@selection-change="selectionChangeScope"
|
||||||
|
@current-change="currentChangeScope"
|
||||||
|
@size-change="sizeChangeScope"
|
||||||
|
@on-load="onLoadScope"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #scopeType="{ row }">
|
||||||
|
<el-tag>{{ row.scopeTypeName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</el-drawer>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu';
|
||||||
|
import {
|
||||||
|
addApiScope,
|
||||||
|
removeApiScope,
|
||||||
|
updateApiScope,
|
||||||
|
getListApiScope,
|
||||||
|
getMenuApiScope,
|
||||||
|
} from '@/api/system/scope';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import iconList from '@/config/iconList';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
parentId: 0,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
drawerVisible: false,
|
||||||
|
direction: 'rtl',
|
||||||
|
scopeLoading: false,
|
||||||
|
scopeMenuId: 0,
|
||||||
|
scopeMenuName: '菜单',
|
||||||
|
menu: true,
|
||||||
|
option: {
|
||||||
|
lazy: true,
|
||||||
|
tip: false,
|
||||||
|
simplePage: true,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
dialogWidth: '60%',
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 150,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '菜单名称',
|
||||||
|
prop: 'name',
|
||||||
|
width: 300,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '路由地址',
|
||||||
|
prop: 'path',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入路由地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上级菜单',
|
||||||
|
prop: 'parentId',
|
||||||
|
type: 'tree',
|
||||||
|
dicUrl: '/blade-system/menu/tree',
|
||||||
|
hide: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: '请选择上级菜单',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单图标',
|
||||||
|
prop: 'source',
|
||||||
|
type: 'icon',
|
||||||
|
slot: true,
|
||||||
|
width: 85,
|
||||||
|
iconList: iconList,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单图标',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单类型',
|
||||||
|
prop: 'category',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '菜单',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '按钮',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择菜单类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单别名',
|
||||||
|
prop: 'alias',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单别名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '按钮功能',
|
||||||
|
prop: 'action',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '工具栏',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作栏',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '工具操作栏',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择按钮功能',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
width: 85,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '新窗口',
|
||||||
|
prop: 'isOpen',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 6,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
formScope: {},
|
||||||
|
selectionListScope: [],
|
||||||
|
pageScope: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
optionScope: {
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
menuWidth: 200,
|
||||||
|
dialogWidth: 900,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '权限名称',
|
||||||
|
prop: 'scopeName',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入权限名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '权限编号',
|
||||||
|
prop: 'resourceCode',
|
||||||
|
search: true,
|
||||||
|
width: 180,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入权限编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '权限路径',
|
||||||
|
prop: 'scopePath',
|
||||||
|
width: 180,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入权限编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '接口类型',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=api_scope_type',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
width: 100,
|
||||||
|
prop: 'scopeType',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dataScope: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.menu_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.menu_view, false),
|
||||||
|
delBtn: this.validData(this.permission.menu_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.menu_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
scopeIds() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionListScope.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 菜单管理模块
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = 0;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.parentId = '';
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getMenu(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
treeLoad(tree, treeNode, resolve) {
|
||||||
|
const parentId = tree.id;
|
||||||
|
getLazyMenuList(parentId).then(res => {
|
||||||
|
resolve(res.data.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 数据权限模块
|
||||||
|
handleDataScope(row) {
|
||||||
|
this.drawerVisible = true;
|
||||||
|
this.scopeMenuId = row.id;
|
||||||
|
this.scopeMenuName = row.name;
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
},
|
||||||
|
handleDrawerClose(hide) {
|
||||||
|
hide();
|
||||||
|
},
|
||||||
|
rowSaveScope(row, done, loading) {
|
||||||
|
row = {
|
||||||
|
...row,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
addApiScope(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateScope(row, index, done, loading) {
|
||||||
|
row = {
|
||||||
|
...row,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
updateApiScope(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelScope(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return removeApiScope(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDeleteScope() {
|
||||||
|
if (this.selectionListScope.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return removeApiScope(this.scopeIds);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudScope.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenScope(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getMenuApiScope(this.formScope.id).then(res => {
|
||||||
|
this.formScope = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchResetScope() {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
},
|
||||||
|
searchChangeScope(params, done) {
|
||||||
|
this.onLoadScope(this.pageScope, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeScope(list) {
|
||||||
|
this.selectionListScope = list;
|
||||||
|
},
|
||||||
|
currentChangeScope(currentPage) {
|
||||||
|
this.pageScope.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeScope(pageSize) {
|
||||||
|
this.pageScope.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
onLoadScope(page, params = {}) {
|
||||||
|
this.scopeLoading = true;
|
||||||
|
const values = {
|
||||||
|
...params,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
getListApiScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageScope.total = data.total;
|
||||||
|
this.dataScope = data.records;
|
||||||
|
this.selectionListScope = [];
|
||||||
|
this.scopeLoading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
764
src/views/authority/datascope.vue
Normal file
764
src/views/authority/datascope.vue
Normal file
@@ -0,0 +1,764 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
@tree-load="treeLoad"
|
||||||
|
>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
v-if="permission.data_scope_setting"
|
||||||
|
plain
|
||||||
|
style="border: 0; background-color: transparent !important"
|
||||||
|
@click.stop="handleDataScope(row)"
|
||||||
|
>权限配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ row }">
|
||||||
|
<i :class="row.source" style="margin-right: 5px" />
|
||||||
|
<span>{{ row.name }}</span>
|
||||||
|
</template>
|
||||||
|
<template #source="{ row }">
|
||||||
|
<div style="text-align: center">
|
||||||
|
<i :class="row.source" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-drawer
|
||||||
|
:title="`[${scopeMenuName}] 数据权限配置`"
|
||||||
|
v-model="drawerVisible"
|
||||||
|
:direction="direction"
|
||||||
|
append-to-body
|
||||||
|
:before-close="handleDrawerClose"
|
||||||
|
size="1000px"
|
||||||
|
>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="optionScope"
|
||||||
|
:data="dataScope"
|
||||||
|
:page="pageScope"
|
||||||
|
v-model="formScope"
|
||||||
|
:table-loading="scopeLoading"
|
||||||
|
ref="crudScope"
|
||||||
|
@row-del="rowDelScope"
|
||||||
|
@row-update="rowUpdateScope"
|
||||||
|
@row-save="rowSaveScope"
|
||||||
|
:before-open="beforeOpenScope"
|
||||||
|
@search-change="searchChangeScope"
|
||||||
|
@search-reset="searchResetScope"
|
||||||
|
@selection-change="selectionChangeScope"
|
||||||
|
@current-change="currentChangeScope"
|
||||||
|
@size-change="sizeChangeScope"
|
||||||
|
@on-load="onLoadScope"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #scopeType="{ row }">
|
||||||
|
<el-tag>{{ row.scopeTypeName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</el-drawer>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu';
|
||||||
|
import {
|
||||||
|
addDataScope,
|
||||||
|
removeDataScope,
|
||||||
|
updateDataScope,
|
||||||
|
getListDataScope,
|
||||||
|
getMenuDataScope,
|
||||||
|
} from '@/api/system/scope';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import iconList from '@/config/iconList';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
parentId: 0,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
drawerVisible: false,
|
||||||
|
direction: 'rtl',
|
||||||
|
scopeMenuId: 0,
|
||||||
|
scopeMenuCode: '',
|
||||||
|
scopeMenuName: '菜单',
|
||||||
|
scopeLoading: false,
|
||||||
|
menu: true,
|
||||||
|
watchMode: true,
|
||||||
|
option: {
|
||||||
|
lazy: true,
|
||||||
|
tip: false,
|
||||||
|
simplePage: true,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
dialogWidth: '60%',
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 150,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '菜单名称',
|
||||||
|
prop: 'name',
|
||||||
|
width: 300,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '路由地址',
|
||||||
|
prop: 'path',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入路由地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上级菜单',
|
||||||
|
prop: 'parentId',
|
||||||
|
type: 'tree',
|
||||||
|
dicUrl: '/blade-system/menu/tree',
|
||||||
|
hide: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: '请选择上级菜单',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单图标',
|
||||||
|
prop: 'source',
|
||||||
|
type: 'icon',
|
||||||
|
slot: true,
|
||||||
|
width: 85,
|
||||||
|
iconList: iconList,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单图标',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单类型',
|
||||||
|
prop: 'category',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '菜单',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '按钮',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择菜单类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单别名',
|
||||||
|
prop: 'alias',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单别名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '按钮功能',
|
||||||
|
prop: 'action',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '工具栏',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作栏',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '工具操作栏',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择按钮功能',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
width: 85,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '新窗口',
|
||||||
|
prop: 'isOpen',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 6,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
formScope: {},
|
||||||
|
selectionListScope: [],
|
||||||
|
pageScope: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
optionScope: {
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
menuWidth: 200,
|
||||||
|
dialogWidth: 900,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '权限名称',
|
||||||
|
prop: 'scopeName',
|
||||||
|
search: true,
|
||||||
|
value: '',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据权限名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '权限编号',
|
||||||
|
prop: 'resourceCode',
|
||||||
|
search: true,
|
||||||
|
width: 100,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据权限编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '权限字段',
|
||||||
|
prop: 'scopeColumn',
|
||||||
|
width: 130,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据权限编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '规则类型',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=data_scope_type',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
width: 140,
|
||||||
|
prop: 'scopeType',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '可见字段',
|
||||||
|
prop: 'scopeField',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
value: '*',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据权限可见的字段',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '权限类名',
|
||||||
|
prop: 'scopeClass',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入MybatisMapper对应方法的完整类名路径',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '规则值',
|
||||||
|
prop: 'scopeValue',
|
||||||
|
span: 24,
|
||||||
|
minRows: 5,
|
||||||
|
type: 'textarea',
|
||||||
|
display: true,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dataScope: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'formScope.scopeType'() {
|
||||||
|
this.initScope();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.menu_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.menu_view, false),
|
||||||
|
delBtn: this.validData(this.permission.menu_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.menu_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
scopeIds() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionListScope.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initScope() {
|
||||||
|
const scopeType = func.toInt(this.formScope.scopeType);
|
||||||
|
const watchMode = this.watchMode;
|
||||||
|
let column = '-',
|
||||||
|
name = '暂无';
|
||||||
|
if (scopeType === 1) {
|
||||||
|
column = '-';
|
||||||
|
name = '全部可见';
|
||||||
|
} else if (scopeType === 2) {
|
||||||
|
column = 'create_user';
|
||||||
|
name = '本人可见';
|
||||||
|
} else if (scopeType === 3) {
|
||||||
|
column = 'create_dept';
|
||||||
|
name = '所在机构可见';
|
||||||
|
} else if (scopeType === 4) {
|
||||||
|
column = 'create_dept';
|
||||||
|
name = '所在机构可见及子级可见';
|
||||||
|
} else if (scopeType === 5) {
|
||||||
|
column = '';
|
||||||
|
name = '自定义';
|
||||||
|
}
|
||||||
|
this.$refs.crudScope.option.column.filter(item => {
|
||||||
|
if (watchMode) {
|
||||||
|
if (item.prop === 'scopeName') {
|
||||||
|
this.formScope.scopeName = `${this.scopeMenuName} [${name}]`;
|
||||||
|
}
|
||||||
|
if (item.prop === 'resourceCode') {
|
||||||
|
this.formScope.resourceCode = this.scopeMenuCode;
|
||||||
|
}
|
||||||
|
if (item.prop === 'scopeColumn') {
|
||||||
|
this.formScope.scopeColumn = column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.prop === 'scopeValue') {
|
||||||
|
item.display = scopeType === 5;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 菜单管理模块
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = 0;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.parentId = '';
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getMenu(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeClose(done) {
|
||||||
|
this.formScope = {};
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
treeLoad(tree, treeNode, resolve) {
|
||||||
|
const parentId = tree.id;
|
||||||
|
getLazyMenuList(parentId).then(res => {
|
||||||
|
resolve(res.data.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 数据权限模块
|
||||||
|
handleDataScope(row) {
|
||||||
|
this.drawerVisible = true;
|
||||||
|
this.scopeMenuId = row.id;
|
||||||
|
this.scopeMenuCode = row.code;
|
||||||
|
this.scopeMenuName = row.name;
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
},
|
||||||
|
handleDrawerClose(hide) {
|
||||||
|
hide();
|
||||||
|
},
|
||||||
|
rowSaveScope(row, done, loading) {
|
||||||
|
row = {
|
||||||
|
...row,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
addDataScope(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateScope(row, index, done, loading) {
|
||||||
|
row = {
|
||||||
|
...row,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
updateDataScope(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelScope(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return removeDataScope(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDeleteScope() {
|
||||||
|
if (this.selectionListScope.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return removeDataScope(this.scopeIds);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudScope.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenScope(done, type) {
|
||||||
|
if (['add'].includes(type)) {
|
||||||
|
this.watchMode = true;
|
||||||
|
this.initScope();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
this.watchMode = false;
|
||||||
|
getMenuDataScope(this.formScope.id).then(res => {
|
||||||
|
this.formScope = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchResetScope() {
|
||||||
|
this.onLoadScope(this.pageScope);
|
||||||
|
},
|
||||||
|
searchChangeScope(params, done) {
|
||||||
|
this.onLoadScope(this.pageScope, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeScope(list) {
|
||||||
|
this.selectionListScope = list;
|
||||||
|
},
|
||||||
|
currentChangeScope(currentPage) {
|
||||||
|
this.pageScope.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeScope(pageSize) {
|
||||||
|
this.pageScope.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
onLoadScope(page, params = {}) {
|
||||||
|
this.scopeLoading = true;
|
||||||
|
const values = {
|
||||||
|
...params,
|
||||||
|
menuId: this.scopeMenuId,
|
||||||
|
};
|
||||||
|
getListDataScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageScope.total = data.total;
|
||||||
|
this.dataScope = data.records;
|
||||||
|
this.selectionListScope = [];
|
||||||
|
this.scopeLoading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
468
src/views/authority/role.vue
Normal file
468
src/views/authority/role.vue
Normal file
@@ -0,0 +1,468 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.role_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>Delete
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click="handleRole"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
plain
|
||||||
|
>Authority
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
plain
|
||||||
|
style="border: 0; background-color: transparent !important"
|
||||||
|
@click.stop="handleRowRole(row)"
|
||||||
|
>Authority
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="RoleSetting" append-to-body v-model="box" width="345px">
|
||||||
|
<el-tabs type="border-card">
|
||||||
|
<el-tab-pane label="Menu">
|
||||||
|
<el-tree
|
||||||
|
:data="menuGrantList"
|
||||||
|
show-checkbox
|
||||||
|
node-key="id"
|
||||||
|
ref="treeMenu"
|
||||||
|
:default-checked-keys="menuTreeObj"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
</el-tree>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="Data">
|
||||||
|
<el-tree
|
||||||
|
:data="dataScopeGrantList"
|
||||||
|
show-checkbox
|
||||||
|
node-key="id"
|
||||||
|
ref="treeDataScope"
|
||||||
|
:default-checked-keys="dataScopeTreeObj"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
</el-tree>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="API">
|
||||||
|
<el-tree
|
||||||
|
:data="apiScopeGrantList"
|
||||||
|
show-checkbox
|
||||||
|
node-key="id"
|
||||||
|
ref="treeApiScope"
|
||||||
|
:default-checked-keys="apiScopeTreeObj"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
</el-tree>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="box = false">Cancel</el-button>
|
||||||
|
<el-button type="primary" @click="submit">Submit</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
add,
|
||||||
|
getList,
|
||||||
|
getRole,
|
||||||
|
getRoleAlias,
|
||||||
|
getRoleTreeById,
|
||||||
|
grant,
|
||||||
|
grantTree,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
} from '@/api/system/role';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import website from '@/config/website';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
box: false,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
value: 'key',
|
||||||
|
},
|
||||||
|
menuGrantList: [],
|
||||||
|
dataScopeGrantList: [],
|
||||||
|
apiScopeGrantList: [],
|
||||||
|
apiGrantList: [],
|
||||||
|
menuTreeObj: [],
|
||||||
|
dataScopeTreeObj: [],
|
||||||
|
apiScopeTreeObj: [],
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
tip: false,
|
||||||
|
simplePage: true,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
labelWidth: 120,
|
||||||
|
searchLabelWidth: 120,
|
||||||
|
menuWidth: 350,
|
||||||
|
dialogWidth: 600,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: 'ParentRole',
|
||||||
|
prop: 'parentId',
|
||||||
|
dicData: [],
|
||||||
|
type: 'tree',
|
||||||
|
hide: true,
|
||||||
|
span: 24,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: '请选择上级角色',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'RoleName',
|
||||||
|
prop: 'roleName',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input role name',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Tenant',
|
||||||
|
prop: 'tenantId',
|
||||||
|
type: 'tree',
|
||||||
|
dicUrl: '/blade-system/tenant/select',
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: website.tenantMode,
|
||||||
|
span: 24,
|
||||||
|
props: {
|
||||||
|
label: 'tenantName',
|
||||||
|
value: 'tenantId',
|
||||||
|
},
|
||||||
|
hide: !website.tenantMode,
|
||||||
|
search: website.tenantMode,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input tenant',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'RoleAlias',
|
||||||
|
labelTip:
|
||||||
|
'An attribute used for permission validation and annotation, which can be entered manually or selected quickly from existing aliases.',
|
||||||
|
prop: 'roleAlias',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input role alias',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'CurrentAlias',
|
||||||
|
labelTip: 'Existing role aliases in the system — click to quickly insert.',
|
||||||
|
prop: 'currentAlias',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [],
|
||||||
|
props: {
|
||||||
|
label: 'roleName',
|
||||||
|
value: 'roleAlias',
|
||||||
|
},
|
||||||
|
hide: true,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Sort',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input role sort',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.role_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.role_view, false),
|
||||||
|
delBtn: this.validData(this.permission.role_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.role_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
idsArray() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.currentAlias'() {
|
||||||
|
const alias = this.form.currentAlias;
|
||||||
|
if (!validatenull(alias)) {
|
||||||
|
this.form.roleAlias = alias;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData(roleId) {
|
||||||
|
getRoleTreeById(roleId).then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
submit() {
|
||||||
|
const menuList = this.$refs.treeMenu.getCheckedKeys();
|
||||||
|
const dataScopeList = this.$refs.treeDataScope.getCheckedKeys();
|
||||||
|
const apiScopeList = this.$refs.treeApiScope.getCheckedKeys();
|
||||||
|
grant(this.idsArray, menuList, dataScopeList, apiScopeList).then(() => {
|
||||||
|
this.box = false;
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.selectionList = [];
|
||||||
|
this.onLoad(this.page);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData(this.form.id);
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
if (this.form.parentId === '0') {
|
||||||
|
this.form.parentId = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getRoleAlias().then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'currentAlias');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
handleRole() {
|
||||||
|
if (this.selectionList.length !== 1) {
|
||||||
|
this.$message.warning('只能选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.menuTreeObj = [];
|
||||||
|
this.dataScopeTreeObj = [];
|
||||||
|
this.apiScopeTreeObj = [];
|
||||||
|
grantTree().then(res => {
|
||||||
|
this.menuGrantList = res.data.data.menu;
|
||||||
|
this.dataScopeGrantList = res.data.data.dataScope;
|
||||||
|
this.apiScopeGrantList = res.data.data.apiScope;
|
||||||
|
getRole(this.ids).then(res => {
|
||||||
|
this.menuTreeObj = res.data.data.menu;
|
||||||
|
this.dataScopeTreeObj = res.data.data.dataScope;
|
||||||
|
this.apiScopeTreeObj = res.data.data.apiScope;
|
||||||
|
this.box = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowRole(row) {
|
||||||
|
this.menuTreeObj = [];
|
||||||
|
this.dataScopeTreeObj = [];
|
||||||
|
this.apiScopeTreeObj = [];
|
||||||
|
grantTree().then(res => {
|
||||||
|
this.menuGrantList = res.data.data.menu;
|
||||||
|
this.dataScopeGrantList = res.data.data.dataScope;
|
||||||
|
this.apiScopeGrantList = res.data.data.apiScope;
|
||||||
|
getRole(row.id).then(res => {
|
||||||
|
this.menuTreeObj = res.data.data.menu;
|
||||||
|
this.dataScopeTreeObj = res.data.data.dataScope;
|
||||||
|
this.apiScopeTreeObj = res.data.data.apiScope;
|
||||||
|
this.selectionList.push(row);
|
||||||
|
this.box = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
472
src/views/base/region.vue
Normal file
472
src/views/base/region.vue
Normal file
@@ -0,0 +1,472 @@
|
|||||||
|
<template>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="9">
|
||||||
|
<div class="box">
|
||||||
|
<el-scrollbar>
|
||||||
|
<basic-container>
|
||||||
|
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
|
||||||
|
</basic-container>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="15">
|
||||||
|
<basic-container>
|
||||||
|
<el-button-group>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.region_add"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="addChildren"
|
||||||
|
>新增下级
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.region_delete"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.region_import"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-upload"
|
||||||
|
@click="handleImport"
|
||||||
|
>导入
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.region_export"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-download"
|
||||||
|
@click="handleExport"
|
||||||
|
>导出
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.region_debug"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-video-play"
|
||||||
|
@click="handleDebug"
|
||||||
|
>调试
|
||||||
|
</el-button>
|
||||||
|
</el-button-group>
|
||||||
|
</basic-container>
|
||||||
|
<basic-container>
|
||||||
|
<avue-form ref="form" :option="regionOption" v-model="regionForm" @submit="handleSubmit">
|
||||||
|
<template #code="{}">
|
||||||
|
<el-input placeholder="请输入 区划子编号" v-model="regionForm.subCode">
|
||||||
|
<template #prepend>{{ regionForm.parentCode }}</template>
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</avue-form>
|
||||||
|
<el-dialog title="行政区划数据导入" append-to-body v-model="excelBox" width="555px">
|
||||||
|
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
|
||||||
|
<template #excelTemplate>
|
||||||
|
<el-button type="primary" @click="handleTemplate">
|
||||||
|
点击下载<i class="el-icon-download el-icon--right"></i>
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-form>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog title="行政区划数据调试" append-to-body v-model="debugBox" width="350px">
|
||||||
|
<avue-form :option="debugOption" v-model="debugForm" />
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getLazyTree, getDetail, submit, remove } from '@/api/base/region';
|
||||||
|
import { exportBlob } from '@/api/common';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
import { downloadXls } from '@/utils/util';
|
||||||
|
import { getToken } from '@/utils/auth';
|
||||||
|
import NProgress from 'nprogress';
|
||||||
|
import 'nprogress/nprogress.css';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
topCode: '00',
|
||||||
|
treeCode: '',
|
||||||
|
treeParentCode: '',
|
||||||
|
treeData: [],
|
||||||
|
treeOption: {
|
||||||
|
nodeKey: 'id',
|
||||||
|
lazy: true,
|
||||||
|
treeLoad: function (node, resolve) {
|
||||||
|
const parentCode = node.level === 0 ? '00' : node.data.id;
|
||||||
|
getLazyTree(parentCode).then(res => {
|
||||||
|
resolve(
|
||||||
|
res.data.data.map(item => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
leaf: !item.hasChildren,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addBtn: false,
|
||||||
|
menu: false,
|
||||||
|
size: 'small',
|
||||||
|
props: {
|
||||||
|
labelText: '标题',
|
||||||
|
label: 'title',
|
||||||
|
value: 'value',
|
||||||
|
children: 'children',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
regionForm: {},
|
||||||
|
regionOption: {
|
||||||
|
labelWidth: 100,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '父区划编号',
|
||||||
|
prop: 'parentCode',
|
||||||
|
span: 24,
|
||||||
|
disabled: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入父区划编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '父区划名称',
|
||||||
|
prop: 'parentName',
|
||||||
|
span: 24,
|
||||||
|
disabled: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划编号',
|
||||||
|
prop: 'code',
|
||||||
|
formslot: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入区划编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划子编号',
|
||||||
|
prop: 'subCode',
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划名称',
|
||||||
|
prop: 'name',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入区划名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划等级',
|
||||||
|
prop: 'regionLevel',
|
||||||
|
type: 'radio',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=region',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择区划等级',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入区划排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区划备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
minRows: 6,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
excelBox: false,
|
||||||
|
excelForm: {},
|
||||||
|
excelOption: {
|
||||||
|
submitBtn: false,
|
||||||
|
emptyBtn: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '模板上传',
|
||||||
|
prop: 'excelFile',
|
||||||
|
type: 'upload',
|
||||||
|
drag: true,
|
||||||
|
loadText: '模板上传中,请稍等',
|
||||||
|
span: 24,
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
},
|
||||||
|
tip: '请上传 .xls,.xlsx 标准格式文件',
|
||||||
|
action: '/blade-system/region/import-region',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '数据覆盖',
|
||||||
|
prop: 'isCovered',
|
||||||
|
type: 'switch',
|
||||||
|
align: 'center',
|
||||||
|
width: 80,
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
value: 0,
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否覆盖',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模板下载',
|
||||||
|
prop: 'excelTemplate',
|
||||||
|
formslot: true,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
debugBox: false,
|
||||||
|
debugForm: {},
|
||||||
|
debugOption: {
|
||||||
|
labelWidth: 50,
|
||||||
|
submitBtn: false,
|
||||||
|
emptyBtn: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '省份',
|
||||||
|
prop: 'province',
|
||||||
|
type: 'select',
|
||||||
|
props: {
|
||||||
|
label: 'name',
|
||||||
|
value: 'code',
|
||||||
|
},
|
||||||
|
cascader: ['city'],
|
||||||
|
dicUrl: '/blade-system/region/select',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '地市',
|
||||||
|
prop: 'city',
|
||||||
|
type: 'select',
|
||||||
|
props: {
|
||||||
|
label: 'name',
|
||||||
|
value: 'code',
|
||||||
|
},
|
||||||
|
cascader: ['district'],
|
||||||
|
dicFlag: false,
|
||||||
|
dicUrl: '/blade-system/region/select?code={{province}}',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '区县',
|
||||||
|
prop: 'district',
|
||||||
|
type: 'select',
|
||||||
|
props: {
|
||||||
|
label: 'name',
|
||||||
|
value: 'code',
|
||||||
|
},
|
||||||
|
dicFlag: false,
|
||||||
|
dicUrl: '/blade-system/region/select?code={{city}}',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'regionForm.subCode'() {
|
||||||
|
this.regionForm.code = this.regionForm.parentCode + this.regionForm.subCode;
|
||||||
|
},
|
||||||
|
'excelForm.isCovered'() {
|
||||||
|
if (this.excelForm.isCovered !== '') {
|
||||||
|
const column = this.findObject(this.excelOption.column, 'excelFile');
|
||||||
|
column.action = `/blade-system/region/import-region?isCovered=${this.excelForm.isCovered}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.region_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.region_view, false),
|
||||||
|
delBtn: this.validData(this.permission.region_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.region_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initTree() {
|
||||||
|
this.treeData = [];
|
||||||
|
getLazyTree(this.topCode).then(res => {
|
||||||
|
this.treeData = res.data.data.map(item => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
leaf: !item.hasChildren,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
nodeClick(data) {
|
||||||
|
const column = this.findObject(this.regionOption.column, 'parentCode');
|
||||||
|
column.disabled = true;
|
||||||
|
this.treeCode = data.id;
|
||||||
|
this.treeParentCode = data.parentId;
|
||||||
|
getDetail(this.treeCode).then(res => {
|
||||||
|
this.regionForm = res.data.data;
|
||||||
|
this.regionForm.subCode = this.regionForm.code.replace(this.regionForm.parentCode, '');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addChildren() {
|
||||||
|
if (validatenull(this.regionForm.code) || validatenull(this.regionForm.name)) {
|
||||||
|
this.$message.warning('请先选择一项区划');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.regionForm.parentCode = this.regionForm.code;
|
||||||
|
this.regionForm.parentName = this.regionForm.name;
|
||||||
|
this.regionForm.code = '';
|
||||||
|
this.regionForm.subCode = '';
|
||||||
|
this.regionForm.name = '';
|
||||||
|
this.regionForm.regionLevel =
|
||||||
|
this.regionForm.regionLevel === 5 ? 5 : this.regionForm.regionLevel + 1;
|
||||||
|
},
|
||||||
|
handleSubmit(form, done) {
|
||||||
|
const parentCode = form.parentCode === this.topCode ? '' : form.parentCode;
|
||||||
|
form.code = parentCode + form.subCode;
|
||||||
|
submit(form).then(
|
||||||
|
() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.initTree();
|
||||||
|
this.regionForm.subCode = '';
|
||||||
|
this.$refs.form.resetForm();
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
done();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (validatenull(this.regionForm.code)) {
|
||||||
|
this.$message.warning('请先选择一项区划');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm(`确定将 [${this.regionForm.name}] 数据删除?`, {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.treeCode);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.initTree();
|
||||||
|
this.regionForm.subCode = '';
|
||||||
|
this.$refs.form.resetForm();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
uploadAfter(res, done, loading, column) {
|
||||||
|
window.console.log(column);
|
||||||
|
this.excelBox = false;
|
||||||
|
this.initTree();
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
handleDebug() {
|
||||||
|
this.debugBox = true;
|
||||||
|
},
|
||||||
|
handleImport() {
|
||||||
|
this.excelBox = true;
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
this.$confirm('是否导出行政区划数据?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
NProgress.start();
|
||||||
|
exportBlob(
|
||||||
|
`/blade-system/region/export-region?${this.website.tokenHeader}=${getToken()}`
|
||||||
|
).then(res => {
|
||||||
|
downloadXls(res.data, `行政区划数据${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
|
||||||
|
NProgress.done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleTemplate() {
|
||||||
|
exportBlob(
|
||||||
|
`/blade-system/region/export-template?${this.website.tokenHeader}=${getToken()}`
|
||||||
|
).then(res => {
|
||||||
|
downloadXls(res.data, '行政区划模板.xlsx');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.box {
|
||||||
|
height: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-scrollbar {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box .el-scrollbar__wrap {
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
290
src/views/data/record.vue
Normal file
290
src/views/data/record.vue
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model:page="page"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #userAgent-form="{}">
|
||||||
|
<code-editor v-model="form.userAgent" :readonly="true" theme="nord" height="50px" />
|
||||||
|
</template>
|
||||||
|
<template #oldData-form="{}">
|
||||||
|
<code-editor
|
||||||
|
v-model="form.oldData"
|
||||||
|
:json="true"
|
||||||
|
:readonly="true"
|
||||||
|
theme="nord"
|
||||||
|
height="200px"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #newData-form="{}">
|
||||||
|
<code-editor
|
||||||
|
v-model="form.newData"
|
||||||
|
:json="true"
|
||||||
|
:readonly="true"
|
||||||
|
theme="nord"
|
||||||
|
height="200px"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #recordResult-form="{}">
|
||||||
|
<code-editor
|
||||||
|
v-model="form.recordResult"
|
||||||
|
:json="true"
|
||||||
|
:readonly="true"
|
||||||
|
theme="nord"
|
||||||
|
height="350px"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #recordMessage-form="{}">
|
||||||
|
<code-editor v-model="form.recordMessage" :readonly="true" theme="nord" height="350px" />
|
||||||
|
</template>
|
||||||
|
<template #env="{ row }">
|
||||||
|
<el-tag>{{ row.env }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #tableName="{ row }">
|
||||||
|
<el-tag>{{ row.tableName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #method="{ row }">
|
||||||
|
<el-tag>{{ row.method }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #recordLevel="{ row }">
|
||||||
|
<el-tag>{{ row.recordLevel }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #remoteIp="{ row }">
|
||||||
|
<el-tag>{{ row.remoteIp }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getRecordList, getRecordDetail } from '@/api/data/record';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
searchIndex: 3,
|
||||||
|
searchIcon: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 120,
|
||||||
|
labelWidth: 120,
|
||||||
|
dialogType: 'drawer',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '服务ID',
|
||||||
|
prop: 'serviceId',
|
||||||
|
width: '120',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务器名',
|
||||||
|
prop: 'serverHost',
|
||||||
|
width: '140',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务器IP',
|
||||||
|
prop: 'serverIp',
|
||||||
|
width: '180',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '环境',
|
||||||
|
prop: 'env',
|
||||||
|
width: '80',
|
||||||
|
search: true,
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '审计级别',
|
||||||
|
prop: 'recordLevel',
|
||||||
|
width: '100',
|
||||||
|
search: true,
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '数据表名',
|
||||||
|
prop: 'tableName',
|
||||||
|
width: '150',
|
||||||
|
search: true,
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作方式',
|
||||||
|
prop: 'method',
|
||||||
|
width: '100',
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求URI',
|
||||||
|
prop: 'requestUri',
|
||||||
|
search: true,
|
||||||
|
overHidden: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作类型',
|
||||||
|
prop: 'operation',
|
||||||
|
width: '100',
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作IP',
|
||||||
|
prop: 'remoteIp',
|
||||||
|
width: '140',
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '记录人',
|
||||||
|
prop: 'recordUserName',
|
||||||
|
width: '120',
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '记录耗时',
|
||||||
|
prop: 'recordCost',
|
||||||
|
width: '100',
|
||||||
|
suffix: 'ms',
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '记录时间',
|
||||||
|
prop: 'recordTime',
|
||||||
|
width: '180',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户代理',
|
||||||
|
prop: 'userAgent',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作前数据',
|
||||||
|
prop: 'oldData',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 3,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '操作后数据',
|
||||||
|
prop: 'newData',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 3,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '审计结果',
|
||||||
|
prop: 'recordResult',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 3,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '审计消息',
|
||||||
|
prop: 'recordMessage',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
viewBtn: this.validData(this.permission.record_view, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getRecordDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getRecordList(page.currentPage, page.pageSize, Object.assign(params, this.query))
|
||||||
|
.then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 可以根据需要添加自定义样式 */
|
||||||
|
</style>
|
||||||
309
src/views/desk/notice-composition.vue
Normal file
309
src/views/desk/notice-composition.vue
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model:search="search"
|
||||||
|
ref="crud"
|
||||||
|
@row-del="rowDel"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.notice_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #category="{ row }">
|
||||||
|
<el-tag>{{ row.categoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
|
import { ref, reactive, computed, onMounted } from 'vue';
|
||||||
|
import { useStore } from 'vuex';
|
||||||
|
import { getList, remove, update, add, getNotice } from '@/api/desk/notice';
|
||||||
|
|
||||||
|
// 定义响应式数据
|
||||||
|
const form = ref({});
|
||||||
|
const search = ref({});
|
||||||
|
const loading = ref(true);
|
||||||
|
const page = ref({
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
});
|
||||||
|
const selectionList = ref([]);
|
||||||
|
const data = ref([]);
|
||||||
|
const option = reactive({
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 950,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
excelBtn: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
grid: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '通知标题',
|
||||||
|
prop: 'title',
|
||||||
|
span: 24,
|
||||||
|
row: true,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知标题',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知类型',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=notice',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
prop: 'category',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知时间',
|
||||||
|
prop: 'releaseTimeRange',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
searchRange: true,
|
||||||
|
hide: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知时间',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知日期',
|
||||||
|
prop: 'releaseTime',
|
||||||
|
type: 'date',
|
||||||
|
gridRow: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知日期',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知内容',
|
||||||
|
prop: 'content',
|
||||||
|
component: 'avue-ueditor',
|
||||||
|
action: '/blade-resource/oss/endpoint/put-file',
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
url: 'link',
|
||||||
|
},
|
||||||
|
hide: true,
|
||||||
|
minRows: 4,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// 使用 vuex store
|
||||||
|
const store = useStore();
|
||||||
|
const permission = computed(() => store.getters.permission);
|
||||||
|
|
||||||
|
// 计算权限
|
||||||
|
const permissionList = computed(() => {
|
||||||
|
const validData = (value, defaultVal = false) => (value ? true : defaultVal);
|
||||||
|
return {
|
||||||
|
addBtn: validData(permission.value.notice_add, false),
|
||||||
|
viewBtn: validData(permission.value.notice_view, false),
|
||||||
|
delBtn: validData(permission.value.notice_delete, false),
|
||||||
|
editBtn: validData(permission.value.notice_edit, false),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算选中的id
|
||||||
|
const ids = computed(() => {
|
||||||
|
return selectionList.value.map(ele => ele.id).join(',');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
const rowSave = (row, done, loading) => {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
onLoad();
|
||||||
|
ElMessage.success('操作成功!');
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.error(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 修改
|
||||||
|
const rowUpdate = (row, index, done, loading) => {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
onLoad();
|
||||||
|
ElMessage.success('操作成功!');
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.error(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const rowDel = row => {
|
||||||
|
ElMessageBox.confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => remove(row.id))
|
||||||
|
.then(() => {
|
||||||
|
onLoad();
|
||||||
|
ElMessage.success('操作成功!');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置查询
|
||||||
|
const searchReset = () => {
|
||||||
|
search.value = {};
|
||||||
|
page.value.currentPage = 1;
|
||||||
|
onLoad();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
const searchChange = (params, done) => {
|
||||||
|
page.value.currentPage = 1;
|
||||||
|
onLoad();
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 勾选事件
|
||||||
|
const selectionChange = list => {
|
||||||
|
selectionList.value = list;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置勾选
|
||||||
|
const selectionClear = () => {
|
||||||
|
selectionList.value = [];
|
||||||
|
// 假设你有一个 ref 为 'crud' 的组件,可以调用 toggleSelection 方法
|
||||||
|
// if (crudRef.value) crudRef.value.toggleSelection();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (selectionList.value.length === 0) {
|
||||||
|
ElMessage.success('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessageBox.confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => remove(ids.value))
|
||||||
|
.then(() => {
|
||||||
|
onLoad();
|
||||||
|
ElMessage.success('操作成功!');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开前事件
|
||||||
|
const beforeOpen = (done, type) => {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getNotice(form.value.id).then(res => {
|
||||||
|
form.value = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新事件
|
||||||
|
const refreshChange = () => {
|
||||||
|
onLoad();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 加载数据
|
||||||
|
const onLoad = () => {
|
||||||
|
const { releaseTimeRange } = search.value;
|
||||||
|
let values = { ...search.value };
|
||||||
|
if (releaseTimeRange) {
|
||||||
|
values = {
|
||||||
|
...values,
|
||||||
|
releaseTime_datege: releaseTimeRange[0],
|
||||||
|
releaseTime_datelt: releaseTimeRange[1],
|
||||||
|
};
|
||||||
|
values.releaseTimeRange = null;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
getList(page.value.currentPage, page.value.pageSize, values).then(res => {
|
||||||
|
const { total, records } = res.data.data;
|
||||||
|
page.value.total = total;
|
||||||
|
data.value = records;
|
||||||
|
loading.value = false;
|
||||||
|
selectionClear();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 生命周期钩子
|
||||||
|
onMounted(() => {
|
||||||
|
// 可以在这里执行组件挂载后的逻辑
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 你的样式代码 */
|
||||||
|
</style>
|
||||||
309
src/views/desk/notice.vue
Normal file
309
src/views/desk/notice.vue
Normal file
@@ -0,0 +1,309 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
ref="crud"
|
||||||
|
@row-del="rowDel"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.notice_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #category="{ row }">
|
||||||
|
<el-tag>{{ row.categoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, remove, update, add, getNotice } from '@/api/desk/notice';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 950,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
excelBtn: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
grid: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '通知标题',
|
||||||
|
prop: 'title',
|
||||||
|
span: 24,
|
||||||
|
row: true,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知标题',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知类型',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=notice',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
prop: 'category',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知时间',
|
||||||
|
prop: 'releaseTimeRange',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
searchRange: true,
|
||||||
|
hide: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知时间',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知日期',
|
||||||
|
prop: 'releaseTime',
|
||||||
|
type: 'date',
|
||||||
|
gridRow: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入通知日期',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '通知内容',
|
||||||
|
prop: 'content',
|
||||||
|
component: 'avue-ueditor',
|
||||||
|
action: '/blade-resource/oss/endpoint/put-file',
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
url: 'link',
|
||||||
|
},
|
||||||
|
hide: true,
|
||||||
|
minRows: 4,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.notice_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.notice_view, false),
|
||||||
|
delBtn: this.validData(this.permission.notice_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.notice_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getNotice(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
const { releaseTimeRange } = this.query;
|
||||||
|
let values = {
|
||||||
|
...params,
|
||||||
|
...this.query,
|
||||||
|
};
|
||||||
|
if (releaseTimeRange) {
|
||||||
|
values = {
|
||||||
|
...values,
|
||||||
|
releaseTime_datege: releaseTimeRange[0],
|
||||||
|
releaseTime_datelt: releaseTimeRange[1],
|
||||||
|
};
|
||||||
|
values.releaseTimeRange = null;
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
225
src/views/kiosk/category.vue
Normal file
225
src/views/kiosk/category.vue
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud :option="option"
|
||||||
|
v-model:search="search"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model="form"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad">
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.category_delete"
|
||||||
|
@click="handleDelete">删 除
|
||||||
|
</el-button>
|
||||||
|
<el-button type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
@click="handleExport">导 出
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {getList, getDetail, add, update, remove} from "@/api/kiosk/category";
|
||||||
|
import option from "@/option/kiosk/category";
|
||||||
|
import {mapGetters} from "vuex";
|
||||||
|
import {exportBlob} from "@/api/common";
|
||||||
|
import {getToken} from '@/utils/auth';
|
||||||
|
import {downloadXls} from "@/utils/util";
|
||||||
|
import {dateNow} from "@/utils/date";
|
||||||
|
import NProgress from 'nprogress';
|
||||||
|
import 'nprogress/nprogress.css';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
search: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: option,
|
||||||
|
data: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["permission"]),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.category_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.category_view, false),
|
||||||
|
delBtn: this.validData(this.permission.category_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.category_edit, false)
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(",");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "操作成功!"
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
}, error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "操作成功!"
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
}, error => {
|
||||||
|
loading();
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm("确定将选择数据删除?", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "操作成功!"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning("请选择至少一条数据");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm("确定将选择数据删除?", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "操作成功!"
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
let downloadUrl = `/kiosk-category/category/export-category?${this.website.tokenHeader}=${getToken()}`;
|
||||||
|
const {
|
||||||
|
} = this.query;
|
||||||
|
let values = {
|
||||||
|
};
|
||||||
|
this.$confirm("是否导出数据?", "提示", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(() => {
|
||||||
|
NProgress.start();
|
||||||
|
exportBlob(downloadUrl, values).then(res => {
|
||||||
|
downloadXls(res.data, `自助终端产品目录表${dateNow()}.xlsx`);
|
||||||
|
NProgress.done();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (["edit", "view"].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage){
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize){
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
const {
|
||||||
|
} = this.query;
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
};
|
||||||
|
|
||||||
|
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
162
src/views/monitor/log/api.vue
Normal file
162
src/views/monitor/log/api.vue
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model:page="page"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getApiList, getApiLogs } from '@/api/logs';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 120,
|
||||||
|
dialogType: 'drawer',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '服务id',
|
||||||
|
prop: 'serviceId',
|
||||||
|
width: '120',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务host',
|
||||||
|
prop: 'serverHost',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务ip',
|
||||||
|
prop: 'serverIp',
|
||||||
|
width: '160',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '软件环境',
|
||||||
|
prop: 'env',
|
||||||
|
width: '85',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志名',
|
||||||
|
prop: 'title',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求方法',
|
||||||
|
prop: 'method',
|
||||||
|
width: '85',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求接口',
|
||||||
|
prop: 'requestUri',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
width: '180',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户代理',
|
||||||
|
prop: 'userAgent',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求数据',
|
||||||
|
prop: 'params',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
viewBtn: this.validData(this.permission.log_api_view, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getApiLogs(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getApiList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
166
src/views/monitor/log/error.vue
Normal file
166
src/views/monitor/log/error.vue
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
v-model:page="page"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getErrorList, getErrorLogs } from '@/api/logs';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 120,
|
||||||
|
dialogType: 'drawer',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '服务id',
|
||||||
|
prop: 'serviceId',
|
||||||
|
search: true,
|
||||||
|
width: '120',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务host',
|
||||||
|
prop: 'serverHost',
|
||||||
|
search: true,
|
||||||
|
width: '150',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务ip',
|
||||||
|
prop: 'serverIp',
|
||||||
|
width: '160',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '软件环境',
|
||||||
|
prop: 'env',
|
||||||
|
width: '85',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求方法',
|
||||||
|
prop: 'method',
|
||||||
|
width: '85',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求接口',
|
||||||
|
prop: 'requestUri',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
width: '180',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户代理',
|
||||||
|
prop: 'userAgent',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求数据',
|
||||||
|
prop: 'params',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志数据',
|
||||||
|
prop: 'stackTrace',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 16,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
viewBtn: this.validData(this.permission.log_error_view, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getErrorLogs(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getErrorList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
166
src/views/monitor/log/usual.vue
Normal file
166
src/views/monitor/log/usual.vue
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
v-model:page="page"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getUsualList, getUsualLogs } from '@/api/logs';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
editBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
menuWidth: 120,
|
||||||
|
dialogType: 'drawer',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '服务id',
|
||||||
|
prop: 'serviceId',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务host',
|
||||||
|
prop: 'serverHost',
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '服务ip',
|
||||||
|
prop: 'serverIp',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '软件环境',
|
||||||
|
prop: 'env',
|
||||||
|
width: '100',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志级别',
|
||||||
|
prop: 'logLevel',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志id',
|
||||||
|
prop: 'logId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求接口',
|
||||||
|
prop: 'requestUri',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
width: '180',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户代理',
|
||||||
|
prop: 'userAgent',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '日志数据',
|
||||||
|
prop: 'logData',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '请求数据',
|
||||||
|
prop: 'params',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
viewBtn: this.validData(this.permission.log_usual_view, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getUsualLogs(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getUsualList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
210
src/views/report/reportlist.vue
Normal file
210
src/views/report/reportlist.vue
Normal file
@@ -0,0 +1,210 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click.stop="handleDesign(scope.row.name)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>设计
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-view"
|
||||||
|
@click.stop="handlePreview(scope.row.name)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>预览
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ row }">
|
||||||
|
<el-tag style="cursor: pointer" @click="handlePreview(row.name)">{{ row.name }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, remove } from '@/api/report/report';
|
||||||
|
import { getToken } from '@/utils/auth';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '文件名',
|
||||||
|
prop: 'name',
|
||||||
|
search: true,
|
||||||
|
slot: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '创建时间',
|
||||||
|
prop: 'createTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '更新时间',
|
||||||
|
prop: 'updateTime',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: false,
|
||||||
|
viewBtn: false,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handlePreview(name) {
|
||||||
|
window.open(
|
||||||
|
`${this.website.design.reportUrl}/preview?_u=blade-${name}&${
|
||||||
|
this.website.tokenHeader
|
||||||
|
}=bearer ${getToken()}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleDesign(name) {
|
||||||
|
window.open(
|
||||||
|
`${this.website.design.reportUrl}/designer?_u=blade-${name}&${
|
||||||
|
this.website.tokenHeader
|
||||||
|
}=bearer ${getToken()}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
306
src/views/resource/attach.vue
Normal file
306
src/views/resource/attach.vue
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
v-if="permission.attach_upload"
|
||||||
|
icon="el-icon-upload"
|
||||||
|
@click="handleUpload"
|
||||||
|
>上 传
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.attach_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-download"
|
||||||
|
v-if="permission.attach_download"
|
||||||
|
@click="handleDownload(scope.row)"
|
||||||
|
>下载
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #attachSize="{ row }">
|
||||||
|
<el-tag>{{ `${func.bytesToKB(row.attachSize)} KB` }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="附件管理" append-to-body v-model="attachBox" width="555px">
|
||||||
|
<avue-form ref="form" :option="attachOption" v-model="attachForm" :upload-after="uploadAfter">
|
||||||
|
</avue-form>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, remove } from '@/api/resource/attach';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
attachBox: false,
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
grid: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '附件地址',
|
||||||
|
prop: 'link',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件域名',
|
||||||
|
prop: 'domainUrl',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件域名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件名称',
|
||||||
|
prop: 'name',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件原名',
|
||||||
|
prop: 'originalName',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件原名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件拓展名',
|
||||||
|
prop: 'extension',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件拓展名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '附件大小',
|
||||||
|
prop: 'attachSize',
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入附件大小',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
attachForm: {},
|
||||||
|
attachOption: {
|
||||||
|
submitBtn: false,
|
||||||
|
emptyBtn: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '附件上传',
|
||||||
|
prop: 'attachFile',
|
||||||
|
type: 'upload',
|
||||||
|
drag: true,
|
||||||
|
loadText: '模板上传中,请稍等',
|
||||||
|
span: 24,
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
},
|
||||||
|
action: '/blade-resource/oss/endpoint/put-file-attach',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
func() {
|
||||||
|
return func;
|
||||||
|
},
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
viewBtn: false,
|
||||||
|
delBtn: this.validData(this.permission.attach_delete, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleUpload() {
|
||||||
|
this.attachBox = true;
|
||||||
|
},
|
||||||
|
uploadAfter(res, done, loading, column) {
|
||||||
|
window.console.log(column);
|
||||||
|
this.attachBox = false;
|
||||||
|
this.refreshChange();
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
handleDownload(row) {
|
||||||
|
window.open(`${row.link}`);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
469
src/views/resource/oss.vue
Normal file
469
src/views/resource/oss.vue
Normal file
@@ -0,0 +1,469 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.oss_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-video-play"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
@click="handleDebug(scope.row)"
|
||||||
|
>调试
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-check"
|
||||||
|
v-if="permission.oss_enable"
|
||||||
|
@click.stop="handleEnable(scope.row)"
|
||||||
|
>启用
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #status="{ row }">
|
||||||
|
<el-tag>{{ row.statusName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #category="{ row }">
|
||||||
|
<el-tag>{{ row.categoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="对象存储上传调试" append-to-body v-model="box" width="550px">
|
||||||
|
<avue-form ref="form" :option="debugOption" v-model="debugForm" @submit="handleSubmit" />
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove, enable } from '@/api/resource/oss';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
import { sensitive } from '@/utils/sensitive';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
sensitiveManager: null,
|
||||||
|
loading: true,
|
||||||
|
box: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
grid: true,
|
||||||
|
menuWidth: 350,
|
||||||
|
labelWidth: 100,
|
||||||
|
dialogWidth: 880,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '分类',
|
||||||
|
type: 'radio',
|
||||||
|
value: 1,
|
||||||
|
span: 24,
|
||||||
|
width: 120,
|
||||||
|
searchLabelWidth: 50,
|
||||||
|
row: true,
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=oss',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
prop: 'category',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择分类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '资源编号',
|
||||||
|
prop: 'ossCode',
|
||||||
|
span: 24,
|
||||||
|
width: 120,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入资源编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '资源地址',
|
||||||
|
labelTip: '对象存储通用资源地址,可以是内网也可以是外网',
|
||||||
|
prop: 'endpoint',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入资源地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '外网地址',
|
||||||
|
labelTip: '资源地址设置为内网上传,则外部访问需要配置外网映射地址',
|
||||||
|
prop: 'transformEndpoint',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '空间名',
|
||||||
|
prop: 'bucketName',
|
||||||
|
span: 24,
|
||||||
|
width: 120,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入空间名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'accessKey',
|
||||||
|
prop: 'accessKey',
|
||||||
|
span: 24,
|
||||||
|
search: true,
|
||||||
|
width: 200,
|
||||||
|
overHidden: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入accessKey',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'secretKey',
|
||||||
|
prop: 'secretKey',
|
||||||
|
span: 24,
|
||||||
|
width: 200,
|
||||||
|
hide: true,
|
||||||
|
overHidden: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入secretKey',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'appId',
|
||||||
|
prop: 'appId',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'region',
|
||||||
|
prop: 'region',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是否启用',
|
||||||
|
prop: 'status',
|
||||||
|
span: 24,
|
||||||
|
width: 85,
|
||||||
|
align: 'center',
|
||||||
|
slot: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
debugForm: {
|
||||||
|
code: '',
|
||||||
|
},
|
||||||
|
debugOption: {
|
||||||
|
submitText: '提交',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '资源编号',
|
||||||
|
prop: 'code',
|
||||||
|
disabled: true,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上传背景',
|
||||||
|
prop: 'backgroundUrl',
|
||||||
|
type: 'upload',
|
||||||
|
listType: 'picture-img',
|
||||||
|
dataType: 'string',
|
||||||
|
action: '/blade-resource/oss/endpoint/put-file',
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
url: 'link',
|
||||||
|
},
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.category'() {
|
||||||
|
const category = func.toInt(this.form.category);
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'endpoint') {
|
||||||
|
item.labelTip = category === 7 ? '本地服务器上传路径使用Nginx代理后的服务地址' : '';
|
||||||
|
}
|
||||||
|
if (item.prop === 'accessKey') {
|
||||||
|
item.labelTip =
|
||||||
|
category === 7
|
||||||
|
? '本地服务器文件上传基础路径,注意必须提前创建好并分配目录读写权限'
|
||||||
|
: '';
|
||||||
|
}
|
||||||
|
if (item.prop === 'secretKey') {
|
||||||
|
item.display = category !== 7;
|
||||||
|
}
|
||||||
|
if (item.prop === 'appId') {
|
||||||
|
item.display = category === 4;
|
||||||
|
}
|
||||||
|
if (item.prop === 'region') {
|
||||||
|
item.display = category === 4 || category === 5;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'debugForm.code'() {
|
||||||
|
const column = this.findObject(this.debugOption.column, 'backgroundUrl');
|
||||||
|
column.action = `/blade-resource/oss/endpoint/put-file?code=${this.debugForm.code}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.oss_add),
|
||||||
|
viewBtn: this.validData(this.permission.oss_view),
|
||||||
|
delBtn: this.validData(this.permission.oss_delete),
|
||||||
|
editBtn: this.validData(this.permission.oss_edit),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 创建脱敏工具实例
|
||||||
|
this.sensitiveManager = sensitive.create({
|
||||||
|
fields: ['accessKey', 'secretKey'], // 配置需要脱敏的字段
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
// 获取需要提交的数据
|
||||||
|
const submitData = this.sensitiveManager.getSubmitData(row);
|
||||||
|
update(submitData).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleEnable(row) {
|
||||||
|
this.$confirm('是否确定启用这条配置?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return enable(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDebug(row) {
|
||||||
|
this.box = true;
|
||||||
|
this.debugForm.code = row.ossCode;
|
||||||
|
this.debugForm.backgroundUrl = '';
|
||||||
|
},
|
||||||
|
handleSubmit(form, done) {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: `获取到图片地址:[${form.backgroundUrl}]`,
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
// 保存初始脱敏数据
|
||||||
|
this.sensitiveManager.saveInitialData(this.form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
501
src/views/resource/sms.vue
Normal file
501
src/views/resource/sms.vue
Normal file
@@ -0,0 +1,501 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.sms_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-video-play"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
@click="handleDebug(scope.row)"
|
||||||
|
>调试
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-check"
|
||||||
|
v-if="permission.sms_enable"
|
||||||
|
@click.stop="handleEnable(scope.row)"
|
||||||
|
>启用
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #status="{ row }">
|
||||||
|
<el-tag>{{ row.statusName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #category="{ row }">
|
||||||
|
<el-tag>{{ row.categoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="手机短信发送调试" append-to-body v-model="box" width="550px">
|
||||||
|
<avue-form :option="debugOption" v-model="debugForm" @submit="handleSend" />
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove, enable, send } from '@/api/resource/sms';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
import { sensitive } from '@/utils/sensitive';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
sensitiveManager: null,
|
||||||
|
loading: true,
|
||||||
|
box: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
grid: true,
|
||||||
|
menuWidth: 350,
|
||||||
|
labelWidth: 100,
|
||||||
|
dialogWidth: 880,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '分类',
|
||||||
|
type: 'radio',
|
||||||
|
value: 1,
|
||||||
|
span: 24,
|
||||||
|
width: 100,
|
||||||
|
searchLabelWidth: 50,
|
||||||
|
row: true,
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=sms',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
prop: 'category',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择分类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '资源编号',
|
||||||
|
prop: 'smsCode',
|
||||||
|
span: 24,
|
||||||
|
width: 200,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入资源编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '模版ID',
|
||||||
|
prop: 'templateId',
|
||||||
|
span: 24,
|
||||||
|
width: 200,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入模版ID',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'SDKAppID',
|
||||||
|
prop: 'appId',
|
||||||
|
span: 24,
|
||||||
|
width: 200,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入appId',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'accessKey',
|
||||||
|
prop: 'accessKey',
|
||||||
|
span: 24,
|
||||||
|
overHidden: true,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入accessKey',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'secretKey',
|
||||||
|
prop: 'secretKey',
|
||||||
|
span: 24,
|
||||||
|
overHidden: true,
|
||||||
|
display: true,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入secretKey',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'regionId',
|
||||||
|
prop: 'regionId',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入regionId',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '短信签名',
|
||||||
|
prop: 'signName',
|
||||||
|
span: 24,
|
||||||
|
width: 200,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入短信签名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是否启用',
|
||||||
|
prop: 'status',
|
||||||
|
span: 24,
|
||||||
|
width: 85,
|
||||||
|
align: 'center',
|
||||||
|
slot: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
debugForm: {
|
||||||
|
code: '',
|
||||||
|
},
|
||||||
|
debugOption: {
|
||||||
|
submitText: '发送',
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '资源编号',
|
||||||
|
prop: 'code',
|
||||||
|
disabled: true,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '发送手机',
|
||||||
|
prop: 'phones',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '发送参数',
|
||||||
|
prop: 'params',
|
||||||
|
span: 24,
|
||||||
|
placeholder: "例: {'code':2333,'title':'通知标题'}",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.category'() {
|
||||||
|
const category = func.toInt(this.form.category);
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'templateId') {
|
||||||
|
if (category === 1) {
|
||||||
|
item.label = '模版内容';
|
||||||
|
} else {
|
||||||
|
item.label = '模版ID';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.prop === 'accessKey') {
|
||||||
|
if (category === 1) {
|
||||||
|
item.label = 'apiKey';
|
||||||
|
} else if (category === 4) {
|
||||||
|
item.label = 'secretId';
|
||||||
|
} else {
|
||||||
|
item.label = 'accessKey';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.prop === 'secretKey') {
|
||||||
|
item.display = category !== 1;
|
||||||
|
if (category === 4) {
|
||||||
|
item.label = 'secretKey';
|
||||||
|
} else {
|
||||||
|
item.label = 'secretKey';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.prop === 'regionId') {
|
||||||
|
if (category === 3) {
|
||||||
|
item.display = true;
|
||||||
|
this.form.regionId = 'cn-hangzhou';
|
||||||
|
} else if (category === 4) {
|
||||||
|
item.display = true;
|
||||||
|
this.form.regionId = 'ap-guangzhou';
|
||||||
|
} else {
|
||||||
|
item.display = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.prop === 'appId') {
|
||||||
|
item.display = category === 4;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.sms_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.sms_view, false),
|
||||||
|
delBtn: this.validData(this.permission.sms_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.sms_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 创建脱敏工具实例
|
||||||
|
this.sensitiveManager = sensitive.create({
|
||||||
|
fields: ['accessKey', 'secretKey'], // 配置需要脱敏的字段
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
// 获取需要提交的数据
|
||||||
|
const submitData = this.sensitiveManager.getSubmitData(row);
|
||||||
|
update(submitData).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleEnable(row) {
|
||||||
|
this.$confirm('是否确定启用这条配置?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return enable(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDebug(row) {
|
||||||
|
this.box = true;
|
||||||
|
this.debugForm.code = row.smsCode;
|
||||||
|
},
|
||||||
|
handleSend(form, done) {
|
||||||
|
send(form.code, form.phones, form.params).then(
|
||||||
|
res => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '发送成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
window.console.log(res);
|
||||||
|
this.box = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
// 保存初始脱敏数据
|
||||||
|
this.sensitiveManager.saveInitialData(this.form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
385
src/views/system/client.vue
Normal file
385
src/views/system/client.vue
Normal file
@@ -0,0 +1,385 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
@row-del="rowDel"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
:permission="permissionList"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.client_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>Del
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/system/client';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
grid: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: 'ClientId',
|
||||||
|
prop: 'clientId',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input client id',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Secret',
|
||||||
|
prop: 'clientSecret',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input client secret',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'GrantType',
|
||||||
|
prop: 'authorizedGrantTypes',
|
||||||
|
type: 'checkbox',
|
||||||
|
value: 'refresh_token,password,authorization_code,captcha,social,sms_code,register',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: 'refresh_token',
|
||||||
|
value: 'refresh_token',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'password',
|
||||||
|
value: 'password',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'authorization_code',
|
||||||
|
value: 'authorization_code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'captcha',
|
||||||
|
value: 'captcha',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'social',
|
||||||
|
value: 'social',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'sms_code',
|
||||||
|
value: 'sms_code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'register',
|
||||||
|
value: 'register',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input grant type',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Scope',
|
||||||
|
prop: 'scope',
|
||||||
|
value: 'all',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input scope',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'TokenLimit',
|
||||||
|
prop: 'accessTokenValidity',
|
||||||
|
type: 'number',
|
||||||
|
value: 3600,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input token limit second(s)',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'RefreshLimit',
|
||||||
|
prop: 'refreshTokenValidity',
|
||||||
|
type: 'number',
|
||||||
|
value: 604800,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input token refresh limit second(s)',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'CallbackURL',
|
||||||
|
prop: 'webServerRedirectUri',
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input callback URL',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'AutoApprove',
|
||||||
|
prop: 'autoapprove',
|
||||||
|
hide: true,
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: 'yes',
|
||||||
|
value: 'true',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'no',
|
||||||
|
value: 'false',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
value: 'true',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please input auto approve',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Resource',
|
||||||
|
prop: 'resourceIds',
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
message: 'Please input resources',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Authority',
|
||||||
|
prop: 'authorities',
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
message: 'Please input authorities',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'AdditionalInfo',
|
||||||
|
hide: true,
|
||||||
|
prop: 'additionalInformation',
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
message: '',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.client_add),
|
||||||
|
viewBtn: this.validData(this.permission.client_view),
|
||||||
|
delBtn: this.validData(this.permission.client_delete),
|
||||||
|
editBtn: this.validData(this.permission.client_edit),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
405
src/views/system/dept.vue
Normal file
405
src/views/system/dept.vue
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
@tree-load="treeLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dept_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>DEL
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>ADD SUB
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #deptCategory="{ row }">
|
||||||
|
<el-tag>{{ row.deptCategoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getLazyList, remove, update, add, getDept, getDeptTree } from '@/api/system/dept';
|
||||||
|
import { getLeaderList } from '@/api/system/user';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import website from '@/config/website';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
parentId: 0,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
lazy: true,
|
||||||
|
tip: false,
|
||||||
|
simplePage: true,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
menuWidth: 320,
|
||||||
|
dialogWidth: 800,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: 'Store',
|
||||||
|
prop: 'deptName',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'please input store name',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Tenant',
|
||||||
|
prop: 'tenantId',
|
||||||
|
type: 'tree',
|
||||||
|
dicUrl: '/blade-system/tenant/select',
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: website.tenantMode,
|
||||||
|
span: 24,
|
||||||
|
props: {
|
||||||
|
label: 'tenantName',
|
||||||
|
value: 'tenantId',
|
||||||
|
},
|
||||||
|
hide: !website.tenantMode,
|
||||||
|
search: website.tenantMode,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'please input tenant',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'FullName',
|
||||||
|
prop: 'fullName',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'please input store full name',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Parent',
|
||||||
|
prop: 'parentId',
|
||||||
|
dicData: [],
|
||||||
|
type: 'tree',
|
||||||
|
hide: true,
|
||||||
|
addDisabled: false,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: 'please select parent store',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Leader',
|
||||||
|
prop: 'leaderId',
|
||||||
|
type: 'tree',
|
||||||
|
multiple: true,
|
||||||
|
filterable: true,
|
||||||
|
dicData: [],
|
||||||
|
props: {
|
||||||
|
label: 'realName',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
clearable: true,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Type',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=org_category',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
width: 120,
|
||||||
|
prop: 'deptCategory',
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'please input store type',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Sort',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
align: 'right',
|
||||||
|
width: 80,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'please input sort number',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Remark',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dept_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.dept_view, false),
|
||||||
|
delBtn: this.validData(this.permission.dept_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dept_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData(tenantId) {
|
||||||
|
getDeptTree(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
getLeaderList(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'leaderId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.parentId = row.id;
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.value = row.id;
|
||||||
|
column.addDisabled = true;
|
||||||
|
this.$refs.crud.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
row.leaderId = func.join(row.leaderId);
|
||||||
|
add(row).then(
|
||||||
|
res => {
|
||||||
|
// 获取新增数据的相关字段
|
||||||
|
const data = res.data.data;
|
||||||
|
row.id = data.id;
|
||||||
|
row.deptCategoryName = data.deptCategoryName;
|
||||||
|
row.tenantId = data.tenantId;
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
row.leaderId = func.join(row.leaderId);
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row, index, done) {
|
||||||
|
this.$confirm('Confirmation for Del?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('Please select one or more');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('Confirmation for Del?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// 刷新表格数据并重载
|
||||||
|
this.data = [];
|
||||||
|
this.parentId = 0;
|
||||||
|
this.$refs.crud.refreshTable();
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
// 表格数据重载
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = 0;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.parentId = '';
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData(this.form.tenantId);
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDept(this.form.id).then(res => {
|
||||||
|
this.form = Object.assign(res.data.data, {
|
||||||
|
hasChildren: this.form.hasChildren,
|
||||||
|
});
|
||||||
|
if (this.form.parentId === '0') {
|
||||||
|
this.form.parentId = '';
|
||||||
|
}
|
||||||
|
if (this.form.hasOwnProperty('leaderId')) {
|
||||||
|
this.form.leaderId = func.split(this.form.leaderId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeClose(done) {
|
||||||
|
this.parentId = '';
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.value = '';
|
||||||
|
column.addDisabled = false;
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
treeLoad(tree, treeNode, resolve) {
|
||||||
|
const parentId = tree.id;
|
||||||
|
getLazyList(parentId).then(res => {
|
||||||
|
resolve(res.data.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
450
src/views/system/dict.vue
Normal file
450
src/views/system/dict.vue
Normal file
@@ -0,0 +1,450 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="optionParent"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click.stop="handleRowClick(scope.row)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>字典配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<el-tag @click="handleRowClick(row)" style="cursor: pointer">{{ row.code }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog :title="`[${dictValue}]字典配置`" append-to-body v-model="box" width="1000px">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionChild"
|
||||||
|
:table-loading="loadingChild"
|
||||||
|
:data="dataChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
:before-close="beforeCloseChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getParentList,
|
||||||
|
getChildList,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
add,
|
||||||
|
getDict,
|
||||||
|
getDictTree,
|
||||||
|
} from '@/api/system/dict';
|
||||||
|
import { optionParent, optionChild } from '@/option/system/dict';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dictValue: '暂无',
|
||||||
|
parentId: -1,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
box: false,
|
||||||
|
loading: true,
|
||||||
|
loadingChild: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
optionParent: optionParent,
|
||||||
|
optionChild: optionChild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dict_add, false),
|
||||||
|
delBtn: this.validData(this.permission.dict_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dict_edit, false),
|
||||||
|
viewBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getDictTree().then(res => {
|
||||||
|
const column = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.formChild.dictValue = '';
|
||||||
|
this.formChild.dictKey = '';
|
||||||
|
this.formChild.sort = 0;
|
||||||
|
this.formChild.isSealed = 0;
|
||||||
|
this.formChild.remark = '';
|
||||||
|
this.formChild.parentId = row.id;
|
||||||
|
this.$refs.crudChild.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const form = {
|
||||||
|
...row,
|
||||||
|
dictKey: -1,
|
||||||
|
};
|
||||||
|
add(form).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.dictValue = row.dictValue;
|
||||||
|
|
||||||
|
const code = this.findObject(this.optionChild.column, 'code');
|
||||||
|
code.value = row.code;
|
||||||
|
const parentId = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
parentId.value = row.id;
|
||||||
|
|
||||||
|
this.formChild.code = row.code;
|
||||||
|
this.formChild.parentId = row.id;
|
||||||
|
|
||||||
|
this.box = true;
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.pageParent, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeCloseChild(done) {
|
||||||
|
this.$refs.crudChild.modelValue.parentId = this.parentId;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = this.parentId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loadingChild = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
this.dataChild = res.data.data;
|
||||||
|
this.loadingChild = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
450
src/views/system/dictbiz.vue
Normal file
450
src/views/system/dictbiz.vue
Normal file
@@ -0,0 +1,450 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="optionParent"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dictbiz_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click.stop="handleRowClick(scope.row)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>字典配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<el-tag @click="handleRowClick(row)" style="cursor: pointer">{{ row.code }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog :title="`[${dictValue}]字典配置`" append-to-body v-model="box" width="1000px">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionChild"
|
||||||
|
:table-loading="loadingChild"
|
||||||
|
:data="dataChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
:before-close="beforeCloseChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getParentList,
|
||||||
|
getChildList,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
add,
|
||||||
|
getDict,
|
||||||
|
getDictTree,
|
||||||
|
} from '@/api/system/dictbiz';
|
||||||
|
import { optionParent, optionChild } from '@/option/system/dictbiz';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dictValue: '暂无',
|
||||||
|
parentId: -1,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
box: false,
|
||||||
|
loading: true,
|
||||||
|
loadingChild: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
optionParent: optionParent,
|
||||||
|
optionChild: optionChild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dictbiz_add, false),
|
||||||
|
delBtn: this.validData(this.permission.dictbiz_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dictbiz_edit, false),
|
||||||
|
viewBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getDictTree().then(res => {
|
||||||
|
const column = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.formChild.dictValue = '';
|
||||||
|
this.formChild.dictKey = '';
|
||||||
|
this.formChild.sort = 0;
|
||||||
|
this.formChild.isSealed = 0;
|
||||||
|
this.formChild.remark = '';
|
||||||
|
this.formChild.parentId = row.id;
|
||||||
|
this.$refs.crudChild.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const form = {
|
||||||
|
...row,
|
||||||
|
dictKey: -1,
|
||||||
|
};
|
||||||
|
add(form).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.dictValue = row.dictValue;
|
||||||
|
|
||||||
|
const code = this.findObject(this.optionChild.column, 'code');
|
||||||
|
code.value = row.code;
|
||||||
|
const parentId = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
parentId.value = row.id;
|
||||||
|
|
||||||
|
this.formChild.code = row.code;
|
||||||
|
this.formChild.parentId = row.id;
|
||||||
|
|
||||||
|
this.box = true;
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.pageParent, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeCloseChild(done) {
|
||||||
|
this.$refs.crudChild.modelValue.parentId = this.parentId;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = this.parentId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loadingChild = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
this.dataChild = res.data.data;
|
||||||
|
this.loadingChild = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
438
src/views/system/menu.vue
Normal file
438
src/views/system/menu.vue
Normal file
@@ -0,0 +1,438 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
@tree-load="treeLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.menu_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin') && scope.row.category === 1"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ row }">
|
||||||
|
<i :class="row.source" style="margin-right: 5px" />
|
||||||
|
<span>{{ row.name }}</span>
|
||||||
|
</template>
|
||||||
|
<template #source="{ row }">
|
||||||
|
<div style="text-align: center">
|
||||||
|
<i :class="row.source" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getLazyList, remove, update, add, getMenu } from '@/api/system/menu';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import iconList from '@/config/iconList';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
import { getMenuTree } from '@/api/system/menu';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
selectionList: [],
|
||||||
|
parentId: 0,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
lazy: true,
|
||||||
|
tip: false,
|
||||||
|
simplePage: true,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
dialogWidth: '60%',
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
menuWidth: 320,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '菜单名称',
|
||||||
|
prop: 'name',
|
||||||
|
width: 300,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '路由地址',
|
||||||
|
prop: 'path',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入路由地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上级菜单',
|
||||||
|
prop: 'parentId',
|
||||||
|
type: 'tree',
|
||||||
|
dicData: [],
|
||||||
|
hide: true,
|
||||||
|
addDisabled: false,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: '请选择上级菜单',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单图标',
|
||||||
|
prop: 'source',
|
||||||
|
type: 'icon',
|
||||||
|
slot: true,
|
||||||
|
iconList: iconList,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单图标',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单类型',
|
||||||
|
prop: 'category',
|
||||||
|
type: 'radio',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '菜单',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '按钮',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择菜单类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单别名',
|
||||||
|
prop: 'alias',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单别名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是否缓存',
|
||||||
|
prop: 'isOpen',
|
||||||
|
type: 'radio',
|
||||||
|
hide: true,
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
value: 1,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择是否缓存',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单备注',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.category'() {
|
||||||
|
const category = func.toInt(this.form.category);
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'path') {
|
||||||
|
item.rules[0].required = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'isOpen') {
|
||||||
|
item.disabled = category === 2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.menu_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.menu_view, false),
|
||||||
|
delBtn: this.validData(this.permission.menu_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.menu_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.parentId = row.id;
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.value = row.id;
|
||||||
|
column.addDisabled = true;
|
||||||
|
this.$refs.crud.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
res => {
|
||||||
|
// 获取新增数据的相关字段
|
||||||
|
const data = res.data.data;
|
||||||
|
row.id = data.id;
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row, index, done) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
// 数据回调进行刷新
|
||||||
|
done(row);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// 刷新表格数据并重载
|
||||||
|
this.data = [];
|
||||||
|
this.parentId = 0;
|
||||||
|
this.$refs.crud.refreshTable();
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
// 表格数据重载
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = 0;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.parentId = '';
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getMenu(this.form.id).then(res => {
|
||||||
|
this.form = Object.assign(res.data.data, {
|
||||||
|
hasChildren: this.form.hasChildren,
|
||||||
|
});
|
||||||
|
if (this.form.parentId === '0') {
|
||||||
|
this.form.parentId = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeClose(done) {
|
||||||
|
this.parentId = '';
|
||||||
|
const column = this.findObject(this.option.column, 'parentId');
|
||||||
|
column.value = '';
|
||||||
|
column.addDisabled = false;
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
treeLoad(tree, treeNode, resolve) {
|
||||||
|
const parentId = tree.id;
|
||||||
|
getLazyList(parentId).then(res => {
|
||||||
|
resolve(res.data.data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
371
src/views/system/param.vue
Normal file
371
src/views/system/param.vue
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<div class="avue-crud">
|
||||||
|
<el-row :hidden="!search" style="padding: 6px 18px">
|
||||||
|
<!-- 查询模块 -->
|
||||||
|
<el-form :inline="true" :model="query">
|
||||||
|
<el-form-item label="参数名:">
|
||||||
|
<el-input v-model="query.paramName" placeholder="请输入参数名"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="参数键:">
|
||||||
|
<el-input v-model="query.paramKey" placeholder="请输入参数键"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- 查询按钮 -->
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button>
|
||||||
|
<el-button icon="el-icon-delete" @click="searchReset()">清 空</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<div class="avue-crud__header">
|
||||||
|
<!-- 头部左侧按钮模块 -->
|
||||||
|
<div class="avue-crud__left">
|
||||||
|
<el-button
|
||||||
|
v-if="this.permissionList.addBtn"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
>新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="this.permissionList.delBtn"
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
plain
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<!-- 头部右侧按钮模块 -->
|
||||||
|
<div class="avue-crud__right">
|
||||||
|
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
|
||||||
|
<el-button icon="el-icon-search" @click="searchHide" circle></el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<!-- 列表模块 -->
|
||||||
|
<el-table
|
||||||
|
ref="table"
|
||||||
|
v-loading="loading"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
:data="data"
|
||||||
|
:height="height"
|
||||||
|
style="width: 100%"
|
||||||
|
:border="option.border"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
type="selection"
|
||||||
|
v-if="option.selection"
|
||||||
|
width="55"
|
||||||
|
align="center"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
|
||||||
|
<el-table-column v-if="option.index" label="#" type="index" width="50" align="center">
|
||||||
|
</el-table-column>
|
||||||
|
<template v-for="(item, index) in option.column">
|
||||||
|
<!-- table字段 -->
|
||||||
|
<el-table-column
|
||||||
|
v-if="item.hide !== true"
|
||||||
|
:prop="item.prop"
|
||||||
|
:label="item.label"
|
||||||
|
:width="item.width"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
</template>
|
||||||
|
<!-- 操作栏模块 -->
|
||||||
|
<el-table-column prop="menu" label="操作" :width="220" align="center">
|
||||||
|
<template #="{ row }">
|
||||||
|
<el-button
|
||||||
|
v-if="this.permissionList.viewBtn"
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-view"
|
||||||
|
@click="handleView(row)"
|
||||||
|
>查看
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="this.permissionList.editBtn"
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleEdit(row)"
|
||||||
|
>编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="this.permissionList.delBtn"
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="rowDel(row)"
|
||||||
|
>删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<div class="avue-crud__pagination" style="width: 100%">
|
||||||
|
<!-- 分页模块 -->
|
||||||
|
<el-pagination
|
||||||
|
align="right"
|
||||||
|
background
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
:current-page="page.currentPage"
|
||||||
|
:page-sizes="[10, 20, 30, 40, 50, 100]"
|
||||||
|
:page-size="page.pageSize"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="page.total"
|
||||||
|
>
|
||||||
|
</el-pagination>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<!-- 表单模块 -->
|
||||||
|
<el-dialog
|
||||||
|
:title="title"
|
||||||
|
v-model="box"
|
||||||
|
width="50%"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
append-to-body
|
||||||
|
>
|
||||||
|
<el-form :disabled="view" ref="form" :model="form" label-width="80px">
|
||||||
|
<!-- 表单字段 -->
|
||||||
|
<el-form-item label="参数名:" prop="paramName">
|
||||||
|
<el-input v-model="form.paramName" placeholder="请输入参数名" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="参数键:" prop="paramKey">
|
||||||
|
<el-input v-model="form.paramKey" placeholder="请输入参数键" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="参数值:" prop="paramValue">
|
||||||
|
<el-input v-model="form.paramValue" placeholder="请输入参数值" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注:" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<!-- 表单按钮 -->
|
||||||
|
<template #footer>
|
||||||
|
<span v-if="!view" class="dialog-footer">
|
||||||
|
<el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit"
|
||||||
|
>提 交</el-button
|
||||||
|
>
|
||||||
|
<el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/system/param';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
height: 0,
|
||||||
|
// 弹框标题
|
||||||
|
title: '',
|
||||||
|
// 是否展示弹框
|
||||||
|
box: false,
|
||||||
|
// 是否显示查询
|
||||||
|
search: true,
|
||||||
|
// 加载中
|
||||||
|
loading: true,
|
||||||
|
// 是否为查看模式
|
||||||
|
view: false,
|
||||||
|
// 查询信息
|
||||||
|
query: {},
|
||||||
|
// 分页信息
|
||||||
|
page: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
total: 40,
|
||||||
|
},
|
||||||
|
// 表单数据
|
||||||
|
form: {},
|
||||||
|
// 选择行
|
||||||
|
selectionList: [],
|
||||||
|
// 表单配置
|
||||||
|
option: {
|
||||||
|
expand: false,
|
||||||
|
index: true,
|
||||||
|
border: true,
|
||||||
|
selection: true,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '参数名',
|
||||||
|
prop: 'paramName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '参数键',
|
||||||
|
prop: 'paramKey',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '参数值',
|
||||||
|
prop: 'paramValue',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// 表单列表
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init();
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.param_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.param_view, false),
|
||||||
|
delBtn: this.validData(this.permission.param_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.param_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
this.height = this.setPx(document.body.clientHeight - 340);
|
||||||
|
},
|
||||||
|
searchHide() {
|
||||||
|
this.search = !this.search;
|
||||||
|
},
|
||||||
|
searchChange() {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
handleSubmit() {
|
||||||
|
if (!this.form.id) {
|
||||||
|
add(this.form).then(() => {
|
||||||
|
this.box = false;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
update(this.form).then(() => {
|
||||||
|
this.box = false;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.title = '新增';
|
||||||
|
this.form = {};
|
||||||
|
this.box = true;
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
this.title = '编辑';
|
||||||
|
this.box = true;
|
||||||
|
getDetail(row.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleView(row) {
|
||||||
|
this.title = '查看';
|
||||||
|
this.view = true;
|
||||||
|
this.box = true;
|
||||||
|
getDetail(row.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.selectionClear();
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeClose(done) {
|
||||||
|
done();
|
||||||
|
this.form = {};
|
||||||
|
this.view = false;
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.table.clearSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
298
src/views/system/post.vue
Normal file
298
src/views/system/post.vue
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.post_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #category="{ row }">
|
||||||
|
<el-tag>{{ row.categoryName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/system/post';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import website from '@/config/website';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '所属租户',
|
||||||
|
prop: 'tenantId',
|
||||||
|
type: 'tree',
|
||||||
|
dicUrl: '/blade-system/tenant/select',
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
viewDisplay: website.tenantMode,
|
||||||
|
span: 24,
|
||||||
|
props: {
|
||||||
|
label: 'tenantName',
|
||||||
|
value: 'tenantId',
|
||||||
|
},
|
||||||
|
hide: !website.tenantMode,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入所属租户',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位类型',
|
||||||
|
prop: 'category',
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=post_category',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
slot: true,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择岗位类型',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位编号',
|
||||||
|
prop: 'postCode',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入岗位编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位名称',
|
||||||
|
prop: 'postName',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入岗位名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入岗位排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '岗位描述',
|
||||||
|
prop: 'remark',
|
||||||
|
type: 'textarea',
|
||||||
|
span: 24,
|
||||||
|
minRows: 6,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.post_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.post_view, false),
|
||||||
|
delBtn: this.validData(this.permission.post_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.post_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
770
src/views/system/tenant.vue
Normal file
770
src/views/system/tenant.vue
Normal file
@@ -0,0 +1,770 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.tenant_add && !recycleMode"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="$refs.crud.rowAdd()"
|
||||||
|
>新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.tenant_delete && !recycleMode"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
@click="handleRecycle"
|
||||||
|
>回收站
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-check"
|
||||||
|
v-if="userInfo.authority.includes('administrator') && recycleMode"
|
||||||
|
@click="handleRecyclePass"
|
||||||
|
>恢 复
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-close"
|
||||||
|
v-if="userInfo.authority.includes('administrator') && recycleMode"
|
||||||
|
@click="handleRecycleRemove"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-refresh-left"
|
||||||
|
v-if="userInfo.authority.includes('administrator') && recycleMode"
|
||||||
|
@click="handleRecycleBack"
|
||||||
|
>返 回
|
||||||
|
</el-button>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="给租户配置账号额度、过期时间等授权信息"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
type="info"
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click="handleSetting"
|
||||||
|
>批量授权配置
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #menu-right>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="将自定义的数据源定制为租户绑定的独立数据源"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
icon="el-icon-message-box"
|
||||||
|
@click="handleDatasourceSetting"
|
||||||
|
>数据源管理
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="将自定义的菜单集合定制为租户绑定的菜单产品包"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
icon="el-icon-set-up"
|
||||||
|
@click="handlePackageSetting"
|
||||||
|
>产品包管理
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-coin"
|
||||||
|
@click.stop="handleRowDatasource(scope.row)"
|
||||||
|
>数据源
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="userInfo.authority.includes('administrator') && !recycleMode"
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-notebook"
|
||||||
|
@click.stop="handleRowPackage(scope.row)"
|
||||||
|
>产品包
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #accountNumber="{ row }">
|
||||||
|
<el-tag>{{ row.accountNumber > 0 ? row.accountNumber : '不限制' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #expireTime="{ row }">
|
||||||
|
<el-tag>{{ row.expireTime ? row.expireTime : '不限制' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="租户授权配置" append-to-body v-model="box" width="450px">
|
||||||
|
<avue-form :option="settingOption" v-model="settingForm" @submit="handleSubmit" />
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog title="租户数据源配置" append-to-body v-model="datasourceBox" width="450px">
|
||||||
|
<avue-form
|
||||||
|
ref="formDatasource"
|
||||||
|
:option="datasourceOption"
|
||||||
|
v-model="datasourceForm"
|
||||||
|
@submit="handleDatasourceSubmit"
|
||||||
|
/>
|
||||||
|
</el-dialog>
|
||||||
|
<el-drawer
|
||||||
|
title="租户数据源管理"
|
||||||
|
append-to-body
|
||||||
|
v-model="datasourceSettingBox"
|
||||||
|
direction="rtl"
|
||||||
|
size="50%"
|
||||||
|
>
|
||||||
|
<tenant-datasource></tenant-datasource>
|
||||||
|
</el-drawer>
|
||||||
|
<el-dialog title="租户产品包配置" append-to-body v-model="packageBox" width="450px">
|
||||||
|
<avue-form
|
||||||
|
ref="formPackage"
|
||||||
|
:option="packageOption"
|
||||||
|
v-model="packageForm"
|
||||||
|
@submit="handlePackageSubmit"
|
||||||
|
/>
|
||||||
|
</el-dialog>
|
||||||
|
<el-drawer
|
||||||
|
title="租户产品包管理"
|
||||||
|
append-to-body
|
||||||
|
v-model="packageSettingBox"
|
||||||
|
direction="rtl"
|
||||||
|
size="50%"
|
||||||
|
>
|
||||||
|
<tenant-package></tenant-package>
|
||||||
|
</el-drawer>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getList,
|
||||||
|
getDetail,
|
||||||
|
update,
|
||||||
|
add,
|
||||||
|
setting,
|
||||||
|
datasource,
|
||||||
|
packageInfo,
|
||||||
|
packageSetting,
|
||||||
|
recycle,
|
||||||
|
pass,
|
||||||
|
remove,
|
||||||
|
} from '@/api/system/tenant';
|
||||||
|
import { getDetail as packageDetail } from '@/api/system/tenantpackage';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { getMenuTree } from '@/api/system/menu';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
box: false,
|
||||||
|
datasourceBox: false,
|
||||||
|
datasourceSettingBox: false,
|
||||||
|
packageBox: false,
|
||||||
|
packageSettingBox: false,
|
||||||
|
recycleMode: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
addBtn: false,
|
||||||
|
viewBtn: true,
|
||||||
|
menuWidth: 380,
|
||||||
|
dialogWidth: 900,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '租户ID',
|
||||||
|
prop: 'tenantId',
|
||||||
|
width: 100,
|
||||||
|
search: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入租户ID',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '租户名称',
|
||||||
|
prop: 'tenantName',
|
||||||
|
search: true,
|
||||||
|
width: 180,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入参数名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '联系人',
|
||||||
|
prop: 'linkman',
|
||||||
|
width: 100,
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入联系人',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '联系电话',
|
||||||
|
prop: 'contactNumber',
|
||||||
|
width: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '联系地址',
|
||||||
|
prop: 'address',
|
||||||
|
span: 24,
|
||||||
|
minRows: 2,
|
||||||
|
type: 'textarea',
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '账号额度',
|
||||||
|
prop: 'accountNumber',
|
||||||
|
width: 90,
|
||||||
|
slot: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '过期时间',
|
||||||
|
prop: 'expireTime',
|
||||||
|
width: 180,
|
||||||
|
slot: true,
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '绑定域名',
|
||||||
|
prop: 'domainUrl',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '系统背景',
|
||||||
|
prop: 'backgroundUrl',
|
||||||
|
type: 'upload',
|
||||||
|
listType: 'picture-img',
|
||||||
|
dataType: 'string',
|
||||||
|
action: '/blade-resource/oss/endpoint/put-file',
|
||||||
|
propsHttp: {
|
||||||
|
res: 'data',
|
||||||
|
url: 'link',
|
||||||
|
},
|
||||||
|
hide: true,
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
settingForm: {},
|
||||||
|
settingOption: {
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '账号额度',
|
||||||
|
labelTip: '代表租户可创建的最大额度,若不限制则默认为-1',
|
||||||
|
prop: 'accountNumber',
|
||||||
|
type: 'number',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '过期时间',
|
||||||
|
labelTip: '代表租户可使用的最后日期,若不限制则默认为空',
|
||||||
|
prop: 'expireTime',
|
||||||
|
type: 'date',
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
datasourceForm: {},
|
||||||
|
datasourceOption: {
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '数据源',
|
||||||
|
prop: 'datasourceId',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/tenant-datasource/select',
|
||||||
|
props: {
|
||||||
|
label: 'name',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择数据源',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
packageForm: {},
|
||||||
|
packageOption: {
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '产品包',
|
||||||
|
prop: 'packageId',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
type: 'select',
|
||||||
|
dicUrl: '/blade-system/tenant-package/select',
|
||||||
|
props: {
|
||||||
|
label: 'packageName',
|
||||||
|
value: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单预览',
|
||||||
|
prop: 'menuId',
|
||||||
|
span: 24,
|
||||||
|
type: 'tree',
|
||||||
|
dicData: [],
|
||||||
|
hide: true,
|
||||||
|
multiple: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'packageForm.packageId'() {
|
||||||
|
if (!validatenull(this.packageForm.packageId)) {
|
||||||
|
packageDetail(this.packageForm.packageId).then(res => {
|
||||||
|
this.packageForm.menuId = res.data.data.menuId;
|
||||||
|
this.initData();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.tenant_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.tenant_view, false),
|
||||||
|
delBtn: this.validData(this.permission.tenant_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.tenant_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
tenantId() {
|
||||||
|
return this.selectionList[0].tenantId;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.packageOption.column, 'menuId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('删除后所选租户将进入回收站,是否继续?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return recycle(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
if (!(data.accountNumber > 0)) {
|
||||||
|
data.accountNumber = '不限制';
|
||||||
|
}
|
||||||
|
if (!data.expireTime) {
|
||||||
|
data.expireTime = '不限制';
|
||||||
|
}
|
||||||
|
this.form = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('删除后所选租户将进入回收站,是否继续?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return recycle(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRecycle() {
|
||||||
|
this.recycleMode = true;
|
||||||
|
this.$refs.crud.option.editBtn = false;
|
||||||
|
this.$refs.crud.option.delBtn = false;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
handleRecyclePass() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将所选租户进行恢复?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return pass(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRecycleRemove() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将所选租户永久删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRecycleBack() {
|
||||||
|
this.recycleMode = false;
|
||||||
|
this.$refs.crud.option.editBtn = true;
|
||||||
|
this.$refs.crud.option.delBtn = true;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
handleSetting() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selectionList.length === 1) {
|
||||||
|
getDetail(this.selectionList[0].id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.settingForm.accountNumber = data.accountNumber;
|
||||||
|
this.settingForm.expireTime = data.expireTime;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.settingForm.accountNumber = -1;
|
||||||
|
this.settingForm.expireTime = '';
|
||||||
|
}
|
||||||
|
this.box = true;
|
||||||
|
},
|
||||||
|
handleRowDatasource(row) {
|
||||||
|
getDetail(row.id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.datasourceForm.tenantId = row.tenantId;
|
||||||
|
this.datasourceForm.datasourceId = data.datasourceId;
|
||||||
|
});
|
||||||
|
this.datasourceBox = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.formDatasource.updateDic('datasourceId');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDatasource() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selectionList.length !== 1) {
|
||||||
|
this.$message.warning('只能选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getDetail(this.selectionList[0].id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.datasourceForm.tenantId = this.selectionList[0].tenantId;
|
||||||
|
this.datasourceForm.datasourceId = data.datasourceId;
|
||||||
|
});
|
||||||
|
this.datasourceBox = true;
|
||||||
|
},
|
||||||
|
handleRowPackage(row) {
|
||||||
|
packageInfo(row.id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.packageForm.tenantId = row.tenantId;
|
||||||
|
this.packageForm.packageId = data.id;
|
||||||
|
this.packageForm.menuId = data.menuId;
|
||||||
|
});
|
||||||
|
this.packageBox = true;
|
||||||
|
//更新字典远程数据
|
||||||
|
setTimeout(() => {
|
||||||
|
const form = this.$refs.formPackage;
|
||||||
|
form.updateDic('packageId');
|
||||||
|
}, 10);
|
||||||
|
},
|
||||||
|
handlePackage() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selectionList.length !== 1) {
|
||||||
|
this.$message.warning('只能选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selectionList.length === 1) {
|
||||||
|
packageInfo(this.selectionList[0].id).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.packageForm.tenantId = this.selectionList[0].tenantId;
|
||||||
|
this.packageForm.packageId = data.id;
|
||||||
|
this.packageForm.menuId = data.menuId;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.packageForm.menuId = '';
|
||||||
|
}
|
||||||
|
this.packageBox = true;
|
||||||
|
//更新字典远程数据
|
||||||
|
setTimeout(() => {
|
||||||
|
const form = this.$refs.formPackage;
|
||||||
|
form.updateDic('packageId');
|
||||||
|
}, 10);
|
||||||
|
},
|
||||||
|
handleDatasourceSetting() {
|
||||||
|
this.datasourceSettingBox = true;
|
||||||
|
},
|
||||||
|
handlePackageSetting() {
|
||||||
|
this.packageSettingBox = true;
|
||||||
|
},
|
||||||
|
handleSubmit(form, done) {
|
||||||
|
setting(this.ids, form).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '配置成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
this.box = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleDatasourceSubmit(form, done) {
|
||||||
|
datasource(form.tenantId, form.datasourceId).then(
|
||||||
|
() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '配置成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
this.datasourceBox = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handlePackageSubmit(form, done) {
|
||||||
|
packageSetting(form.tenantId, form.packageId).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '配置成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
this.packageBox = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
Object.assign(params, this.query, {
|
||||||
|
status_equal: this.recycleMode ? -1 : 1,
|
||||||
|
})
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
377
src/views/system/tenantdatasource.vue
Normal file
377
src/views/system/tenantdatasource.vue
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #shardingConfig-form="{}">
|
||||||
|
<code-editor v-model="form.shardingConfig" height="300px" />
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/system/tenantdatasource';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 900,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
grid: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '名称',
|
||||||
|
prop: 'name',
|
||||||
|
width: 120,
|
||||||
|
span: 24,
|
||||||
|
search: true,
|
||||||
|
gridRow: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据源名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '数据类型',
|
||||||
|
type: 'radio',
|
||||||
|
value: 1,
|
||||||
|
span: 24,
|
||||||
|
width: 120,
|
||||||
|
searchLabelWidth: 100,
|
||||||
|
row: true,
|
||||||
|
gridRow: true,
|
||||||
|
dicUrl: '/blade-system/dict/dictionary?code=datasource_category',
|
||||||
|
props: {
|
||||||
|
label: 'dictValue',
|
||||||
|
value: 'dictKey',
|
||||||
|
},
|
||||||
|
dataType: 'number',
|
||||||
|
prop: 'category',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择分类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'YAML',
|
||||||
|
prop: 'shardingConfig',
|
||||||
|
span: 24,
|
||||||
|
minRows: 5,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
gridRow: true,
|
||||||
|
slot: true,
|
||||||
|
type: 'textarea',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入YAML配置',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '驱动类',
|
||||||
|
prop: 'driverClass',
|
||||||
|
type: 'select',
|
||||||
|
span: 24,
|
||||||
|
gridRow: true,
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: 'com.mysql.cj.jdbc.Driver',
|
||||||
|
value: 'com.mysql.cj.jdbc.Driver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'org.postgresql.Driver',
|
||||||
|
value: 'org.postgresql.Driver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'oracle.jdbc.OracleDriver',
|
||||||
|
value: 'oracle.jdbc.OracleDriver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
value: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'dm.jdbc.driver.DmDriver',
|
||||||
|
value: 'dm.jdbc.driver.DmDriver',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
width: 200,
|
||||||
|
display: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入驱动类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户名',
|
||||||
|
prop: 'username',
|
||||||
|
width: 120,
|
||||||
|
display: true,
|
||||||
|
gridRow: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入用户名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '密码',
|
||||||
|
prop: 'password',
|
||||||
|
hide: true,
|
||||||
|
display: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入密码',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '连接地址',
|
||||||
|
prop: 'url',
|
||||||
|
span: 24,
|
||||||
|
display: true,
|
||||||
|
gridRow: true,
|
||||||
|
hide: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入连接地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
minRows: 3,
|
||||||
|
hide: true,
|
||||||
|
type: 'textarea',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.category'() {
|
||||||
|
const category = func.toInt(this.form.category);
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'driverClass') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'url') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'username') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'password') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'shardingConfig') {
|
||||||
|
item.display = category === 2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: true,
|
||||||
|
viewBtn: true,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
249
src/views/system/tenantpackage.vue
Normal file
249
src/views/system/tenantpackage.vue
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
<template>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete">删 除</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/system/tenantpackage';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { getMenuTree } from '@/api/system/menu';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'tenantPackage',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
dialogWidth: 600,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '产品包名',
|
||||||
|
prop: 'packageName',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入产品包名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单列表',
|
||||||
|
prop: 'menuId',
|
||||||
|
span: 24,
|
||||||
|
type: 'tree',
|
||||||
|
dicData: [],
|
||||||
|
hide: true,
|
||||||
|
multiple: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择菜单',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: true,
|
||||||
|
viewBtn: false,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'menuId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
row.menuId = row.menuId.join(',');
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
365
src/views/system/topmenu.vue
Normal file
365
src/views/system/topmenu.vue
Normal file
@@ -0,0 +1,365 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.topmenu_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click="handleMenuSetting"
|
||||||
|
v-if="permission.topmenu_setting"
|
||||||
|
plain
|
||||||
|
>菜单配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #name="{ row }">
|
||||||
|
<i :class="row.source" style="margin-right: 5px" />
|
||||||
|
<span>{{ row.name }}</span>
|
||||||
|
</template>
|
||||||
|
<template #source="{ row }">
|
||||||
|
<div style="text-align: center">
|
||||||
|
<i :class="row.source"></i>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #sort="{ row }">
|
||||||
|
<el-input-number
|
||||||
|
v-model="row.sort"
|
||||||
|
@change="sortChange(row)"
|
||||||
|
:min="1"
|
||||||
|
:max="100"
|
||||||
|
></el-input-number>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="下级菜单配置" append-to-body v-model="box" width="345px">
|
||||||
|
<el-tree
|
||||||
|
:data="menuGrantList"
|
||||||
|
show-checkbox
|
||||||
|
node-key="id"
|
||||||
|
ref="treeMenu"
|
||||||
|
:default-checked-keys="menuTreeObj"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
</el-tree>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="box = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submit">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getList,
|
||||||
|
getDetail,
|
||||||
|
add,
|
||||||
|
update,
|
||||||
|
remove,
|
||||||
|
grant,
|
||||||
|
grantTree,
|
||||||
|
getTopTree,
|
||||||
|
} from '@/api/system/topmenu';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import iconList from '@/config/iconList';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
box: false,
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
value: 'key',
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
menuGrantList: [],
|
||||||
|
menuTreeObj: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
selection: true,
|
||||||
|
dialogWidth: 900,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '菜单名',
|
||||||
|
prop: 'name',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单图标',
|
||||||
|
prop: 'source',
|
||||||
|
type: 'icon',
|
||||||
|
slot: true,
|
||||||
|
iconList: iconList,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单图标',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '菜单排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入菜单排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.topmenu_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.topmenu_view, false),
|
||||||
|
delBtn: this.validData(this.permission.topmenu_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.topmenu_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
idsArray() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submit() {
|
||||||
|
const menuList = this.$refs.treeMenu.getCheckedKeys();
|
||||||
|
grant(this.idsArray, menuList).then(() => {
|
||||||
|
this.box = false;
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.onLoad(this.page);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleMenuSetting() {
|
||||||
|
if (this.selectionList.length !== 1) {
|
||||||
|
this.$message.warning('只能选择一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.menuTreeObj = [];
|
||||||
|
grantTree().then(res => {
|
||||||
|
this.menuGrantList = res.data.data.menu;
|
||||||
|
getTopTree(this.ids).then(res => {
|
||||||
|
this.menuTreeObj = res.data.data.menu;
|
||||||
|
this.box = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
sortChange(row) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.none-border {
|
||||||
|
border: 0;
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
809
src/views/system/user.vue
Normal file
809
src/views/system/user.vue
Normal file
@@ -0,0 +1,809 @@
|
|||||||
|
<template>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="5">
|
||||||
|
<div class="box">
|
||||||
|
<el-scrollbar>
|
||||||
|
<basic-container>
|
||||||
|
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
|
||||||
|
</basic-container>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="19">
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="userOption"
|
||||||
|
v-model:search="search"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model:page="page"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
v-if="permission.user_add && !auditMode"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="$refs.crud.rowAdd()"
|
||||||
|
>Add
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.user_delete && !auditMode"
|
||||||
|
@click="handleDelete"
|
||||||
|
>Delete
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-operation"
|
||||||
|
v-if="userInfo.authority.includes('admin') && !auditMode"
|
||||||
|
@click="handleAudit"
|
||||||
|
>Audit
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-check"
|
||||||
|
v-if="userInfo.authority.includes('admin') && auditMode"
|
||||||
|
@click="handleAuditPass"
|
||||||
|
>Pass
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-close"
|
||||||
|
v-if="userInfo.authority.includes('admin') && auditMode"
|
||||||
|
@click="handleAuditRefuse"
|
||||||
|
>Reject
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-refresh-left"
|
||||||
|
v-if="userInfo.authority.includes('admin') && auditMode"
|
||||||
|
@click="handleAuditBack"
|
||||||
|
>Back
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
v-if="permission.user_role && !auditMode"
|
||||||
|
icon="el-icon-user"
|
||||||
|
@click="handleGrant"
|
||||||
|
>Role
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
v-if="permission.user_reset && !auditMode"
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
@click="handleReset"
|
||||||
|
>Reset
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('admin') && !auditMode"
|
||||||
|
icon="el-icon-setting"
|
||||||
|
@click="handlePlatform"
|
||||||
|
>Platform
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('admin') && !auditMode"
|
||||||
|
icon="el-icon-coordinate"
|
||||||
|
@click="handleLock"
|
||||||
|
>Unlock
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('admin') && !auditMode"
|
||||||
|
icon="el-icon-upload"
|
||||||
|
@click="handleImport"
|
||||||
|
>Import
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('admin') && !auditMode"
|
||||||
|
icon="el-icon-download"
|
||||||
|
@click="handleExport"
|
||||||
|
>Export
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row, index, size }">
|
||||||
|
<el-button
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-view"
|
||||||
|
v-if="this.permission.user_view"
|
||||||
|
@click.stop="$refs.crud.rowView(row, index)"
|
||||||
|
>View
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
v-if="this.permission.user_edit"
|
||||||
|
@click.stop="$refs.crud.rowEdit(row, index)"
|
||||||
|
>Edit
|
||||||
|
</el-button>
|
||||||
|
<el-dropdown @command="command => handleDropdownCommand(command, row, index)">
|
||||||
|
<el-button text type="primary" icon="el-icon-setting">More</el-button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item command="setLeader" v-if="userInfo.authority.includes('admin')">
|
||||||
|
<el-icon><circle-close v-if="row.isLeader === 1" /><user v-else /></el-icon>
|
||||||
|
{{ row.isLeader === 1 ? 'Cancel leader' : 'Set leader' }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="delete" v-if="this.permission.user_delete">
|
||||||
|
<el-icon><delete /></el-icon>
|
||||||
|
Delete
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</template>
|
||||||
|
<template #tenantName="{ row }">
|
||||||
|
<el-tag>{{ row.tenantName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #roleName="{ row }">
|
||||||
|
<el-tag>{{ row.roleName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #deptName="{ row }">
|
||||||
|
<el-tag>{{ row.deptName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #userTypeName="{ row }">
|
||||||
|
<el-tag>{{ row.userTypeName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="Role" append-to-body v-model="roleBox" width="345px">
|
||||||
|
<el-tree
|
||||||
|
:data="roleGrantList"
|
||||||
|
show-checkbox
|
||||||
|
check-strictly
|
||||||
|
default-expand-all
|
||||||
|
node-key="id"
|
||||||
|
ref="treeRole"
|
||||||
|
:default-checked-keys="roleTreeObj"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
</el-tree>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="roleBox = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submitRole">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog title="ImportUser" append-to-body v-model="excelBox" width="555px">
|
||||||
|
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
|
||||||
|
<template #excelTemplate>
|
||||||
|
<el-button type="primary" @click="handleTemplate">
|
||||||
|
Download<i class="el-icon-download el-icon--right"></i>
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-form>
|
||||||
|
</el-dialog>
|
||||||
|
<el-dialog title="Platform" append-to-body v-model="platformBox">
|
||||||
|
<avue-crud
|
||||||
|
:option="platformOption"
|
||||||
|
:table-loading="platformLoading"
|
||||||
|
:data="platformData"
|
||||||
|
ref="platformCrud"
|
||||||
|
v-model="platformForm"
|
||||||
|
:before-open="platformBeforeOpen"
|
||||||
|
v-model:page="platformPage"
|
||||||
|
:permission="platformPermissionList"
|
||||||
|
@row-update="platformRowUpdate"
|
||||||
|
@search-change="platformSearchChange"
|
||||||
|
@search-reset="platformSearchReset"
|
||||||
|
@selection-change="platformSelectionChange"
|
||||||
|
@current-change="platformCurrentChange"
|
||||||
|
@size-change="platformSizeChange"
|
||||||
|
@refresh-change="platformRefreshChange"
|
||||||
|
@on-load="platformOnLoad"
|
||||||
|
>
|
||||||
|
<template #tenantName="{ row }">
|
||||||
|
<el-tag>{{ row.tenantName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #userTypeName="{ row }">
|
||||||
|
<el-tag>{{ row.userTypeName }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getList,
|
||||||
|
getUser,
|
||||||
|
getUserPlatform,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
updatePlatform,
|
||||||
|
add,
|
||||||
|
grant,
|
||||||
|
resetPassword,
|
||||||
|
unlock,
|
||||||
|
auditPass,
|
||||||
|
auditRefuse,
|
||||||
|
setLeader,
|
||||||
|
getLeaderList,
|
||||||
|
} from '@/api/system/user';
|
||||||
|
import { exportBlob } from '@/api/common';
|
||||||
|
import { getDeptTree } from '@/api/system/dept';
|
||||||
|
import { getRoleTree } from '@/api/system/role';
|
||||||
|
import { getPostList } from '@/api/system/post';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import website from '@/config/website';
|
||||||
|
import { getToken } from '@/utils/auth';
|
||||||
|
import { downloadXls } from '@/utils/util';
|
||||||
|
import NProgress from 'nprogress';
|
||||||
|
import 'nprogress/nprogress.css';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
import { sensitive } from '@/utils/sensitive';
|
||||||
|
import { excelOption, platformOption, treeOption, userOption } from '@/option/system/user';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
search: {},
|
||||||
|
sensitiveManager: null,
|
||||||
|
roleBox: false,
|
||||||
|
excelBox: false,
|
||||||
|
platformBox: false,
|
||||||
|
initFlag: true,
|
||||||
|
auditMode: false,
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
platformLoading: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
platformPage: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
init: {
|
||||||
|
roleTree: [],
|
||||||
|
deptTree: [],
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
value: 'key',
|
||||||
|
},
|
||||||
|
roleGrantList: [],
|
||||||
|
roleTreeObj: [],
|
||||||
|
treeDeptId: '',
|
||||||
|
treeData: [],
|
||||||
|
treeOption: treeOption,
|
||||||
|
userOption: userOption(this),
|
||||||
|
data: [],
|
||||||
|
platformQuery: {},
|
||||||
|
platformSelectionList: [],
|
||||||
|
platformData: [],
|
||||||
|
platformForm: {},
|
||||||
|
platformOption: platformOption,
|
||||||
|
excelForm: {},
|
||||||
|
excelOption: excelOption,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.tenantId'() {
|
||||||
|
if (this.form.tenantId !== '' && this.initFlag) {
|
||||||
|
this.initData(this.form.tenantId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'excelForm.isCovered'() {
|
||||||
|
if (this.excelForm.isCovered !== '') {
|
||||||
|
const column = this.findObject(this.excelOption.column, 'excelFile');
|
||||||
|
column.action = `/blade-system/user/import-user?isCovered=${this.excelForm.isCovered}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.user_add, false),
|
||||||
|
viewBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
platformPermissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: false,
|
||||||
|
viewBtn: false,
|
||||||
|
delBtn: false,
|
||||||
|
editBtn: this.validData(this.permission.user_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 非租户模式默认加载管理组数据
|
||||||
|
if (!website.tenantMode) {
|
||||||
|
this.initData(website.tenantId);
|
||||||
|
} else {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 创建脱敏工具实例
|
||||||
|
this.sensitiveManager = sensitive.create({
|
||||||
|
fields: ['phone', 'email'], // 配置需要脱敏的字段
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
nodeClick(data) {
|
||||||
|
this.treeDeptId = data.id;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
handleDropdownCommand(command, row, index) {
|
||||||
|
if (command === 'setLeader') {
|
||||||
|
this.handleSetLeader(row);
|
||||||
|
} else if (command === 'delete') {
|
||||||
|
this.$refs.crud.rowDel(row, index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleSetLeader(row) {
|
||||||
|
const tip = row.isLeader === 1 ? 'Confirmation for Cancel?' : 'Confirmation for Set?';
|
||||||
|
const message = row.isLeader === 1 ? 'Cancellation Success!' : 'Setting Success!';
|
||||||
|
this.$confirm(tip, {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return setLeader(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: message,
|
||||||
|
});
|
||||||
|
this.onLoad(this.page);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
initData(tenantId) {
|
||||||
|
getRoleTree(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.userOption.group, 'roleId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
getDeptTree(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.userOption.group, 'deptId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
getPostList(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.userOption.group, 'postId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
getLeaderList(tenantId).then(res => {
|
||||||
|
const column = this.findObject(this.userOption.group, 'leaderId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
submitRole() {
|
||||||
|
const roleList = this.$refs.treeRole.getCheckedKeys().join(',');
|
||||||
|
grant(this.ids, roleList).then(() => {
|
||||||
|
this.roleBox = false;
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
this.onLoad(this.page);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
row.deptId = func.join(row.deptId);
|
||||||
|
row.roleId = func.join(row.roleId);
|
||||||
|
row.postId = func.join(row.postId);
|
||||||
|
row.leaderId = func.join(row.leaderId);
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.initFlag = false;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
row.deptId = func.join(row.deptId);
|
||||||
|
row.roleId = func.join(row.roleId);
|
||||||
|
row.postId = func.join(row.postId);
|
||||||
|
row.leaderId = func.join(row.leaderId);
|
||||||
|
// 获取需要提交的数据
|
||||||
|
const submitData = this.sensitiveManager.getSubmitData(row);
|
||||||
|
update(submitData).then(
|
||||||
|
() => {
|
||||||
|
this.initFlag = false;
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('Confirmation for DEL?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.treeDeptId = '';
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('please select one or more');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('Confirmation for DEL?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAudit() {
|
||||||
|
this.auditMode = true;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
handleAuditPass() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('please select one or more');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据通过审核?', {
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return auditPass(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAuditRefuse() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('Please select at least one record');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据拒绝审核?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return auditRefuse(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: 'Success!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAuditBack() {
|
||||||
|
this.auditMode = false;
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
handleReset() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('Please select at least one record');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择账号密码重置为初始密码?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return resetPassword(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleGrant() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('Please select at least one record');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.roleTreeObj = [];
|
||||||
|
if (this.selectionList.length === 1) {
|
||||||
|
this.roleTreeObj = this.selectionList[0].roleId.split(',');
|
||||||
|
}
|
||||||
|
getRoleTree().then(res => {
|
||||||
|
this.roleGrantList = res.data.data;
|
||||||
|
this.roleBox = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handlePlatform() {
|
||||||
|
this.platformBox = true;
|
||||||
|
},
|
||||||
|
handleLock() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('Please select at least one record');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择账号解封?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return unlock(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleImport() {
|
||||||
|
this.excelBox = true;
|
||||||
|
},
|
||||||
|
uploadAfter(res, done, loading, column) {
|
||||||
|
window.console.log(column);
|
||||||
|
this.excelBox = false;
|
||||||
|
this.refreshChange();
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
const account = func.toStr(this.search.account);
|
||||||
|
const realName = func.toStr(this.search.realName);
|
||||||
|
this.$confirm('是否导出用户数据?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
NProgress.start();
|
||||||
|
exportBlob(
|
||||||
|
`/blade-system/user/export-user?${
|
||||||
|
this.website.tokenHeader
|
||||||
|
}=${getToken()}&account=${account}&realName=${realName}`
|
||||||
|
).then(res => {
|
||||||
|
downloadXls(res.data, `用户数据表${this.$dayjs().format('YYYY-MM-DD')}.xlsx`);
|
||||||
|
NProgress.done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleTemplate() {
|
||||||
|
exportBlob(
|
||||||
|
`/blade-system/user/export-template?${this.website.tokenHeader}=${getToken()}`
|
||||||
|
).then(res => {
|
||||||
|
downloadXls(res.data, '用户数据模板.xlsx');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getUser(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
if (this.form.hasOwnProperty('deptId')) {
|
||||||
|
this.form.deptId = func.split(this.form.deptId);
|
||||||
|
}
|
||||||
|
if (this.form.hasOwnProperty('roleId')) {
|
||||||
|
this.form.roleId = func.split(this.form.roleId);
|
||||||
|
}
|
||||||
|
if (this.form.hasOwnProperty('postId')) {
|
||||||
|
this.form.postId = func.split(this.form.postId);
|
||||||
|
}
|
||||||
|
if (this.form.hasOwnProperty('leaderId')) {
|
||||||
|
this.form.leaderId = func.split(this.form.leaderId);
|
||||||
|
}
|
||||||
|
if (this.form.sex === -1) {
|
||||||
|
this.form.sex = '';
|
||||||
|
}
|
||||||
|
// 保存初始脱敏数据
|
||||||
|
this.sensitiveManager.saveInitialData(this.form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.initFlag = true;
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
Object.assign(params, this.query, { status: this.auditMode ? 0 : 1 }),
|
||||||
|
this.treeDeptId
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
platformRowUpdate(row, index, done, loading) {
|
||||||
|
updatePlatform(row.id, row.userType, row.userExt).then(
|
||||||
|
() => {
|
||||||
|
this.platformOnLoad(this.platformPage);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
platformBeforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getUserPlatform(this.platformForm.id).then(res => {
|
||||||
|
this.platformForm = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
platformSearchReset() {
|
||||||
|
this.platformQuery = {};
|
||||||
|
this.platformOnLoad(this.platformPage);
|
||||||
|
},
|
||||||
|
platformSearchChange(params, done) {
|
||||||
|
this.platformQuery = params;
|
||||||
|
this.platformPage.currentPage = 1;
|
||||||
|
this.platformOnLoad(this.platformPage, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
platformSelectionChange(list) {
|
||||||
|
this.platformSelectionList = list;
|
||||||
|
},
|
||||||
|
platformSelectionClear() {
|
||||||
|
this.platformSelectionList = [];
|
||||||
|
this.$refs.platformCrud.toggleSelection();
|
||||||
|
},
|
||||||
|
platformCurrentChange(currentPage) {
|
||||||
|
this.platformPage.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
platformSizeChange(pageSize) {
|
||||||
|
this.platformPage.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
platformRefreshChange() {
|
||||||
|
this.platformOnLoad(this.platformPage, this.platformQuery);
|
||||||
|
},
|
||||||
|
platformOnLoad(page, params = {}) {
|
||||||
|
this.platformLoading = true;
|
||||||
|
getList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
Object.assign(params, this.query),
|
||||||
|
this.treeDeptId
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.platformPage.total = data.total;
|
||||||
|
this.platformData = data.records;
|
||||||
|
this.platformLoading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.box {
|
||||||
|
height: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-scrollbar {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box .el-scrollbar__wrap {
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
113
src/views/system/userinfo.vue
Normal file
113
src/views/system/userinfo.vue
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<basic-container>
|
||||||
|
<avue-form
|
||||||
|
:option="option"
|
||||||
|
v-model="form"
|
||||||
|
@tab-click="handleTabClick"
|
||||||
|
@submit="handleSubmit"
|
||||||
|
></avue-form>
|
||||||
|
</basic-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import option from '@/option/user/info';
|
||||||
|
import { getUserInfo, updateInfo, updatePassword } from '@/api/system/user';
|
||||||
|
import md5 from 'js-md5';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
import { sensitive } from '@/utils/sensitive';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
index: 0,
|
||||||
|
option: option,
|
||||||
|
form: {},
|
||||||
|
sensitiveManager: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.handleWitch();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSubmit(form, done) {
|
||||||
|
if (this.index === 0) {
|
||||||
|
const submitData = this.sensitiveManager.getSubmitData(form);
|
||||||
|
updateInfo(submitData).then(
|
||||||
|
res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '修改信息成功!',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: res.data.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
updatePassword(md5(form.oldPassword), md5(form.newPassword), md5(form.newPassword1)).then(
|
||||||
|
res => {
|
||||||
|
if (res.data.success) {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '修改密码成功!',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: res.data.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleWitch() {
|
||||||
|
// 创建脱敏工具实例
|
||||||
|
this.sensitiveManager = sensitive.create({
|
||||||
|
fields: ['phone', 'email'], // 配置需要脱敏的字段
|
||||||
|
});
|
||||||
|
if (this.index === 0) {
|
||||||
|
getUserInfo().then(res => {
|
||||||
|
const user = res.data.data;
|
||||||
|
this.form = {
|
||||||
|
id: user.id,
|
||||||
|
avatar: user.avatar,
|
||||||
|
name: user.name,
|
||||||
|
realName: user.realName,
|
||||||
|
phone: user.phone,
|
||||||
|
email: user.email,
|
||||||
|
};
|
||||||
|
// 保存初始脱敏数据
|
||||||
|
this.sensitiveManager.saveInitialData(this.form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleTabClick(tabs) {
|
||||||
|
if (validatenull(tabs.index)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.index = func.toInt(tabs.index, 0);
|
||||||
|
this.handleWitch();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
9
src/views/test.vue
Normal file
9
src/views/test.vue
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>测试页</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
579
src/views/tool/code.vue
Normal file
579
src/views/tool/code.vue
Normal file
@@ -0,0 +1,579 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
v-model:page="page"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.code_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="将选中的多重配置集合批量生成代码"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button type="primary" plain icon="el-icon-refresh" @click="handleBuild"
|
||||||
|
>代码批量生成
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="不通过多重配置直接生成最简化的CRUD代码"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button type="info" plain icon="el-icon-cpu" @click="handleCodeGen"
|
||||||
|
>代码快速生成
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #menu-right>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="通过可视化表单设计器快速生成单表模块"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('administrator')"
|
||||||
|
:loading="!componentLoaded"
|
||||||
|
icon="el-icon-connection"
|
||||||
|
@click="handleFormSetting"
|
||||||
|
>可视化表单设计器
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip
|
||||||
|
class="item"
|
||||||
|
effect="dark"
|
||||||
|
content="配置代码生成的默认参数后自动绑定"
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
plain
|
||||||
|
v-if="userInfo.authority.includes('administrator')"
|
||||||
|
icon="el-icon-message-box"
|
||||||
|
@click="handleCodeSetting"
|
||||||
|
>默认配置管理
|
||||||
|
</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-document-copy"
|
||||||
|
v-if="permission.code_edit"
|
||||||
|
class="none-border"
|
||||||
|
@click.stop="handleCopy(scope.row)"
|
||||||
|
>复制
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
v-if="userInfo.authority.includes('administrator')"
|
||||||
|
class="none-border"
|
||||||
|
@click.stop="handleBuildSingle(scope.row)"
|
||||||
|
>生成
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-drawer title="代码快速生成" append-to-body v-model="codeGenBox" direction="rtl" size="50%">
|
||||||
|
<avue-form :option="genOption" v-model="genForm" @submit="handleCodeGenSubmit" />
|
||||||
|
</el-drawer>
|
||||||
|
<el-drawer
|
||||||
|
title="可视化表单管理"
|
||||||
|
append-to-body
|
||||||
|
v-model="formSettingBox"
|
||||||
|
direction="rtl"
|
||||||
|
size="1000px"
|
||||||
|
>
|
||||||
|
<form-setting></form-setting>
|
||||||
|
</el-drawer>
|
||||||
|
<el-drawer
|
||||||
|
title="默认配置管理"
|
||||||
|
append-to-body
|
||||||
|
v-model="codeSettingBox"
|
||||||
|
direction="rtl"
|
||||||
|
size="1000px"
|
||||||
|
>
|
||||||
|
<code-setting></code-setting>
|
||||||
|
</el-drawer>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getCode, build, remove, add, update, copy, buildFast } from '@/api/tool/code';
|
||||||
|
import { getEnableDetail, getTableForm } from '@/api/tool/codesetting';
|
||||||
|
import {
|
||||||
|
getDetail as modelDetail,
|
||||||
|
getTableInfoByName,
|
||||||
|
getTableList,
|
||||||
|
prototypeDetail,
|
||||||
|
} from '@/api/tool/model';
|
||||||
|
import { codeOption, genOption } from '@/option/tool/code';
|
||||||
|
import { validatejson, validatenull } from '@/utils/validate';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { getMenuTree } from '@/api/system/menu';
|
||||||
|
import { loadFormDesignModule, loadFormModule } from '@/utils/module';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
genForm: {},
|
||||||
|
selectionList: [],
|
||||||
|
componentLoaded: false,
|
||||||
|
loading: true,
|
||||||
|
loadingOption: {
|
||||||
|
lock: true,
|
||||||
|
text: '物理表读取中',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)',
|
||||||
|
},
|
||||||
|
addMode: false,
|
||||||
|
codeGenBox: false,
|
||||||
|
codeSettingBox: false,
|
||||||
|
codeSetting: {},
|
||||||
|
formSettingBox: false,
|
||||||
|
query: {},
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: codeOption,
|
||||||
|
genOption: genOption,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 懒加载表单设计器模块
|
||||||
|
Promise.all([loadFormModule(this.$app), loadFormDesignModule(this.$app)]).then(() => {
|
||||||
|
this.componentLoaded = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.modelId'() {
|
||||||
|
if (!validatenull(this.form.modelId) && this.addMode) {
|
||||||
|
// 获取数据模型信息
|
||||||
|
modelDetail(this.form.modelId).then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
const { modelName, modelTable, modelCode } = result.data;
|
||||||
|
const lowerModelCode = modelCode.toLowerCase();
|
||||||
|
//if (validatenull(this.form.tablePrefix)) {
|
||||||
|
this.form.tablePrefix = modelTable.split('_')[0] + '_';
|
||||||
|
//}
|
||||||
|
//if (validatenull(this.form.tableName)) {
|
||||||
|
this.form.tableName = modelTable;
|
||||||
|
//}
|
||||||
|
//if (validatenull(this.form.codeName)) {
|
||||||
|
this.form.codeName = modelName;
|
||||||
|
//}
|
||||||
|
if (validatenull(this.form.serviceName)) {
|
||||||
|
this.form.serviceName = `blade-${lowerModelCode}`;
|
||||||
|
}
|
||||||
|
//if (validatenull(this.form.pkName)) {
|
||||||
|
this.form.pkName = 'id';
|
||||||
|
//}
|
||||||
|
if (validatenull(this.form.packageName)) {
|
||||||
|
this.form.packageName = `org.springblade.${lowerModelCode}`;
|
||||||
|
}
|
||||||
|
//if (validatenull(this.form.subFkId) && !validatenull(this.form.tablePrefix)) {
|
||||||
|
this.form.subFkId = modelTable.replace(this.form.tablePrefix, '') + '_id';
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 获取数据原型信息
|
||||||
|
prototypeDetail(this.form.modelId).then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
const columnTreeId = this.findObject(this.option.group, 'treeId');
|
||||||
|
const columnTreePid = this.findObject(this.option.group, 'treePid');
|
||||||
|
const columnTreeName = this.findObject(this.option.group, 'treeName');
|
||||||
|
columnTreeId.dicData = result.data;
|
||||||
|
columnTreePid.dicData = result.data;
|
||||||
|
columnTreeName.dicData = result.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'form.templateType'() {
|
||||||
|
// 模版类型
|
||||||
|
const type = this.form.templateType;
|
||||||
|
|
||||||
|
// 主子表字段显隐
|
||||||
|
const columnSubModelId = this.findObject(this.option.group, 'subModelId');
|
||||||
|
const columnSubFkId = this.findObject(this.option.group, 'subFkId');
|
||||||
|
columnSubModelId.display = type === 'sub';
|
||||||
|
columnSubFkId.display = type === 'sub';
|
||||||
|
|
||||||
|
// 树表字段显隐
|
||||||
|
const columnTreeId = this.findObject(this.option.group, 'treeId');
|
||||||
|
const columnTreePid = this.findObject(this.option.group, 'treePid');
|
||||||
|
const columnTreeName = this.findObject(this.option.group, 'treeName');
|
||||||
|
columnTreeId.display = type === 'tree';
|
||||||
|
columnTreePid.display = type === 'tree';
|
||||||
|
columnTreeName.display = type === 'tree';
|
||||||
|
},
|
||||||
|
'genForm.datasourceId'() {
|
||||||
|
if (!validatenull(this.genForm.datasourceId)) {
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableList(this.genForm.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const column = this.findObject(this.genOption.column, 'modelTable');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
fullLoading.close();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'genForm.modelTable'() {
|
||||||
|
if (!validatenull(this.genForm.modelTable)) {
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableInfoByName(this.genForm.modelTable, this.genForm.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
// 赋默认值
|
||||||
|
const { comment, entityName } = result.data;
|
||||||
|
this.genForm.modelClass = entityName;
|
||||||
|
this.genForm.modelCode = entityName.replace(/^\S/, s => s.toLowerCase());
|
||||||
|
const lowerModelCode = this.genForm.modelCode.toLowerCase();
|
||||||
|
this.genForm.tablePrefix = this.genForm.modelTable.split('_')[0] + '_';
|
||||||
|
this.genForm.tableName = this.genForm.modelTable;
|
||||||
|
this.genForm.codeName = comment;
|
||||||
|
this.genForm.pkName = 'id';
|
||||||
|
if (validatenull(this.genForm.serviceName)) {
|
||||||
|
this.genForm.serviceName = `blade-${lowerModelCode}`;
|
||||||
|
}
|
||||||
|
if (validatenull(this.genForm.packageName)) {
|
||||||
|
this.genForm.packageName = `org.springblade.${lowerModelCode}`;
|
||||||
|
}
|
||||||
|
// 字段显隐
|
||||||
|
const columnModelForm = this.findObject(this.genOption.column, 'modelForm');
|
||||||
|
const columnModelClass = this.findObject(this.genOption.column, 'modelClass');
|
||||||
|
const columnModelCode = this.findObject(this.genOption.column, 'modelCode');
|
||||||
|
const columnTablePrefix = this.findObject(this.genOption.column, 'tablePrefix');
|
||||||
|
const columnTableName = this.findObject(this.genOption.column, 'tableName');
|
||||||
|
const columnCodeName = this.findObject(this.genOption.column, 'codeName');
|
||||||
|
const columnPkName = this.findObject(this.genOption.column, 'pkName');
|
||||||
|
this.genForm.modelForm = '';
|
||||||
|
getTableForm(this.genForm.modelTable).then(res => {
|
||||||
|
columnModelForm.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
columnModelForm.display = true;
|
||||||
|
columnModelClass.display = true;
|
||||||
|
columnModelCode.display = true;
|
||||||
|
columnTablePrefix.display = true;
|
||||||
|
columnTableName.display = true;
|
||||||
|
columnCodeName.display = true;
|
||||||
|
columnPkName.display = true;
|
||||||
|
fullLoading.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.code_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.code_view, false),
|
||||||
|
delBtn: this.validData(this.permission.code_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.code_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.option.group, 'menuId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
initGenData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.genOption.column, 'menuId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
getEnableDetail().then(res => {
|
||||||
|
if (validatejson(res.data.data.settings)) {
|
||||||
|
this.codeSetting = JSON.parse(res.data.data.settings);
|
||||||
|
this.genForm = {
|
||||||
|
menuId: this.codeSetting.menuId,
|
||||||
|
serviceName: this.codeSetting.serviceName,
|
||||||
|
packageName: this.codeSetting.packageName,
|
||||||
|
baseMode: this.codeSetting.baseMode,
|
||||||
|
wrapMode: this.codeSetting.wrapMode,
|
||||||
|
feignMode: this.codeSetting.feignMode,
|
||||||
|
codeStyle: this.codeSetting.codeStyle,
|
||||||
|
apiPath: this.codeSetting.apiPath,
|
||||||
|
webPath: this.codeSetting.webPath,
|
||||||
|
};
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '默认配置加载成功',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
initSetting() {
|
||||||
|
getEnableDetail().then(res => {
|
||||||
|
if (validatejson(res.data.data.settings)) {
|
||||||
|
this.codeSetting = JSON.parse(res.data.data.settings);
|
||||||
|
this.form = {
|
||||||
|
menuId: this.codeSetting.menuId,
|
||||||
|
serviceName: this.codeSetting.serviceName,
|
||||||
|
packageName: this.codeSetting.packageName,
|
||||||
|
baseMode: this.codeSetting.baseMode,
|
||||||
|
wrapMode: this.codeSetting.wrapMode,
|
||||||
|
feignMode: this.codeSetting.feignMode,
|
||||||
|
codeStyle: this.codeSetting.codeStyle,
|
||||||
|
apiPath: this.codeSetting.apiPath,
|
||||||
|
webPath: this.codeSetting.webPath,
|
||||||
|
};
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '默认配置加载成功',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleCodeGen() {
|
||||||
|
this.initGenData();
|
||||||
|
this.codeGenBox = true;
|
||||||
|
},
|
||||||
|
handleFormSetting() {
|
||||||
|
this.formSettingBox = true;
|
||||||
|
},
|
||||||
|
handleCodeSetting() {
|
||||||
|
this.codeSettingBox = true;
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleBuild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('是否生成选中模块的代码?', {
|
||||||
|
title: '代码生成确认',
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
return build(this.ids).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleBuildSingle(row) {
|
||||||
|
this.$confirm(`是否生成选中模块 [${row.codeName}] 的代码?`, {
|
||||||
|
title: '代码生成确认',
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
return build(row.id).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleCodeGenSubmit(form, done) {
|
||||||
|
buildFast(form).then(
|
||||||
|
() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '代码生成成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
this.codeGenBox = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
handleCopy(row) {
|
||||||
|
copy(row.id).then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '复制成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add'].includes(type)) {
|
||||||
|
this.addMode = true;
|
||||||
|
this.initSetting();
|
||||||
|
}
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
this.addMode = false;
|
||||||
|
getCode(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
281
src/views/tool/codesetting.vue
Normal file
281
src/views/tool/codesetting.vue
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
v-model:search="search"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model="form"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-check"
|
||||||
|
@click.stop="handleEnable(scope.row)"
|
||||||
|
>启 用
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #status="{ row }">
|
||||||
|
<el-tag>{{ row.status === 1 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove, enable } from '@/api/tool/codesetting';
|
||||||
|
import { getMenuTree } from '@/api/system/menu';
|
||||||
|
import option from '@/option/tool/codesetting';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
search: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: option,
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: true,
|
||||||
|
viewBtn: true,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getMenuTree().then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'menuId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSettings(row) {
|
||||||
|
return JSON.stringify({
|
||||||
|
serviceName: row.serviceName,
|
||||||
|
packageName: row.packageName,
|
||||||
|
menuId: row.menuId,
|
||||||
|
baseMode: row.baseMode,
|
||||||
|
wrapMode: row.wrapMode,
|
||||||
|
feignMode: row.feignMode,
|
||||||
|
codeStyle: row.codeStyle,
|
||||||
|
apiPath: row.apiPath,
|
||||||
|
webPath: row.webPath,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rowSettingsForm(data) {
|
||||||
|
const row = JSON.parse(data);
|
||||||
|
return {
|
||||||
|
serviceName: row.serviceName,
|
||||||
|
packageName: row.packageName,
|
||||||
|
menuId: row.menuId,
|
||||||
|
baseMode: row.baseMode,
|
||||||
|
wrapMode: row.wrapMode,
|
||||||
|
feignMode: row.feignMode,
|
||||||
|
codeStyle: row.codeStyle,
|
||||||
|
apiPath: row.apiPath,
|
||||||
|
webPath: row.webPath,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const data = {
|
||||||
|
name: row.name,
|
||||||
|
code: row.code,
|
||||||
|
settings: this.rowSettings(row),
|
||||||
|
};
|
||||||
|
add(data).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
const data = {
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
code: row.code,
|
||||||
|
settings: this.rowSettings(row),
|
||||||
|
};
|
||||||
|
update(data).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleEnable(row) {
|
||||||
|
this.$confirm('是否确定启用这条配置?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return enable(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = {
|
||||||
|
...this.form,
|
||||||
|
...this.rowSettingsForm(res.data.data.settings),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
...params,
|
||||||
|
...this.query,
|
||||||
|
category: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
378
src/views/tool/datasource.vue
Normal file
378
src/views/tool/datasource.vue
Normal file
@@ -0,0 +1,378 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
v-model:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
plain
|
||||||
|
v-if="permission.datasource_delete"
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove } from '@/api/tool/datasource';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: {
|
||||||
|
height: 'auto',
|
||||||
|
calcHeight: 32,
|
||||||
|
dialogWidth: 900,
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
viewBtn: true,
|
||||||
|
grid: true,
|
||||||
|
selection: true,
|
||||||
|
dialogClickModal: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '名称',
|
||||||
|
prop: 'name',
|
||||||
|
width: 120,
|
||||||
|
span: 24,
|
||||||
|
search: true,
|
||||||
|
gridRow: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入数据源名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '数据类型',
|
||||||
|
type: 'radio',
|
||||||
|
value: 1,
|
||||||
|
span: 24,
|
||||||
|
width: 120,
|
||||||
|
searchLabelWidth: 100,
|
||||||
|
row: true,
|
||||||
|
gridRow: true,
|
||||||
|
display: false,
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: 'jdbc',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dataType: 'number',
|
||||||
|
prop: 'category',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择分类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'YAML',
|
||||||
|
prop: 'shardingConfig',
|
||||||
|
span: 24,
|
||||||
|
minRows: 5,
|
||||||
|
hide: true,
|
||||||
|
display: false,
|
||||||
|
gridRow: true,
|
||||||
|
type: 'textarea',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入YAML配置',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '驱动类',
|
||||||
|
prop: 'driverClass',
|
||||||
|
type: 'select',
|
||||||
|
span: 24,
|
||||||
|
gridRow: true,
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: 'com.mysql.cj.jdbc.Driver',
|
||||||
|
value: 'com.mysql.cj.jdbc.Driver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'org.postgresql.Driver',
|
||||||
|
value: 'org.postgresql.Driver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'oracle.jdbc.OracleDriver',
|
||||||
|
value: 'oracle.jdbc.OracleDriver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
value: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'dm.jdbc.driver.DmDriver',
|
||||||
|
value: 'dm.jdbc.driver.DmDriver',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
width: 200,
|
||||||
|
display: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入驱动类',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户名',
|
||||||
|
prop: 'username',
|
||||||
|
width: 120,
|
||||||
|
display: true,
|
||||||
|
gridRow: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入用户名',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '密码',
|
||||||
|
prop: 'password',
|
||||||
|
hide: true,
|
||||||
|
display: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入密码',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '连接地址',
|
||||||
|
prop: 'url',
|
||||||
|
span: 24,
|
||||||
|
display: true,
|
||||||
|
gridRow: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入连接地址',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '备注',
|
||||||
|
prop: 'remark',
|
||||||
|
span: 24,
|
||||||
|
minRows: 3,
|
||||||
|
hide: true,
|
||||||
|
type: 'textarea',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.category'() {
|
||||||
|
const category = func.toInt(this.form.category);
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'driverClass') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'url') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'username') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'password') {
|
||||||
|
item.display = category === 1;
|
||||||
|
}
|
||||||
|
if (item.prop === 'shardingConfig') {
|
||||||
|
item.display = category === 2;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.datasource_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.datasource_view, false),
|
||||||
|
delBtn: this.validData(this.permission.datasource_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.datasource_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
419
src/views/tool/formsetting.vue
Normal file
419
src/views/tool/formsetting.vue
Normal file
@@ -0,0 +1,419 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
v-model:search="search"
|
||||||
|
v-model:page="page"
|
||||||
|
v-model="form"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button type="primary" text icon="el-icon-setting" @click.stop="handleDesign(scope.row)"
|
||||||
|
>设 计
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog
|
||||||
|
title="可视化表单设计"
|
||||||
|
v-model="designBox"
|
||||||
|
:fullscreen="true"
|
||||||
|
:before-close="handleDesignClose"
|
||||||
|
append-to-body
|
||||||
|
>
|
||||||
|
<nf-form-design
|
||||||
|
ref="formDesign"
|
||||||
|
style="height: 90vh"
|
||||||
|
:options="options"
|
||||||
|
:toolbar="['clear', 'preview', 'import', 'generate']"
|
||||||
|
:includeFields="[
|
||||||
|
'group', // 分组
|
||||||
|
'dynamic', // 子表单
|
||||||
|
'title', // 标题
|
||||||
|
'table', // 表格
|
||||||
|
'input', // 输入框
|
||||||
|
'password', // 密码
|
||||||
|
'textarea', // 文本域
|
||||||
|
'number', // 数字
|
||||||
|
'ueditor', // 富文本
|
||||||
|
'map', // 地图选择器
|
||||||
|
'radio', // 单选
|
||||||
|
'checkbox', // 多选
|
||||||
|
'select', // 下拉选择
|
||||||
|
'tree', // 树形选择
|
||||||
|
'cascader', // 级联选择
|
||||||
|
'table-select', // 表格选择
|
||||||
|
'upload', // 上传
|
||||||
|
'year', // 年
|
||||||
|
'month', // 月
|
||||||
|
'week', // 周
|
||||||
|
'date', // 日期
|
||||||
|
'time', // 时间
|
||||||
|
'datetime', // 日期时间
|
||||||
|
'daterange', // 日期范围
|
||||||
|
'datetimerange', // 日期时间范围
|
||||||
|
'timerange', // 时间范围
|
||||||
|
'sign', // 签名
|
||||||
|
'switch', // 开关
|
||||||
|
'rate', // 评价
|
||||||
|
'color', // 颜色
|
||||||
|
'icon', // 图标
|
||||||
|
'slider', // 滑块
|
||||||
|
]"
|
||||||
|
:is-crud="isCrud"
|
||||||
|
>
|
||||||
|
<template #toolbar>
|
||||||
|
<el-button
|
||||||
|
style="padding: 0"
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
size="default"
|
||||||
|
icon="el-icon-download"
|
||||||
|
@click="handleSubmit"
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</nf-form-design>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, getDetail, add, update, remove, getTablePrototype } from '@/api/tool/codesetting';
|
||||||
|
import option from '@/option/tool/formsetting';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
import { getTableInfoByName, getTableList } from '@/api/tool/model';
|
||||||
|
import func from '@/utils/func';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
search: {},
|
||||||
|
loading: true,
|
||||||
|
loadingOption: {
|
||||||
|
lock: true,
|
||||||
|
text: '物理表读取中',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)',
|
||||||
|
},
|
||||||
|
designId: '',
|
||||||
|
designBox: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
option: option,
|
||||||
|
data: [],
|
||||||
|
modelTable: '',
|
||||||
|
datasourceId: '',
|
||||||
|
isCrud: true,
|
||||||
|
options: {},
|
||||||
|
// 默认不需要显示的字段名
|
||||||
|
hideFields: [
|
||||||
|
'id',
|
||||||
|
'tenant_id',
|
||||||
|
'create_user',
|
||||||
|
'create_dept',
|
||||||
|
'create_time',
|
||||||
|
'update_user',
|
||||||
|
'update_time',
|
||||||
|
'status',
|
||||||
|
'is_deleted',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: true,
|
||||||
|
viewBtn: true,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.datasourceId'() {
|
||||||
|
if (!validatenull(this.form.datasourceId)) {
|
||||||
|
this.datasourceId = this.form.datasourceId;
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableList(this.form.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'modelTable');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
fullLoading.close();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'form.modelTable'() {
|
||||||
|
if (!validatenull(this.form.modelTable)) {
|
||||||
|
this.modelTable = this.form.modelTable;
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableInfoByName(this.form.modelTable, this.form.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
// 赋默认值
|
||||||
|
const { comment } = result.data;
|
||||||
|
this.form.name = comment;
|
||||||
|
this.form.code = this.form.modelTable;
|
||||||
|
fullLoading.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const data = {
|
||||||
|
name: row.name,
|
||||||
|
code: row.code,
|
||||||
|
category: 2,
|
||||||
|
settings: row.settings,
|
||||||
|
};
|
||||||
|
add(data).then(
|
||||||
|
res => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
let design = {
|
||||||
|
id: res.data.data.id,
|
||||||
|
name: data.name,
|
||||||
|
code: data.code,
|
||||||
|
};
|
||||||
|
this.handleDesign(design);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
const data = {
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
code: row.code,
|
||||||
|
settings: row.settings,
|
||||||
|
};
|
||||||
|
update(data).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDesign(design) {
|
||||||
|
this.designBox = true;
|
||||||
|
this.designId = design.id;
|
||||||
|
getDetail(design.id).then(res => {
|
||||||
|
const settings = res.data.data.settings;
|
||||||
|
if (!validatenull(settings)) {
|
||||||
|
this.options = JSON.parse(settings);
|
||||||
|
} else if (!validatenull(this.modelTable) && !validatenull(this.datasourceId)) {
|
||||||
|
getTablePrototype(this.modelTable, this.datasourceId).then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
const column = result.data
|
||||||
|
.filter(field => {
|
||||||
|
return !validatenull(field.name) && !this.hideFields.includes(field.name);
|
||||||
|
})
|
||||||
|
.map(field => {
|
||||||
|
return {
|
||||||
|
type: 'input',
|
||||||
|
label: field.comment,
|
||||||
|
display: true,
|
||||||
|
prop: func.camelCaseString(field.name),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.options = {
|
||||||
|
column: column,
|
||||||
|
};
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDesignClose() {
|
||||||
|
this.modelTable = '';
|
||||||
|
this.datasourceId = '';
|
||||||
|
this.options = {};
|
||||||
|
this.designBox = false;
|
||||||
|
},
|
||||||
|
// 可视化表单提交
|
||||||
|
handleSubmit() {
|
||||||
|
// json, string, app
|
||||||
|
this.$refs.formDesign.getData('json').then(data => {
|
||||||
|
// 表单/表格option
|
||||||
|
console.log(data);
|
||||||
|
const row = {
|
||||||
|
id: this.designId,
|
||||||
|
settings: JSON.stringify(data),
|
||||||
|
};
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.designBox = false;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.$refs.formDesign.getChangeList().then(changeList => {
|
||||||
|
// 字段prop, type, label修改记录
|
||||||
|
console.log(changeList);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = {
|
||||||
|
...this.form,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
let values = {
|
||||||
|
...params,
|
||||||
|
...this.query,
|
||||||
|
category: 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
getList(page.currentPage, page.pageSize, values).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
393
src/views/tool/model.vue
Normal file
393
src/views/tool/model.vue
Normal file
@@ -0,0 +1,393 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
:page="page"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
v-model="form"
|
||||||
|
v-loading.fullscreen.lock="fullscreenLoading"
|
||||||
|
ref="crud"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-setting"
|
||||||
|
plain
|
||||||
|
class="none-border"
|
||||||
|
@click.stop="handleModel(row)"
|
||||||
|
>模型配置
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #modelTable="{ row }">
|
||||||
|
<el-tag>{{ row.modelTable }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
<el-dialog title="数据库模型配置" v-model="modelBox" :fullscreen="true" append-to-body>
|
||||||
|
<avue-crud
|
||||||
|
ref="crudModel"
|
||||||
|
:option="optionModel"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="fields"
|
||||||
|
></avue-crud>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button type="danger" @click="modelBox = false">关 闭</el-button>
|
||||||
|
<el-button type="primary" @click="handleSubmit">提 交</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getList,
|
||||||
|
getDetail,
|
||||||
|
add,
|
||||||
|
update,
|
||||||
|
remove,
|
||||||
|
getTableList,
|
||||||
|
getTableInfoByName,
|
||||||
|
getModelPrototype,
|
||||||
|
submitModelPrototype,
|
||||||
|
} from '@/api/tool/model';
|
||||||
|
import { entityDic, option, optionModel } from '@/const/tool/model';
|
||||||
|
import { validatenull } from '@/utils/validate';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
loadingOption: {
|
||||||
|
lock: true,
|
||||||
|
text: '物理表读取中',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)',
|
||||||
|
},
|
||||||
|
fullscreenLoading: false,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
selectionList: [],
|
||||||
|
modelBox: false,
|
||||||
|
modelId: 0,
|
||||||
|
datasourceId: 1,
|
||||||
|
tableInfo: {},
|
||||||
|
active: 0,
|
||||||
|
stepStart: 0,
|
||||||
|
stepEnd: 4,
|
||||||
|
data: [],
|
||||||
|
option: option,
|
||||||
|
optionModel: optionModel,
|
||||||
|
formStep: {},
|
||||||
|
fields: [],
|
||||||
|
selectionModelList: [],
|
||||||
|
// 默认不需要显示的字段名
|
||||||
|
hideFields: [
|
||||||
|
'id',
|
||||||
|
'tenant_id',
|
||||||
|
'create_user',
|
||||||
|
'create_dept',
|
||||||
|
'create_time',
|
||||||
|
'update_user',
|
||||||
|
'update_time',
|
||||||
|
'status',
|
||||||
|
'is_deleted',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'form.datasourceId'() {
|
||||||
|
if (!validatenull(this.form.datasourceId)) {
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableList(this.form.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const column = this.findObject(this.option.column, 'modelTable');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
fullLoading.close();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'form.modelTable'() {
|
||||||
|
if (!validatenull(this.form.modelTable)) {
|
||||||
|
const fullLoading = this.$loading(this.loadingOption);
|
||||||
|
getTableInfoByName(this.form.modelTable, this.form.datasourceId)
|
||||||
|
.then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
const { comment, entityName } = result.data;
|
||||||
|
//if (validatenull(this.form.modelClass)) {
|
||||||
|
this.form.modelClass = entityName;
|
||||||
|
//}
|
||||||
|
//if (validatenull(this.form.modelName)) {
|
||||||
|
this.form.modelName = comment;
|
||||||
|
//}
|
||||||
|
//if (validatenull(this.form.modelCode)) {
|
||||||
|
this.form.modelCode = entityName.replace(/^\S/, s => s.toLowerCase());
|
||||||
|
//}
|
||||||
|
fullLoading.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
fullLoading.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: true,
|
||||||
|
delBtn: true,
|
||||||
|
editBtn: true,
|
||||||
|
viewBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
res => {
|
||||||
|
done();
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$confirm('是否进行模型配置?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
let model = {
|
||||||
|
id: res.data.data.id,
|
||||||
|
datasourceId: res.data.data.datasourceId,
|
||||||
|
};
|
||||||
|
this.handleModel(model);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
done();
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
loading();
|
||||||
|
window.console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDetail(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionModelChange(list) {
|
||||||
|
this.selectionModelList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.page.total = data.total;
|
||||||
|
this.data = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleModel(row) {
|
||||||
|
this.fields = [];
|
||||||
|
this.modelBox = true;
|
||||||
|
this.loading = true;
|
||||||
|
this.modelId = row.id;
|
||||||
|
this.datasourceId = row.datasourceId;
|
||||||
|
getModelPrototype(this.modelId, this.datasourceId).then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
this.fields = result.data;
|
||||||
|
this.fields.forEach(item => {
|
||||||
|
item.$cellEdit = true;
|
||||||
|
item.modelId = this.modelId;
|
||||||
|
// 根据字段物理类型自动适配实体类型
|
||||||
|
if (!validatenull(item.name)) {
|
||||||
|
item.jdbcName = item.name;
|
||||||
|
item.jdbcType = item.propertyType;
|
||||||
|
item.jdbcComment = item.comment;
|
||||||
|
if (item.propertyType === 'LocalDateTime') {
|
||||||
|
item.propertyType = 'Date';
|
||||||
|
item.propertyEntity = 'java.util.Date';
|
||||||
|
} else {
|
||||||
|
entityDic.forEach(d => {
|
||||||
|
if (d.label === item.propertyType) {
|
||||||
|
item.propertyType = d.label;
|
||||||
|
item.propertyEntity = d.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 首次加载配置默认值
|
||||||
|
if (validatenull(item.id)) {
|
||||||
|
item.isList = 1;
|
||||||
|
item.isForm = 1;
|
||||||
|
item.isRow = 0;
|
||||||
|
item.isRequired = 0;
|
||||||
|
item.isQuery = 0;
|
||||||
|
item.componentType = 'input';
|
||||||
|
// 默认不需要显示的字段名配置
|
||||||
|
if (this.hideFields.includes(item.jdbcName)) {
|
||||||
|
item.isList = 0;
|
||||||
|
item.isForm = 0;
|
||||||
|
item.isRequired = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSubmit() {
|
||||||
|
console.log(this.fields);
|
||||||
|
this.$confirm('确定提交模型配置?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}).then(() => {
|
||||||
|
this.fields.forEach(item => {
|
||||||
|
entityDic.forEach(d => {
|
||||||
|
if (d.value === item.propertyEntity) {
|
||||||
|
item.propertyType = d.label;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
submitModelPrototype(this.fields).then(res => {
|
||||||
|
const result = res.data;
|
||||||
|
if (result.success) {
|
||||||
|
this.$message.success(result.msg);
|
||||||
|
this.modelBox = false;
|
||||||
|
} else {
|
||||||
|
this.$message.error(result.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.none-border {
|
||||||
|
border: 0;
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-div {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
45
src/views/util/affix.vue
Normal file
45
src/views/util/affix.vue
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<template>
|
||||||
|
<div class="affix">
|
||||||
|
<avue-affix id="avue-view">
|
||||||
|
<span class="affix-affix">固定在最顶部</span>
|
||||||
|
</avue-affix>
|
||||||
|
<div class="affix-line"></div>
|
||||||
|
<avue-affix id="avue-view" :offset-top="50">
|
||||||
|
<span class="affix-affix">固定在距离顶部 50px 的位置</span>
|
||||||
|
</avue-affix>
|
||||||
|
<div class="affix-line"></div>
|
||||||
|
<avue-affix id="avue-view" :offset-top="100">
|
||||||
|
<span class="affix-affix">固定在距离顶部 100px 的位置</span>
|
||||||
|
</avue-affix>
|
||||||
|
<div class="affix-line"></div>
|
||||||
|
<avue-affix id="avue-view" :offset-top="150">
|
||||||
|
<span class="affix-affix">固定在距离顶部 150px 的位置</span>
|
||||||
|
</avue-affix>
|
||||||
|
<div style="height: 2000px">
|
||||||
|
<div style="padding: 15px 20px; font-size: 18px">往下拉就会出现图钉</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.affix {
|
||||||
|
position: relative;
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
&-affix {
|
||||||
|
display: inline-block;
|
||||||
|
color: #fff;
|
||||||
|
padding: 10px 30px;
|
||||||
|
text-align: center;
|
||||||
|
background: rgba(0, 153, 229, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
&-line {
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
26
src/views/util/cache.vue
Normal file
26
src/views/util/cache.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>这个页面会被 keep-alive</h3>
|
||||||
|
<el-tag
|
||||||
|
>在下面的输入框输入任意字符后,切换到其它页面,再回到此页时输入框文字保留,证明被缓存
|
||||||
|
</el-tag>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<el-tag>同时滚动下拉,返回时还会保持滚动条所在的位置</el-tag>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<el-input v-model="value" placeholder="input here" />
|
||||||
|
|
||||||
|
<div style="height: 1000px"></div>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: '',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
52
src/views/util/crud-form.vue
Normal file
52
src/views/util/crud-form.vue
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>点击新增或编辑跳转到新的页面</h3>
|
||||||
|
<avue-crud :option="option" :data="data">
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button type="primary" @click="handleForm()" icon="el-icon-plus">add</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="{ row }">
|
||||||
|
<el-button type="primary" text @click="handleForm(row.id)" icon="el-icon-edit"
|
||||||
|
>edit
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
option: {
|
||||||
|
addBtn: false,
|
||||||
|
editBtn: false,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '姓名',
|
||||||
|
prop: 'name',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'small',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleForm(id) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/form-detail/index',
|
||||||
|
query: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
198
src/views/util/data.vue
Normal file
198
src/views/util/data.vue
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>数据展示</h3>
|
||||||
|
<avue-data-pay :option="option"></avue-data-pay>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
option: {
|
||||||
|
span: 8,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
title: '后台模版',
|
||||||
|
src: '/img/bg/vip1.png',
|
||||||
|
money: '299',
|
||||||
|
dismoney: '199',
|
||||||
|
tip: '/永久',
|
||||||
|
color: '#808695',
|
||||||
|
subtext: '购买',
|
||||||
|
click: () => {
|
||||||
|
this.box = true;
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
title: '点击体验',
|
||||||
|
href: 'https://cli1.avue.top',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '面向全屏幕尺寸的响应式适配能力',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '支持IE9+等系列浏览器',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '全新的前端错误日志监控机制',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '基于最新的avuex底层开发',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '前端路由动态服务端加载',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '灵活的多款主题自由配置',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '模块的可拆卸化,达到开箱即用',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '免费的私人git私服',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '专属会员群',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '前端最新干货分享',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
|
||||||
|
href: 'https://www.kancloud.cn/smallwei/avue',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue 修仙系列视频教程',
|
||||||
|
href: 'https://www.bilibili.com/video/av24644922',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Avuex源码',
|
||||||
|
src: '/img/bg/vip2.png',
|
||||||
|
color: '#ffa820',
|
||||||
|
money: '999',
|
||||||
|
dismoney: '399',
|
||||||
|
tip: '/永久',
|
||||||
|
subtext: '购买',
|
||||||
|
click: () => {
|
||||||
|
this.box = true;
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
title: '一键集成表格的导出excel,打印,等功能',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '底层代码可重用轻松对接多个UI框架',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '底层更加完善的开发错误调试机制',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '一套代码多个终端自适应',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '一键集成表格的导出excel,打印,等常用功能',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '表格的批量操作,表单的级联操作更加便捷',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '新增大量常用组件(搜索,选项卡)',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '新增大量全新可配置的骚属性',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '丰富的数据展示模版组件包',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '专属的开发者文档,助你快速掌握',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
|
||||||
|
href: 'https://www.kancloud.cn/smallwei/avue',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue 修仙系列视频教程',
|
||||||
|
href: 'https://www.bilibili.com/video/av24644922',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '全家桶',
|
||||||
|
src: '/img/bg/vip3.png',
|
||||||
|
color: '#ef4868',
|
||||||
|
money: '999.99',
|
||||||
|
dismoney: '399.99',
|
||||||
|
tip: '/永久',
|
||||||
|
subtext: '购买',
|
||||||
|
click: () => {
|
||||||
|
this.box = true;
|
||||||
|
},
|
||||||
|
list: [
|
||||||
|
{
|
||||||
|
title: '授权商业化开发,永久更新授权使用',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '后期更新和新产品将全部免费',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '拥有avuex系列的全部特权和全部源码',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '免费的私人git私服',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '专属会员群',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '前端最新干货分享',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
|
||||||
|
href: 'https://www.kancloud.cn/smallwei/avue',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '赠送 Avue 修仙系列视频教程',
|
||||||
|
href: 'https://www.bilibili.com/video/av24644922',
|
||||||
|
check: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style></style>
|
||||||
352
src/views/util/demo/dict-classic.vue
Normal file
352
src/views/util/demo/dict-classic.vue
Normal file
@@ -0,0 +1,352 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="data"
|
||||||
|
ref="crud"
|
||||||
|
v-model="form"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
:before-close="beforeClose"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoad"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getList, remove, update, add, getDict, getDictTree } from '@/api/system/dict';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
page: {
|
||||||
|
pageSize: 10,
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
option: {
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
menuWidth: 300,
|
||||||
|
dialogWidth: 880,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '字典编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典名称',
|
||||||
|
prop: 'dictValue',
|
||||||
|
search: true,
|
||||||
|
align: 'center',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上级字典',
|
||||||
|
prop: 'parentId',
|
||||||
|
type: 'tree',
|
||||||
|
dicData: [],
|
||||||
|
hide: true,
|
||||||
|
props: {
|
||||||
|
label: 'title',
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: '请选择上级字典',
|
||||||
|
trigger: 'click',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典键值',
|
||||||
|
prop: 'dictKey',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典键值',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '封存',
|
||||||
|
prop: 'isSealed',
|
||||||
|
type: 'select',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择封存',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典备注',
|
||||||
|
prop: 'remark',
|
||||||
|
search: true,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dict_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.dict_view, false),
|
||||||
|
delBtn: this.validData(this.permission.dict_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dict_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
getDictTree().then(res => {
|
||||||
|
const column = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleAdd(row) {
|
||||||
|
this.$refs.crud.value.code = row.code;
|
||||||
|
this.$refs.crud.value.parentId = row.id;
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'code') {
|
||||||
|
item.value = row.code;
|
||||||
|
item.addDisabled = true;
|
||||||
|
}
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = row.id;
|
||||||
|
item.addDisabled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$refs.crud.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoad(this.page);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.page.currentPage = 1;
|
||||||
|
this.onLoad(this.page, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoad(this.page);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.form.id).then(res => {
|
||||||
|
this.form = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeClose(done) {
|
||||||
|
this.$refs.crud.tableForm = {};
|
||||||
|
this.$refs.crud.value.code = '';
|
||||||
|
this.$refs.crud.value.parentId = '';
|
||||||
|
this.$refs.crud.value.addDisabled = false;
|
||||||
|
this.$refs.crud.option.column.filter(item => {
|
||||||
|
if (item.prop === 'code') {
|
||||||
|
item.value = '';
|
||||||
|
item.addDisabled = false;
|
||||||
|
}
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = '';
|
||||||
|
item.addDisabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.page.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.page.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoad(this.page, this.query);
|
||||||
|
},
|
||||||
|
onLoad(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
||||||
|
this.data = res.data.data;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
469
src/views/util/demo/dict-horizontal.vue
Normal file
469
src/views/util/demo/dict-horizontal.vue
Normal file
@@ -0,0 +1,469 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<basic-container>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataChild"
|
||||||
|
:page="pageChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</basic-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getParentList, getChildList, remove, update, add, getDict } from '@/api/system/dict';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
parentId: 0,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
option: {
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
menuWidth: 300,
|
||||||
|
dialogWidth: 880,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '字典编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典键值',
|
||||||
|
prop: 'dictKey',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典键值',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典名称',
|
||||||
|
prop: 'dictValue',
|
||||||
|
search: true,
|
||||||
|
align: 'center',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '封存',
|
||||||
|
prop: 'isSealed',
|
||||||
|
type: 'select',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择封存',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典备注',
|
||||||
|
prop: 'remark',
|
||||||
|
search: true,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dict_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.dict_view, false),
|
||||||
|
delBtn: this.validData(this.permission.dict_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dict_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.page, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageChild.total = data.total;
|
||||||
|
this.dataChild = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
474
src/views/util/demo/dict-vertical.vue
Normal file
474
src/views/util/demo/dict-vertical.vue
Normal file
@@ -0,0 +1,474 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<basic-container>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</basic-container>
|
||||||
|
<basic-container>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<avue-crud
|
||||||
|
:option="option"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataChild"
|
||||||
|
:page="pageChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</basic-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getParentList, getChildList, remove, update, add, getDict } from '@/api/system/dict';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
parentId: 0,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 5,
|
||||||
|
pageSizes: [5, 10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 5,
|
||||||
|
pageSizes: [5, 10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
option: {
|
||||||
|
tip: false,
|
||||||
|
searchShow: true,
|
||||||
|
searchMenuSpan: 6,
|
||||||
|
tree: true,
|
||||||
|
border: true,
|
||||||
|
index: true,
|
||||||
|
selection: true,
|
||||||
|
viewBtn: true,
|
||||||
|
height: 300,
|
||||||
|
menuWidth: 300,
|
||||||
|
dialogWidth: 880,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '字典编号',
|
||||||
|
prop: 'code',
|
||||||
|
search: true,
|
||||||
|
span: 24,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典编号',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典键值',
|
||||||
|
prop: 'dictKey',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典键值',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典名称',
|
||||||
|
prop: 'dictValue',
|
||||||
|
search: true,
|
||||||
|
align: 'center',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典名称',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典排序',
|
||||||
|
prop: 'sort',
|
||||||
|
type: 'number',
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入字典排序',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '封存',
|
||||||
|
prop: 'isSealed',
|
||||||
|
type: 'select',
|
||||||
|
dicData: [
|
||||||
|
{
|
||||||
|
label: '否',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '是',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
slot: true,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择封存',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '字典备注',
|
||||||
|
prop: 'remark',
|
||||||
|
search: true,
|
||||||
|
hide: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dict_add, false),
|
||||||
|
viewBtn: this.validData(this.permission.dict_view, false),
|
||||||
|
delBtn: this.validData(this.permission.dict_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dict_edit, false),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.page, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageChild.total = data.total;
|
||||||
|
this.dataChild = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
465
src/views/util/demo/dict.vue
Normal file
465
src/views/util/demo/dict.vue
Normal file
@@ -0,0 +1,465 @@
|
|||||||
|
<template>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="11">
|
||||||
|
<basic-container>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>字典列表</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="clearfix">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionParent"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="13">
|
||||||
|
<basic-container>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>[{{ dictValue }}] 字典详情</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="clearfix">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionChild"
|
||||||
|
:table-loading="loadingChild"
|
||||||
|
:data="dataChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
:before-close="beforeCloseChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getParentList,
|
||||||
|
getChildList,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
add,
|
||||||
|
getDict,
|
||||||
|
getDictTree,
|
||||||
|
} from '@/api/system/dict';
|
||||||
|
import { optionParent, optionChild } from '@/option/system/dict';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dictValue: '暂无',
|
||||||
|
parentId: -1,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
loadingChild: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
optionParent: optionParent,
|
||||||
|
optionChild: optionChild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dict_add, false),
|
||||||
|
delBtn: this.validData(this.permission.dict_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dict_edit, false),
|
||||||
|
viewBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getDictTree().then(res => {
|
||||||
|
const column = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.$refs.crudChild.value.dictValue = '';
|
||||||
|
this.$refs.crudChild.value.dictKey = '';
|
||||||
|
this.$refs.crudChild.value.sort = 0;
|
||||||
|
this.$refs.crudChild.value.isSealed = 0;
|
||||||
|
this.$refs.crudChild.value.remark = '';
|
||||||
|
this.$refs.crudChild.modelValue.parentId = row.id;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = row.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const form = {
|
||||||
|
...row,
|
||||||
|
dictKey: -1,
|
||||||
|
};
|
||||||
|
add(form).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.dictValue = row.dictValue;
|
||||||
|
this.$refs.crudChild.value.code = row.code;
|
||||||
|
this.$refs.crudChild.modelValue.parentId = row.id;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'code') {
|
||||||
|
item.value = row.code;
|
||||||
|
}
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = row.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.pageParent, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeCloseChild(done) {
|
||||||
|
this.$refs.crudChild.modelValue.parentId = this.parentId;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = this.parentId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loadingChild = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
this.dataChild = res.data.data;
|
||||||
|
this.loadingChild = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
459
src/views/util/demo/dictbiz.vue
Normal file
459
src/views/util/demo/dictbiz.vue
Normal file
@@ -0,0 +1,459 @@
|
|||||||
|
<template>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="11">
|
||||||
|
<basic-container>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>业务字典列表</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="clearfix">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionParent"
|
||||||
|
:table-loading="loading"
|
||||||
|
:data="dataParent"
|
||||||
|
:page="pageParent"
|
||||||
|
ref="crud"
|
||||||
|
v-model="formParent"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpen"
|
||||||
|
@row-del="rowDel"
|
||||||
|
@row-update="rowUpdate"
|
||||||
|
@row-save="rowSave"
|
||||||
|
@row-click="handleRowClick"
|
||||||
|
@search-change="searchChange"
|
||||||
|
@search-reset="searchReset"
|
||||||
|
@selection-change="selectionChange"
|
||||||
|
@current-change="currentChange"
|
||||||
|
@size-change="sizeChange"
|
||||||
|
@refresh-change="refreshChange"
|
||||||
|
@on-load="onLoadParent"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="13">
|
||||||
|
<basic-container>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template #header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>[{{ dictValue }}] 业务字典详情</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="clearfix">
|
||||||
|
<avue-crud
|
||||||
|
:option="optionChild"
|
||||||
|
:table-loading="loadingChild"
|
||||||
|
:data="dataChild"
|
||||||
|
ref="crudChild"
|
||||||
|
v-model="formChild"
|
||||||
|
:permission="permissionList"
|
||||||
|
:before-open="beforeOpenChild"
|
||||||
|
:before-close="beforeCloseChild"
|
||||||
|
@row-del="rowDelChild"
|
||||||
|
@row-update="rowUpdateChild"
|
||||||
|
@row-save="rowSaveChild"
|
||||||
|
@search-change="searchChangeChild"
|
||||||
|
@search-reset="searchResetChild"
|
||||||
|
@selection-change="selectionChangeChild"
|
||||||
|
@current-change="currentChangeChild"
|
||||||
|
@size-change="sizeChangeChild"
|
||||||
|
@refresh-change="refreshChangeChild"
|
||||||
|
@on-load="onLoadChild"
|
||||||
|
>
|
||||||
|
<template #menu-left>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
v-if="permission.dict_delete"
|
||||||
|
plain
|
||||||
|
@click="handleDelete"
|
||||||
|
>删 除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #menu="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
text
|
||||||
|
icon="el-icon-circle-plus"
|
||||||
|
@click.stop="handleAdd(scope.row, scope.index)"
|
||||||
|
v-if="userInfo.authority.includes('admin')"
|
||||||
|
>新增子项
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<template #isSealed="{ row }">
|
||||||
|
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</basic-container>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getParentList,
|
||||||
|
getChildList,
|
||||||
|
remove,
|
||||||
|
update,
|
||||||
|
add,
|
||||||
|
getDict,
|
||||||
|
getDictTree,
|
||||||
|
} from '@/api/system/dictbiz';
|
||||||
|
import { optionParent, optionChild } from '@/option/system/dictbiz';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dictValue: '暂无',
|
||||||
|
parentId: -1,
|
||||||
|
formParent: {},
|
||||||
|
formChild: {},
|
||||||
|
selectionList: [],
|
||||||
|
query: {},
|
||||||
|
loading: true,
|
||||||
|
loadingChild: true,
|
||||||
|
pageParent: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
pageChild: {
|
||||||
|
pageSize: 10,
|
||||||
|
pageSizes: [10, 30, 50, 100, 200],
|
||||||
|
currentPage: 1,
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
dataParent: [],
|
||||||
|
dataChild: [],
|
||||||
|
optionParent: optionParent,
|
||||||
|
optionChild: optionChild,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['userInfo', 'permission']),
|
||||||
|
permissionList() {
|
||||||
|
return {
|
||||||
|
addBtn: this.validData(this.permission.dictbiz_add, false),
|
||||||
|
delBtn: this.validData(this.permission.dictbiz_delete, false),
|
||||||
|
editBtn: this.validData(this.permission.dictbiz_edit, false),
|
||||||
|
viewBtn: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
ids() {
|
||||||
|
let ids = [];
|
||||||
|
this.selectionList.forEach(ele => {
|
||||||
|
ids.push(ele.id);
|
||||||
|
});
|
||||||
|
return ids.join(',');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData() {
|
||||||
|
getDictTree().then(res => {
|
||||||
|
const column = this.findObject(this.optionChild.column, 'parentId');
|
||||||
|
column.dicData = res.data.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleAdd(row) {
|
||||||
|
this.$refs.crudChild.modelValue.parentId = row.id;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = row.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.rowAdd();
|
||||||
|
},
|
||||||
|
rowSave(row, done, loading) {
|
||||||
|
const form = {
|
||||||
|
...row,
|
||||||
|
dictKey: -1,
|
||||||
|
};
|
||||||
|
add(form).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdate(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDel(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleRowClick(row) {
|
||||||
|
this.query = {};
|
||||||
|
this.parentId = row.id;
|
||||||
|
this.dictValue = row.dictValue;
|
||||||
|
this.$refs.crudChild.value.code = row.code;
|
||||||
|
this.$refs.crudChild.modelValue.parentId = row.id;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'code') {
|
||||||
|
item.value = row.code;
|
||||||
|
}
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = row.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchReset() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
},
|
||||||
|
searchChange(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageParent.currentPage = 1;
|
||||||
|
this.onLoadParent(this.pageParent, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChange(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClear() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadParent(this.pageParent);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crud.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpen(done, type) {
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formParent.id).then(res => {
|
||||||
|
this.formParent = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChange(currentPage) {
|
||||||
|
this.pageParent.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChange(pageSize) {
|
||||||
|
this.pageParent.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChange() {
|
||||||
|
this.onLoadParent(this.pageParent, this.query);
|
||||||
|
},
|
||||||
|
rowSaveChild(row, done, loading) {
|
||||||
|
add(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowUpdateChild(row, index, done, loading) {
|
||||||
|
update(row).then(
|
||||||
|
() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
window.console.log(error);
|
||||||
|
loading();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
rowDelChild(row) {
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(row.id);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchResetChild() {
|
||||||
|
this.query = {};
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
},
|
||||||
|
searchChangeChild(params, done) {
|
||||||
|
this.query = params;
|
||||||
|
this.pageChild.currentPage = 1;
|
||||||
|
this.onLoadChild(this.pageChild, params);
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
selectionChangeChild(list) {
|
||||||
|
this.selectionList = list;
|
||||||
|
},
|
||||||
|
selectionClearChild() {
|
||||||
|
this.selectionList = [];
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
},
|
||||||
|
handleDeleteChild() {
|
||||||
|
if (this.selectionList.length === 0) {
|
||||||
|
this.$message.warning('请选择至少一条数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$confirm('确定将选择数据删除?', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return remove(this.ids);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.onLoadChild(this.pageChild);
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: '操作成功!',
|
||||||
|
});
|
||||||
|
this.$refs.crudChild.toggleSelection();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeOpenChild(done, type) {
|
||||||
|
if (['add', 'edit'].includes(type)) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
if (['edit', 'view'].includes(type)) {
|
||||||
|
getDict(this.formChild.id).then(res => {
|
||||||
|
this.formChild = res.data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
beforeCloseChild(done) {
|
||||||
|
this.$refs.crudChild.modelValue.parentId = this.parentId;
|
||||||
|
this.$refs.crudChild.option.column.filter(item => {
|
||||||
|
if (item.prop === 'parentId') {
|
||||||
|
item.value = this.parentId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
},
|
||||||
|
currentChangeChild(currentPage) {
|
||||||
|
this.pageChild.currentPage = currentPage;
|
||||||
|
},
|
||||||
|
sizeChangeChild(pageSize) {
|
||||||
|
this.pageChild.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
refreshChangeChild() {
|
||||||
|
this.onLoadChild(this.pageChild, this.query);
|
||||||
|
},
|
||||||
|
onLoadParent(page, params = {}) {
|
||||||
|
this.loading = true;
|
||||||
|
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
|
||||||
|
res => {
|
||||||
|
const data = res.data.data;
|
||||||
|
this.pageParent.total = data.total;
|
||||||
|
this.dataParent = data.records;
|
||||||
|
this.loading = false;
|
||||||
|
this.selectionClear();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onLoadChild(page, params = {}) {
|
||||||
|
this.loadingChild = true;
|
||||||
|
getChildList(
|
||||||
|
page.currentPage,
|
||||||
|
page.pageSize,
|
||||||
|
this.parentId,
|
||||||
|
Object.assign(params, this.query)
|
||||||
|
).then(res => {
|
||||||
|
this.dataChild = res.data.data;
|
||||||
|
this.loadingChild = false;
|
||||||
|
this.selectionClear();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
37
src/views/util/form-detail.vue
Normal file
37
src/views/util/form-detail.vue
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>{{ $route.query.id ? '编辑' : '新增' }}</h3>
|
||||||
|
<avue-form :option="option" v-model="form">
|
||||||
|
<template #menu-form>
|
||||||
|
<el-button icon="el-icon-back" @click="handleBack()">返 回</el-button>
|
||||||
|
</template>
|
||||||
|
</avue-form>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
option: {
|
||||||
|
labelWidth: 110,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '姓名',
|
||||||
|
prop: 'name',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleBack() {
|
||||||
|
this.$router.$avueRouter.closeTag();
|
||||||
|
this.$router.back();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
53
src/views/util/form.vue
Normal file
53
src/views/util/form.vue
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>表单例子</h3>
|
||||||
|
<avue-form :option="option" v-model="form"></avue-form>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {},
|
||||||
|
option: {
|
||||||
|
labelWidth: 110,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '用户名',
|
||||||
|
prop: 'username',
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '密码',
|
||||||
|
prop: 'password',
|
||||||
|
type: 'password',
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '再次输入密码',
|
||||||
|
prop: 'password',
|
||||||
|
type: 'newpassword',
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '申请日期',
|
||||||
|
prop: 'date',
|
||||||
|
type: 'date',
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '个性签名',
|
||||||
|
prop: 'textarea',
|
||||||
|
type: 'textarea',
|
||||||
|
minRows: 8,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
16
src/views/util/logs.vue
Normal file
16
src/views/util/logs.vue
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>请打开浏览器控制台,然后点击下面的按钮</h3>
|
||||||
|
<el-button type="danger" @click="handleNewError">触发一个错误</el-button>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
handleNewError() {
|
||||||
|
window.console.log(a); // eslint-disable-line
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
81
src/views/util/permission.vue
Normal file
81
src/views/util/permission.vue
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<basic-container>
|
||||||
|
<h3>表格权限控制</h3>
|
||||||
|
<avue-crud ref="crud" :permission="permission" :option="option" :data="data">
|
||||||
|
<template #expand="scope">
|
||||||
|
{{ scope }}
|
||||||
|
</template>
|
||||||
|
</avue-crud>
|
||||||
|
</basic-container>
|
||||||
|
<basic-container>
|
||||||
|
权限开关
|
||||||
|
<el-switch
|
||||||
|
:active-value="false"
|
||||||
|
:inactive-value="true"
|
||||||
|
v-model="text"
|
||||||
|
active-color="#13ce66"
|
||||||
|
inactive-color="#ff4949"
|
||||||
|
>
|
||||||
|
</el-switch>
|
||||||
|
<p>
|
||||||
|
具体参考<a href="https://avuex.avue.top/#/doc/crud-permission"
|
||||||
|
>https://avuex.avue.top/#/doc/crud-permission</a
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
</basic-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
text: false,
|
||||||
|
permission: {},
|
||||||
|
option: {
|
||||||
|
expand: true,
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '姓名',
|
||||||
|
prop: 'name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '年龄',
|
||||||
|
prop: 'sex',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: '张三',
|
||||||
|
sex: 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: '李四',
|
||||||
|
sex: 20,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
text() {
|
||||||
|
if (this.text === true) {
|
||||||
|
this.permission = {
|
||||||
|
delBtn: false,
|
||||||
|
addBtn: false,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.permission = {
|
||||||
|
delBtn: true,
|
||||||
|
addBtn: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
95
src/views/util/store.vue
Normal file
95
src/views/util/store.vue
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>存储</h3>
|
||||||
|
<el-tag class="title">基本读写删(持久化存储)</el-tag>
|
||||||
|
<div class="box">
|
||||||
|
<el-button type="primary" @click="setItem({ name: 'username', value: 'avuex' })"
|
||||||
|
>set('username', 'avuex')
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button type="success" @click="getItem({ name: 'username' })">get('username')</el-button>
|
||||||
|
|
||||||
|
<el-button type="danger" @click="delItem({ name: 'username' })"
|
||||||
|
>remove('username')
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-tag class="title">设置session(session存储)</el-tag>
|
||||||
|
<div class="box">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="setItem({ name: 'username', value: 'avuex', type: 'session' })"
|
||||||
|
>set('username', 'avuex')
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button type="success" @click="getItem({ name: 'username', type: 'session' })"
|
||||||
|
>get('username')
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<el-button type="danger" @click="delItem({ name: 'username', type: 'session' })"
|
||||||
|
>remove('username')
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
<el-tag class="title">获取所有可以获得的数据</el-tag>
|
||||||
|
<div class="box">
|
||||||
|
<el-button type="success" @click="getAll()">getAll(持久化存储)</el-button>
|
||||||
|
<el-button type="success" @click="getAll({ type: 'session' })"
|
||||||
|
>getAll(session存储)
|
||||||
|
</el-button>
|
||||||
|
<el-button type="danger" @click="clearAll()">delAll(持久化存储)</el-button>
|
||||||
|
<el-button type="danger" @click="clearAll({ type: 'session' })"
|
||||||
|
>delAll(session存储)
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { setStore, getStore, removeStore, clearStore, getAllStore } from '@/utils/store';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'store',
|
||||||
|
methods: {
|
||||||
|
setItem(params = {}) {
|
||||||
|
const { name, value, type } = params;
|
||||||
|
setStore({
|
||||||
|
name: name,
|
||||||
|
content: value,
|
||||||
|
type: type,
|
||||||
|
});
|
||||||
|
this.$message(`设置数据 ${name} = ${value}`);
|
||||||
|
},
|
||||||
|
getItem(params = {}) {
|
||||||
|
const { name, type } = params;
|
||||||
|
const content = getStore({
|
||||||
|
name: name,
|
||||||
|
type: type,
|
||||||
|
});
|
||||||
|
this.$message(`获取数据 ${name} = ${content}`);
|
||||||
|
},
|
||||||
|
delItem(params = {}) {
|
||||||
|
const { name, type } = params;
|
||||||
|
removeStore({ name, type });
|
||||||
|
this.$message(`删除数据 ${name}`);
|
||||||
|
},
|
||||||
|
clearAll(params = {}) {
|
||||||
|
clearStore(params);
|
||||||
|
this.$message(`清除全部数据完成`);
|
||||||
|
},
|
||||||
|
getAll(params = {}) {
|
||||||
|
const list = getAllStore(params);
|
||||||
|
window.console.log(list);
|
||||||
|
this.$message(`结果已经打印到控制台`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.title {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
126
src/views/util/table.vue
Normal file
126
src/views/util/table.vue
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>表格例子</h3>
|
||||||
|
<avue-crud :option="option" v-model:page="page" :data="data" />
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
page: {
|
||||||
|
total: 122,
|
||||||
|
},
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
username: 'smallwei',
|
||||||
|
name: 'avue',
|
||||||
|
password: '123456',
|
||||||
|
newpassword: '123456',
|
||||||
|
date: '2019-01-01',
|
||||||
|
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
option: {
|
||||||
|
column: [
|
||||||
|
{
|
||||||
|
label: '用户名',
|
||||||
|
prop: 'username',
|
||||||
|
span: 14,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '姓名',
|
||||||
|
prop: 'name',
|
||||||
|
span: 14,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '密码',
|
||||||
|
prop: 'password',
|
||||||
|
type: 'password',
|
||||||
|
span: 14,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '确认密码',
|
||||||
|
prop: 'newpassword',
|
||||||
|
type: 'password',
|
||||||
|
hide: true,
|
||||||
|
span: 14,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '申请日期',
|
||||||
|
prop: 'date',
|
||||||
|
type: 'date',
|
||||||
|
span: 14,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '个性签名',
|
||||||
|
prop: 'textarea',
|
||||||
|
type: 'textarea',
|
||||||
|
minRows: 8,
|
||||||
|
span: 24,
|
||||||
|
overHidden: true,
|
||||||
|
row: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
18
src/views/util/tags.vue
Normal file
18
src/views/util/tags.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<basic-container>
|
||||||
|
<h3>标签</h3>
|
||||||
|
<el-button type="primary" @click="$router.push('/test/index')">打开一个页面</el-button>
|
||||||
|
<el-button type="primary" @click="$router.$avueRouter.closeTag('/test/index')"
|
||||||
|
>关闭打开的页面
|
||||||
|
</el-button>
|
||||||
|
<el-button type="primary" @click="$router.$avueRouter.closeTag()">关闭本标签</el-button>
|
||||||
|
</basic-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
19
src/views/util/test.vue
Normal file
19
src/views/util/test.vue
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<basic-container>测试页</basic-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'wel',
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
created() {},
|
||||||
|
methods: {},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped="scoped" lang="scss"></style>
|
||||||
26
src/views/util/top.vue
Normal file
26
src/views/util/top.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div style="height: 2000px; background-color: #fff">
|
||||||
|
<div style="padding: 15px 20px; font-size: 18px">往下拉就会出现返回菜单</div>
|
||||||
|
</div>
|
||||||
|
<avue-back-top id="avue-view"></avue-back-top>
|
||||||
|
<avue-back-top id="avue-view" :height="100" :bottom="200">
|
||||||
|
<div class="top">返回顶端</div>
|
||||||
|
</avue-back-top>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.top {
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
background: rgba(0, 153, 229, 0.7);
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user