chore: 基于vue-cli的standard代码规范格式化代码

This commit is contained in:
hankaibo 2021-08-18 14:51:51 +08:00
parent 5c155f5f11
commit 2211400ecc
171 changed files with 19195 additions and 19380 deletions

3
ruoyi-ui/.browserslistrc Normal file
View File

@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead

View File

@ -1,10 +1 @@
# 忽略build目录下类型为js的文件的语法检查 vue.config.js
build/*.js
# 忽略src/assets目录下文件的语法检查
src/assets
# 忽略public目录下文件的语法检查
public
# 忽略当前目录下为js的文件的语法检查
*.js
# 忽略当前目录下为vue的文件的语法检查
*.vue

View File

@ -1,199 +1,21 @@
// ESlint 检查配置
module.exports = { module.exports = {
root: true, root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: { env: {
browser: true, browser: true,
node: true, node: true,
es6: true, es6: true
},
extends: [
'plugin:vue/essential',
'@vue/standard'
],
parserOptions: {
parser: 'babel-eslint'
}, },
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
rules: { rules: {
"vue/max-attributes-per-line": [2, { // 允许props修改
"singleline": 10, 'vue/no-mutating-props': 'off',
"multiline": { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
"max": 1, 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
"allowFirstLine": false
}
}],
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline":"off",
"vue/name-property-casing": ["error", "PascalCase"],
"vue/no-v-html": "off",
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': ["error", "always", {"null": "ignore"}],
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': [2, 2, {
'SwitchCase': 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
} }
} }

22
ruoyi-ui/.gitignore vendored
View File

@ -1,14 +1,17 @@
.DS_Store .DS_Store
node_modules/ node_modules
dist/ /dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
**/*.log pnpm-debug.log*
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
# Editor directories and files # Editor directories and files
.idea .idea
@ -17,7 +20,4 @@ selenium-debug.log
*.ntvs* *.ntvs*
*.njsproj *.njsproj
*.sln *.sln
*.local *.sw?
package-lock.json
yarn.lock

View File

@ -1,13 +1,12 @@
module.exports = { module.exports = {
presets: [ presets: [
// https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
'@vue/cli-plugin-babel/preset' '@vue/cli-plugin-babel/preset'
], ],
'env': { env: {
'development': { development: {
// babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require(). // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
// This plugin can significantly increase the speed of hot updates, when you have a large number of pages. // This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
'plugins': ['dynamic-import-node'] plugins: ['dynamic-import-node']
} }
} }
} }

View File

@ -1,6 +1,6 @@
@echo off @echo off
echo. echo.
echo [信息] 打包Web工程生成dist文件。 echo [信息] 打包Web工程生成dist文件。
echo. echo.
%~d0 %~d0

View File

@ -1,6 +1,6 @@
@echo off @echo off
echo. echo.
echo [信息] 安装Web工程生成node_modules文件。 echo [信息] 安装Web工程生成node_modules文件。
echo. echo.
%~d0 %~d0

View File

@ -1,6 +1,6 @@
@echo off @echo off
echo. echo.
echo [信息] 使用 Vue CLI 命令运行 Web 工程。 echo [信息] 使用 Vue CLI 命令运行 Web 工程。
echo. echo.
%~d0 %~d0

View File

@ -1,5 +1,5 @@
{ {
"name": "ruoyi", "name": "ruoyi-template",
"version": "3.6.0", "version": "3.6.0",
"description": "若依管理系统", "description": "若依管理系统",
"author": "若依", "author": "若依",
@ -9,7 +9,7 @@
"build:prod": "vue-cli-service build", "build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging", "build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview", "preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src" "lint": "vue-cli-service lint"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
@ -64,10 +64,15 @@
"@vue/cli-plugin-babel": "4.4.6", "@vue/cli-plugin-babel": "4.4.6",
"@vue/cli-plugin-eslint": "4.4.6", "@vue/cli-plugin-eslint": "4.4.6",
"@vue/cli-service": "4.4.6", "@vue/cli-service": "4.4.6",
"@vue/eslint-config-standard": "^6.1.0",
"babel-eslint": "10.1.0", "babel-eslint": "10.1.0",
"chalk": "4.1.0", "chalk": "4.1.0",
"connect": "3.6.6", "connect": "3.6.6",
"eslint": "7.15.0", "eslint": "7.15.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "7.2.0", "eslint-plugin-vue": "7.2.0",
"lint-staged": "10.5.3", "lint-staged": "10.5.3",
"runjs": "4.4.2", "runjs": "4.4.2",
@ -80,9 +85,5 @@
"engines": { "engines": {
"node": ">=8.9", "node": ">=8.9",
"npm": ">= 3.0.0" "npm": ">= 3.0.0"
}, }
"browserslist": [
"> 1%",
"last 2 versions"
]
} }

View File

@ -7,7 +7,7 @@
<script> <script>
export default { export default {
name: 'App', name: 'App',
metaInfo() { metaInfo () {
return { return {
title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title, title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
titleTemplate: title => { titleTemplate: title => {

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 登录方法 // 登录方法
export function login(username, password, code, uuid) { export function login (username, password, code, uuid) {
const data = { const data = {
username, username,
password, password,
@ -16,7 +16,7 @@ export function login(username, password, code, uuid) {
} }
// 注册方法 // 注册方法
export function register(data) { export function register (data) {
return request({ return request({
url: '/register', url: '/register',
headers: { headers: {
@ -28,7 +28,7 @@ export function register(data) {
} }
// 获取用户详细信息 // 获取用户详细信息
export function getInfo() { export function getInfo () {
return request({ return request({
url: '/getInfo', url: '/getInfo',
method: 'get' method: 'get'
@ -36,7 +36,7 @@ export function getInfo() {
} }
// 退出方法 // 退出方法
export function logout() { export function logout () {
return request({ return request({
url: '/logout', url: '/logout',
method: 'post' method: 'post'
@ -44,7 +44,7 @@ export function logout() {
} }
// 获取验证码 // 获取验证码
export function getCodeImg() { export function getCodeImg () {
return request({ return request({
url: '/captchaImage', url: '/captchaImage',
method: 'get' method: 'get'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询缓存详细 // 查询缓存详细
export function getCache() { export function getCache () {
return request({ return request({
url: '/monitor/cache', url: '/monitor/cache',
method: 'get' method: 'get'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询定时任务调度列表 // 查询定时任务调度列表
export function listJob(query) { export function listJob (query) {
return request({ return request({
url: '/monitor/job/list', url: '/monitor/job/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listJob(query) {
} }
// 查询定时任务调度详细 // 查询定时任务调度详细
export function getJob(jobId) { export function getJob (jobId) {
return request({ return request({
url: '/monitor/job/' + jobId, url: '/monitor/job/' + jobId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getJob(jobId) {
} }
// 新增定时任务调度 // 新增定时任务调度
export function addJob(data) { export function addJob (data) {
return request({ return request({
url: '/monitor/job', url: '/monitor/job',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function addJob(data) {
} }
// 修改定时任务调度 // 修改定时任务调度
export function updateJob(data) { export function updateJob (data) {
return request({ return request({
url: '/monitor/job', url: '/monitor/job',
method: 'put', method: 'put',
@ -36,7 +36,7 @@ export function updateJob(data) {
} }
// 删除定时任务调度 // 删除定时任务调度
export function delJob(jobId) { export function delJob (jobId) {
return request({ return request({
url: '/monitor/job/' + jobId, url: '/monitor/job/' + jobId,
method: 'delete' method: 'delete'
@ -44,7 +44,7 @@ export function delJob(jobId) {
} }
// 导出定时任务调度 // 导出定时任务调度
export function exportJob(query) { export function exportJob (query) {
return request({ return request({
url: '/monitor/job/export', url: '/monitor/job/export',
method: 'get', method: 'get',
@ -53,7 +53,7 @@ export function exportJob(query) {
} }
// 任务状态修改 // 任务状态修改
export function changeJobStatus(jobId, status) { export function changeJobStatus (jobId, status) {
const data = { const data = {
jobId, jobId,
status status
@ -65,9 +65,8 @@ export function changeJobStatus(jobId, status) {
}) })
} }
// 定时任务立即执行一次 // 定时任务立即执行一次
export function runJob(jobId, jobGroup) { export function runJob (jobId, jobGroup) {
const data = { const data = {
jobId, jobId,
jobGroup jobGroup

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询调度日志列表 // 查询调度日志列表
export function listJobLog(query) { export function listJobLog (query) {
return request({ return request({
url: '/monitor/jobLog/list', url: '/monitor/jobLog/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listJobLog(query) {
} }
// 删除调度日志 // 删除调度日志
export function delJobLog(jobLogId) { export function delJobLog (jobLogId) {
return request({ return request({
url: '/monitor/jobLog/' + jobLogId, url: '/monitor/jobLog/' + jobLogId,
method: 'delete' method: 'delete'
@ -18,7 +18,7 @@ export function delJobLog(jobLogId) {
} }
// 清空调度日志 // 清空调度日志
export function cleanJobLog() { export function cleanJobLog () {
return request({ return request({
url: '/monitor/jobLog/clean', url: '/monitor/jobLog/clean',
method: 'delete' method: 'delete'
@ -26,7 +26,7 @@ export function cleanJobLog() {
} }
// 导出调度日志 // 导出调度日志
export function exportJobLog(query) { export function exportJobLog (query) {
return request({ return request({
url: '/monitor/jobLog/export', url: '/monitor/jobLog/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询登录日志列表 // 查询登录日志列表
export function list(query) { export function list (query) {
return request({ return request({
url: '/monitor/logininfor/list', url: '/monitor/logininfor/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function list(query) {
} }
// 删除登录日志 // 删除登录日志
export function delLogininfor(infoId) { export function delLogininfor (infoId) {
return request({ return request({
url: '/monitor/logininfor/' + infoId, url: '/monitor/logininfor/' + infoId,
method: 'delete' method: 'delete'
@ -18,7 +18,7 @@ export function delLogininfor(infoId) {
} }
// 清空登录日志 // 清空登录日志
export function cleanLogininfor() { export function cleanLogininfor () {
return request({ return request({
url: '/monitor/logininfor/clean', url: '/monitor/logininfor/clean',
method: 'delete' method: 'delete'
@ -26,7 +26,7 @@ export function cleanLogininfor() {
} }
// 导出登录日志 // 导出登录日志
export function exportLogininfor(query) { export function exportLogininfor (query) {
return request({ return request({
url: '/monitor/logininfor/export', url: '/monitor/logininfor/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询在线用户列表 // 查询在线用户列表
export function list(query) { export function list (query) {
return request({ return request({
url: '/monitor/online/list', url: '/monitor/online/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function list(query) {
} }
// 强退用户 // 强退用户
export function forceLogout(tokenId) { export function forceLogout (tokenId) {
return request({ return request({
url: '/monitor/online/' + tokenId, url: '/monitor/online/' + tokenId,
method: 'delete' method: 'delete'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询操作日志列表 // 查询操作日志列表
export function list(query) { export function list (query) {
return request({ return request({
url: '/monitor/operlog/list', url: '/monitor/operlog/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function list(query) {
} }
// 删除操作日志 // 删除操作日志
export function delOperlog(operId) { export function delOperlog (operId) {
return request({ return request({
url: '/monitor/operlog/' + operId, url: '/monitor/operlog/' + operId,
method: 'delete' method: 'delete'
@ -18,7 +18,7 @@ export function delOperlog(operId) {
} }
// 清空操作日志 // 清空操作日志
export function cleanOperlog() { export function cleanOperlog () {
return request({ return request({
url: '/monitor/operlog/clean', url: '/monitor/operlog/clean',
method: 'delete' method: 'delete'
@ -26,7 +26,7 @@ export function cleanOperlog() {
} }
// 导出操作日志 // 导出操作日志
export function exportOperlog(query) { export function exportOperlog (query) {
return request({ return request({
url: '/monitor/operlog/export', url: '/monitor/operlog/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询服务器详细 // 查询服务器详细
export function getServer() { export function getServer () {
return request({ return request({
url: '/monitor/server', url: '/monitor/server',
method: 'get' method: 'get'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询参数列表 // 查询参数列表
export function listConfig(query) { export function listConfig (query) {
return request({ return request({
url: '/system/config/list', url: '/system/config/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listConfig(query) {
} }
// 查询参数详细 // 查询参数详细
export function getConfig(configId) { export function getConfig (configId) {
return request({ return request({
url: '/system/config/' + configId, url: '/system/config/' + configId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getConfig(configId) {
} }
// 根据参数键名查询参数值 // 根据参数键名查询参数值
export function getConfigKey(configKey) { export function getConfigKey (configKey) {
return request({ return request({
url: '/system/config/configKey/' + configKey, url: '/system/config/configKey/' + configKey,
method: 'get' method: 'get'
@ -26,7 +26,7 @@ export function getConfigKey(configKey) {
} }
// 新增参数配置 // 新增参数配置
export function addConfig(data) { export function addConfig (data) {
return request({ return request({
url: '/system/config', url: '/system/config',
method: 'post', method: 'post',
@ -35,7 +35,7 @@ export function addConfig(data) {
} }
// 修改参数配置 // 修改参数配置
export function updateConfig(data) { export function updateConfig (data) {
return request({ return request({
url: '/system/config', url: '/system/config',
method: 'put', method: 'put',
@ -44,7 +44,7 @@ export function updateConfig(data) {
} }
// 删除参数配置 // 删除参数配置
export function delConfig(configId) { export function delConfig (configId) {
return request({ return request({
url: '/system/config/' + configId, url: '/system/config/' + configId,
method: 'delete' method: 'delete'
@ -52,7 +52,7 @@ export function delConfig(configId) {
} }
// 刷新参数缓存 // 刷新参数缓存
export function refreshCache() { export function refreshCache () {
return request({ return request({
url: '/system/config/refreshCache', url: '/system/config/refreshCache',
method: 'delete' method: 'delete'
@ -60,7 +60,7 @@ export function refreshCache() {
} }
// 导出参数 // 导出参数
export function exportConfig(query) { export function exportConfig (query) {
return request({ return request({
url: '/system/config/export', url: '/system/config/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询部门列表 // 查询部门列表
export function listDept(query) { export function listDept (query) {
return request({ return request({
url: '/system/dept/list', url: '/system/dept/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listDept(query) {
} }
// 查询部门列表(排除节点) // 查询部门列表(排除节点)
export function listDeptExcludeChild(deptId) { export function listDeptExcludeChild (deptId) {
return request({ return request({
url: '/system/dept/list/exclude/' + deptId, url: '/system/dept/list/exclude/' + deptId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function listDeptExcludeChild(deptId) {
} }
// 查询部门详细 // 查询部门详细
export function getDept(deptId) { export function getDept (deptId) {
return request({ return request({
url: '/system/dept/' + deptId, url: '/system/dept/' + deptId,
method: 'get' method: 'get'
@ -26,7 +26,7 @@ export function getDept(deptId) {
} }
// 查询部门下拉树结构 // 查询部门下拉树结构
export function treeselect() { export function treeselect () {
return request({ return request({
url: '/system/dept/treeselect', url: '/system/dept/treeselect',
method: 'get' method: 'get'
@ -34,7 +34,7 @@ export function treeselect() {
} }
// 根据角色ID查询部门树结构 // 根据角色ID查询部门树结构
export function roleDeptTreeselect(roleId) { export function roleDeptTreeselect (roleId) {
return request({ return request({
url: '/system/dept/roleDeptTreeselect/' + roleId, url: '/system/dept/roleDeptTreeselect/' + roleId,
method: 'get' method: 'get'
@ -42,7 +42,7 @@ export function roleDeptTreeselect(roleId) {
} }
// 新增部门 // 新增部门
export function addDept(data) { export function addDept (data) {
return request({ return request({
url: '/system/dept', url: '/system/dept',
method: 'post', method: 'post',
@ -51,7 +51,7 @@ export function addDept(data) {
} }
// 修改部门 // 修改部门
export function updateDept(data) { export function updateDept (data) {
return request({ return request({
url: '/system/dept', url: '/system/dept',
method: 'put', method: 'put',
@ -60,7 +60,7 @@ export function updateDept(data) {
} }
// 删除部门 // 删除部门
export function delDept(deptId) { export function delDept (deptId) {
return request({ return request({
url: '/system/dept/' + deptId, url: '/system/dept/' + deptId,
method: 'delete' method: 'delete'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询字典数据列表 // 查询字典数据列表
export function listData(query) { export function listData (query) {
return request({ return request({
url: '/system/dict/data/list', url: '/system/dict/data/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listData(query) {
} }
// 查询字典数据详细 // 查询字典数据详细
export function getData(dictCode) { export function getData (dictCode) {
return request({ return request({
url: '/system/dict/data/' + dictCode, url: '/system/dict/data/' + dictCode,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getData(dictCode) {
} }
// 根据字典类型查询字典数据信息 // 根据字典类型查询字典数据信息
export function getDicts(dictType) { export function getDicts (dictType) {
return request({ return request({
url: '/system/dict/data/type/' + dictType, url: '/system/dict/data/type/' + dictType,
method: 'get' method: 'get'
@ -26,7 +26,7 @@ export function getDicts(dictType) {
} }
// 新增字典数据 // 新增字典数据
export function addData(data) { export function addData (data) {
return request({ return request({
url: '/system/dict/data', url: '/system/dict/data',
method: 'post', method: 'post',
@ -35,7 +35,7 @@ export function addData(data) {
} }
// 修改字典数据 // 修改字典数据
export function updateData(data) { export function updateData (data) {
return request({ return request({
url: '/system/dict/data', url: '/system/dict/data',
method: 'put', method: 'put',
@ -44,7 +44,7 @@ export function updateData(data) {
} }
// 删除字典数据 // 删除字典数据
export function delData(dictCode) { export function delData (dictCode) {
return request({ return request({
url: '/system/dict/data/' + dictCode, url: '/system/dict/data/' + dictCode,
method: 'delete' method: 'delete'
@ -52,7 +52,7 @@ export function delData(dictCode) {
} }
// 导出字典数据 // 导出字典数据
export function exportData(query) { export function exportData (query) {
return request({ return request({
url: '/system/dict/data/export', url: '/system/dict/data/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询字典类型列表 // 查询字典类型列表
export function listType(query) { export function listType (query) {
return request({ return request({
url: '/system/dict/type/list', url: '/system/dict/type/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listType(query) {
} }
// 查询字典类型详细 // 查询字典类型详细
export function getType(dictId) { export function getType (dictId) {
return request({ return request({
url: '/system/dict/type/' + dictId, url: '/system/dict/type/' + dictId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getType(dictId) {
} }
// 新增字典类型 // 新增字典类型
export function addType(data) { export function addType (data) {
return request({ return request({
url: '/system/dict/type', url: '/system/dict/type',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function addType(data) {
} }
// 修改字典类型 // 修改字典类型
export function updateType(data) { export function updateType (data) {
return request({ return request({
url: '/system/dict/type', url: '/system/dict/type',
method: 'put', method: 'put',
@ -36,7 +36,7 @@ export function updateType(data) {
} }
// 删除字典类型 // 删除字典类型
export function delType(dictId) { export function delType (dictId) {
return request({ return request({
url: '/system/dict/type/' + dictId, url: '/system/dict/type/' + dictId,
method: 'delete' method: 'delete'
@ -44,7 +44,7 @@ export function delType(dictId) {
} }
// 刷新字典缓存 // 刷新字典缓存
export function refreshCache() { export function refreshCache () {
return request({ return request({
url: '/system/dict/type/refreshCache', url: '/system/dict/type/refreshCache',
method: 'delete' method: 'delete'
@ -52,7 +52,7 @@ export function refreshCache() {
} }
// 导出字典类型 // 导出字典类型
export function exportType(query) { export function exportType (query) {
return request({ return request({
url: '/system/dict/type/export', url: '/system/dict/type/export',
method: 'get', method: 'get',
@ -61,7 +61,7 @@ export function exportType(query) {
} }
// 获取字典选择框列表 // 获取字典选择框列表
export function optionselect() { export function optionselect () {
return request({ return request({
url: '/system/dict/type/optionselect', url: '/system/dict/type/optionselect',
method: 'get' method: 'get'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询菜单列表 // 查询菜单列表
export function listMenu(query) { export function listMenu (query) {
return request({ return request({
url: '/system/menu/list', url: '/system/menu/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listMenu(query) {
} }
// 查询菜单详细 // 查询菜单详细
export function getMenu(menuId) { export function getMenu (menuId) {
return request({ return request({
url: '/system/menu/' + menuId, url: '/system/menu/' + menuId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getMenu(menuId) {
} }
// 查询菜单下拉树结构 // 查询菜单下拉树结构
export function treeselect() { export function treeselect () {
return request({ return request({
url: '/system/menu/treeselect', url: '/system/menu/treeselect',
method: 'get' method: 'get'
@ -26,7 +26,7 @@ export function treeselect() {
} }
// 根据角色ID查询菜单下拉树结构 // 根据角色ID查询菜单下拉树结构
export function roleMenuTreeselect(roleId) { export function roleMenuTreeselect (roleId) {
return request({ return request({
url: '/system/menu/roleMenuTreeselect/' + roleId, url: '/system/menu/roleMenuTreeselect/' + roleId,
method: 'get' method: 'get'
@ -34,7 +34,7 @@ export function roleMenuTreeselect(roleId) {
} }
// 新增菜单 // 新增菜单
export function addMenu(data) { export function addMenu (data) {
return request({ return request({
url: '/system/menu', url: '/system/menu',
method: 'post', method: 'post',
@ -43,7 +43,7 @@ export function addMenu(data) {
} }
// 修改菜单 // 修改菜单
export function updateMenu(data) { export function updateMenu (data) {
return request({ return request({
url: '/system/menu', url: '/system/menu',
method: 'put', method: 'put',
@ -52,7 +52,7 @@ export function updateMenu(data) {
} }
// 删除菜单 // 删除菜单
export function delMenu(menuId) { export function delMenu (menuId) {
return request({ return request({
url: '/system/menu/' + menuId, url: '/system/menu/' + menuId,
method: 'delete' method: 'delete'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询公告列表 // 查询公告列表
export function listNotice(query) { export function listNotice (query) {
return request({ return request({
url: '/system/notice/list', url: '/system/notice/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listNotice(query) {
} }
// 查询公告详细 // 查询公告详细
export function getNotice(noticeId) { export function getNotice (noticeId) {
return request({ return request({
url: '/system/notice/' + noticeId, url: '/system/notice/' + noticeId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getNotice(noticeId) {
} }
// 新增公告 // 新增公告
export function addNotice(data) { export function addNotice (data) {
return request({ return request({
url: '/system/notice', url: '/system/notice',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function addNotice(data) {
} }
// 修改公告 // 修改公告
export function updateNotice(data) { export function updateNotice (data) {
return request({ return request({
url: '/system/notice', url: '/system/notice',
method: 'put', method: 'put',
@ -36,7 +36,7 @@ export function updateNotice(data) {
} }
// 删除公告 // 删除公告
export function delNotice(noticeId) { export function delNotice (noticeId) {
return request({ return request({
url: '/system/notice/' + noticeId, url: '/system/notice/' + noticeId,
method: 'delete' method: 'delete'

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询岗位列表 // 查询岗位列表
export function listPost(query) { export function listPost (query) {
return request({ return request({
url: '/system/post/list', url: '/system/post/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listPost(query) {
} }
// 查询岗位详细 // 查询岗位详细
export function getPost(postId) { export function getPost (postId) {
return request({ return request({
url: '/system/post/' + postId, url: '/system/post/' + postId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getPost(postId) {
} }
// 新增岗位 // 新增岗位
export function addPost(data) { export function addPost (data) {
return request({ return request({
url: '/system/post', url: '/system/post',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function addPost(data) {
} }
// 修改岗位 // 修改岗位
export function updatePost(data) { export function updatePost (data) {
return request({ return request({
url: '/system/post', url: '/system/post',
method: 'put', method: 'put',
@ -36,7 +36,7 @@ export function updatePost(data) {
} }
// 删除岗位 // 删除岗位
export function delPost(postId) { export function delPost (postId) {
return request({ return request({
url: '/system/post/' + postId, url: '/system/post/' + postId,
method: 'delete' method: 'delete'
@ -44,7 +44,7 @@ export function delPost(postId) {
} }
// 导出岗位 // 导出岗位
export function exportPost(query) { export function exportPost (query) {
return request({ return request({
url: '/system/post/export', url: '/system/post/export',
method: 'get', method: 'get',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询角色列表 // 查询角色列表
export function listRole(query) { export function listRole (query) {
return request({ return request({
url: '/system/role/list', url: '/system/role/list',
method: 'get', method: 'get',
@ -10,7 +10,7 @@ export function listRole(query) {
} }
// 查询角色详细 // 查询角色详细
export function getRole(roleId) { export function getRole (roleId) {
return request({ return request({
url: '/system/role/' + roleId, url: '/system/role/' + roleId,
method: 'get' method: 'get'
@ -18,7 +18,7 @@ export function getRole(roleId) {
} }
// 新增角色 // 新增角色
export function addRole(data) { export function addRole (data) {
return request({ return request({
url: '/system/role', url: '/system/role',
method: 'post', method: 'post',
@ -27,7 +27,7 @@ export function addRole(data) {
} }
// 修改角色 // 修改角色
export function updateRole(data) { export function updateRole (data) {
return request({ return request({
url: '/system/role', url: '/system/role',
method: 'put', method: 'put',
@ -36,7 +36,7 @@ export function updateRole(data) {
} }
// 角色数据权限 // 角色数据权限
export function dataScope(data) { export function dataScope (data) {
return request({ return request({
url: '/system/role/dataScope', url: '/system/role/dataScope',
method: 'put', method: 'put',
@ -45,7 +45,7 @@ export function dataScope(data) {
} }
// 角色状态修改 // 角色状态修改
export function changeRoleStatus(roleId, status) { export function changeRoleStatus (roleId, status) {
const data = { const data = {
roleId, roleId,
status status
@ -58,7 +58,7 @@ export function changeRoleStatus(roleId, status) {
} }
// 删除角色 // 删除角色
export function delRole(roleId) { export function delRole (roleId) {
return request({ return request({
url: '/system/role/' + roleId, url: '/system/role/' + roleId,
method: 'delete' method: 'delete'
@ -66,7 +66,7 @@ export function delRole(roleId) {
} }
// 导出角色 // 导出角色
export function exportRole(query) { export function exportRole (query) {
return request({ return request({
url: '/system/role/export', url: '/system/role/export',
method: 'get', method: 'get',
@ -75,7 +75,7 @@ export function exportRole(query) {
} }
// 查询角色已授权用户列表 // 查询角色已授权用户列表
export function allocatedUserList(query) { export function allocatedUserList (query) {
return request({ return request({
url: '/system/role/authUser/allocatedList', url: '/system/role/authUser/allocatedList',
method: 'get', method: 'get',
@ -84,7 +84,7 @@ export function allocatedUserList(query) {
} }
// 查询角色未授权用户列表 // 查询角色未授权用户列表
export function unallocatedUserList(query) { export function unallocatedUserList (query) {
return request({ return request({
url: '/system/role/authUser/unallocatedList', url: '/system/role/authUser/unallocatedList',
method: 'get', method: 'get',
@ -93,7 +93,7 @@ export function unallocatedUserList(query) {
} }
// 取消用户授权角色 // 取消用户授权角色
export function authUserCancel(data) { export function authUserCancel (data) {
return request({ return request({
url: '/system/role/authUser/cancel', url: '/system/role/authUser/cancel',
method: 'put', method: 'put',
@ -102,7 +102,7 @@ export function authUserCancel(data) {
} }
// 批量取消用户授权角色 // 批量取消用户授权角色
export function authUserCancelAll(data) { export function authUserCancelAll (data) {
return request({ return request({
url: '/system/role/authUser/cancelAll', url: '/system/role/authUser/cancelAll',
method: 'put', method: 'put',
@ -111,7 +111,7 @@ export function authUserCancelAll(data) {
} }
// 授权用户选择 // 授权用户选择
export function authUserSelectAll(data) { export function authUserSelectAll (data) {
return request({ return request({
url: '/system/role/authUser/selectAll', url: '/system/role/authUser/selectAll',
method: 'put', method: 'put',

View File

@ -1,8 +1,8 @@
import request from '@/utils/request' import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/ruoyi"; import { praseStrEmpty } from '@/utils/ruoyi'
// 查询用户列表 // 查询用户列表
export function listUser(query) { export function listUser (query) {
return request({ return request({
url: '/system/user/list', url: '/system/user/list',
method: 'get', method: 'get',
@ -11,7 +11,7 @@ export function listUser(query) {
} }
// 查询用户详细 // 查询用户详细
export function getUser(userId) { export function getUser (userId) {
return request({ return request({
url: '/system/user/' + praseStrEmpty(userId), url: '/system/user/' + praseStrEmpty(userId),
method: 'get' method: 'get'
@ -19,7 +19,7 @@ export function getUser(userId) {
} }
// 新增用户 // 新增用户
export function addUser(data) { export function addUser (data) {
return request({ return request({
url: '/system/user', url: '/system/user',
method: 'post', method: 'post',
@ -28,7 +28,7 @@ export function addUser(data) {
} }
// 修改用户 // 修改用户
export function updateUser(data) { export function updateUser (data) {
return request({ return request({
url: '/system/user', url: '/system/user',
method: 'put', method: 'put',
@ -37,7 +37,7 @@ export function updateUser(data) {
} }
// 删除用户 // 删除用户
export function delUser(userId) { export function delUser (userId) {
return request({ return request({
url: '/system/user/' + userId, url: '/system/user/' + userId,
method: 'delete' method: 'delete'
@ -45,7 +45,7 @@ export function delUser(userId) {
} }
// 导出用户 // 导出用户
export function exportUser(query) { export function exportUser (query) {
return request({ return request({
url: '/system/user/export', url: '/system/user/export',
method: 'get', method: 'get',
@ -54,7 +54,7 @@ export function exportUser(query) {
} }
// 用户密码重置 // 用户密码重置
export function resetUserPwd(userId, password) { export function resetUserPwd (userId, password) {
const data = { const data = {
userId, userId,
password password
@ -67,7 +67,7 @@ export function resetUserPwd(userId, password) {
} }
// 用户状态修改 // 用户状态修改
export function changeUserStatus(userId, status) { export function changeUserStatus (userId, status) {
const data = { const data = {
userId, userId,
status status
@ -80,7 +80,7 @@ export function changeUserStatus(userId, status) {
} }
// 查询用户个人信息 // 查询用户个人信息
export function getUserProfile() { export function getUserProfile () {
return request({ return request({
url: '/system/user/profile', url: '/system/user/profile',
method: 'get' method: 'get'
@ -88,7 +88,7 @@ export function getUserProfile() {
} }
// 修改用户个人信息 // 修改用户个人信息
export function updateUserProfile(data) { export function updateUserProfile (data) {
return request({ return request({
url: '/system/user/profile', url: '/system/user/profile',
method: 'put', method: 'put',
@ -97,7 +97,7 @@ export function updateUserProfile(data) {
} }
// 用户密码重置 // 用户密码重置
export function updateUserPwd(oldPassword, newPassword) { export function updateUserPwd (oldPassword, newPassword) {
const data = { const data = {
oldPassword, oldPassword,
newPassword newPassword
@ -110,7 +110,7 @@ export function updateUserPwd(oldPassword, newPassword) {
} }
// 用户头像上传 // 用户头像上传
export function uploadAvatar(data) { export function uploadAvatar (data) {
return request({ return request({
url: '/system/user/profile/avatar', url: '/system/user/profile/avatar',
method: 'post', method: 'post',
@ -119,7 +119,7 @@ export function uploadAvatar(data) {
} }
// 下载用户导入模板 // 下载用户导入模板
export function importTemplate() { export function importTemplate () {
return request({ return request({
url: '/system/user/importTemplate', url: '/system/user/importTemplate',
method: 'get' method: 'get'
@ -127,7 +127,7 @@ export function importTemplate() {
} }
// 查询授权角色 // 查询授权角色
export function getAuthRole(userId) { export function getAuthRole (userId) {
return request({ return request({
url: '/system/user/authRole/' + userId, url: '/system/user/authRole/' + userId,
method: 'get' method: 'get'
@ -135,7 +135,7 @@ export function getAuthRole(userId) {
} }
// 保存授权角色 // 保存授权角色
export function updateAuthRole(data) { export function updateAuthRole (data) {
return request({ return request({
url: '/system/user/authRole', url: '/system/user/authRole',
method: 'put', method: 'put',

View File

@ -1,7 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询生成表数据 // 查询生成表数据
export function listTable(query) { export function listTable (query) {
return request({ return request({
url: '/tool/gen/list', url: '/tool/gen/list',
method: 'get', method: 'get',
@ -9,7 +9,7 @@ export function listTable(query) {
}) })
} }
// 查询db数据库列表 // 查询db数据库列表
export function listDbTable(query) { export function listDbTable (query) {
return request({ return request({
url: '/tool/gen/db/list', url: '/tool/gen/db/list',
method: 'get', method: 'get',
@ -18,7 +18,7 @@ export function listDbTable(query) {
} }
// 查询表详细信息 // 查询表详细信息
export function getGenTable(tableId) { export function getGenTable (tableId) {
return request({ return request({
url: '/tool/gen/' + tableId, url: '/tool/gen/' + tableId,
method: 'get' method: 'get'
@ -26,7 +26,7 @@ export function getGenTable(tableId) {
} }
// 修改代码生成信息 // 修改代码生成信息
export function updateGenTable(data) { export function updateGenTable (data) {
return request({ return request({
url: '/tool/gen', url: '/tool/gen',
method: 'put', method: 'put',
@ -35,7 +35,7 @@ export function updateGenTable(data) {
} }
// 导入表 // 导入表
export function importTable(data) { export function importTable (data) {
return request({ return request({
url: '/tool/gen/importTable', url: '/tool/gen/importTable',
method: 'post', method: 'post',
@ -44,7 +44,7 @@ export function importTable(data) {
} }
// 预览生成代码 // 预览生成代码
export function previewTable(tableId) { export function previewTable (tableId) {
return request({ return request({
url: '/tool/gen/preview/' + tableId, url: '/tool/gen/preview/' + tableId,
method: 'get' method: 'get'
@ -52,7 +52,7 @@ export function previewTable(tableId) {
} }
// 删除表数据 // 删除表数据
export function delTable(tableId) { export function delTable (tableId) {
return request({ return request({
url: '/tool/gen/' + tableId, url: '/tool/gen/' + tableId,
method: 'delete' method: 'delete'
@ -60,7 +60,7 @@ export function delTable(tableId) {
} }
// 生成代码(自定义路径) // 生成代码(自定义路径)
export function genCode(tableName) { export function genCode (tableName) {
return request({ return request({
url: '/tool/gen/genCode/' + tableName, url: '/tool/gen/genCode/' + tableName,
method: 'get' method: 'get'
@ -68,7 +68,7 @@ export function genCode(tableName) {
} }
// 同步数据库 // 同步数据库
export function synchDb(tableName) { export function synchDb (tableName) {
return request({ return request({
url: '/tool/gen/synchDb/' + tableName, url: '/tool/gen/synchDb/' + tableName,
method: 'get' method: 'get'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -2,7 +2,7 @@
<el-breadcrumb class="app-breadcrumb" separator="/"> <el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb"> <transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path"> <el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
<span v-if="item.redirect==='noRedirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span> <span v-if="item.redirect==='noRedirect'||index===levelList.length-1" class="no-redirect">{{ item.meta.title }}</span>
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a> <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
</el-breadcrumb-item> </el-breadcrumb-item>
</transition-group> </transition-group>
@ -11,13 +11,13 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
levelList: null levelList: null
} }
}, },
watch: { watch: {
$route(route) { $route (route) {
// if you go to the redirect page, do not update the breadcrumbs // if you go to the redirect page, do not update the breadcrumbs
if (route.path.startsWith('/redirect/')) { if (route.path.startsWith('/redirect/')) {
return return
@ -25,29 +25,29 @@ export default {
this.getBreadcrumb() this.getBreadcrumb()
} }
}, },
created() { created () {
this.getBreadcrumb() this.getBreadcrumb()
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb () {
// only show routes with meta.title // only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title) let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
const first = matched[0] const first = matched[0]
if (!this.isDashboard(first)) { if (!this.isDashboard(first)) {
matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched) matched = [{ path: '/index', meta: { title: '首页' } }].concat(matched)
} }
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
}, },
isDashboard(route) { isDashboard (route) {
const name = route && route.name const name = route && route.name
if (!name) { if (!name) {
return false return false
} }
return name.trim() === 'Index' return name.trim() === 'Index'
}, },
handleLink(item) { handleLink (item) {
const { redirect, path } = item const { redirect, path } = item
if (redirect) { if (redirect) {
this.$router.push(redirect) this.$router.push(redirect)

View File

@ -3,7 +3,7 @@
<template v-for="(item, index) in options"> <template v-for="(item, index) in options">
<template v-if="values.includes(item.dictValue)"> <template v-if="values.includes(item.dictValue)">
<span <span
v-if="item.listClass == 'default' || item.listClass == ''" v-if="item.listClass === 'default' || item.listClass === ''"
:key="item.dictValue" :key="item.dictValue"
:index="index" :index="index"
:class="item.cssClass" :class="item.cssClass"
@ -13,7 +13,7 @@
v-else v-else
:key="item.dictValue" :key="item.dictValue"
:index="index" :index="index"
:type="item.listClass == 'primary' ? '' : item.listClass" :type="item.listClass === 'primary' ? '' : item.listClass"
:class="item.cssClass" :class="item.cssClass"
> >
{{ item.dictLabel }} {{ item.dictLabel }}
@ -25,24 +25,24 @@
<script> <script>
export default { export default {
name: "DictTag", name: 'DictTag',
props: { props: {
options: { options: {
type: Array, type: Array,
default: null, default: null
}, },
value: [String, Array], value: [String, Array]
}, },
computed: { computed: {
values() { values () {
if (this.value) { if (this.value) {
return Array.isArray(this.value) ? this.value : [this.value]; return Array.isArray(this.value) ? this.value : [this.value]
} else { } else {
return []; return []
} }
}, }
}, }
}; }
</script> </script>
<style scoped> <style scoped>
.el-tag + .el-tag { .el-tag + .el-tag {

View File

@ -10,7 +10,7 @@
:headers="headers" :headers="headers"
style="display: none" style="display: none"
ref="upload" ref="upload"
v-if="this.type == 'url'" v-if="this.type === 'url'"
> >
</el-upload> </el-upload>
<div class="editor" ref="editor" :style="styles"></div> <div class="editor" ref="editor" :style="styles"></div>
@ -18,176 +18,176 @@
</template> </template>
<script> <script>
import Quill from "quill"; import Quill from 'quill'
import "quill/dist/quill.core.css"; import 'quill/dist/quill.core.css'
import "quill/dist/quill.snow.css"; import 'quill/dist/quill.snow.css'
import "quill/dist/quill.bubble.css"; import 'quill/dist/quill.bubble.css'
import { getToken } from "@/utils/auth"; import { getToken } from '@/utils/auth'
export default { export default {
name: "Editor", name: 'Editor',
props: { props: {
/* 编辑器的内容 */ /* 编辑器的内容 */
value: { value: {
type: String, type: String,
default: "", default: ''
}, },
/* 高度 */ /* 高度 */
height: { height: {
type: Number, type: Number,
default: null, default: null
}, },
/* 最小高度 */ /* 最小高度 */
minHeight: { minHeight: {
type: Number, type: Number,
default: null, default: null
}, },
/* 只读 */ /* 只读 */
readOnly: { readOnly: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
// (MB) // (MB)
fileSize: { fileSize: {
type: Number, type: Number,
default: 5, default: 5
}, },
/* 类型base64格式、url格式 */ /* 类型base64格式、url格式 */
type: { type: {
type: String, type: String,
default: "url", default: 'url'
} }
}, },
data() { data () {
return { return {
uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // uploadUrl: process.env.VUE_APP_BASE_API + '/common/upload', //
headers: { headers: {
Authorization: "Bearer " + getToken() Authorization: 'Bearer ' + getToken()
}, },
Quill: null, Quill: null,
currentValue: "", currentValue: '',
options: { options: {
theme: "snow", theme: 'snow',
bounds: document.body, bounds: document.body,
debug: "warn", debug: 'warn',
modules: { modules: {
// //
toolbar: [ toolbar: [
["bold", "italic", "underline", "strike"], // 线 线 ['bold', 'italic', 'underline', 'strike'], // 线 线
["blockquote", "code-block"], // ['blockquote', 'code-block'], //
[{ list: "ordered" }, { list: "bullet" }], // [{ list: 'ordered' }, { list: 'bullet' }], //
[{ indent: "-1" }, { indent: "+1" }], // [{ indent: '-1' }, { indent: '+1' }], //
[{ size: ["small", false, "large", "huge"] }], // [{ size: ['small', false, 'large', 'huge'] }], //
[{ header: [1, 2, 3, 4, 5, 6, false] }], // [{ header: [1, 2, 3, 4, 5, 6, false] }], //
[{ color: [] }, { background: [] }], // [{ color: [] }, { background: [] }], //
[{ align: [] }], // [{ align: [] }], //
["clean"], // ['clean'], //
["link", "image", "video"] // ['link', 'image', 'video'] //
], ]
}, },
placeholder: "请输入内容", placeholder: '请输入内容',
readOnly: this.readOnly, readOnly: this.readOnly
}, }
}; }
}, },
computed: { computed: {
styles() { styles () {
let style = {}; const style = {}
if (this.minHeight) { if (this.minHeight) {
style.minHeight = `${this.minHeight}px`; style.minHeight = `${this.minHeight}px`
} }
if (this.height) { if (this.height) {
style.height = `${this.height}px`; style.height = `${this.height}px`
}
return style
} }
return style;
},
}, },
watch: { watch: {
value: { value: {
handler(val) { handler (val) {
if (val !== this.currentValue) { if (val !== this.currentValue) {
this.currentValue = val === null ? "" : val; this.currentValue = val === null ? '' : val
if (this.Quill) { if (this.Quill) {
this.Quill.pasteHTML(this.currentValue); this.Quill.pasteHTML(this.currentValue)
} }
} }
}, },
immediate: true, immediate: true
}
}, },
mounted () {
this.init()
}, },
mounted() { beforeDestroy () {
this.init(); this.Quill = null
},
beforeDestroy() {
this.Quill = null;
}, },
methods: { methods: {
init() { init () {
const editor = this.$refs.editor; const editor = this.$refs.editor
this.Quill = new Quill(editor, this.options); this.Quill = new Quill(editor, this.options)
// //
if (this.type == 'url') { if (this.type === 'url') {
let toolbar = this.Quill.getModule("toolbar"); const toolbar = this.Quill.getModule('toolbar')
toolbar.addHandler("image", (value) => { toolbar.addHandler('image', (value) => {
this.uploadType = "image"; this.uploadType = 'image'
if (value) { if (value) {
this.$refs.upload.$children[0].$refs.input.click(); this.$refs.upload.$children[0].$refs.input.click()
} else { } else {
this.quill.format("image", false); this.quill.format('image', false)
} }
}); })
} }
this.Quill.pasteHTML(this.currentValue); this.Quill.pasteHTML(this.currentValue)
this.Quill.on("text-change", (delta, oldDelta, source) => { this.Quill.on('text-change', (delta, oldDelta, source) => {
const html = this.$refs.editor.children[0].innerHTML; const html = this.$refs.editor.children[0].innerHTML
const text = this.Quill.getText(); const text = this.Quill.getText()
const quill = this.Quill; const quill = this.Quill
this.currentValue = html; this.currentValue = html
this.$emit("input", html); this.$emit('input', html)
this.$emit("on-change", { html, text, quill }); this.$emit('on-change', { html, text, quill })
}); })
this.Quill.on("text-change", (delta, oldDelta, source) => { this.Quill.on('text-change', (delta, oldDelta, source) => {
this.$emit("on-text-change", delta, oldDelta, source); this.$emit('on-text-change', delta, oldDelta, source)
}); })
this.Quill.on("selection-change", (range, oldRange, source) => { this.Quill.on('selection-change', (range, oldRange, source) => {
this.$emit("on-selection-change", range, oldRange, source); this.$emit('on-selection-change', range, oldRange, source)
}); })
this.Quill.on("editor-change", (eventName, ...args) => { this.Quill.on('editor-change', (eventName, ...args) => {
this.$emit("on-editor-change", eventName, ...args); this.$emit('on-editor-change', eventName, ...args)
}); })
}, },
// //
handleBeforeUpload(file) { handleBeforeUpload (file) {
// //
if (this.fileSize) { if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize; const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) { if (!isLt) {
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`); this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`)
return false; return false
} }
} }
return true; return true
}, },
handleUploadSuccess(res, file) { handleUploadSuccess (res, file) {
// //
let quill = this.Quill; const quill = this.Quill
// //
if (res.code == 200) { if (res.code === 200) {
// //
let length = quill.getSelection().index; const length = quill.getSelection().index
// res.url // res.url
quill.insertEmbed(length, "image", process.env.VUE_APP_BASE_API + res.fileName); quill.insertEmbed(length, 'image', process.env.VUE_APP_BASE_API + res.fileName)
// //
quill.setSelection(length + 1); quill.setSelection(length + 1)
} else { } else {
this.$message.error("图片插入失败"); this.$message.error('图片插入失败')
} }
}, },
handleUploadError() { handleUploadError () {
this.$message.error("图片插入失败"); this.$message.error('图片插入失败')
}, }
}, }
}; }
</script> </script>
<style> <style>

View File

@ -39,27 +39,27 @@
</template> </template>
<script> <script>
import { getToken } from "@/utils/auth"; import { getToken } from '@/utils/auth'
export default { export default {
name: "FileUpload", name: 'FileUpload',
props: { props: {
// //
value: [String, Object, Array], value: [String, Object, Array],
// //
limit: { limit: {
type: Number, type: Number,
default: 5, default: 5
}, },
// (MB) // (MB)
fileSize: { fileSize: {
type: Number, type: Number,
default: 5, default: 5
}, },
// , ['png', 'jpg', 'jpeg'] // , ['png', 'jpg', 'jpeg']
fileType: { fileType: {
type: Array, type: Array,
default: () => ["doc", "xls", "ppt", "txt", "pdf"], default: () => ['doc', 'xls', 'ppt', 'txt', 'pdf']
}, },
// //
isShowTip: { isShowTip: {
@ -67,34 +67,34 @@ export default {
default: true default: true
} }
}, },
data() { data () {
return { return {
baseUrl: process.env.VUE_APP_BASE_API, baseUrl: process.env.VUE_APP_BASE_API,
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // uploadFileUrl: process.env.VUE_APP_BASE_API + '/common/upload', //
headers: { headers: {
Authorization: "Bearer " + getToken(), Authorization: 'Bearer ' + getToken()
}, },
fileList: [], fileList: []
}; }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler (val) {
if (val) { if (val) {
let temp = 1; let temp = 1
// //
const list = Array.isArray(val) ? val : this.value.split(','); const list = Array.isArray(val) ? val : this.value.split(',')
// //
this.fileList = list.map(item => { this.fileList = list.map(item => {
if (typeof item === "string") { if (typeof item === 'string') {
item = { name: item, url: item }; item = { name: item, url: item }
} }
item.uid = item.uid || new Date().getTime() + temp++; item.uid = item.uid || new Date().getTime() + temp++
return item; return item
}); })
} else { } else {
this.fileList = []; this.fileList = []
return []; return []
} }
}, },
deep: true, deep: true,
@ -103,77 +103,77 @@ export default {
}, },
computed: { computed: {
// //
showTip() { showTip () {
return this.isShowTip && (this.fileType || this.fileSize); return this.isShowTip && (this.fileType || this.fileSize)
}, }
}, },
methods: { methods: {
// //
handleBeforeUpload(file) { handleBeforeUpload (file) {
// //
if (this.fileType) { if (this.fileType) {
let fileExtension = ""; let fileExtension = ''
if (file.name.lastIndexOf(".") > -1) { if (file.name.lastIndexOf('.') > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); fileExtension = file.name.slice(file.name.lastIndexOf('.') + 1)
} }
const isTypeOk = this.fileType.some((type) => { const isTypeOk = this.fileType.some((type) => {
if (file.type.indexOf(type) > -1) return true; if (file.type.indexOf(type) > -1) return true
if (fileExtension && fileExtension.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true
return false; return false
}); })
if (!isTypeOk) { if (!isTypeOk) {
this.$message.error(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`); this.$message.error(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`)
return false; return false
} }
} }
// //
if (this.fileSize) { if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize; const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) { if (!isLt) {
this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`); this.$message.error(`上传文件大小不能超过 ${this.fileSize} MB!`)
return false; return false
} }
} }
return true; return true
}, },
// //
handleExceed() { handleExceed () {
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`); this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`)
}, },
// //
handleUploadError(err) { handleUploadError () {
this.$message.error("上传失败, 请重试"); this.$message.error('上传失败, 请重试')
}, },
// //
handleUploadSuccess(res, file) { handleUploadSuccess (res, file) {
this.$message.success("上传成功"); this.$message.success('上传成功')
this.fileList.push({ name: res.fileName, url: res.fileName }); this.fileList.push({ name: res.fileName, url: res.fileName })
this.$emit("input", this.listToString(this.fileList)); this.$emit('input', this.listToString(this.fileList))
}, },
// //
handleDelete(index) { handleDelete (index) {
this.fileList.splice(index, 1); this.fileList.splice(index, 1)
this.$emit("input", this.listToString(this.fileList)); this.$emit('input', this.listToString(this.fileList))
}, },
// //
getFileName(name) { getFileName (name) {
if (name.lastIndexOf("/") > -1) { if (name.lastIndexOf('/') > -1) {
return name.slice(name.lastIndexOf("/") + 1).toLowerCase(); return name.slice(name.lastIndexOf('/') + 1).toLowerCase()
} else { } else {
return ""; return ''
} }
}, },
// //
listToString(list, separator) { listToString (list, separator) {
let strs = ""; let strs = ''
separator = separator || ","; separator = separator || ','
for (let i in list) { for (const i in list) {
strs += list[i].url + separator; strs += list[i].url + separator
} }
return strs != '' ? strs.substr(0, strs.length - 1) : ''; return strs !== '' ? strs.substr(0, strs.length - 1) : ''
} }
} }
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -23,7 +23,7 @@ export default {
} }
}, },
methods: { methods: {
toggleClick() { toggleClick () {
this.$emit('toggleClick') this.$emit('toggleClick')
} }
} }

View File

@ -25,7 +25,7 @@ import path from 'path'
export default { export default {
name: 'HeaderSearch', name: 'HeaderSearch',
data() { data () {
return { return {
search: '', search: '',
options: [], options: [],
@ -35,18 +35,18 @@ export default {
} }
}, },
computed: { computed: {
routes() { routes () {
return this.$store.getters.permission_routes return this.$store.getters.permission_routes
} }
}, },
watch: { watch: {
routes() { routes () {
this.searchPool = this.generateRoutes(this.routes) this.searchPool = this.generateRoutes(this.routes)
}, },
searchPool(list) { searchPool (list) {
this.initFuse(list) this.initFuse(list)
}, },
show(value) { show (value) {
if (value) { if (value) {
document.body.addEventListener('click', this.close) document.body.addEventListener('click', this.close)
} else { } else {
@ -54,27 +54,27 @@ export default {
} }
} }
}, },
mounted() { mounted () {
this.searchPool = this.generateRoutes(this.routes) this.searchPool = this.generateRoutes(this.routes)
}, },
methods: { methods: {
click() { click () {
this.show = !this.show this.show = !this.show
if (this.show) { if (this.show) {
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus() this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus()
} }
}, },
close() { close () {
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur() this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur()
this.options = [] this.options = []
this.show = false this.show = false
}, },
change(val) { change (val) {
const path = val.path; const path = val.path
if(this.ishttp(val.path)) { if (this.ishttp(val.path)) {
// http(s):// // http(s)://
const pindex = path.indexOf("http"); const pindex = path.indexOf('http')
window.open(path.substr(pindex, path.length), "_blank"); window.open(path.substr(pindex, path.length), '_blank')
} else { } else {
this.$router.push(val.path) this.$router.push(val.path)
} }
@ -84,7 +84,7 @@ export default {
this.show = false this.show = false
}) })
}, },
initFuse(list) { initFuse (list) {
this.fuse = new Fuse(list, { this.fuse = new Fuse(list, {
shouldSort: true, shouldSort: true,
threshold: 0.4, threshold: 0.4,
@ -103,7 +103,7 @@ export default {
}, },
// Filter out the routes that can be displayed in the sidebar // Filter out the routes that can be displayed in the sidebar
// And generate the internationalized title // And generate the internationalized title
generateRoutes(routes, basePath = '/', prefixTitle = []) { generateRoutes (routes, basePath = '/', prefixTitle = []) {
let res = [] let res = []
for (const router of routes) { for (const router of routes) {
@ -135,14 +135,14 @@ export default {
} }
return res return res
}, },
querySearch(query) { querySearch (query) {
if (query !== '') { if (query !== '') {
this.options = this.fuse.search(query) this.options = this.fuse.search(query)
} else { } else {
this.options = [] this.options = []
} }
}, },
ishttp(url) { ishttp (url) {
return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1 return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
} }
} }

View File

@ -17,24 +17,24 @@
import icons from './requireIcons' import icons from './requireIcons'
export default { export default {
name: 'IconSelect', name: 'IconSelect',
data() { data () {
return { return {
name: '', name: '',
iconList: icons iconList: icons
} }
}, },
methods: { methods: {
filterIcons() { filterIcons () {
this.iconList = icons this.iconList = icons
if (this.name) { if (this.name) {
this.iconList = this.iconList.filter(item => item.includes(this.name)) this.iconList = this.iconList.filter(item => item.includes(this.name))
} }
}, },
selectedIcon(name) { selectedIcon (name) {
this.$emit('selected', name) this.$emit('selected', name)
document.body.click() document.body.click()
}, },
reset() { reset () {
this.name = '' this.name = ''
this.iconList = icons this.iconList = icons
} }

View File

@ -42,7 +42,7 @@
</template> </template>
<script> <script>
import { getToken } from "@/utils/auth"; import { getToken } from '@/utils/auth'
export default { export default {
props: { props: {
@ -50,17 +50,17 @@ export default {
// //
limit: { limit: {
type: Number, type: Number,
default: 5, default: 5
}, },
// (MB) // (MB)
fileSize: { fileSize: {
type: Number, type: Number,
default: 5, default: 5
}, },
// , ['png', 'jpg', 'jpeg'] // , ['png', 'jpg', 'jpeg']
fileType: { fileType: {
type: Array, type: Array,
default: () => ["png", "jpg", "jpeg"], default: () => ['png', 'jpg', 'jpeg']
}, },
// //
isShowTip: { isShowTip: {
@ -68,39 +68,39 @@ export default {
default: true default: true
} }
}, },
data() { data () {
return { return {
dialogImageUrl: "", dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
hideUpload: false, hideUpload: false,
baseUrl: process.env.VUE_APP_BASE_API, baseUrl: process.env.VUE_APP_BASE_API,
uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // uploadImgUrl: process.env.VUE_APP_BASE_API + '/common/upload', //
headers: { headers: {
Authorization: "Bearer " + getToken(), Authorization: 'Bearer ' + getToken()
}, },
fileList: [] fileList: []
}; }
}, },
watch: { watch: {
value: { value: {
handler(val) { handler (val) {
if (val) { if (val) {
// //
const list = Array.isArray(val) ? val : this.value.split(','); const list = Array.isArray(val) ? val : this.value.split(',')
// //
this.fileList = list.map(item => { this.fileList = list.map(item => {
if (typeof item === "string") { if (typeof item === 'string') {
if (item.indexOf(this.baseUrl) === -1) { if (item.indexOf(this.baseUrl) === -1) {
item = { name: this.baseUrl + item, url: this.baseUrl + item }; item = { name: this.baseUrl + item, url: this.baseUrl + item }
} else { } else {
item = { name: item, url: item }; item = { name: item, url: item }
} }
} }
return item; return item
}); })
} else { } else {
this.fileList = []; this.fileList = []
return []; return []
} }
}, },
deep: true, deep: true,
@ -109,87 +109,87 @@ export default {
}, },
computed: { computed: {
// //
showTip() { showTip () {
return this.isShowTip && (this.fileType || this.fileSize); return this.isShowTip && (this.fileType || this.fileSize)
}, }
}, },
methods: { methods: {
// //
handleRemove(file, fileList) { handleRemove (file, fileList) {
const findex = this.fileList.map(f => f.name).indexOf(file.name); const findex = this.fileList.map(f => f.name).indexOf(file.name)
this.fileList.splice(findex, 1); this.fileList.splice(findex, 1)
this.$emit("input", this.listToString(this.fileList)); this.$emit('input', this.listToString(this.fileList))
}, },
// //
handleUploadSuccess(res) { handleUploadSuccess (res) {
this.fileList.push({ name: res.fileName, url: res.fileName }); this.fileList.push({ name: res.fileName, url: res.fileName })
this.$emit("input", this.listToString(this.fileList)); this.$emit('input', this.listToString(this.fileList))
this.loading.close(); this.loading.close()
}, },
// loading // loading
handleBeforeUpload(file) { handleBeforeUpload (file) {
let isImg = false; let isImg = false
if (this.fileType.length) { if (this.fileType.length) {
let fileExtension = ""; let fileExtension = ''
if (file.name.lastIndexOf(".") > -1) { if (file.name.lastIndexOf('.') > -1) {
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1); fileExtension = file.name.slice(file.name.lastIndexOf('.') + 1)
} }
isImg = this.fileType.some(type => { isImg = this.fileType.some(type => {
if (file.type.indexOf(type) > -1) return true; if (file.type.indexOf(type) > -1) return true
if (fileExtension && fileExtension.indexOf(type) > -1) return true; if (fileExtension && fileExtension.indexOf(type) > -1) return true
return false; return false
}); })
} else { } else {
isImg = file.type.indexOf("image") > -1; isImg = file.type.indexOf('image') > -1
} }
if (!isImg) { if (!isImg) {
this.$message.error( this.$message.error(
`文件格式不正确, 请上传${this.fileType.join("/")}图片格式文件!` `文件格式不正确, 请上传${this.fileType.join('/')}图片格式文件!`
); )
return false; return false
} }
if (this.fileSize) { if (this.fileSize) {
const isLt = file.size / 1024 / 1024 < this.fileSize; const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) { if (!isLt) {
this.$message.error(`上传头像图片大小不能超过 ${this.fileSize} MB!`); this.$message.error(`上传头像图片大小不能超过 ${this.fileSize} MB!`)
return false; return false
} }
} }
this.loading = this.$loading({ this.loading = this.$loading({
lock: true, lock: true,
text: "上传中", text: '上传中',
background: "rgba(0, 0, 0, 0.7)", background: 'rgba(0, 0, 0, 0.7)'
}); })
}, },
// //
handleExceed() { handleExceed () {
this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`); this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`)
}, },
// //
handleUploadError() { handleUploadError () {
this.$message({ this.$message({
type: "error", type: 'error',
message: "上传失败", message: '上传失败'
}); })
this.loading.close(); this.loading.close()
}, },
// //
handlePictureCardPreview(file) { handlePictureCardPreview (file) {
this.dialogImageUrl = file.url; this.dialogImageUrl = file.url
this.dialogVisible = true; this.dialogVisible = true
}, },
// //
listToString(list, separator) { listToString (list, separator) {
let strs = ""; let strs = ''
separator = separator || ","; separator = separator || ','
for (let i in list) { for (const i in list) {
strs += list[i].url.replace(this.baseUrl, "") + separator; strs += list[i].url.replace(this.baseUrl, '') + separator
} }
return strs != '' ? strs.substr(0, strs.length - 1) : ''; return strs !== '' ? strs.substr(0, strs.length - 1) : ''
} }
} }
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
// .el-upload--picture-card // .el-upload--picture-card
@ -207,4 +207,3 @@ export default {
transform: translateY(0); transform: translateY(0);
} }
</style> </style>

View File

@ -35,7 +35,7 @@ export default {
}, },
pageSizes: { pageSizes: {
type: Array, type: Array,
default() { default () {
return [10, 20, 30, 50] return [10, 20, 30, 50]
} }
}, },
@ -63,30 +63,30 @@ export default {
}, },
computed: { computed: {
currentPage: { currentPage: {
get() { get () {
return this.page return this.page
}, },
set(val) { set (val) {
this.$emit('update:page', val) this.$emit('update:page', val)
} }
}, },
pageSize: { pageSize: {
get() { get () {
return this.limit return this.limit
}, },
set(val) { set (val) {
this.$emit('update:limit', val) this.$emit('update:limit', val)
} }
} }
}, },
methods: { methods: {
handleSizeChange(val) { handleSizeChange (val) {
this.$emit('pagination', { page: this.currentPage, limit: val }) this.$emit('pagination', { page: this.currentPage, limit: val })
if (this.autoScroll) { if (this.autoScroll) {
scrollTo(0, 800) scrollTo(0, 800)
} }
}, },
handleCurrentChange(val) { handleCurrentChange (val) {
this.$emit('pagination', { page: val, limit: this.pageSize }) this.$emit('pagination', { page: val, limit: this.pageSize })
if (this.autoScroll) { if (this.autoScroll) {
scrollTo(0, 800) scrollTo(0, 800)

View File

@ -26,22 +26,22 @@ export default {
}, },
computed: { computed: {
show: { show: {
get() { get () {
return this.$store.state.settings.showSettings return this.$store.state.settings.showSettings
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'showSettings', key: 'showSettings',
value: val value: val
}) })
} }
}, },
theme() { theme () {
return this.$store.state.settings.theme return this.$store.state.settings.theme
}, }
}, },
watch: { watch: {
show(value) { show (value) {
if (value && !this.clickNotClose) { if (value && !this.clickNotClose) {
this.addEventClick() this.addEventClick()
} }
@ -52,26 +52,26 @@ export default {
} }
} }
}, },
mounted() { mounted () {
this.insertToBody() this.insertToBody()
this.addEventClick() this.addEventClick()
}, },
beforeDestroy() { beforeDestroy () {
const elx = this.$refs.rightPanel const elx = this.$refs.rightPanel
elx.remove() elx.remove()
}, },
methods: { methods: {
addEventClick() { addEventClick () {
window.addEventListener('click', this.closeSidebar) window.addEventListener('click', this.closeSidebar)
}, },
closeSidebar(evt) { closeSidebar (evt) {
const parent = evt.target.closest('.rightPanel') const parent = evt.target.closest('.rightPanel')
if (!parent) { if (!parent) {
this.show = false this.show = false
window.removeEventListener('click', this.closeSidebar) window.removeEventListener('click', this.closeSidebar)
} }
}, },
insertToBody() { insertToBody () {
const elx = this.$refs.rightPanel const elx = this.$refs.rightPanel
const body = document.querySelector('body') const body = document.querySelector('body')
body.insertBefore(elx, body.firstChild) body.insertBefore(elx, body.firstChild)

View File

@ -23,56 +23,56 @@
</template> </template>
<script> <script>
export default { export default {
name: "RightToolbar", name: 'RightToolbar',
data() { data () {
return { return {
// //
value: [], value: [],
// //
title: "显示/隐藏", title: '显示/隐藏',
// //
open: false, open: false
}; }
}, },
props: { props: {
showSearch: { showSearch: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
columns: { columns: {
type: Array, type: Array
}
}, },
}, created () {
created() {
// //
for (let item in this.columns) { for (const item in this.columns) {
if (this.columns[item].visible === false) { if (this.columns[item].visible === false) {
this.value.push(parseInt(item)); this.value.push(parseInt(item))
} }
} }
}, },
methods: { methods: {
// //
toggleSearch() { toggleSearch () {
this.$emit("update:showSearch", !this.showSearch); this.$emit('update:showSearch', !this.showSearch)
}, },
// //
refresh() { refresh () {
this.$emit("queryTable"); this.$emit('queryTable')
}, },
// //
dataChange(data) { dataChange (data) {
for (var item in this.columns) { for (const item in this.columns) {
const key = this.columns[item].key; const key = this.columns[item].key
this.columns[item].visible = !data.includes(key); this.columns[item].visible = !data.includes(key)
} }
}, },
// dialog // dialog
showColumn() { showColumn () {
this.open = true; this.open = true
}, }
}, }
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .el-transfer__button { ::v-deep .el-transfer__button {

View File

@ -7,13 +7,13 @@
<script> <script>
export default { export default {
name: 'RuoYiDoc', name: 'RuoYiDoc',
data() { data () {
return { return {
url: 'http://doc.ruoyi.vip/ruoyi-vue' url: 'http://doc.ruoyi.vip/ruoyi-vue'
} }
}, },
methods: { methods: {
goto() { goto () {
window.open(this.url) window.open(this.url)
} }
} }

View File

@ -7,13 +7,13 @@
<script> <script>
export default { export default {
name: 'RuoYiGit', name: 'RuoYiGit',
data() { data () {
return { return {
url: 'https://gitee.com/y_project/RuoYi-Vue' url: 'https://gitee.com/y_project/RuoYi-Vue'
} }
}, },
methods: { methods: {
goto() { goto () {
window.open(this.url) window.open(this.url)
} }
} }

View File

@ -9,34 +9,34 @@ import screenfull from 'screenfull'
export default { export default {
name: 'Screenfull', name: 'Screenfull',
data() { data () {
return { return {
isFullscreen: false isFullscreen: false
} }
}, },
mounted() { mounted () {
this.init() this.init()
}, },
beforeDestroy() { beforeDestroy () {
this.destroy() this.destroy()
}, },
methods: { methods: {
click() { click () {
if (!screenfull.isEnabled) { if (!screenfull.isEnabled) {
this.$message({ message: '你的浏览器不支持全屏', type: 'warning' }) this.$message({ message: '你的浏览器不支持全屏', type: 'warning' })
return false return false
} }
screenfull.toggle() screenfull.toggle()
}, },
change() { change () {
this.isFullscreen = screenfull.isFullscreen this.isFullscreen = screenfull.isFullscreen
}, },
init() { init () {
if (screenfull.isEnabled) { if (screenfull.isEnabled) {
screenfull.on('change', this.change) screenfull.on('change', this.change)
} }
}, },
destroy() { destroy () {
if (screenfull.isEnabled) { if (screenfull.isEnabled) {
screenfull.off('change', this.change) screenfull.off('change', this.change)
} }

View File

@ -14,7 +14,7 @@
<script> <script>
export default { export default {
data() { data () {
return { return {
sizeOptions: [ sizeOptions: [
{ label: 'Default', value: 'default' }, { label: 'Default', value: 'default' },
@ -25,12 +25,12 @@ export default {
} }
}, },
computed: { computed: {
size() { size () {
return this.$store.getters.size return this.$store.getters.size
} }
}, },
methods: { methods: {
handleSetSize(size) { handleSetSize (size) {
this.$ELEMENT.size = size this.$ELEMENT.size = size
this.$store.dispatch('app/setSize', size) this.$store.dispatch('app/setSize', size)
this.refreshView() this.refreshView()
@ -39,7 +39,7 @@ export default {
type: 'success' type: 'success'
}) })
}, },
refreshView() { refreshView () {
// In order to make the cached page re-rendered // In order to make the cached page re-rendered
this.$store.dispatch('tagsView/delAllCachedViews', this.$route) this.$store.dispatch('tagsView/delAllCachedViews', this.$route)

View File

@ -21,20 +21,20 @@ export default {
} }
}, },
computed: { computed: {
isExternal() { isExternal () {
return isExternal(this.iconClass) return isExternal(this.iconClass)
}, },
iconName() { iconName () {
return `#icon-${this.iconClass}` return `#icon-${this.iconClass}`
}, },
svgClass() { svgClass () {
if (this.className) { if (this.className) {
return 'svg-icon ' + this.className return 'svg-icon ' + this.className
} else { } else {
return 'svg-icon' return 'svg-icon'
} }
}, },
styleExternalIcon() { styleExternalIcon () {
return { return {
mask: `url(${this.iconClass}) no-repeat 50% 50%`, mask: `url(${this.iconClass}) no-repeat 50% 50%`,
'-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%` '-webkit-mask': `url(${this.iconClass}) no-repeat 50% 50%`

View File

@ -12,25 +12,25 @@ const version = require('element-ui/package.json').version // element-ui version
const ORIGINAL_THEME = '#409EFF' // default color const ORIGINAL_THEME = '#409EFF' // default color
export default { export default {
data() { data () {
return { return {
chalk: '', // content of theme-chalk css chalk: '', // content of theme-chalk css
theme: '' theme: ''
} }
}, },
computed: { computed: {
defaultTheme() { defaultTheme () {
return this.$store.state.settings.theme return this.$store.state.settings.theme
} }
}, },
watch: { watch: {
defaultTheme: { defaultTheme: {
handler: function(val, oldVal) { handler: function (val, oldVal) {
this.theme = val this.theme = val
}, },
immediate: true immediate: true
}, },
async theme(val) { async theme (val) {
const oldVal = this.chalk ? this.theme : ORIGINAL_THEME const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
if (typeof val !== 'string') return if (typeof val !== 'string') return
const themeCluster = this.getThemeCluster(val.replace('#', '')) const themeCluster = this.getThemeCluster(val.replace('#', ''))
@ -86,7 +86,7 @@ export default {
}, },
methods: { methods: {
updateStyle(style, oldCluster, newCluster) { updateStyle (style, oldCluster, newCluster) {
let newStyle = style let newStyle = style
oldCluster.forEach((color, index) => { oldCluster.forEach((color, index) => {
newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index]) newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index])
@ -94,7 +94,7 @@ export default {
return newStyle return newStyle
}, },
getCSSString(url, variable) { getCSSString (url, variable) {
return new Promise(resolve => { return new Promise(resolve => {
const xhr = new XMLHttpRequest() const xhr = new XMLHttpRequest()
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
@ -108,7 +108,7 @@ export default {
}) })
}, },
getThemeCluster(theme) { getThemeCluster (theme) {
const tintColor = (color, tint) => { const tintColor = (color, tint) => {
let red = parseInt(color.slice(0, 2), 16) let red = parseInt(color.slice(0, 2), 16)
let green = parseInt(color.slice(2, 4), 16) let green = parseInt(color.slice(2, 4), 16)

View File

@ -28,10 +28,10 @@
</template> </template>
<script> <script>
import { constantRoutes } from "@/router"; import { constantRoutes } from '@/router'
export default { export default {
data() { data () {
return { return {
// //
visibleNumber: 5, visibleNumber: 5,
@ -39,133 +39,138 @@ export default {
isFrist: false, isFrist: false,
// index // index
currentIndex: undefined currentIndex: undefined
}; }
}, },
computed: { computed: {
theme() { theme () {
return this.$store.state.settings.theme; return this.$store.state.settings.theme
}, },
// //
topMenus() { topMenus () {
let topMenus = []; const topMenus = []
this.routers.map((menu) => { this.routers.map((menu) => {
if (menu.hidden !== true) { if (menu.hidden !== true) {
// //
if (menu.path === "/") { if (menu.path === '/') {
topMenus.push(menu.children[0]); topMenus.push(menu.children[0])
} else { } else {
topMenus.push(menu); topMenus.push(menu)
} }
} }
}); return undefined
return topMenus; })
return topMenus
}, },
// //
routers() { routers () {
return this.$store.state.permission.topbarRouters; return this.$store.state.permission.topbarRouters
}, },
// //
childrenMenus() { childrenMenus () {
var childrenMenus = []; const childrenMenus = []
this.routers.map((router) => { this.routers.map((router) => {
for (var item in router.children) { for (const item in router.children) {
if (router.children[item].parentPath === undefined) { if (router.children[item].parentPath === undefined) {
if(router.path === "/") { if (router.path === '/') {
router.children[item].path = "/redirect/" + router.children[item].path; router.children[item].path = '/redirect/' + router.children[item].path
} else { } else {
if(!this.ishttp(router.children[item].path)) { if (!this.ishttp(router.children[item].path)) {
router.children[item].path = router.path + "/" + router.children[item].path; router.children[item].path = router.path + '/' + router.children[item].path
} }
} }
router.children[item].parentPath = router.path; router.children[item].parentPath = router.path
} }
childrenMenus.push(router.children[item]); childrenMenus.push(router.children[item])
} }
}); return undefined
return constantRoutes.concat(childrenMenus); })
return constantRoutes.concat(childrenMenus)
}, },
// //
activeMenu() { activeMenu () {
const path = this.$route.path; const path = this.$route.path
let activePath = this.defaultRouter(); let activePath = this.defaultRouter()
if (path.lastIndexOf("/") > 0) { if (path.lastIndexOf('/') > 0) {
const tmpPath = path.substring(1, path.length); const tmpPath = path.substring(1, path.length)
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); activePath = '/' + tmpPath.substring(0, tmpPath.indexOf('/'))
} else if ("/index" == path || "" == path) { } else if (path === '/index' || path === '') {
if (!this.isFrist) { if (!this.isFrist) {
this.isFrist = true; // eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.isFrist = true
} else { } else {
activePath = "index"; activePath = 'index'
} }
} }
var routes = this.activeRoutes(activePath); const routes = this.activeRoutes(activePath)
if (routes.length === 0) { if (routes.length === 0) {
activePath = this.currentIndex || this.defaultRouter() activePath = this.currentIndex || this.defaultRouter()
this.activeRoutes(activePath); this.activeRoutes(activePath)
}
return activePath
} }
return activePath;
}, },
}, beforeMount () {
beforeMount() {
window.addEventListener('resize', this.setVisibleNumber) window.addEventListener('resize', this.setVisibleNumber)
}, },
beforeDestroy() { beforeDestroy () {
window.removeEventListener('resize', this.setVisibleNumber) window.removeEventListener('resize', this.setVisibleNumber)
}, },
mounted() { mounted () {
this.setVisibleNumber(); this.setVisibleNumber()
}, },
methods: { methods: {
// //
setVisibleNumber() { setVisibleNumber () {
const width = document.body.getBoundingClientRect().width / 3; const width = document.body.getBoundingClientRect().width / 3
this.visibleNumber = parseInt(width / 85); this.visibleNumber = parseInt(width / 85)
}, },
// //
defaultRouter() { defaultRouter () {
let router; let router
Object.keys(this.routers).some((key) => { Object.keys(this.routers).some((key) => {
if (!this.routers[key].hidden) { if (!this.routers[key].hidden) {
router = this.routers[key].path; router = this.routers[key].path
return true; return true
} }
}); return undefined
return router; })
return router
}, },
// //
handleSelect(key, keyPath) { handleSelect (key, keyPath) {
this.currentIndex = key; this.currentIndex = key
if (this.ishttp(key)) { if (this.ishttp(key)) {
// http(s):// // http(s)://
window.open(key, "_blank"); window.open(key, '_blank')
} else if (key.indexOf("/redirect") !== -1) { } else if (key.indexOf('/redirect') !== -1) {
// /redirect // /redirect
this.$router.push({ path: key.replace("/redirect", "") }); this.$router.push({ path: key.replace('/redirect', '') })
} else { } else {
// //
this.activeRoutes(key); this.activeRoutes(key)
} }
}, },
// //
activeRoutes(key) { activeRoutes (key) {
var routes = []; const routes = []
if (this.childrenMenus && this.childrenMenus.length > 0) { if (this.childrenMenus && this.childrenMenus.length > 0) {
this.childrenMenus.map((item) => { this.childrenMenus.map((item) => {
if (key == item.parentPath || (key == "index" && "" == item.path)) { if (key === item.parentPath || (key === 'index' && item.path === '')) {
routes.push(item); routes.push(item)
} }
}); return undefined
})
} }
if(routes.length > 0) { if (routes.length > 0) {
this.$store.commit("SET_SIDEBAR_ROUTERS", routes); this.$store.commit('SET_SIDEBAR_ROUTERS', routes)
} }
return routes; return routes
}, },
ishttp(url) { ishttp (url) {
return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1 return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
} }
}, }
}; }
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -14,23 +14,23 @@ export default {
src: { src: {
type: String, type: String,
required: true required: true
}
}, },
}, data () {
data() {
return { return {
height: document.documentElement.clientHeight - 94.5 + "px;", height: document.documentElement.clientHeight - 94.5 + 'px;',
loading: true, loading: true,
url: this.src url: this.src
}; }
}, },
mounted: function () { mounted: function () {
setTimeout(() => { setTimeout(() => {
this.loading = false; this.loading = false
}, 300); }, 300)
const that = this; const that = this
window.onresize = function temp() { window.onresize = function temp () {
that.height = document.documentElement.clientHeight - 94.5 + "px;"; that.height = document.documentElement.clientHeight - 94.5 + 'px;'
};
} }
}; }
}
</script> </script>

View File

@ -4,61 +4,60 @@
*/ */
export default { export default {
bind(el, binding, vnode, oldVnode) { bind (el, binding, vnode, oldVnode) {
const value = binding.value const value = binding.value
if (value == false) return if (value === false) return
// 获取拖拽内容头部 // 获取拖拽内容头部
const dialogHeaderEl = el.querySelector('.el-dialog__header'); const dialogHeaderEl = el.querySelector('.el-dialog__header')
const dragDom = el.querySelector('.el-dialog'); const dragDom = el.querySelector('.el-dialog')
dialogHeaderEl.style.cursor = 'move'; dialogHeaderEl.style.cursor = 'move'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null); // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null); const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null)
dragDom.style.position = 'absolute'; dragDom.style.position = 'absolute'
dragDom.style.marginTop = 0; dragDom.style.marginTop = 0
let width = dragDom.style.width; let width = dragDom.style.width
if (width.includes('%')) { if (width.includes('%')) {
width = +document.body.clientWidth * (+width.replace(/\%/g, '') / 100); width = +document.body.clientWidth * (+width.replace(/%/g, '') / 100)
} else { } else {
width = +width.replace(/\px/g, ''); width = +width.replace(/\px/g, '')
} }
dragDom.style.left = `${(document.body.clientWidth - width) / 2}px`; dragDom.style.left = `${(document.body.clientWidth - width) / 2}px`
// 鼠标按下事件 // 鼠标按下事件
dialogHeaderEl.onmousedown = (e) => { dialogHeaderEl.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离 (鼠标点击位置距离可视窗口的距离) // 鼠标按下,计算当前元素距离可视区的距离 (鼠标点击位置距离可视窗口的距离)
const disX = e.clientX - dialogHeaderEl.offsetLeft; const disX = e.clientX - dialogHeaderEl.offsetLeft
const disY = e.clientY - dialogHeaderEl.offsetTop; const disY = e.clientY - dialogHeaderEl.offsetTop
// 获取到的值带px 正则匹配替换 // 获取到的值带px 正则匹配替换
let styL, styT; let styL, styT
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
if (sty.left.includes('%')) { if (sty.left.includes('%')) {
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100); styL = +document.body.clientWidth * (+sty.left.replace(/%/g, '') / 100)
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100); styT = +document.body.clientHeight * (+sty.top.replace(/%/g, '') / 100)
} else { } else {
styL = +sty.left.replace(/\px/g, ''); styL = +sty.left.replace(/\px/g, '')
styT = +sty.top.replace(/\px/g, ''); styT = +sty.top.replace(/\px/g, '')
}; };
// 鼠标拖拽事件 // 鼠标拖拽事件
document.onmousemove = function (e) { document.onmousemove = function (e) {
// 通过事件委托,计算移动的距离 (开始拖拽至结束拖拽的距离) // 通过事件委托,计算移动的距离 (开始拖拽至结束拖拽的距离)
const l = e.clientX - disX; const l = e.clientX - disX
const t = e.clientY - disY; const t = e.clientY - disY
let finallyL = l + styL const finallyL = l + styL
let finallyT = t + styT const finallyT = t + styT
// 移动当前元素 // 移动当前元素
dragDom.style.left = `${finallyL}px`; dragDom.style.left = `${finallyL}px`
dragDom.style.top = `${finallyT}px`; dragDom.style.top = `${finallyT}px`
}
};
document.onmouseup = function (e) { document.onmouseup = function (e) {
document.onmousemove = null; document.onmousemove = null
document.onmouseup = null; document.onmouseup = null
};
} }
} }
}; }
}

View File

@ -2,17 +2,17 @@ import hasRole from './permission/hasRole'
import hasPermi from './permission/hasPermi' import hasPermi from './permission/hasPermi'
import dialogDrag from './dialog/drag' import dialogDrag from './dialog/drag'
const install = function(Vue) { const install = function (Vue) {
Vue.directive('hasRole', hasRole) Vue.directive('hasRole', hasRole)
Vue.directive('hasPermi', hasPermi) Vue.directive('hasPermi', hasPermi)
Vue.directive('dialogDrag', dialogDrag) Vue.directive('dialogDrag', dialogDrag)
} }
if (window.Vue) { if (window.Vue) {
window['hasRole'] = hasRole window.hasRole = hasRole
window['hasPermi'] = hasPermi window.hasPermi = hasPermi
window['dialogDrag'] = dialogDrag window.dialogDrag = dialogDrag
Vue.use(install); // eslint-disable-line window.Vue.use(install)
} }
export default install export default install

View File

@ -1,4 +1,4 @@
/** /**
* v-hasPermi 操作权限处理 * v-hasPermi 操作权限处理
* Copyright (c) 2019 ruoyi * Copyright (c) 2019 ruoyi
*/ */
@ -6,23 +6,23 @@
import store from '@/store' import store from '@/store'
export default { export default {
inserted(el, binding, vnode) { inserted (el, binding, vnode) {
const { value } = binding const { value } = binding
const all_permission = "*:*:*"; const allPermission = '*:*:*'
const permissions = store.getters && store.getters.permissions const permissions = store.getters && store.getters.permissions
if (value && value instanceof Array && value.length > 0) { if (value && value instanceof Array && value.length > 0) {
const permissionFlag = value const permissionFlag = value
const hasPermissions = permissions.some(permission => { const hasPermissions = permissions.some(permission => {
return all_permission === permission || permissionFlag.includes(permission) return allPermission === permission || permissionFlag.includes(permission)
}) })
if (!hasPermissions) { if (!hasPermissions) {
el.parentNode && el.parentNode.removeChild(el) el.parentNode && el.parentNode.removeChild(el)
} }
} else { } else {
throw new Error(`请设置操作权限标签值`) throw new Error('请设置操作权限标签值')
} }
} }
} }

View File

@ -1,4 +1,4 @@
/** /**
* v-hasRole 角色权限处理 * v-hasRole 角色权限处理
* Copyright (c) 2019 ruoyi * Copyright (c) 2019 ruoyi
*/ */
@ -6,23 +6,23 @@
import store from '@/store' import store from '@/store'
export default { export default {
inserted(el, binding, vnode) { inserted (el, binding, vnode) {
const { value } = binding const { value } = binding
const super_admin = "admin"; const superAdmin = 'admin'
const roles = store.getters && store.getters.roles const roles = store.getters && store.getters.roles
if (value && value instanceof Array && value.length > 0) { if (value && value instanceof Array && value.length > 0) {
const roleFlag = value const roleFlag = value
const hasRole = roles.some(role => { const hasRole = roles.some(role => {
return super_admin === role || roleFlag.includes(role) return superAdmin === role || roleFlag.includes(role)
}) })
if (!hasRole) { if (!hasRole) {
el.parentNode && el.parentNode.removeChild(el) el.parentNode && el.parentNode.removeChild(el)
} }
} else { } else {
throw new Error(`请设置角色权限标签值"`) throw new Error('请设置角色权限标签值"')
} }
} }
} }

View File

@ -12,10 +12,10 @@
export default { export default {
name: 'AppMain', name: 'AppMain',
computed: { computed: {
cachedViews() { cachedViews () {
return this.$store.state.tagsView.cachedViews return this.$store.state.tagsView.cachedViews
}, },
key() { key () {
return this.$route.path return this.$route.path
} }
} }

View File

@ -1,16 +1,16 @@
<script> <script>
export default { export default {
data() { data () {
return {}; return {}
}, },
render() { render () {
const { $route: { meta: { link } }, } = this; const { $route: { meta: { link } } } = this
if ({ link }.link === "") { if ({ link }.link === '') {
return "404"; return '404'
} }
let url = { link }.link; const url = { link }.link
const height = document.documentElement.clientHeight - 94.5 + "px"; const height = document.documentElement.clientHeight - 94.5 + 'px'
const style = { height: height }; const style = { height: height }
return ( return (
<div style={style}> <div style={style}>
@ -21,7 +21,7 @@ export default {
scrolling="auto" scrolling="auto"
></iframe> ></iframe>
</div> </div>
); )
}, }
}; }
</script> </script>

View File

@ -75,10 +75,10 @@ export default {
'device' 'device'
]), ]),
setting: { setting: {
get() { get () {
return this.$store.state.settings.showSettings return this.$store.state.settings.showSettings
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'showSettings', key: 'showSettings',
value: val value: val
@ -86,25 +86,25 @@ export default {
} }
}, },
topNav: { topNav: {
get() { get () {
return this.$store.state.settings.topNav return this.$store.state.settings.topNav
} }
} }
}, },
methods: { methods: {
toggleSideBar() { toggleSideBar () {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
}, },
async logout() { async logout () {
this.$confirm('确定注销并退出系统吗?', '提示', { this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.href = '/index'; location.href = '/index'
}) })
}).catch(() => {}); }).catch(() => {})
} }
} }
} }

View File

@ -80,18 +80,18 @@ import ThemePicker from '@/components/ThemePicker'
export default { export default {
components: { ThemePicker }, components: { ThemePicker },
data() { data () {
return { return {
theme: this.$store.state.settings.theme, theme: this.$store.state.settings.theme,
sideTheme: this.$store.state.settings.sideTheme sideTheme: this.$store.state.settings.sideTheme
}; }
}, },
computed: { computed: {
fixedHeader: { fixedHeader: {
get() { get () {
return this.$store.state.settings.fixedHeader return this.$store.state.settings.fixedHeader
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'fixedHeader', key: 'fixedHeader',
value: val value: val
@ -99,24 +99,24 @@ export default {
} }
}, },
topNav: { topNav: {
get() { get () {
return this.$store.state.settings.topNav return this.$store.state.settings.topNav
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'topNav', key: 'topNav',
value: val value: val
}) })
if (!val) { if (!val) {
this.$store.commit("SET_SIDEBAR_ROUTERS", this.$store.state.permission.defaultRoutes); this.$store.commit('SET_SIDEBAR_ROUTERS', this.$store.state.permission.defaultRoutes)
} }
} }
}, },
tagsView: { tagsView: {
get() { get () {
return this.$store.state.settings.tagsView return this.$store.state.settings.tagsView
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'tagsView', key: 'tagsView',
value: val value: val
@ -124,10 +124,10 @@ export default {
} }
}, },
sidebarLogo: { sidebarLogo: {
get() { get () {
return this.$store.state.settings.sidebarLogo return this.$store.state.settings.sidebarLogo
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'sidebarLogo', key: 'sidebarLogo',
value: val value: val
@ -135,42 +135,42 @@ export default {
} }
}, },
dynamicTitle: { dynamicTitle: {
get() { get () {
return this.$store.state.settings.dynamicTitle return this.$store.state.settings.dynamicTitle
}, },
set(val) { set (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'dynamicTitle', key: 'dynamicTitle',
value: val value: val
}) })
} }
}, }
}, },
methods: { methods: {
themeChange(val) { themeChange (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'theme', key: 'theme',
value: val value: val
}) })
this.theme = val; this.theme = val
}, },
handleTheme(val) { handleTheme (val) {
this.$store.dispatch('settings/changeSetting', { this.$store.dispatch('settings/changeSetting', {
key: 'sideTheme', key: 'sideTheme',
value: val value: val
}) })
this.sideTheme = val; this.sideTheme = val
}, },
saveSetting() { saveSetting () {
const loading = this.$loading({ const loading = this.$loading({
lock: true, lock: true,
fullscreen: false, fullscreen: false,
text: "正在保存到本地,请稍后...", text: '正在保存到本地,请稍后...',
spinner: "el-icon-loading", spinner: 'el-icon-loading',
background: "rgba(0, 0, 0, 0.7)" background: 'rgba(0, 0, 0, 0.7)'
}); })
localStorage.setItem( localStorage.setItem(
"layout-setting", 'layout-setting',
`{ `{
"topNav":${this.topNav}, "topNav":${this.topNav},
"tagsView":${this.tagsView}, "tagsView":${this.tagsView},
@ -180,19 +180,19 @@ export default {
"sideTheme":"${this.sideTheme}", "sideTheme":"${this.sideTheme}",
"theme":"${this.theme}" "theme":"${this.theme}"
}` }`
); )
setTimeout(loading.close(), 1000) setTimeout(loading.close(), 1000)
}, },
resetSetting() { resetSetting () {
this.$loading({ this.$loading({
lock: true, lock: true,
fullscreen: false, fullscreen: false,
text: "正在清除设置缓存并刷新,请稍后...", text: '正在清除设置缓存并刷新,请稍后...',
spinner: "el-icon-loading", spinner: 'el-icon-loading',
background: "rgba(0, 0, 0, 0.7)" background: 'rgba(0, 0, 0, 0.7)'
}); })
localStorage.removeItem("layout-setting") localStorage.removeItem('layout-setting')
setTimeout("window.location.reload()", 1000) setTimeout(window.location.reload(), 1000)
} }
} }
} }

View File

@ -1,15 +1,15 @@
export default { export default {
computed: { computed: {
device() { device () {
return this.$store.state.app.device return this.$store.state.app.device
} }
}, },
mounted() { mounted () {
// In order to fix the click on menu on the ios device will trigger the mouseleave bug // In order to fix the click on menu on the ios device will trigger the mouseleave bug
this.fixBugIniOS() this.fixBugIniOS()
}, },
methods: { methods: {
fixBugIniOS() { fixBugIniOS () {
const $subMenu = this.$refs.subMenu const $subMenu = this.$refs.subMenu
if ($subMenu) { if ($subMenu) {
const handleMouseleave = $subMenu.handleMouseleave const handleMouseleave = $subMenu.handleMouseleave

View File

@ -12,7 +12,7 @@ export default {
default: '' default: ''
} }
}, },
render(h, context) { render (h, context) {
const { icon, title } = context.props const { icon, title } = context.props
const vnodes = [] const vnodes = []

View File

@ -15,10 +15,10 @@ export default {
} }
}, },
computed: { computed: {
isExternal() { isExternal () {
return isExternal(this.to) return isExternal(this.to)
}, },
type() { type () {
if (this.isExternal) { if (this.isExternal) {
return 'a' return 'a'
} }
@ -26,7 +26,7 @@ export default {
} }
}, },
methods: { methods: {
linkProps(to) { linkProps (to) {
if (this.isExternal) { if (this.isExternal) {
return { return {
href: to, href: to,

View File

@ -26,14 +26,14 @@ export default {
} }
}, },
computed: { computed: {
variables() { variables () {
return variables; return variables
}, },
sideTheme() { sideTheme () {
return this.$store.state.settings.sideTheme return this.$store.state.settings.sideTheme
} }
}, },
data() { data () {
return { return {
title: '若依管理系统', title: '若依管理系统',
logo: logoImg logo: logoImg

View File

@ -50,14 +50,14 @@ export default {
default: '' default: ''
} }
}, },
data() { data () {
this.onlyOneChild = null this.onlyOneChild = null
return {} return {}
}, },
methods: { methods: {
hasOneShowingChild(children = [], parent) { hasOneShowingChild (children = [], parent) {
if (!children) { if (!children) {
children = []; children = []
} }
const showingChildren = children.filter(item => { const showingChildren = children.filter(item => {
if (item.hidden) { if (item.hidden) {
@ -76,13 +76,13 @@ export default {
// Show parent if there are no child router to display // Show parent if there are no child router to display
if (showingChildren.length === 0) { if (showingChildren.length === 0) {
this.onlyOneChild = { ... parent, path: '', noShowingChildren: true } this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
return true return true
} }
return false return false
}, },
resolvePath(routePath) { resolvePath (routePath) {
if (isExternal(routePath)) { if (isExternal(routePath)) {
return routePath return routePath
} }

View File

@ -24,34 +24,34 @@
</template> </template>
<script> <script>
import { mapGetters, mapState } from "vuex"; import { mapGetters, mapState } from 'vuex'
import Logo from "./Logo"; import Logo from './Logo'
import SidebarItem from "./SidebarItem"; import SidebarItem from './SidebarItem'
import variables from "@/assets/styles/variables.scss"; import variables from '@/assets/styles/variables.scss'
export default { export default {
components: { SidebarItem, Logo }, components: { SidebarItem, Logo },
computed: { computed: {
...mapState(["settings"]), ...mapState(['settings']),
...mapGetters(["sidebarRouters", "sidebar"]), ...mapGetters(['sidebarRouters', 'sidebar']),
activeMenu() { activeMenu () {
const route = this.$route; const route = this.$route
const { meta, path } = route; const { meta, path } = route
// if set path, the sidebar will highlight the path you set // if set path, the sidebar will highlight the path you set
if (meta.activeMenu) { if (meta.activeMenu) {
return meta.activeMenu; return meta.activeMenu
} }
return path; return path
}, },
showLogo() { showLogo () {
return this.$store.state.settings.sidebarLogo; return this.$store.state.settings.sidebarLogo
}, },
variables() { variables () {
return variables; return variables
}, },
isCollapse() { isCollapse () {
return !this.sidebar.opened; return !this.sidebar.opened
} }
} }
}; }
</script> </script>

View File

@ -9,32 +9,32 @@ const tagAndTagSpacing = 4 // tagAndTagSpacing
export default { export default {
name: 'ScrollPane', name: 'ScrollPane',
data() { data () {
return { return {
left: 0 left: 0
} }
}, },
computed: { computed: {
scrollWrapper() { scrollWrapper () {
return this.$refs.scrollContainer.$refs.wrap return this.$refs.scrollContainer.$refs.wrap
} }
}, },
mounted() { mounted () {
this.scrollWrapper.addEventListener('scroll', this.emitScroll, true) this.scrollWrapper.addEventListener('scroll', this.emitScroll, true)
}, },
beforeDestroy() { beforeDestroy () {
this.scrollWrapper.removeEventListener('scroll', this.emitScroll) this.scrollWrapper.removeEventListener('scroll', this.emitScroll)
}, },
methods: { methods: {
handleScroll(e) { handleScroll (e) {
const eventDelta = e.wheelDelta || -e.deltaY * 40 const eventDelta = e.wheelDelta || -e.deltaY * 40
const $scrollWrapper = this.scrollWrapper const $scrollWrapper = this.scrollWrapper
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4 $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
}, },
emitScroll() { emitScroll () {
this.$emit('scroll') this.$emit('scroll')
}, },
moveToTarget(currentTag) { moveToTarget (currentTag) {
const $container = this.$refs.scrollContainer.$el const $container = this.$refs.scrollContainer.$el
const $containerWidth = $container.offsetWidth const $containerWidth = $container.offsetWidth
const $scrollWrapper = this.scrollWrapper const $scrollWrapper = this.scrollWrapper

View File

@ -33,7 +33,7 @@ import path from 'path'
export default { export default {
components: { ScrollPane }, components: { ScrollPane },
data() { data () {
return { return {
visible: false, visible: false,
top: 0, top: 0,
@ -43,22 +43,22 @@ export default {
} }
}, },
computed: { computed: {
visitedViews() { visitedViews () {
return this.$store.state.tagsView.visitedViews return this.$store.state.tagsView.visitedViews
}, },
routes() { routes () {
return this.$store.state.permission.routes return this.$store.state.permission.routes
}, },
theme() { theme () {
return this.$store.state.settings.theme; return this.$store.state.settings.theme
} }
}, },
watch: { watch: {
$route() { $route () {
this.addTags() this.addTags()
this.moveToCurrentTag() this.moveToCurrentTag()
}, },
visible(value) { visible (value) {
if (value) { if (value) {
document.body.addEventListener('click', this.closeMenu) document.body.addEventListener('click', this.closeMenu)
} else { } else {
@ -66,32 +66,32 @@ export default {
} }
} }
}, },
mounted() { mounted () {
this.initTags() this.initTags()
this.addTags() this.addTags()
}, },
methods: { methods: {
isActive(route) { isActive (route) {
return route.path === this.$route.path return route.path === this.$route.path
}, },
activeStyle(tag) { activeStyle (tag) {
if (!this.isActive(tag)) return {}; if (!this.isActive(tag)) return {}
return { return {
"background-color": this.theme, 'background-color': this.theme,
"border-color": this.theme 'border-color': this.theme
}; }
}, },
isAffix(tag) { isAffix (tag) {
return tag.meta && tag.meta.affix return tag.meta && tag.meta.affix
}, },
isLastView() { isLastView () {
try { try {
return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath return this.selectedTag.fullPath === this.visitedViews[this.visitedViews.length - 1].fullPath
} catch (err) { } catch (err) {
return false return false
} }
}, },
filterAffixTags(routes, basePath = '/') { filterAffixTags (routes, basePath = '/') {
let tags = [] let tags = []
routes.forEach(route => { routes.forEach(route => {
if (route.meta && route.meta.affix) { if (route.meta && route.meta.affix) {
@ -112,7 +112,7 @@ export default {
}) })
return tags return tags
}, },
initTags() { initTags () {
const affixTags = this.affixTags = this.filterAffixTags(this.routes) const affixTags = this.affixTags = this.filterAffixTags(this.routes)
for (const tag of affixTags) { for (const tag of affixTags) {
// Must have tag name // Must have tag name
@ -121,14 +121,14 @@ export default {
} }
} }
}, },
addTags() { addTags () {
const { name } = this.$route const { name } = this.$route
if (name) { if (name) {
this.$store.dispatch('tagsView/addView', this.$route) this.$store.dispatch('tagsView/addView', this.$route)
} }
return false return false
}, },
moveToCurrentTag() { moveToCurrentTag () {
const tags = this.$refs.tag const tags = this.$refs.tag
this.$nextTick(() => { this.$nextTick(() => {
for (const tag of tags) { for (const tag of tags) {
@ -143,7 +143,7 @@ export default {
} }
}) })
}, },
refreshSelectedTag(view) { refreshSelectedTag (view) {
this.$store.dispatch('tagsView/delCachedView', view).then(() => { this.$store.dispatch('tagsView/delCachedView', view).then(() => {
const { fullPath } = view const { fullPath } = view
this.$nextTick(() => { this.$nextTick(() => {
@ -153,27 +153,27 @@ export default {
}) })
}) })
}, },
closeSelectedTag(view) { closeSelectedTag (view) {
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
if (this.isActive(view)) { if (this.isActive(view)) {
this.toLastView(visitedViews, view) this.toLastView(visitedViews, view)
} }
}) })
}, },
closeRightTags() { closeRightTags () {
this.$store.dispatch('tagsView/delRightTags', this.selectedTag).then(visitedViews => { this.$store.dispatch('tagsView/delRightTags', this.selectedTag).then(visitedViews => {
if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) { if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
this.toLastView(visitedViews) this.toLastView(visitedViews)
} }
}) })
}, },
closeOthersTags() { closeOthersTags () {
this.$router.push(this.selectedTag).catch(()=>{}); this.$router.push(this.selectedTag).catch(() => {})
this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => { this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => {
this.moveToCurrentTag() this.moveToCurrentTag()
}) })
}, },
closeAllTags(view) { closeAllTags (view) {
this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => { this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
if (this.affixTags.some(tag => tag.path === this.$route.path)) { if (this.affixTags.some(tag => tag.path === this.$route.path)) {
return return
@ -181,7 +181,7 @@ export default {
this.toLastView(visitedViews, view) this.toLastView(visitedViews, view)
}) })
}, },
toLastView(visitedViews, view) { toLastView (visitedViews, view) {
const latestView = visitedViews.slice(-1)[0] const latestView = visitedViews.slice(-1)[0]
if (latestView) { if (latestView) {
this.$router.push(latestView.fullPath) this.$router.push(latestView.fullPath)
@ -196,7 +196,7 @@ export default {
} }
} }
}, },
openMenu(tag, e) { openMenu (tag, e) {
const menuMinWidth = 105 const menuMinWidth = 105
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
const offsetWidth = this.$el.offsetWidth // container width const offsetWidth = this.$el.offsetWidth // container width
@ -213,10 +213,10 @@ export default {
this.visible = true this.visible = true
this.selectedTag = tag this.selectedTag = tag
}, },
closeMenu() { closeMenu () {
this.visible = false this.visible = false
}, },
handleScroll() { handleScroll () {
this.closeMenu() this.closeMenu()
} }
} }

View File

@ -43,7 +43,7 @@ export default {
needTagsView: state => state.settings.tagsView, needTagsView: state => state.settings.tagsView,
fixedHeader: state => state.settings.fixedHeader fixedHeader: state => state.settings.fixedHeader
}), }),
classObj() { classObj () {
return { return {
hideSidebar: !this.sidebar.opened, hideSidebar: !this.sidebar.opened,
openSidebar: this.sidebar.opened, openSidebar: this.sidebar.opened,
@ -51,12 +51,12 @@ export default {
mobile: this.device === 'mobile' mobile: this.device === 'mobile'
} }
}, },
variables() { variables () {
return variables; return variables
} }
}, },
methods: { methods: {
handleClickOutside() { handleClickOutside () {
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false }) this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
} }
} }

View File

@ -5,19 +5,19 @@ const WIDTH = 992 // refer to Bootstrap's responsive design
export default { export default {
watch: { watch: {
$route(route) { $route (route) {
if (this.device === 'mobile' && this.sidebar.opened) { if (this.device === 'mobile' && this.sidebar.opened) {
store.dispatch('app/closeSideBar', { withoutAnimation: false }) store.dispatch('app/closeSideBar', { withoutAnimation: false })
} }
} }
}, },
beforeMount() { beforeMount () {
window.addEventListener('resize', this.$_resizeHandler) window.addEventListener('resize', this.$_resizeHandler)
}, },
beforeDestroy() { beforeDestroy () {
window.removeEventListener('resize', this.$_resizeHandler) window.removeEventListener('resize', this.$_resizeHandler)
}, },
mounted() { mounted () {
const isMobile = this.$_isMobile() const isMobile = this.$_isMobile()
if (isMobile) { if (isMobile) {
store.dispatch('app/toggleDevice', 'mobile') store.dispatch('app/toggleDevice', 'mobile')
@ -27,11 +27,11 @@ export default {
methods: { methods: {
// use $_ for mixins properties // use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_isMobile() { $_isMobile () {
const rect = body.getBoundingClientRect() const rect = body.getBoundingClientRect()
return rect.width - 1 < WIDTH return rect.width - 1 < WIDTH
}, },
$_resizeHandler() { $_resizeHandler () {
if (!document.hidden) { if (!document.hidden) {
const isMobile = this.$_isMobile() const isMobile = this.$_isMobile()
store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop') store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')

View File

@ -10,22 +10,22 @@ import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App' import App from './App'
import store from './store' import store from './store'
import router from './router' import router from './router'
import directive from './directive' //directive import directive from './directive' // directive
import './assets/icons' // icon import './assets/icons' // icon
import './permission' // permission control import './permission' // permission control
import { getDicts } from "@/api/system/dict/data"; import { getDicts } from '@/api/system/dict/data'
import { getConfigKey } from "@/api/system/config"; import { getConfigKey } from '@/api/system/config'
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from '@/utils/ruoyi'
import Pagination from "@/components/Pagination"; import Pagination from '@/components/Pagination'
// 自定义表格工具组件 // 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar" import RightToolbar from '@/components/RightToolbar'
// 富文本组件 // 富文本组件
import Editor from "@/components/Editor" import Editor from '@/components/Editor'
// 文件上传组件 // 文件上传组件
import FileUpload from "@/components/FileUpload" import FileUpload from '@/components/FileUpload'
// 图片上传组件 // 图片上传组件
import ImageUpload from "@/components/ImageUpload" import ImageUpload from '@/components/ImageUpload'
// 字典标签组件 // 字典标签组件
import DictTag from '@/components/DictTag' import DictTag from '@/components/DictTag'
// 头部标签组件 // 头部标签组件
@ -43,15 +43,15 @@ Vue.prototype.download = download
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
Vue.prototype.msgSuccess = function (msg) { Vue.prototype.msgSuccess = function (msg) {
this.$message({ showClose: true, message: msg, type: "success" }); this.$message({ showClose: true, message: msg, type: 'success' })
} }
Vue.prototype.msgError = function (msg) { Vue.prototype.msgError = function (msg) {
this.$message({ showClose: true, message: msg, type: "error" }); this.$message({ showClose: true, message: msg, type: 'error' })
} }
Vue.prototype.msgInfo = function (msg) { Vue.prototype.msgInfo = function (msg) {
this.$message.info(msg); this.$message.info(msg)
} }
// 全局组件挂载 // 全局组件挂载
@ -80,6 +80,7 @@ Vue.use(Element, {
Vue.config.productionTip = false Vue.config.productionTip = false
// eslint-disable-next-line no-new
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,

View File

@ -13,7 +13,7 @@ router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
if (getToken()) { if (getToken()) {
to.meta.title && store.dispatch('settings/setTitle', to.meta.title) to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
/* has token*/ /* has token */
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }) next({ path: '/' })
NProgress.done() NProgress.done()

View File

@ -1,11 +1,11 @@
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
Vue.use(Router)
/* Layout */ /* Layout */
import Layout from '@/layout' import Layout from '@/layout'
Vue.use(Router)
/** /**
* Note: 路由配置项 * Note: 路由配置项
* *
@ -94,7 +94,7 @@ export const constantRoutes = [
path: 'role/:userId(\\d+)', path: 'role/:userId(\\d+)',
component: (resolve) => require(['@/views/system/user/authRole'], resolve), component: (resolve) => require(['@/views/system/user/authRole'], resolve),
name: 'AuthRole', name: 'AuthRole',
meta: { title: '分配角色', activeMenu: '/system/user'} meta: { title: '分配角色', activeMenu: '/system/user' }
} }
] ]
}, },
@ -107,7 +107,7 @@ export const constantRoutes = [
path: 'user/:roleId(\\d+)', path: 'user/:roleId(\\d+)',
component: (resolve) => require(['@/views/system/role/authUser'], resolve), component: (resolve) => require(['@/views/system/role/authUser'], resolve),
name: 'AuthUser', name: 'AuthUser',
meta: { title: '分配用户', activeMenu: '/system/role'} meta: { title: '分配用户', activeMenu: '/system/role' }
} }
] ]
}, },
@ -120,7 +120,7 @@ export const constantRoutes = [
path: 'index/:dictId(\\d+)', path: 'index/:dictId(\\d+)',
component: (resolve) => require(['@/views/system/dict/data'], resolve), component: (resolve) => require(['@/views/system/dict/data'], resolve),
name: 'Data', name: 'Data',
meta: { title: '字典数据', activeMenu: '/system/dict'} meta: { title: '字典数据', activeMenu: '/system/dict' }
} }
] ]
}, },
@ -133,7 +133,7 @@ export const constantRoutes = [
path: 'index', path: 'index',
component: (resolve) => require(['@/views/monitor/job/log'], resolve), component: (resolve) => require(['@/views/monitor/job/log'], resolve),
name: 'JobLog', name: 'JobLog',
meta: { title: '调度日志', activeMenu: '/monitor/job'} meta: { title: '调度日志', activeMenu: '/monitor/job' }
} }
] ]
}, },
@ -146,7 +146,7 @@ export const constantRoutes = [
path: 'index/:tableId(\\d+)', path: 'index/:tableId(\\d+)',
component: (resolve) => require(['@/views/tool/gen/editTable'], resolve), component: (resolve) => require(['@/views/tool/gen/editTable'], resolve),
name: 'GenEdit', name: 'GenEdit',
meta: { title: '修改生成配置', activeMenu: '/tool/gen'} meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
} }
] ]
} }

View File

@ -11,8 +11,8 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
permissions: state => state.user.permissions, permissions: state => state.user.permissions,
permission_routes: state => state.permission.routes, permission_routes: state => state.permission.routes,
topbarRouters:state => state.permission.topbarRouters, topbarRouters: state => state.permission.topbarRouters,
defaultRoutes:state => state.permission.defaultRoutes, defaultRoutes: state => state.permission.defaultRoutes,
sidebarRouters:state => state.permission.sidebarRouters, sidebarRouters: state => state.permission.sidebarRouters
} }
export default getters export default getters

View File

@ -34,16 +34,16 @@ const mutations = {
} }
const actions = { const actions = {
toggleSideBar({ commit }) { toggleSideBar ({ commit }) {
commit('TOGGLE_SIDEBAR') commit('TOGGLE_SIDEBAR')
}, },
closeSideBar({ commit }, { withoutAnimation }) { closeSideBar ({ commit }, { withoutAnimation }) {
commit('CLOSE_SIDEBAR', withoutAnimation) commit('CLOSE_SIDEBAR', withoutAnimation)
}, },
toggleDevice({ commit }, device) { toggleDevice ({ commit }, device) {
commit('TOGGLE_DEVICE', device) commit('TOGGLE_DEVICE', device)
}, },
setSize({ commit }, size) { setSize ({ commit }, size) {
commit('SET_SIZE', size) commit('SET_SIZE', size)
} }
} }

View File

@ -1,7 +1,7 @@
import { constantRoutes } from '@/router' import { constantRoutes } from '@/router'
import { getRouters } from '@/api/menu' import { getRouters } from '@/api/menu'
import Layout from '@/layout/index' import Layout from '@/layout/index'
import ParentView from '@/components/ParentView'; import ParentView from '@/components/ParentView'
import InnerLink from '@/layout/components/InnerLink' import InnerLink from '@/layout/components/InnerLink'
const permission = { const permission = {
@ -24,17 +24,17 @@ const permission = {
// 顶部导航菜单默认添加统计报表栏指向首页 // 顶部导航菜单默认添加统计报表栏指向首页
const index = [{ const index = [{
path: 'index', path: 'index',
meta: { title: '统计报表', icon: 'dashboard'} meta: { title: '统计报表', icon: 'dashboard' }
}] }]
state.topbarRouters = routes.concat(index); state.topbarRouters = routes.concat(index)
}, },
SET_SIDEBAR_ROUTERS: (state, routes) => { SET_SIDEBAR_ROUTERS: (state, routes) => {
state.sidebarRouters = routes state.sidebarRouters = routes
}, }
}, },
actions: { actions: {
// 生成路由 // 生成路由
GenerateRoutes({ commit }) { GenerateRoutes ({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
// 向后端请求路由数据 // 向后端请求路由数据
getRouters().then(res => { getRouters().then(res => {
@ -55,7 +55,7 @@ const permission = {
} }
// 遍历后台传来的路由字符串,转换为组件对象 // 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { function filterAsyncRouter (asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter(route => { return asyncRouterMap.filter(route => {
if (type && route.children) { if (type && route.children) {
route.children = filterChildren(route.children) route.children = filterChildren(route.children)
@ -72,18 +72,18 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
route.component = loadView(route.component) route.component = loadView(route.component)
} }
} }
if (route.children != null && route.children && route.children.length) { if (route.children !== null && route.children && route.children.length) {
route.children = filterAsyncRouter(route.children, route, type) route.children = filterAsyncRouter(route.children, route, type)
} else { } else {
delete route['children'] delete route.children
delete route['redirect'] delete route.redirect
} }
return true return true
}) })
} }
function filterChildren(childrenMap, lastRouter = false) { function filterChildren (childrenMap, lastRouter = false) {
var children = [] let children = []
childrenMap.forEach((el, index) => { childrenMap.forEach((el, index) => {
if (el.children && el.children.length) { if (el.children && el.children.length) {
if (el.component === 'ParentView') { if (el.component === 'ParentView') {

View File

@ -17,19 +17,19 @@ const state = {
} }
const mutations = { const mutations = {
CHANGE_SETTING: (state, { key, value }) => { CHANGE_SETTING: (state, { key, value }) => {
if (state.hasOwnProperty(key)) { if (Object.prototype.hasOwnProperty.call(state, key)) {
state[key] = value state[key] = value
} }
} }
} }
const actions = { const actions = {
// 修改布局设置 // <EFBFBD>޸IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
changeSetting({ commit }, data) { changeSetting ({ commit }, data) {
commit('CHANGE_SETTING', data) commit('CHANGE_SETTING', data)
}, },
// 设置网页标题 // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
setTitle({ commit }, title) { setTitle ({ commit }, title) {
state.title = title state.title = title
} }
} }
@ -40,4 +40,3 @@ export default {
mutations, mutations,
actions actions
} }

View File

@ -83,18 +83,18 @@ const mutations = {
} }
const actions = { const actions = {
addView({ dispatch }, view) { addView ({ dispatch }, view) {
dispatch('addVisitedView', view) dispatch('addVisitedView', view)
dispatch('addCachedView', view) dispatch('addCachedView', view)
}, },
addVisitedView({ commit }, view) { addVisitedView ({ commit }, view) {
commit('ADD_VISITED_VIEW', view) commit('ADD_VISITED_VIEW', view)
}, },
addCachedView({ commit }, view) { addCachedView ({ commit }, view) {
commit('ADD_CACHED_VIEW', view) commit('ADD_CACHED_VIEW', view)
}, },
delView({ dispatch, state }, view) { delView ({ dispatch, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
dispatch('delVisitedView', view) dispatch('delVisitedView', view)
dispatch('delCachedView', view) dispatch('delCachedView', view)
@ -104,20 +104,20 @@ const actions = {
}) })
}) })
}, },
delVisitedView({ commit, state }, view) { delVisitedView ({ commit, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_VISITED_VIEW', view) commit('DEL_VISITED_VIEW', view)
resolve([...state.visitedViews]) resolve([...state.visitedViews])
}) })
}, },
delCachedView({ commit, state }, view) { delCachedView ({ commit, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_CACHED_VIEW', view) commit('DEL_CACHED_VIEW', view)
resolve([...state.cachedViews]) resolve([...state.cachedViews])
}) })
}, },
delOthersViews({ dispatch, state }, view) { delOthersViews ({ dispatch, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
dispatch('delOthersVisitedViews', view) dispatch('delOthersVisitedViews', view)
dispatch('delOthersCachedViews', view) dispatch('delOthersCachedViews', view)
@ -127,20 +127,20 @@ const actions = {
}) })
}) })
}, },
delOthersVisitedViews({ commit, state }, view) { delOthersVisitedViews ({ commit, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_OTHERS_VISITED_VIEWS', view) commit('DEL_OTHERS_VISITED_VIEWS', view)
resolve([...state.visitedViews]) resolve([...state.visitedViews])
}) })
}, },
delOthersCachedViews({ commit, state }, view) { delOthersCachedViews ({ commit, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_OTHERS_CACHED_VIEWS', view) commit('DEL_OTHERS_CACHED_VIEWS', view)
resolve([...state.cachedViews]) resolve([...state.cachedViews])
}) })
}, },
delAllViews({ dispatch, state }, view) { delAllViews ({ dispatch, state }, view) {
return new Promise(resolve => { return new Promise(resolve => {
dispatch('delAllVisitedViews', view) dispatch('delAllVisitedViews', view)
dispatch('delAllCachedViews', view) dispatch('delAllCachedViews', view)
@ -150,24 +150,24 @@ const actions = {
}) })
}) })
}, },
delAllVisitedViews({ commit, state }) { delAllVisitedViews ({ commit, state }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_ALL_VISITED_VIEWS') commit('DEL_ALL_VISITED_VIEWS')
resolve([...state.visitedViews]) resolve([...state.visitedViews])
}) })
}, },
delAllCachedViews({ commit, state }) { delAllCachedViews ({ commit, state }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_ALL_CACHED_VIEWS') commit('DEL_ALL_CACHED_VIEWS')
resolve([...state.cachedViews]) resolve([...state.cachedViews])
}) })
}, },
updateVisitedView({ commit }, view) { updateVisitedView ({ commit }, view) {
commit('UPDATE_VISITED_VIEW', view) commit('UPDATE_VISITED_VIEW', view)
}, },
delRightTags({ commit }, view) { delRightTags ({ commit }, view) {
return new Promise(resolve => { return new Promise(resolve => {
commit('DEL_RIGHT_VIEWS', view) commit('DEL_RIGHT_VIEWS', view)
resolve([...state.visitedViews]) resolve([...state.visitedViews])

View File

@ -30,7 +30,7 @@ const user = {
actions: { actions: {
// 登录 // 登录
Login({ commit }, userInfo) { Login ({ commit }, userInfo) {
const username = userInfo.username.trim() const username = userInfo.username.trim()
const password = userInfo.password const password = userInfo.password
const code = userInfo.code const code = userInfo.code
@ -47,11 +47,11 @@ const user = {
}, },
// 获取用户信息 // 获取用户信息
GetInfo({ commit, state }) { GetInfo ({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo().then(res => { getInfo().then(res => {
const user = res.user const user = res.user
const avatar = user.avatar == "" ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; const avatar = user.avatar === '' ? require('@/assets/images/profile.jpg') : process.env.VUE_APP_BASE_API + user.avatar
if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
commit('SET_ROLES', res.roles) commit('SET_ROLES', res.roles)
commit('SET_PERMISSIONS', res.permissions) commit('SET_PERMISSIONS', res.permissions)
@ -68,7 +68,7 @@ const user = {
}, },
// 退出系统 // 退出系统
LogOut({ commit, state }) { LogOut ({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
logout(state.token).then(() => { logout(state.token).then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
@ -83,7 +83,7 @@ const user = {
}, },
// 前端 登出 // 前端 登出
FedLogOut({ commit }) { FedLogOut ({ commit }) {
return new Promise(resolve => { return new Promise(resolve => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
removeToken() removeToken()

View File

@ -2,14 +2,14 @@ import Cookies from 'js-cookie'
const TokenKey = 'Admin-Token' const TokenKey = 'Admin-Token'
export function getToken() { export function getToken () {
return Cookies.get(TokenKey) return Cookies.get(TokenKey)
} }
export function setToken(token) { export function setToken (token) {
return Cookies.set(TokenKey, token) return Cookies.set(TokenKey, token)
} }
export function removeToken() { export function removeToken () {
return Cookies.remove(TokenKey) return Cookies.remove(TokenKey)
} }

View File

@ -1,6 +1,6 @@
export default { export default {
'401': '认证失败,无法访问系统资源', 401: '认证失败,无法访问系统资源',
'403': '当前操作没有权限', 403: '当前操作没有权限',
'404': '访问资源不存在', 404: '访问资源不存在',
'default': '系统未知错误,请反馈给管理员' default: '系统未知错误,请反馈给管理员'
} }

View File

@ -3,7 +3,7 @@ const styles = {
'el-upload': '.el-upload__tip{line-height: 1.2;}' 'el-upload': '.el-upload__tip{line-height: 1.2;}'
} }
function addCss(cssList, el) { function addCss (cssList, el) {
const css = styles[el.tag] const css = styles[el.tag]
css && cssList.indexOf(css) === -1 && cssList.push(css) css && cssList.indexOf(css) === -1 && cssList.push(css)
if (el.children) { if (el.children) {
@ -11,7 +11,7 @@ function addCss(cssList, el) {
} }
} }
export function makeUpCss(conf) { export function makeUpCss (conf) {
const cssList = [] const cssList = []
conf.fields.forEach(el => addCss(cssList, el)) conf.fields.forEach(el => addCss(cssList, el))
return cssList.join('\n') return cssList.join('\n')

View File

@ -4,7 +4,7 @@ import { trigger } from './config'
let confGlobal let confGlobal
let someSpanIsNot24 let someSpanIsNot24
export function dialogWrapper(str) { export function dialogWrapper (str) {
return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile"> return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
${str} ${str}
<div slot="footer"> <div slot="footer">
@ -14,7 +14,7 @@ export function dialogWrapper(str) {
</el-dialog>` </el-dialog>`
} }
export function vueTemplate(str) { export function vueTemplate (str) {
return `<template> return `<template>
<div> <div>
${str} ${str}
@ -22,19 +22,19 @@ export function vueTemplate(str) {
</template>` </template>`
} }
export function vueScript(str) { export function vueScript (str) {
return `<script> return `<script>
${str} ${str}
</script>` </script>`
} }
export function cssStyle(cssStr) { export function cssStyle (cssStr) {
return `<style> return `<style>
${cssStr} ${cssStr}
</style>` </style>`
} }
function buildFormTemplate(conf, child, type) { function buildFormTemplate (conf, child, type) {
let labelPosition = '' let labelPosition = ''
if (conf.labelPosition !== 'right') { if (conf.labelPosition !== 'right') {
labelPosition = `label-position="${conf.labelPosition}"` labelPosition = `label-position="${conf.labelPosition}"`
@ -52,7 +52,7 @@ function buildFormTemplate(conf, child, type) {
return str return str
} }
function buildFromBtns(conf, type) { function buildFromBtns (conf, type) {
let str = '' let str = ''
if (conf.formBtns && type === 'file') { if (conf.formBtns && type === 'file') {
str = `<el-form-item size="large"> str = `<el-form-item size="large">
@ -69,7 +69,7 @@ function buildFromBtns(conf, type) {
} }
// span不为24的用el-col包裹 // span不为24的用el-col包裹
function colWrapper(element, str) { function colWrapper (element, str) {
if (someSpanIsNot24 || element.span !== 24) { if (someSpanIsNot24 || element.span !== 24) {
return `<el-col :span="${element.span}"> return `<el-col :span="${element.span}">
${str} ${str}
@ -79,7 +79,7 @@ function colWrapper(element, str) {
} }
const layouts = { const layouts = {
colFormItem(element) { colFormItem (element) {
let labelWidth = '' let labelWidth = ''
if (element.labelWidth && element.labelWidth !== confGlobal.labelWidth) { if (element.labelWidth && element.labelWidth !== confGlobal.labelWidth) {
labelWidth = `label-width="${element.labelWidth}px"` labelWidth = `label-width="${element.labelWidth}px"`
@ -92,7 +92,7 @@ const layouts = {
str = colWrapper(element, str) str = colWrapper(element, str)
return str return str
}, },
rowFormItem(element) { rowFormItem (element) {
const type = element.type === 'default' ? '' : `type="${element.type}"` const type = element.type === 'default' ? '' : `type="${element.type}"`
const justify = element.type === 'default' ? '' : `justify="${element.justify}"` const justify = element.type === 'default' ? '' : `justify="${element.justify}"`
const align = element.type === 'default' ? '' : `align="${element.align}"` const align = element.type === 'default' ? '' : `align="${element.align}"`
@ -109,7 +109,7 @@ const layouts = {
const tags = { const tags = {
'el-button': el => { 'el-button': el => {
const { const {
tag, disabled disabled
} = attrBuilder(el) } = attrBuilder(el)
const type = el.type ? `type="${el.type}"` : '' const type = el.type ? `type="${el.type}"` : ''
const icon = el.icon ? `icon="${el.icon}"` : '' const icon = el.icon ? `icon="${el.icon}"` : ''
@ -241,7 +241,6 @@ const tags = {
}, },
'el-rate': el => { 'el-rate': el => {
const { disabled, vModel } = attrBuilder(el) const { disabled, vModel } = attrBuilder(el)
const max = el.max ? `:max='${el.max}'` : ''
const allowHalf = el['allow-half'] ? 'allow-half' : '' const allowHalf = el['allow-half'] ? 'allow-half' : ''
const showText = el['show-text'] ? 'show-text' : '' const showText = el['show-text'] ? 'show-text' : ''
const showScore = el['show-score'] ? 'show-score' : '' const showScore = el['show-score'] ? 'show-score' : ''
@ -274,7 +273,7 @@ const tags = {
} }
} }
function attrBuilder(el) { function attrBuilder (el) {
return { return {
vModel: `v-model="${confGlobal.formModel}.${el.vModel}"`, vModel: `v-model="${confGlobal.formModel}.${el.vModel}"`,
clearable: el.clearable ? 'clearable' : '', clearable: el.clearable ? 'clearable' : '',
@ -285,7 +284,7 @@ function attrBuilder(el) {
} }
// el-buttin 子级 // el-buttin 子级
function buildElButtonChild(conf) { function buildElButtonChild (conf) {
const children = [] const children = []
if (conf.default) { if (conf.default) {
children.push(conf.default) children.push(conf.default)
@ -294,7 +293,7 @@ function buildElButtonChild(conf) {
} }
// el-input innerHTML // el-input innerHTML
function buildElInputChild(conf) { function buildElInputChild (conf) {
const children = [] const children = []
if (conf.prepend) { if (conf.prepend) {
children.push(`<template slot="prepend">${conf.prepend}</template>`) children.push(`<template slot="prepend">${conf.prepend}</template>`)
@ -305,7 +304,7 @@ function buildElInputChild(conf) {
return children.join('\n') return children.join('\n')
} }
function buildElSelectChild(conf) { function buildElSelectChild (conf) {
const children = [] const children = []
if (conf.options && conf.options.length) { if (conf.options && conf.options.length) {
children.push(`<el-option v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>`) children.push(`<el-option v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>`)
@ -313,7 +312,7 @@ function buildElSelectChild(conf) {
return children.join('\n') return children.join('\n')
} }
function buildElRadioGroupChild(conf) { function buildElRadioGroupChild (conf) {
const children = [] const children = []
if (conf.options && conf.options.length) { if (conf.options && conf.options.length) {
const tag = conf.optionType === 'button' ? 'el-radio-button' : 'el-radio' const tag = conf.optionType === 'button' ? 'el-radio-button' : 'el-radio'
@ -323,7 +322,7 @@ function buildElRadioGroupChild(conf) {
return children.join('\n') return children.join('\n')
} }
function buildElCheckboxGroupChild(conf) { function buildElCheckboxGroupChild (conf) {
const children = [] const children = []
if (conf.options && conf.options.length) { if (conf.options && conf.options.length) {
const tag = conf.optionType === 'button' ? 'el-checkbox-button' : 'el-checkbox' const tag = conf.optionType === 'button' ? 'el-checkbox-button' : 'el-checkbox'
@ -333,7 +332,7 @@ function buildElCheckboxGroupChild(conf) {
return children.join('\n') return children.join('\n')
} }
function buildElUploadChild(conf) { function buildElUploadChild (conf) {
const list = [] const list = []
if (conf['list-type'] === 'picture-card') list.push('<i class="el-icon-plus"></i>') if (conf['list-type'] === 'picture-card') list.push('<i class="el-icon-plus"></i>')
else list.push(`<el-button size="small" type="primary" icon="el-icon-upload">${conf.buttonText}</el-button>`) else list.push(`<el-button size="small" type="primary" icon="el-icon-upload">${conf.buttonText}</el-button>`)
@ -341,7 +340,7 @@ function buildElUploadChild(conf) {
return list.join('\n') return list.join('\n')
} }
export function makeUpHtml(conf, type) { export function makeUpHtml (conf, type) {
const htmlList = [] const htmlList = []
confGlobal = conf confGlobal = conf
someSpanIsNot24 = conf.fields.some(item => item.span !== 24) someSpanIsNot24 = conf.fields.some(item => item.span !== 24)

View File

@ -1,4 +1,3 @@
import { isArray } from 'util'
import { exportDefault, titleCase } from '@/utils/index' import { exportDefault, titleCase } from '@/utils/index'
import { trigger } from './config' import { trigger } from './config'
@ -13,8 +12,7 @@ const inheritAttrs = {
dialog: 'inheritAttrs: false,' dialog: 'inheritAttrs: false,'
} }
export function makeUpJs (conf, type) {
export function makeUpJs(conf, type) {
confGlobal = conf = JSON.parse(JSON.stringify(conf)) confGlobal = conf = JSON.parse(JSON.stringify(conf))
const dataList = [] const dataList = []
const ruleList = [] const ruleList = []
@ -41,7 +39,7 @@ export function makeUpJs(conf, type) {
return script return script
} }
function buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList) { function buildAttributes (el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList) {
buildData(el, dataList) buildData(el, dataList)
buildRules(el, ruleList) buildRules(el, ruleList)
@ -76,10 +74,11 @@ function buildAttributes(el, dataList, ruleList, optionsList, methodList, propsL
} }
} }
function mixinMethod(type) { function mixinMethod (type) {
const list = []; const const list = []
minxins = { const minxins = {
file: confGlobal.formBtns ? { file: confGlobal.formBtns
? ({
submitForm: `submitForm() { submitForm: `submitForm() {
this.$refs['${confGlobal.formRef}'].validate(valid => { this.$refs['${confGlobal.formRef}'].validate(valid => {
if(!valid) return if(!valid) return
@ -89,7 +88,8 @@ function mixinMethod(type) {
resetForm: `resetForm() { resetForm: `resetForm() {
this.$refs['${confGlobal.formRef}'].resetFields() this.$refs['${confGlobal.formRef}'].resetFields()
},` },`
} : null, })
: null,
dialog: { dialog: {
onOpen: 'onOpen() {},', onOpen: 'onOpen() {},',
onClose: `onClose() { onClose: `onClose() {
@ -117,7 +117,7 @@ function mixinMethod(type) {
return list return list
} }
function buildData(conf, dataList) { function buildData (conf, dataList) {
if (conf.vModel === undefined) return if (conf.vModel === undefined) return
let defaultValue let defaultValue
if (typeof (conf.defaultValue) === 'string' && !conf.multiple) { if (typeof (conf.defaultValue) === 'string' && !conf.multiple) {
@ -128,19 +128,20 @@ function buildData(conf, dataList) {
dataList.push(`${conf.vModel}: ${defaultValue},`) dataList.push(`${conf.vModel}: ${defaultValue},`)
} }
function buildRules(conf, ruleList) { function buildRules (conf, ruleList) {
if (conf.vModel === undefined) return if (conf.vModel === undefined) return
const rules = [] const rules = []
if (trigger[conf.tag]) { if (trigger[conf.tag]) {
if (conf.required) { if (conf.required) {
const type = isArray(conf.defaultValue) ? 'type: \'array\',' : '' const type = Array.isArray(conf.defaultValue) ? 'type: \'array\',' : ''
let message = isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder let message = Array.isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder
if (message === undefined) message = `${conf.label}不能为空` if (message === undefined) message = `${conf.label}不能为空`
rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`) rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`)
} }
if (conf.regList && isArray(conf.regList)) { if (conf.regList && Array.isArray(conf.regList)) {
conf.regList.forEach(item => { conf.regList.forEach(item => {
if (item.pattern) { if (item.pattern) {
// eslint-disable-next-line no-eval
rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`) rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`)
} }
}) })
@ -149,14 +150,16 @@ function buildRules(conf, ruleList) {
} }
} }
function buildOptions(conf, optionsList) { function buildOptions (conf, optionsList) {
if (conf.vModel === undefined) return if (conf.vModel === undefined) return
if (conf.dataType === 'dynamic') { conf.options = [] } if (conf.dataType === 'dynamic') {
conf.options = []
}
const str = `${conf.vModel}Options: ${JSON.stringify(conf.options)},` const str = `${conf.vModel}Options: ${JSON.stringify(conf.options)},`
optionsList.push(str) optionsList.push(str)
} }
function buildProps(conf, propsList) { function buildProps (conf, propsList) {
if (conf.dataType === 'dynamic') { if (conf.dataType === 'dynamic') {
conf.valueKey !== 'value' && (conf.props.props.value = conf.valueKey) conf.valueKey !== 'value' && (conf.props.props.value = conf.valueKey)
conf.labelKey !== 'label' && (conf.props.props.label = conf.labelKey) conf.labelKey !== 'label' && (conf.props.props.label = conf.labelKey)
@ -166,9 +169,11 @@ function buildProps(conf, propsList) {
propsList.push(str) propsList.push(str)
} }
function buildBeforeUpload(conf) { function buildBeforeUpload (conf) {
const unitNum = units[conf.sizeUnit]; let rightSizeCode = ''; let acceptCode = ''; const const unitNum = units[conf.sizeUnit]
returnList = [] let rightSizeCode = ''
let acceptCode = ''
const returnList = []
if (conf.fileSize) { if (conf.fileSize) {
rightSizeCode = `let isRightSize = file.size / ${unitNum} < ${conf.fileSize} rightSizeCode = `let isRightSize = file.size / ${unitNum} < ${conf.fileSize}
if(!isRightSize){ if(!isRightSize){
@ -191,14 +196,14 @@ function buildBeforeUpload(conf) {
return returnList.length ? str : '' return returnList.length ? str : ''
} }
function buildSubmitUpload(conf) { function buildSubmitUpload (conf) {
const str = `submitUpload() { const str = `submitUpload() {
this.$refs['${conf.vModel}'].submit() this.$refs['${conf.vModel}'].submit()
},` },`
return str return str
} }
function buildOptionMethod(methodName, model, methodList) { function buildOptionMethod (methodName, model, methodList) {
const str = `${methodName}() { const str = `${methodName}() {
// TODO 发起请求获取数据 // TODO 发起请求获取数据
this.${model} this.${model}
@ -206,7 +211,7 @@ function buildOptionMethod(methodName, model, methodList) {
methodList.push(str) methodList.push(str)
} }
function buildexport(conf, type, data, rules, selectOptions, uploadVar, props, methods) { function buildexport (conf, type, data, rules, selectOptions, uploadVar, props, methods) {
const str = `${exportDefault}{ const str = `${exportDefault}{
${inheritAttrs[type]} ${inheritAttrs[type]}
components: {}, components: {},

View File

@ -2,22 +2,22 @@ import { makeMap } from '@/utils/index'
// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js // 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js
const isAttr = makeMap( const isAttr = makeMap(
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
+ 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
+ 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
+ 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
+ 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
+ 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
+ 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
+ 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
+ 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
+ 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
+ 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
+ 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
+ 'target,title,type,usemap,value,width,wrap' 'target,title,type,usemap,value,width,wrap'
) )
function vModel(self, dataObject, defaultValue) { function vModel (self, dataObject, defaultValue) {
dataObject.props.value = defaultValue dataObject.props.value = defaultValue
dataObject.on.input = val => { dataObject.on.input = val => {
@ -27,20 +27,20 @@ function vModel(self, dataObject, defaultValue) {
const componentChild = { const componentChild = {
'el-button': { 'el-button': {
default(h, conf, key) { default (h, conf, key) {
return conf[key] return conf[key]
}, }
}, },
'el-input': { 'el-input': {
prepend(h, conf, key) { prepend (h, conf, key) {
return <template slot="prepend">{conf[key]}</template> return <template slot="prepend">{conf[key]}</template>
}, },
append(h, conf, key) { append (h, conf, key) {
return <template slot="append">{conf[key]}</template> return <template slot="append">{conf[key]}</template>
} }
}, },
'el-select': { 'el-select': {
options(h, conf, key) { options (h, conf, key) {
const list = [] const list = []
conf.options.forEach(item => { conf.options.forEach(item => {
list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>) list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>)
@ -49,7 +49,7 @@ const componentChild = {
} }
}, },
'el-radio-group': { 'el-radio-group': {
options(h, conf, key) { options (h, conf, key) {
const list = [] const list = []
conf.options.forEach(item => { conf.options.forEach(item => {
if (conf.optionType === 'button') list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>) if (conf.optionType === 'button') list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>)
@ -59,7 +59,7 @@ const componentChild = {
} }
}, },
'el-checkbox-group': { 'el-checkbox-group': {
options(h, conf, key) { options (h, conf, key) {
const list = [] const list = []
conf.options.forEach(item => { conf.options.forEach(item => {
if (conf.optionType === 'button') { if (conf.optionType === 'button') {
@ -88,7 +88,7 @@ const componentChild = {
} }
export default { export default {
render(h) { render (h) {
const dataObject = { const dataObject = {
attrs: {}, attrs: {},
props: {}, props: {},

View File

@ -3,15 +3,15 @@ import { parseTime } from './ruoyi'
/** /**
* 表格时间格式化 * 表格时间格式化
*/ */
export function formatDate(cellValue) { export function formatDate (cellValue) {
if (cellValue == null || cellValue == "") return ""; if (cellValue === null || cellValue === '') return ''
var date = new Date(cellValue) const date = new Date(cellValue)
var year = date.getFullYear() const year = date.getFullYear()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
} }
@ -20,7 +20,7 @@ export function formatDate(cellValue) {
* @param {string} option * @param {string} option
* @returns {string} * @returns {string}
*/ */
export function formatTime(time, option) { export function formatTime (time, option) {
if (('' + time).length === 10) { if (('' + time).length === 10) {
time = parseInt(time) * 1000 time = parseInt(time) * 1000
} else { } else {
@ -62,8 +62,8 @@ export function formatTime(time, option) {
* @param {string} url * @param {string} url
* @returns {Object} * @returns {Object}
*/ */
export function getQueryObject(url) { export function getQueryObject (url) {
url = url == null ? window.location.href : url url = url === null ? window.location.href : url
const search = url.substring(url.lastIndexOf('?') + 1) const search = url.substring(url.lastIndexOf('?') + 1)
const obj = {} const obj = {}
const reg = /([^?&=]+)=([^?&=]*)/g const reg = /([^?&=]+)=([^?&=]*)/g
@ -81,10 +81,10 @@ export function getQueryObject(url) {
* @param {string} input value * @param {string} input value
* @returns {number} output value * @returns {number} output value
*/ */
export function byteLength(str) { export function byteLength (str) {
// returns the byte length of an utf8 string // returns the byte length of an utf8 string
let s = str.length let s = str.length
for (var i = str.length - 1; i >= 0; i--) { for (let i = str.length - 1; i >= 0; i--) {
const code = str.charCodeAt(i) const code = str.charCodeAt(i)
if (code > 0x7f && code <= 0x7ff) s++ if (code > 0x7f && code <= 0x7ff) s++
else if (code > 0x7ff && code <= 0xffff) s += 2 else if (code > 0x7ff && code <= 0xffff) s += 2
@ -97,7 +97,7 @@ export function byteLength(str) {
* @param {Array} actual * @param {Array} actual
* @returns {Array} * @returns {Array}
*/ */
export function cleanArray(actual) { export function cleanArray (actual) {
const newArray = [] const newArray = []
for (let i = 0; i < actual.length; i++) { for (let i = 0; i < actual.length; i++) {
if (actual[i]) { if (actual[i]) {
@ -111,7 +111,7 @@ export function cleanArray(actual) {
* @param {Object} json * @param {Object} json
* @returns {Array} * @returns {Array}
*/ */
export function param(json) { export function param (json) {
if (!json) return '' if (!json) return ''
return cleanArray( return cleanArray(
Object.keys(json).map(key => { Object.keys(json).map(key => {
@ -125,7 +125,7 @@ export function param(json) {
* @param {string} url * @param {string} url
* @returns {Object} * @returns {Object}
*/ */
export function param2Obj(url) { export function param2Obj (url) {
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ') const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
if (!search) { if (!search) {
return {} return {}
@ -147,7 +147,7 @@ export function param2Obj(url) {
* @param {string} val * @param {string} val
* @returns {string} * @returns {string}
*/ */
export function html2Text(val) { export function html2Text (val) {
const div = document.createElement('div') const div = document.createElement('div')
div.innerHTML = val div.innerHTML = val
return div.textContent || div.innerText return div.textContent || div.innerText
@ -159,7 +159,7 @@ export function html2Text(val) {
* @param {(Object|Array)} source * @param {(Object|Array)} source
* @returns {Object} * @returns {Object}
*/ */
export function objectMerge(target, source) { export function objectMerge (target, source) {
if (typeof target !== 'object') { if (typeof target !== 'object') {
target = {} target = {}
} }
@ -181,7 +181,7 @@ export function objectMerge(target, source) {
* @param {HTMLElement} element * @param {HTMLElement} element
* @param {string} className * @param {string} className
*/ */
export function toggleClass(element, className) { export function toggleClass (element, className) {
if (!element || !className) { if (!element || !className) {
return return
} }
@ -201,7 +201,7 @@ export function toggleClass(element, className) {
* @param {string} type * @param {string} type
* @returns {Date} * @returns {Date}
*/ */
export function getTime(type) { export function getTime (type) {
if (type === 'start') { if (type === 'start') {
return new Date().getTime() - 3600 * 1000 * 24 * 90 return new Date().getTime() - 3600 * 1000 * 24 * 90
} else { } else {
@ -215,10 +215,10 @@ export function getTime(type) {
* @param {boolean} immediate * @param {boolean} immediate
* @return {*} * @return {*}
*/ */
export function debounce(func, wait, immediate) { export function debounce (func, wait, immediate) {
let timeout, args, context, timestamp, result let timeout, args, context, timestamp, result
const later = function() { const later = function () {
// 据上一次触发时间间隔 // 据上一次触发时间间隔
const last = +new Date() - timestamp const last = +new Date() - timestamp
@ -235,7 +235,7 @@ export function debounce(func, wait, immediate) {
} }
} }
return function(...args) { return function (...args) {
context = this context = this
timestamp = +new Date() timestamp = +new Date()
const callNow = immediate && !timeout const callNow = immediate && !timeout
@ -257,7 +257,7 @@ export function debounce(func, wait, immediate) {
* @param {Object} source * @param {Object} source
* @returns {Object} * @returns {Object}
*/ */
export function deepClone(source) { export function deepClone (source) {
if (!source && typeof source !== 'object') { if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'deepClone') throw new Error('error arguments', 'deepClone')
} }
@ -276,14 +276,14 @@ export function deepClone(source) {
* @param {Array} arr * @param {Array} arr
* @returns {Array} * @returns {Array}
*/ */
export function uniqueArr(arr) { export function uniqueArr (arr) {
return Array.from(new Set(arr)) return Array.from(new Set(arr))
} }
/** /**
* @returns {string} * @returns {string}
*/ */
export function createUniqueString() { export function createUniqueString () {
const timestamp = +new Date() + '' const timestamp = +new Date() + ''
const randomNum = parseInt((1 + Math.random()) * 65536) + '' const randomNum = parseInt((1 + Math.random()) * 65536) + ''
return (+(randomNum + timestamp)).toString(32) return (+(randomNum + timestamp)).toString(32)
@ -295,7 +295,7 @@ export function createUniqueString() {
* @param {string} cls * @param {string} cls
* @returns {boolean} * @returns {boolean}
*/ */
export function hasClass(ele, cls) { export function hasClass (ele, cls) {
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
} }
@ -304,7 +304,7 @@ export function hasClass(ele, cls) {
* @param {HTMLElement} elm * @param {HTMLElement} elm
* @param {string} cls * @param {string} cls
*/ */
export function addClass(ele, cls) { export function addClass (ele, cls) {
if (!hasClass(ele, cls)) ele.className += ' ' + cls if (!hasClass(ele, cls)) ele.className += ' ' + cls
} }
@ -313,14 +313,14 @@ export function addClass(ele, cls) {
* @param {HTMLElement} elm * @param {HTMLElement} elm
* @param {string} cls * @param {string} cls
*/ */
export function removeClass(ele, cls) { export function removeClass (ele, cls) {
if (hasClass(ele, cls)) { if (hasClass(ele, cls)) {
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)') const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
ele.className = ele.className.replace(reg, ' ') ele.className = ele.className.replace(reg, ' ')
} }
} }
export function makeMap(str, expectsLowerCase) { export function makeMap (str, expectsLowerCase) {
const map = Object.create(null) const map = Object.create(null)
const list = str.split(',') const list = str.split(',')
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
@ -375,16 +375,15 @@ export const beautifierConf = {
} }
// 首字母大小 // 首字母大小
export function titleCase(str) { export function titleCase (str) {
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase()) return str.replace(/( |^)[a-z]/g, L => L.toUpperCase())
} }
// 下划转驼峰 // 下划转驼峰
export function camelCase(str) { export function camelCase (str) {
return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase()) return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase())
} }
export function isNumberStr(str) { export function isNumberStr (str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
} }

View File

@ -15,16 +15,15 @@ const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYour
'UP8iWi1Qw0Y=' 'UP8iWi1Qw0Y='
// 加密 // 加密
export function encrypt(txt) { export function encrypt (txt) {
const encryptor = new JSEncrypt() const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey) // 设置公钥 encryptor.setPublicKey(publicKey) // 设置公钥
return encryptor.encrypt(txt) // 对数据进行加密 return encryptor.encrypt(txt) // 对数据进行加密
} }
// 解密 // 解密
export function decrypt(txt) { export function decrypt (txt) {
const encryptor = new JSEncrypt() const encryptor = new JSEncrypt()
encryptor.setPrivateKey(privateKey) // 设置私钥 encryptor.setPrivateKey(privateKey) // 设置私钥
return encryptor.decrypt(txt) // 对数据进行解密 return encryptor.decrypt(txt) // 对数据进行解密
} }

View File

@ -5,14 +5,14 @@ import store from '@/store'
* @param {Array} value 校验值 * @param {Array} value 校验值
* @returns {Boolean} * @returns {Boolean}
*/ */
export function checkPermi(value) { export function checkPermi (value) {
if (value && value instanceof Array && value.length > 0) { if (value && value instanceof Array && value.length > 0) {
const permissions = store.getters && store.getters.permissions const permissions = store.getters && store.getters.permissions
const permissionDatas = value const permissionDatas = value
const all_permission = "*:*:*"; const allPermission = '*:*:*'
const hasPermission = permissions.some(permission => { const hasPermission = permissions.some(permission => {
return all_permission === permission || permissionDatas.includes(permission) return allPermission === permission || permissionDatas.includes(permission)
}) })
if (!hasPermission) { if (!hasPermission) {
@ -20,7 +20,7 @@ export function checkPermi(value) {
} }
return true return true
} else { } else {
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) console.error('need roles! Like checkPermi="[\'system:user:add\',\'system:user:edit\']"')
return false return false
} }
} }
@ -30,14 +30,14 @@ export function checkPermi(value) {
* @param {Array} value 校验值 * @param {Array} value 校验值
* @returns {Boolean} * @returns {Boolean}
*/ */
export function checkRole(value) { export function checkRole (value) {
if (value && value instanceof Array && value.length > 0) { if (value && value instanceof Array && value.length > 0) {
const roles = store.getters && store.getters.roles const roles = store.getters && store.getters.roles
const permissionRoles = value const permissionRoles = value
const super_admin = "admin"; const superAdmin = 'admin'
const hasRole = roles.some(role => { const hasRole = roles.some(role => {
return super_admin === role || permissionRoles.includes(role) return superAdmin === role || permissionRoles.includes(role)
}) })
if (!hasRole) { if (!hasRole) {
@ -45,7 +45,7 @@ export function checkRole(value) {
} }
return true return true
} else { } else {
console.error(`need roles! Like checkRole="['admin','editor']"`) console.error('need roles! Like checkRole="[\'admin\',\'editor\']"')
return false return false
} }
} }

View File

@ -17,31 +17,31 @@ service.interceptors.request.use(config => {
// 是否需要设置 token // 是否需要设置 token
const isToken = (config.headers || {}).isToken === false const isToken = (config.headers || {}).isToken === false
if (getToken() && !isToken) { if (getToken() && !isToken) {
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers.Authorization = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
} }
// get请求映射params参数 // get请求映射params参数
if (config.method === 'get' && config.params) { if (config.method === 'get' && config.params) {
let url = config.url + '?'; let url = config.url + '?'
for (const propName of Object.keys(config.params)) { for (const propName of Object.keys(config.params)) {
const value = config.params[propName]; const value = config.params[propName]
var part = encodeURIComponent(propName) + "="; const part = encodeURIComponent(propName) + '='
if (value !== null && typeof(value) !== "undefined") { if (value !== null && typeof (value) !== 'undefined') {
if (typeof value === 'object') { if (typeof value === 'object') {
for (const key of Object.keys(value)) { for (const key of Object.keys(value)) {
if (value[key] !== null && typeof (value[key]) !== 'undefined') { if (value[key] !== null && typeof (value[key]) !== 'undefined') {
let params = propName + '[' + key + ']'; const params = propName + '[' + key + ']'
let subPart = encodeURIComponent(params) + '='; const subPart = encodeURIComponent(params) + '='
url += subPart + encodeURIComponent(value[key]) + '&'; url += subPart + encodeURIComponent(value[key]) + '&'
} }
} }
} else { } else {
url += part + encodeURIComponent(value) + "&"; url += part + encodeURIComponent(value) + '&'
} }
} }
} }
url = url.slice(0, -1); url = url.slice(0, -1)
config.params = {}; config.params = {}
config.url = url; config.url = url
} }
return config return config
}, error => { }, error => {
@ -52,9 +52,9 @@ service.interceptors.request.use(config => {
// 响应拦截器 // 响应拦截器
service.interceptors.response.use(res => { service.interceptors.response.use(res => {
// 未设置状态码则默认成功状态 // 未设置状态码则默认成功状态
const code = res.data.code || 200; const code = res.data.code || 200
// 获取错误信息 // 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default'] const msg = errorCode[code] || res.data.msg || errorCode.default
if (code === 401) { if (code === 401) {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录', confirmButtonText: '重新登录',
@ -63,10 +63,10 @@ service.interceptors.response.use(res => {
} }
).then(() => { ).then(() => {
store.dispatch('LogOut').then(() => { store.dispatch('LogOut').then(() => {
location.href = '/index'; location.href = '/index'
}) })
}).catch(() => {}); }).catch(() => {})
return Promise.reject('令牌验证失败') return Promise.reject(new Error('令牌验证失败'))
} else if (code === 500) { } else if (code === 500) {
Message({ Message({
message: msg, message: msg,
@ -77,22 +77,20 @@ service.interceptors.response.use(res => {
Notification.error({ Notification.error({
title: msg title: msg
}) })
return Promise.reject('error') return Promise.reject(new Error('error'))
} else { } else {
return res.data return res.data
} }
}, },
error => { error => {
console.log('err' + error) console.log('err' + error)
let { message } = error; let { message } = error
if (message == "Network Error") { if (message === 'Network Error') {
message = "后端接口连接异常"; message = '后端接口连接异常'
} } else if (message.includes('timeout')) {
else if (message.includes("timeout")) { message = '系统接口请求超时'
message = "系统接口请求超时"; } else if (message.includes('Request failed with status code')) {
} message = '系统接口' + message.substr(message.length - 3) + '异常'
else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
} }
Message({ Message({
message: message, message: message,
@ -100,7 +98,7 @@ service.interceptors.response.use(res => {
duration: 5 * 1000 duration: 5 * 1000
}) })
return Promise.reject(error) return Promise.reject(error)
} }
) )
export default service export default service

View File

@ -1,4 +1,4 @@
/** /**
* 通用js方法封装处理 * 通用js方法封装处理
* Copyright (c) 2019 ruoyi * Copyright (c) 2019 ruoyi
*/ */
@ -6,7 +6,7 @@
const baseURL = process.env.VUE_APP_BASE_API const baseURL = process.env.VUE_APP_BASE_API
// 日期格式化 // 日期格式化
export function parseTime(time, pattern) { export function parseTime (time, pattern) {
if (arguments.length === 0 || !time) { if (arguments.length === 0 || !time) {
return null return null
} }
@ -18,7 +18,7 @@ export function parseTime(time, pattern) {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time) time = parseInt(time)
} else if (typeof time === 'string') { } else if (typeof time === 'string') {
time = time.replace(new RegExp(/-/gm), '/'); time = time.replace(/-/gm, '/')
} }
if ((typeof time === 'number') && (time.toString().length === 10)) { if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000 time = time * 1000
@ -34,7 +34,7 @@ export function parseTime(time, pattern) {
s: date.getSeconds(), s: date.getSeconds(),
a: date.getDay() a: date.getDay()
} }
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { const timeStr = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key] let value = formatObj[key]
// Note: getDay() returns 0 on Sunday // Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
@ -43,83 +43,86 @@ export function parseTime(time, pattern) {
} }
return value || 0 return value || 0
}) })
return time_str return timeStr
} }
// 表单重置 // 表单重置
export function resetForm(refName) { export function resetForm (refName) {
if (this.$refs[refName]) { if (this.$refs[refName]) {
this.$refs[refName].resetFields(); this.$refs[refName].resetFields()
} }
} }
// 添加日期范围 // 添加日期范围
export function addDateRange(params, dateRange, propName) { export function addDateRange (params, dateRange, propName) {
let search = params; const search = params
search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}
dateRange = Array.isArray(dateRange) ? dateRange : []; dateRange = Array.isArray(dateRange) ? dateRange : []
if (typeof (propName) === 'undefined') { if (typeof (propName) === 'undefined') {
search.params['beginTime'] = dateRange[0]; search.params.beginTime = dateRange[0]
search.params['endTime'] = dateRange[1]; search.params.endTime = dateRange[1]
} else { } else {
search.params['begin' + propName] = dateRange[0]; search.params['begin' + propName] = dateRange[0]
search.params['end' + propName] = dateRange[1]; search.params['end' + propName] = dateRange[1]
} }
return search; return search
} }
// 回显数据字典 // 回显数据字典
export function selectDictLabel(datas, value) { export function selectDictLabel (datas, value) {
var actions = []; const actions = []
Object.keys(datas).some((key) => { Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + value)) { if (datas[key].dictValue === ('' + value)) {
actions.push(datas[key].dictLabel); actions.push(datas[key].dictLabel)
return true; return true
} }
return undefined
}) })
return actions.join(''); return actions.join('')
} }
// 回显数据字典(字符串数组) // 回显数据字典(字符串数组)
export function selectDictLabels(datas, value, separator) { export function selectDictLabels (datas, value, separator) {
var actions = []; const actions = []
var currentSeparator = undefined === separator ? "," : separator; const currentSeparator = undefined === separator ? ',' : separator
var temp = value.split(currentSeparator); const temp = value.split(currentSeparator)
Object.keys(value.split(currentSeparator)).some((val) => { Object.keys(value.split(currentSeparator)).some((val) => {
Object.keys(datas).some((key) => { Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + temp[val])) { if (datas[key].dictValue === ('' + temp[val])) {
actions.push(datas[key].dictLabel + currentSeparator); actions.push(datas[key].dictLabel + currentSeparator)
} }
return undefined
}) })
return undefined
}) })
return actions.join('').substring(0, actions.join('').length - 1); return actions.join('').substring(0, actions.join('').length - 1)
} }
// 通用下载方法 // 通用下载方法
export function download(fileName) { export function download (fileName) {
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; window.location.href = baseURL + '/common/download?fileName=' + encodeURI(fileName) + '&delete=' + true
} }
// 字符串格式化(%s ) // 字符串格式化(%s )
export function sprintf(str) { export function sprintf (str) {
var args = arguments, flag = true, i = 1; const args = arguments; let flag = true; let i = 1
str = str.replace(/%s/g, function () { str = str.replace(/%s/g, function () {
var arg = args[i++]; const arg = args[i++]
if (typeof arg === 'undefined') { if (typeof arg === 'undefined') {
flag = false; flag = false
return ''; return ''
} }
return arg; return arg
}); })
return flag ? str : ''; return flag ? str : ''
} }
// 转换字符串undefined,null等转化为"" // 转换字符串undefined,null等转化为""
export function praseStrEmpty(str) { export function praseStrEmpty (str) {
if (!str || str == "undefined" || str == "null") { if (!str || str === 'undefined' || str === 'null') {
return ""; return ''
} }
return str; return str
} }
/** /**
@ -129,46 +132,46 @@ export function praseStrEmpty(str) {
* @param {*} parentId 父节点字段 默认 'parentId' * @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children' * @param {*} children 孩子节点字段 默认 'children'
*/ */
export function handleTree(data, id, parentId, children) { export function handleTree (data, id, parentId, children) {
let config = { const config = {
id: id || 'id', id: id || 'id',
parentId: parentId || 'parentId', parentId: parentId || 'parentId',
childrenList: children || 'children' childrenList: children || 'children'
};
var childrenListMap = {};
var nodeIds = {};
var tree = [];
for (let d of data) {
let parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = [];
}
nodeIds[d[config.id]] = d;
childrenListMap[parentId].push(d);
} }
for (let d of data) { const childrenListMap = {}
let parentId = d[config.parentId]; const nodeIds = {}
if (nodeIds[parentId] == null) { const tree = []
tree.push(d);
for (const d of data) {
const parentId = d[config.parentId]
if (childrenListMap[parentId] === null) {
childrenListMap[parentId] = []
}
nodeIds[d[config.id]] = d
childrenListMap[parentId].push(d)
}
for (const d of data) {
const parentId = d[config.parentId]
if (nodeIds[parentId] === null) {
tree.push(d)
} }
} }
for (let t of tree) { for (const t of tree) {
adaptToChildrenList(t); adaptToChildrenList(t)
} }
function adaptToChildrenList(o) { function adaptToChildrenList (o) {
if (childrenListMap[o[config.id]] !== null) { if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]]; o[config.childrenList] = childrenListMap[o[config.id]]
} }
if (o[config.childrenList]) { if (o[config.childrenList]) {
for (let c of o[config.childrenList]) { for (const c of o[config.childrenList]) {
adaptToChildrenList(c); adaptToChildrenList(c)
} }
} }
} }
return tree; return tree
} }

View File

@ -1,4 +1,4 @@
Math.easeInOutQuad = function(t, b, c, d) { Math.easeInOutQuad = function (t, b, c, d) {
t /= d / 2 t /= d / 2
if (t < 1) { if (t < 1) {
return c / 2 * t * t + b return c / 2 * t * t + b
@ -8,21 +8,21 @@ Math.easeInOutQuad = function(t, b, c, d) {
} }
// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts // requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
var requestAnimFrame = (function() { const requestAnimFrame = (function () {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60) }
})() })()
/** /**
* Because it's so fucking difficult to detect the scrolling element, just move them all * Because it's so fucking difficult to detect the scrolling element, just move them all
* @param {number} amount * @param {number} amount
*/ */
function move(amount) { function move (amount) {
document.documentElement.scrollTop = amount document.documentElement.scrollTop = amount
document.body.parentNode.scrollTop = amount document.body.parentNode.scrollTop = amount
document.body.scrollTop = amount document.body.scrollTop = amount
} }
function position() { function position () {
return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop
} }
@ -31,17 +31,17 @@ function position() {
* @param {number} duration * @param {number} duration
* @param {Function} callback * @param {Function} callback
*/ */
export function scrollTo(to, duration, callback) { export function scrollTo (to, duration, callback) {
const start = position() const start = position()
const change = to - start const change = to - start
const increment = 20 const increment = 20
let currentTime = 0 let currentTime = 0
duration = (typeof (duration) === 'undefined') ? 500 : duration duration = (typeof (duration) === 'undefined') ? 500 : duration
var animateScroll = function() { const animateScroll = function () {
// increment the time // increment the time
currentTime += increment currentTime += increment
// find the value with the quadratic in-out easing function // find the value with the quadratic in-out easing function
var val = Math.easeInOutQuad(currentTime, start, change, duration) const val = Math.easeInOutQuad(currentTime, start, change, duration)
// move the document.body // move the document.body
move(val) move(val)
// do the animation unless its over // do the animation unless its over

View File

@ -2,7 +2,7 @@
* @param {string} path * @param {string} path
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isExternal(path) { export function isExternal (path) {
return /^(https?:|mailto:|tel:)/.test(path) return /^(https?:|mailto:|tel:)/.test(path)
} }
@ -10,16 +10,16 @@ export function isExternal(path) {
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validUsername(str) { export function validUsername (str) {
const valid_map = ['admin', 'editor'] const validMap = ['admin', 'editor']
return valid_map.indexOf(str.trim()) >= 0 return validMap.indexOf(str.trim()) >= 0
} }
/** /**
* @param {string} url * @param {string} url
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validURL(url) { export function validURL (url) {
const reg = /^(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.,?'\\+&%$#=~_-]+))*$/ const reg = /^(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 reg.test(url) return reg.test(url)
} }
@ -28,7 +28,7 @@ export function validURL(url) {
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validLowerCase(str) { export function validLowerCase (str) {
const reg = /^[a-z]+$/ const reg = /^[a-z]+$/
return reg.test(str) return reg.test(str)
} }
@ -37,7 +37,7 @@ export function validLowerCase(str) {
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validUpperCase(str) { export function validUpperCase (str) {
const reg = /^[A-Z]+$/ const reg = /^[A-Z]+$/
return reg.test(str) return reg.test(str)
} }
@ -46,7 +46,7 @@ export function validUpperCase(str) {
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validAlphabets(str) { export function validAlphabets (str) {
const reg = /^[A-Za-z]+$/ const reg = /^[A-Za-z]+$/
return reg.test(str) return reg.test(str)
} }
@ -55,8 +55,8 @@ export function validAlphabets(str) {
* @param {string} email * @param {string} email
* @returns {Boolean} * @returns {Boolean}
*/ */
export function validEmail(email) { export function validEmail (email) {
const reg = /^(([^<>()\[\]\\.,;:\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,}))$/ const reg = /^(([^<>()[\]\\.,;:\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 reg.test(email) return reg.test(email)
} }
@ -64,7 +64,7 @@ export function validEmail(email) {
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isString(str) { export function isString (str) {
if (typeof str === 'string' || str instanceof String) { if (typeof str === 'string' || str instanceof String) {
return true return true
} }
@ -75,7 +75,7 @@ export function isString(str) {
* @param {Array} arg * @param {Array} arg
* @returns {Boolean} * @returns {Boolean}
*/ */
export function isArray(arg) { export function isArray (arg) {
if (typeof Array.isArray === 'undefined') { if (typeof Array.isArray === 'undefined') {
return Object.prototype.toString.call(arg) === '[object Array]' return Object.prototype.toString.call(arg) === '[object Array]'
} }

View File

@ -7,13 +7,13 @@ const mimeMap = {
} }
const baseUrl = process.env.VUE_APP_BASE_API const baseUrl = process.env.VUE_APP_BASE_API
export function downLoadZip(str, filename) { export function downLoadZip (str, filename) {
var url = baseUrl + str const url = baseUrl + str
axios({ axios({
method: 'get', method: 'get',
url: url, url: url,
responseType: 'blob', responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() } headers: { Authorization: 'Bearer ' + getToken() }
}).then(res => { }).then(res => {
resolveBlob(res, mimeMap.zip) resolveBlob(res, mimeMap.zip)
}) })
@ -23,20 +23,20 @@ export function downLoadZip(str, filename) {
* @param {*} res blob响应内容 * @param {*} res blob响应内容
* @param {String} mimeType MIME类型 * @param {String} mimeType MIME类型
*/ */
export function resolveBlob(res, mimeType) { export function resolveBlob (res, mimeType) {
const aLink = document.createElement('a') const aLink = document.createElement('a')
var blob = new Blob([res.data], { type: mimeType }) const blob = new Blob([res.data], { type: mimeType })
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名; // //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*') const patt = /filename=([^;]+\\.[^\\.;]+);*/
var contentDisposition = decodeURI(res.headers['content-disposition']) const contentDisposition = decodeURI(res.headers['content-disposition'])
var result = patt.exec(contentDisposition) const result = patt.exec(contentDisposition)
var fileName = result[1] let fileName = result[1]
fileName = fileName.replace(/\"/g, '') fileName = fileName.replace(/"/g, '')
aLink.style.display = 'none' aLink.style.display = 'none'
aLink.href = URL.createObjectURL(blob) aLink.href = URL.createObjectURL(blob)
aLink.setAttribute('download', fileName) // 设置下载文件名称 aLink.setAttribute('download', fileName) // 设置下载文件名称
document.body.appendChild(aLink) document.body.appendChild(aLink)
aLink.click() aLink.click()
URL.revokeObjectURL(aLink.href);//清除引用 URL.revokeObjectURL(aLink.href)// 清除引用
document.body.removeChild(aLink); document.body.removeChild(aLink)
} }

View File

@ -41,17 +41,17 @@ import elementIcons from './element-icons'
export default { export default {
name: 'Icons', name: 'Icons',
data() { data () {
return { return {
svgIcons, svgIcons,
elementIcons elementIcons
} }
}, },
methods: { methods: {
generateIconCode(symbol) { generateIconCode (symbol) {
return `<svg-icon icon-class="${symbol}" />` return `<svg-icon icon-class="${symbol}" />`
}, },
generateElementIconCode(symbol) { generateElementIconCode (symbol) {
return `<i class="el-icon-${symbol}" />` return `<i class="el-icon-${symbol}" />`
} }
} }

View File

@ -3,9 +3,9 @@
</template> </template>
<script> <script>
import echarts from 'echarts' import echarts from 'echarts' // echarts theme
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize' import resize from './mixins/resize'
require('echarts/theme/macarons')
const animationDuration = 6000 const animationDuration = 6000
@ -25,17 +25,17 @@ export default {
default: '300px' default: '300px'
} }
}, },
data() { data () {
return { return {
chart: null chart: null
} }
}, },
mounted() { mounted () {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
}, },
beforeDestroy() { beforeDestroy () {
if (!this.chart) { if (!this.chart) {
return return
} }
@ -43,7 +43,7 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
initChart() { initChart () {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({ this.chart.setOption({

View File

@ -3,9 +3,9 @@
</template> </template>
<script> <script>
import echarts from 'echarts' import echarts from 'echarts' // echarts theme
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize' import resize from './mixins/resize'
require('echarts/theme/macarons')
export default { export default {
mixins: [resize], mixins: [resize],
@ -31,7 +31,7 @@ export default {
required: true required: true
} }
}, },
data() { data () {
return { return {
chart: null chart: null
} }
@ -39,17 +39,17 @@ export default {
watch: { watch: {
chartData: { chartData: {
deep: true, deep: true,
handler(val) { handler (val) {
this.setOptions(val) this.setOptions(val)
} }
} }
}, },
mounted() { mounted () {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
}, },
beforeDestroy() { beforeDestroy () {
if (!this.chart) { if (!this.chart) {
return return
} }
@ -57,11 +57,11 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
initChart() { initChart () {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
this.setOptions(this.chartData) this.setOptions(this.chartData)
}, },
setOptions({ expectedData, actualData } = {}) { setOptions ({ expectedData, actualData } = {}) {
this.chart.setOption({ this.chart.setOption({
xAxis: { xAxis: {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
@ -93,7 +93,8 @@ export default {
data: ['expected', 'actual'] data: ['expected', 'actual']
}, },
series: [{ series: [{
name: 'expected', itemStyle: { name: 'expected',
itemStyle: {
normal: { normal: {
color: '#FF005A', color: '#FF005A',
lineStyle: { lineStyle: {

View File

@ -63,7 +63,7 @@ export default {
CountTo CountTo
}, },
methods: { methods: {
handleSetLineChartData(type) { handleSetLineChartData (type) {
this.$emit('handleSetLineChartData', type) this.$emit('handleSetLineChartData', type)
} }
} }

View File

@ -3,9 +3,9 @@
</template> </template>
<script> <script>
import echarts from 'echarts' import echarts from 'echarts' // echarts theme
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize' import resize from './mixins/resize'
require('echarts/theme/macarons')
export default { export default {
mixins: [resize], mixins: [resize],
@ -23,17 +23,17 @@ export default {
default: '300px' default: '300px'
} }
}, },
data() { data () {
return { return {
chart: null chart: null
} }
}, },
mounted() { mounted () {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
}, },
beforeDestroy() { beforeDestroy () {
if (!this.chart) { if (!this.chart) {
return return
} }
@ -41,7 +41,7 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
initChart() { initChart () {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({ this.chart.setOption({

View File

@ -3,9 +3,9 @@
</template> </template>
<script> <script>
import echarts from 'echarts' import echarts from 'echarts' // echarts theme
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize' import resize from './mixins/resize'
require('echarts/theme/macarons')
const animationDuration = 3000 const animationDuration = 3000
@ -25,17 +25,17 @@ export default {
default: '300px' default: '300px'
} }
}, },
data() { data () {
return { return {
chart: null chart: null
} }
}, },
mounted() { mounted () {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart() this.initChart()
}) })
}, },
beforeDestroy() { beforeDestroy () {
if (!this.chart) { if (!this.chart) {
return return
} }
@ -43,7 +43,7 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
initChart() { initChart () {
this.chart = echarts.init(this.$el, 'macarons') this.chart = echarts.init(this.$el, 'macarons')
this.chart.setOption({ this.chart.setOption({

View File

@ -1,16 +1,16 @@
import { debounce } from '@/utils' import { debounce } from '@/utils'
export default { export default {
data() { data () {
return { return {
$_sidebarElm: null, $_sidebarElm: null,
$_resizeHandler: null $_resizeHandler: null
} }
}, },
mounted() { mounted () {
this.initListener() this.initListener()
}, },
activated() { activated () {
if (!this.$_resizeHandler) { if (!this.$_resizeHandler) {
// avoid duplication init // avoid duplication init
this.initListener() this.initListener()
@ -19,21 +19,21 @@ export default {
// when keep-alive chart activated, auto resize // when keep-alive chart activated, auto resize
this.resize() this.resize()
}, },
beforeDestroy() { beforeDestroy () {
this.destroyListener() this.destroyListener()
}, },
deactivated() { deactivated () {
this.destroyListener() this.destroyListener()
}, },
methods: { methods: {
// use $_ for mixins properties // use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_sidebarResizeHandler(e) { $_sidebarResizeHandler (e) {
if (e.propertyName === 'width') { if (e.propertyName === 'width') {
this.$_resizeHandler() this.$_resizeHandler()
} }
}, },
initListener() { initListener () {
this.$_resizeHandler = debounce(() => { this.$_resizeHandler = debounce(() => {
this.resize() this.resize()
}, 100) }, 100)
@ -42,13 +42,13 @@ export default {
this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0] this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]
this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler) this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)
}, },
destroyListener() { destroyListener () {
window.removeEventListener('resize', this.$_resizeHandler) window.removeEventListener('resize', this.$_resizeHandler)
this.$_resizeHandler = null this.$_resizeHandler = null
this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler) this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)
}, },
resize() { resize () {
const { chart } = this const { chart } = this
chart && chart.resize() chart && chart.resize()
} }

View File

@ -30,13 +30,13 @@ import errGif from '@/assets/401_images/401.gif'
export default { export default {
name: 'Page401', name: 'Page401',
data() { data () {
return { return {
errGif: errGif + '?' + +new Date() errGif: errGif + '?' + +new Date()
} }
}, },
methods: { methods: {
back() { back () {
if (this.$route.query.noGoBack) { if (this.$route.query.noGoBack) {
this.$router.push({ path: '/' }) this.$router.push({ path: '/' })
} else { } else {

View File

@ -30,7 +30,7 @@
export default { export default {
name: 'Page404', name: 'Page404',
computed: { computed: {
message() { message () {
return '找不到网页!' return '找不到网页!'
} }
} }

View File

@ -601,19 +601,19 @@
<script> <script>
export default { export default {
name: "Index", name: 'Index',
data() { data () {
return { return {
// //
version: "3.6.0", version: '3.6.0'
}; }
}, },
methods: { methods: {
goTarget(href) { goTarget (href) {
window.open(href, "_blank"); window.open(href, '_blank')
}, }
}, }
}; }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -679,4 +679,3 @@ export default {
} }
} }
</style> </style>

View File

@ -25,7 +25,6 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
@ -64,13 +63,13 @@ export default {
PieChart, PieChart,
BarChart BarChart
}, },
data() { data () {
return { return {
lineChartData: lineChartData.newVisitis lineChartData: lineChartData.newVisitis
} }
}, },
methods: { methods: {
handleSetLineChartData(type) { handleSetLineChartData (type) {
this.lineChartData = lineChartData[type] this.lineChartData = lineChartData[type]
} }
} }

Some files were not shown because too many files have changed in this diff Show More