Merge remote-tracking branch 'origin/dvadmin-liqianglog' into dvadmin-liqianglog
commit
6b0b8bfd1c
|
@ -5,6 +5,7 @@ src/assets
|
|||
# 忽略public目录下文件的语法检查
|
||||
public
|
||||
# 忽略当前目录下为js的文件的语法检查
|
||||
*.js
|
||||
# *.js
|
||||
# 忽略当前目录下为vue的文件的语法检查
|
||||
*.vue
|
||||
# *.vue
|
||||
vue.config.js
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
sourceType: 'module'
|
||||
parser: "babel-eslint",
|
||||
sourceType: "module"
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
es6: true,
|
||||
es6: true
|
||||
},
|
||||
extends: ['plugin:vue/recommended', 'eslint:recommended'],
|
||||
extends: ["plugin:vue/recommended", "eslint:recommended"],
|
||||
|
||||
// add your custom rules here
|
||||
//it is base on https://github.com/vuejs/eslint-config-vue
|
||||
// it is base on https://github.com/vuejs/eslint-config-vue
|
||||
rules: {
|
||||
"vue/max-attributes-per-line": [2, {
|
||||
"singleline": 10,
|
||||
|
@ -23,177 +23,199 @@ module.exports = {
|
|||
}
|
||||
}],
|
||||
"vue/singleline-html-element-content-newline": "off",
|
||||
"vue/multiline-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
|
||||
"accessor-pairs": 2,
|
||||
"arrow-spacing": [2, {
|
||||
"before": true,
|
||||
"after": true
|
||||
}],
|
||||
'block-spacing': [2, 'always'],
|
||||
'brace-style': [2, '1tbs', {
|
||||
'allowSingleLine': true
|
||||
"block-spacing": [2, "always"],
|
||||
"brace-style": [2, "1tbs", {
|
||||
"allowSingleLine": true
|
||||
}],
|
||||
'camelcase': [0, {
|
||||
'properties': 'always'
|
||||
"camelcase": [0, {
|
||||
"properties": "always"
|
||||
}],
|
||||
'comma-dangle': [2, 'never'],
|
||||
'comma-spacing': [2, {
|
||||
'before': false,
|
||||
'after': true
|
||||
"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
|
||||
"comma-style": [2, "last"],
|
||||
"constructor-super": 2,
|
||||
"curly": [2, "multi-line"],
|
||||
"dot-location": [2, "property"],
|
||||
"eol-last": 2,
|
||||
"eqeqeq": 0,
|
||||
"generator-star-spacing": [2, {
|
||||
"before": true,
|
||||
"after": true
|
||||
}],
|
||||
'handle-callback-err': [2, '^(err|error)$'],
|
||||
'indent': [2, 2, {
|
||||
'SwitchCase': 1
|
||||
"handle-callback-err": [2, "^(err|error)$"],
|
||||
"indent": [2, 2, {
|
||||
"SwitchCase": 2
|
||||
}],
|
||||
'jsx-quotes': [2, 'prefer-single'],
|
||||
'key-spacing': [2, {
|
||||
'beforeColon': false,
|
||||
'afterColon': true
|
||||
"jsx-quotes": [2, "prefer-single"],
|
||||
"key-spacing": [2, {
|
||||
"beforeColon": false,
|
||||
"afterColon": true
|
||||
}],
|
||||
'keyword-spacing': [2, {
|
||||
'before': true,
|
||||
'after': true
|
||||
"keyword-spacing": [2, {
|
||||
"before": true,
|
||||
"after": true
|
||||
}],
|
||||
'new-cap': [2, {
|
||||
'newIsCap': true,
|
||||
'capIsNew': false
|
||||
"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
|
||||
"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-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-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-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'
|
||||
"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'
|
||||
"operator-linebreak": [2, "after", {
|
||||
"overrides": {
|
||||
"?": "before",
|
||||
":": "before"
|
||||
}
|
||||
}],
|
||||
'padded-blocks': [2, 'never'],
|
||||
'quotes': [2, 'single', {
|
||||
'avoidEscape': true,
|
||||
'allowTemplateLiterals': true
|
||||
"padded-blocks": [2, "never"],
|
||||
"quotes": [2, "double", {
|
||||
"avoidEscape": true,
|
||||
"allowTemplateLiterals": true
|
||||
}],
|
||||
'semi': [2, 'never'],
|
||||
'semi-spacing': [2, {
|
||||
'before': false,
|
||||
'after': true
|
||||
"semi": [2, "always"],
|
||||
"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
|
||||
"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', '!', ',']
|
||||
"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', {
|
||||
"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']
|
||||
"array-bracket-spacing": [2, "never"],
|
||||
"vue/no-unused-components": 0,
|
||||
// 对component中的组件命名样式实施特定的大小写
|
||||
"vue/component-name-in-template-casing": 0,
|
||||
// 允许HTML未闭合标签
|
||||
"vue/html-self-closing": 0,
|
||||
// 允许props修改
|
||||
"vue/no-mutating-props": 0,
|
||||
// 允许computed修改名称
|
||||
"vue/no-side-effects-in-computed-properties": 0,
|
||||
// $emit不校验kebab-case
|
||||
"vue/custom-event-name-casing": 0,
|
||||
// 允许v-for和v-if一起用
|
||||
"vue/no-use-v-if-with-v-for": 0,
|
||||
"vue/require-default-prop": 0,
|
||||
"vue/require-valid-default-prop": 0,
|
||||
"vue/require-prop-types": 0,
|
||||
"vue/no-lone-template": 0,
|
||||
"vue/no-template-shadow": 0,
|
||||
"vue/this-in-template": 0,
|
||||
"vue/prop-name-casing": 0,
|
||||
// 允许在 case 子句中使用词法声明
|
||||
"no-case-declarations": 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"build:prod": "vue-cli-service build",
|
||||
"build:stage": "vue-cli-service build --mode staging",
|
||||
"preview": "node build/index.js --preview",
|
||||
"lint": "eslint --ext .js,.vue src"
|
||||
"lint": "eslint --fix --ext .js --ext .jsx --ext .vue src",
|
||||
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
@ -43,7 +44,6 @@
|
|||
"core-js": "3.8.1",
|
||||
"echarts": "^4.9.0",
|
||||
"element-ui": "2.15.0",
|
||||
"eslint-loader": "^4.0.2",
|
||||
"file-saver": "2.0.4",
|
||||
"fuse.js": "6.4.3",
|
||||
"highlight.js": "9.18.5",
|
||||
|
@ -69,10 +69,17 @@
|
|||
"@vue/cli-plugin-eslint": "4.4.6",
|
||||
"@vue/cli-service": "4.4.6",
|
||||
"@vue/composition-api": "^1.0.0-rc.6",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"chalk": "4.1.0",
|
||||
"connect": "3.6.6",
|
||||
"eslint": "7.15.0",
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-loader": "^4.0.2",
|
||||
"eslint-plugin-html": "^6.1.2",
|
||||
"eslint-plugin-import": "^2.23.4",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"eslint-plugin-vue": "7.2.0",
|
||||
"lint-staged": "10.5.3",
|
||||
"runjs": "4.4.2",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App'
|
||||
}
|
||||
export default {
|
||||
name: "App"
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 登录方法
|
||||
export function login(username, password, code, uuid) {
|
||||
|
@ -7,34 +7,34 @@ export function login(username, password, code, uuid) {
|
|||
password,
|
||||
idValueC: code,
|
||||
idKeyC: uuid
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/admin/login/',
|
||||
method: 'post',
|
||||
url: "/admin/login/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
return request({
|
||||
url: '/admin/getInfo/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/getInfo/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 退出方法
|
||||
export function logout() {
|
||||
return request({
|
||||
url: '/admin/logout/',
|
||||
method: 'post'
|
||||
})
|
||||
url: "/admin/logout/",
|
||||
method: "post"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
export function getCodeImg() {
|
||||
return request({
|
||||
url: '/admin/captcha/refresh/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/captcha/refresh/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 获取路由
|
||||
export const getRouters = () => {
|
||||
return request({
|
||||
url: '/admin/getRouters/',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
url: "/admin/getRouters/",
|
||||
method: "get"
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询缓存详细
|
||||
export function getCache() {
|
||||
return request({
|
||||
url: '/monitor/cache',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/monitor/cache",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
/**
|
||||
* 封装celery任务信息接口请求
|
||||
*/
|
||||
// 获取
|
||||
export const sync_data_prefix = '/admin/celery';
|
||||
export const sync_data_prefix = "/admin/celery";
|
||||
|
||||
// 获取
|
||||
export function getIntervalschedulea(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/intervalschedule/${id}/`,
|
||||
method: 'get'
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ export function getIntervalschedulea(id) {
|
|||
export function listIntervalschedule(params) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/intervalschedule/`,
|
||||
method: 'get',
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export function listIntervalschedule(params) {
|
|||
export function updateIntervalschedule(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/intervalschedule/${data.id}/`,
|
||||
method: 'put',
|
||||
method: "put",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ export function updateIntervalschedule(data) {
|
|||
export function createIntervalschedule(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/intervalschedule/`,
|
||||
method: 'post',
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export function createIntervalschedule(data) {
|
|||
export function deleteIntervalschedule(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/intervalschedule/${id}/`,
|
||||
method: 'delete'
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ export function deleteIntervalschedule(id) {
|
|||
export function getCrontabSchedule(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/crontabschedule/${id}/`,
|
||||
method: 'get'
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ export function getCrontabSchedule(id) {
|
|||
export function listCrontabSchedule(params) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/crontabschedule/`,
|
||||
method: 'get',
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ export function listCrontabSchedule(params) {
|
|||
export function updateCrontabSchedule(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/crontabschedule/${data.id}/`,
|
||||
method: 'put',
|
||||
method: "put",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ export function updateCrontabSchedule(data) {
|
|||
export function createCrontabSchedule(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/crontabschedule/`,
|
||||
method: 'post',
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ export function createCrontabSchedule(data) {
|
|||
export function deleteCrontabSchedule(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/crontabschedule/${id}/`,
|
||||
method: 'delete'
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ export function deleteCrontabSchedule(id) {
|
|||
export function getPeriodicTask(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/periodictask/${id}/`,
|
||||
method: 'get'
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ export function getPeriodicTask(id) {
|
|||
export function listPeriodicTask(params) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/periodictask/`,
|
||||
method: 'get',
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export function listPeriodicTask(params) {
|
|||
export function TasksAsChoices(params) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/tasks_as_choices/`,
|
||||
method: 'get',
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ export function TasksAsChoices(params) {
|
|||
export function updatePeriodicTask(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/periodictask/${data.id}/`,
|
||||
method: 'put',
|
||||
method: "put",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ export function updatePeriodicTask(data) {
|
|||
export function createPeriodicTask(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/periodictask/`,
|
||||
method: 'post',
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ export function createPeriodicTask(data) {
|
|||
export function deletePeriodicTask(id) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/periodictask/${id}/`,
|
||||
method: 'delete'
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ export function deletePeriodicTask(id) {
|
|||
export function operatesyncdata(data) {
|
||||
return request({
|
||||
url: `${sync_data_prefix}/operate_celery/`,
|
||||
method: 'post',
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -148,33 +148,33 @@ export function operatesyncdata(data) {
|
|||
// 查询定时任务日志列表
|
||||
export function list(query) {
|
||||
return request({
|
||||
url: '/admin/system/celery_log/',
|
||||
method: 'get',
|
||||
url: "/admin/system/celery_log/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除定时任务日志
|
||||
export function delCeleryLog(infoId) {
|
||||
return request({
|
||||
url: `/admin/system/celery_log/${infoId}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空定时任务日志
|
||||
export function cleanCeleryLog() {
|
||||
return request({
|
||||
url: '/admin/system/celery_log/clean',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/celery_log/clean",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出定时任务日志
|
||||
export function exportCeleryLog(query) {
|
||||
return request({
|
||||
url: '/admin/system/celery_log/export',
|
||||
method: 'get',
|
||||
url: "/admin/system/celery_log/export",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询定时任务调度列表
|
||||
export function listJob(query) {
|
||||
return request({
|
||||
url: '/monitor/job/list',
|
||||
method: 'get',
|
||||
url: "/monitor/job/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询定时任务调度详细
|
||||
export function getJob(jobId) {
|
||||
return request({
|
||||
url: '/monitor/job/' + jobId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/monitor/job/" + jobId,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增定时任务调度
|
||||
export function addJob(data) {
|
||||
return request({
|
||||
url: '/monitor/job',
|
||||
method: 'post',
|
||||
url: "/monitor/job",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改定时任务调度
|
||||
export function updateJob(data) {
|
||||
return request({
|
||||
url: '/monitor/job',
|
||||
method: 'put',
|
||||
url: "/monitor/job",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除定时任务调度
|
||||
export function delJob(jobId) {
|
||||
return request({
|
||||
url: '/monitor/job/' + jobId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/monitor/job/" + jobId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出定时任务调度
|
||||
export function exportJob(query) {
|
||||
return request({
|
||||
url: '/monitor/job/export',
|
||||
method: 'get',
|
||||
url: "/monitor/job/export",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 任务状态修改
|
||||
|
@ -57,24 +57,23 @@ export function changeJobStatus(jobId, status) {
|
|||
const data = {
|
||||
jobId,
|
||||
status
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/monitor/job/changeStatus',
|
||||
method: 'put',
|
||||
url: "/monitor/job/changeStatus",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 定时任务立即执行一次
|
||||
export function runJob(jobId, jobGroup) {
|
||||
const data = {
|
||||
jobId,
|
||||
jobGroup
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/monitor/job/run',
|
||||
method: 'put',
|
||||
url: "/monitor/job/run",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询调度日志列表
|
||||
export function listJobLog(query) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/list',
|
||||
method: 'get',
|
||||
url: "/monitor/jobLog/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除调度日志
|
||||
export function delJobLog(jobLogId) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/' + jobLogId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/monitor/jobLog/" + jobLogId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空调度日志
|
||||
export function cleanJobLog() {
|
||||
return request({
|
||||
url: '/monitor/jobLog/clean',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/monitor/jobLog/clean",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出调度日志
|
||||
export function exportJobLog(query) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/export',
|
||||
method: 'get',
|
||||
url: "/monitor/jobLog/export",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询登录日志列表
|
||||
export function list(query) {
|
||||
return request({
|
||||
url: '/admin/system/logininfor/',
|
||||
method: 'get',
|
||||
url: "/admin/system/logininfor/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除登录日志
|
||||
export function delLogininfor(infoId) {
|
||||
return request({
|
||||
url: `/admin/system/logininfor/${infoId}/`,
|
||||
method: 'delete'
|
||||
})
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空登录日志
|
||||
export function cleanLogininfor() {
|
||||
return request({
|
||||
url: '/admin/system/logininfor/clean',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/logininfor/clean",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出登录日志
|
||||
export function exportLogininfor(query) {
|
||||
return request({
|
||||
url: '/admin/system/logininfor/export',
|
||||
method: 'get',
|
||||
url: "/admin/system/logininfor/export",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询在线用户列表
|
||||
export function list(query) {
|
||||
return request({
|
||||
url: '/admin/monitor/online/list',
|
||||
method: 'get',
|
||||
url: "/admin/monitor/online/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 强退用户
|
||||
export function forceLogout(tokenId) {
|
||||
return request({
|
||||
url: '/admin/monitor/online/' + tokenId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/monitor/online/" + tokenId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询操作日志列表
|
||||
export function list(query) {
|
||||
return request({
|
||||
url: '/monitor/operlog/list',
|
||||
method: 'get',
|
||||
url: "/monitor/operlog/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除操作日志
|
||||
export function delOperlog(operId) {
|
||||
return request({
|
||||
url: '/monitor/operlog/' + operId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/monitor/operlog/" + operId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空操作日志
|
||||
export function cleanOperlog() {
|
||||
return request({
|
||||
url: '/monitor/operlog/clean',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/monitor/operlog/clean",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出操作日志
|
||||
export function exportOperlog(query) {
|
||||
return request({
|
||||
url: '/monitor/operlog/export',
|
||||
method: 'get',
|
||||
url: "/monitor/operlog/export",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询服务器信息详细
|
||||
export function getServerList(params) {
|
||||
return request({
|
||||
url: 'admin/monitor/server/',
|
||||
url: "admin/monitor/server/",
|
||||
params,
|
||||
method: 'get'
|
||||
})
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 修改服务器信息
|
||||
export function updateServerInfo(id, data) {
|
||||
let {name, remark} = data;
|
||||
const { name, remark } = data;
|
||||
return request({
|
||||
url: `admin/monitor/server/${id}/`,
|
||||
data: {
|
||||
name,
|
||||
remark
|
||||
},
|
||||
method: 'PUT'
|
||||
})
|
||||
method: "PUT"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取监控配置信息
|
||||
export function getMonitorStatusInfo() {
|
||||
return request({
|
||||
url: 'admin/monitor/monitor/enabled/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "admin/monitor/monitor/enabled/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 更新监控配置信息
|
||||
export function updateMonitorStatusInfo(params) {
|
||||
return request({
|
||||
url: 'admin/monitor/monitor/enabled/',
|
||||
url: "admin/monitor/monitor/enabled/",
|
||||
params,
|
||||
method: 'get'
|
||||
})
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空记录
|
||||
export function cleanMonitorLog() {
|
||||
return request({
|
||||
url: 'admin/monitor/monitor/clean/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "admin/monitor/monitor/clean/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取监控记录
|
||||
|
@ -52,14 +52,14 @@ export function getMonitorLogs(id, params) {
|
|||
return request({
|
||||
url: `admin/monitor/monitor/rate/${id}/`,
|
||||
params,
|
||||
method: 'get'
|
||||
})
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取服务器最新监控日志信息
|
||||
export function getServerLatestLog(id) {
|
||||
return request({
|
||||
url: `admin/monitor/monitor/info/${id}/`,
|
||||
method: 'get'
|
||||
})
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询部门列表
|
||||
export function listDept(query) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/dept/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询部门列表(排除节点)
|
||||
export function listDeptExcludeChild(deptId) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/exclude/' + deptId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/dept/exclude/" + deptId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 查询部门详细
|
||||
export function getDept(deptId) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/' + deptId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/dept/" + deptId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 查询部门下拉树结构
|
||||
export function treeselect() {
|
||||
return request({
|
||||
url: '/admin/permission/dept/treeselect/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/dept/treeselect/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 根据角色ID查询部门树结构
|
||||
export function roleDeptTreeselect(roleId) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/roleDeptTreeselect/' + roleId + '/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/dept/roleDeptTreeselect/" + roleId + "/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增部门
|
||||
export function addDept(data) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/dept/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改部门
|
||||
export function updateDept(data) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/dept/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除部门
|
||||
export function delDept(deptId) {
|
||||
return request({
|
||||
url: '/admin/permission/dept/' + deptId + '',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/permission/dept/" + deptId + "",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询菜单列表
|
||||
export function listMenu(query) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/menus/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询菜单详细
|
||||
export function getMenu(menuId) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/' + menuId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/menus/" + menuId,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 查询菜单下拉树结构
|
||||
export function treeselect() {
|
||||
return request({
|
||||
url: '/admin/permission/menus/treeselect/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/menus/treeselect/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 根据角色ID查询菜单下拉树结构
|
||||
export function roleMenuTreeselect(roleId) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/roleMenuTreeselect/' + roleId + '/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/menus/roleMenuTreeselect/" + roleId + "/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增菜单
|
||||
export function addMenu(data) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/menus/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改菜单
|
||||
export function updateMenu(data) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/'+ data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/menus/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除菜单
|
||||
export function delMenu(menuId) {
|
||||
return request({
|
||||
url: '/admin/permission/menus/' + menuId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/permission/menus/" + menuId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
* @Description: In User Settings Edit
|
||||
* @FilePath: \dvadmin-ui\src\api\permission\msg.js
|
||||
*/
|
||||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询消息列表
|
||||
export function getList(query) {
|
||||
return request({
|
||||
url: '/admin/system/config/',
|
||||
method: 'get',
|
||||
url: "/admin/system/config/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
export function getDesc(configId) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + configId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/config/" + configId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// // 根据消息标题查询
|
||||
|
@ -36,35 +36,34 @@ export function getDesc(configId) {
|
|||
// 新增消息
|
||||
export function addMsg(data) {
|
||||
return request({
|
||||
url: '/admin/system/config/',
|
||||
method: 'post',
|
||||
url: "/admin/system/config/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改消息
|
||||
export function updateMsg(data) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/system/config/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除消息
|
||||
export function delMsg(configId) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + configId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/config/" + configId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 导出消息
|
||||
export function exportMsg(query) {
|
||||
return request({
|
||||
url: '/admin/system/config/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/config/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询岗位列表
|
||||
export function listPost(query) {
|
||||
return request({
|
||||
url: '/admin/permission/post/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/post/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询岗位详细
|
||||
export function getPost(postId) {
|
||||
return request({
|
||||
url: '/admin/permission/post/' + postId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/post/" + postId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增岗位
|
||||
export function addPost(data) {
|
||||
return request({
|
||||
url: '/admin/permission/post/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/post/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改岗位
|
||||
export function updatePost(data) {
|
||||
return request({
|
||||
url: '/admin/permission/post/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/post/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除岗位
|
||||
export function delPost(postId) {
|
||||
return request({
|
||||
url: '/admin/permission/post/' + postId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/permission/post/" + postId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出岗位
|
||||
export function exportPost(query) {
|
||||
return request({
|
||||
url: '/admin/permission/post/export/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/post/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询角色列表
|
||||
export function listRole(query) {
|
||||
return request({
|
||||
url: '/admin/permission/role/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/role/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询角色详细
|
||||
export function getRole(roleId) {
|
||||
return request({
|
||||
url: '/admin/permission/role/' + roleId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/role/" + roleId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增角色
|
||||
export function addRole(data) {
|
||||
return request({
|
||||
url: '/admin/permission/role/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/role/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改角色
|
||||
export function updateRole(data) {
|
||||
return request({
|
||||
url: '/admin/permission/role/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/role/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 角色数据权限
|
||||
export function dataScope(data) {
|
||||
return request({
|
||||
url: '/admin/permission/role/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/role/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 角色状态修改
|
||||
|
@ -49,27 +49,27 @@ export function changeRoleStatus(roleId, status) {
|
|||
const data = {
|
||||
roleId,
|
||||
status
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/admin/permission/role/changeStatus/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/role/changeStatus/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除角色
|
||||
export function delRole(roleId) {
|
||||
return request({
|
||||
url: '/admin/permission/role/' + roleId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/permission/role/" + roleId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出角色
|
||||
export function exportRole(query) {
|
||||
return request({
|
||||
url: '/admin/permission/role/export/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/role/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
import request from '@/utils/request'
|
||||
import {praseStrEmpty} from "@/utils/ruoyi";
|
||||
import request from "@/utils/request";
|
||||
import { praseStrEmpty } from "@/utils/ruoyi";
|
||||
|
||||
// 查询用户列表
|
||||
export function listUser(query) {
|
||||
return request({
|
||||
url: '/admin/permission/user/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/user/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户详细
|
||||
export function getUser(userId) {
|
||||
return request({
|
||||
url: '/admin/permission/user/details/?userId=' + praseStrEmpty(userId),
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/user/details/?userId=" + praseStrEmpty(userId),
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
export function addUser(data) {
|
||||
return request({
|
||||
url: '/admin/permission/user/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/user/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改用户
|
||||
export function updateUser(data) {
|
||||
return request({
|
||||
url: '/admin/permission/user/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
export function delUser(userId) {
|
||||
return request({
|
||||
url: '/admin/permission/user/' + userId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/permission/user/" + userId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出用户
|
||||
export function exportUser(query) {
|
||||
return request({
|
||||
url: '/admin/permission/user/export/',
|
||||
method: 'get',
|
||||
url: "/admin/permission/user/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 用户密码重置
|
||||
|
@ -58,12 +58,12 @@ export function resetUserPwd(userId, password) {
|
|||
const data = {
|
||||
userId,
|
||||
password
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/admin/permission/user/resetPwd/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/resetPwd/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 用户状态修改
|
||||
|
@ -71,29 +71,29 @@ export function changeUserStatus(userId, status) {
|
|||
const data = {
|
||||
userId,
|
||||
status
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/admin/permission/user/changeStatus/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/changeStatus/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询用户个人信息
|
||||
export function getUserProfile() {
|
||||
return request({
|
||||
url: '/admin/permission/user/profile/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/user/profile/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 修改用户个人信息
|
||||
export function updateUserProfile(data) {
|
||||
return request({
|
||||
url: '/admin/permission/user/profile/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/profile/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 用户密码重置
|
||||
|
@ -101,36 +101,36 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||
const data = {
|
||||
oldPassword,
|
||||
newPassword
|
||||
}
|
||||
};
|
||||
return request({
|
||||
url: '/admin/permission/user/profile/updatePwd/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/profile/updatePwd/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 用户头像上传
|
||||
export function uploadAvatar(data) {
|
||||
return request({
|
||||
url: '/admin/permission/user/profile/avatar/',
|
||||
method: 'put',
|
||||
url: "/admin/permission/user/profile/avatar/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 下载用户导入模板
|
||||
export function importTemplate() {
|
||||
return request({
|
||||
url: '/admin/permission/user/importTemplate/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/permission/user/importTemplate/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 用户导入
|
||||
export function importsUser(data) {
|
||||
return request({
|
||||
url: '/admin/permission/user/importTemplate/',
|
||||
method: 'post',
|
||||
url: "/admin/permission/user/importTemplate/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询参数列表
|
||||
export function listConfig(query) {
|
||||
return request({
|
||||
url: '/admin/system/config/',
|
||||
method: 'get',
|
||||
url: "/admin/system/config/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询参数详细
|
||||
export function getConfig(configId) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + configId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/config/" + configId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 根据参数键名查询参数值
|
||||
export function getConfigKey(configKey) {
|
||||
return request({
|
||||
url: '/admin/system/config/configKey/' + configKey + '/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/config/configKey/" + configKey + "/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增参数配置
|
||||
export function addConfig(data) {
|
||||
return request({
|
||||
url: '/admin/system/config/',
|
||||
method: 'post',
|
||||
url: "/admin/system/config/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改参数配置
|
||||
export function updateConfig(data) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/system/config/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除参数配置
|
||||
export function delConfig(configId) {
|
||||
return request({
|
||||
url: '/admin/system/config/' + configId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/config/" + configId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清理参数缓存
|
||||
export function clearCache() {
|
||||
return request({
|
||||
url: '/admin/system/config/clearCache/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/config/clearCache/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出参数
|
||||
export function exportConfig(query) {
|
||||
return request({
|
||||
url: '/admin/system/config/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/config/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询字典数据列表
|
||||
export function listData(query) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data/',
|
||||
method: 'get',
|
||||
url: "/admin/system/dict/data/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询字典数据详细
|
||||
export function getData(dictCode) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data/' + dictCode + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/dict/data/" + dictCode + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDicts(dictType) {
|
||||
return request({
|
||||
url: '/admin/system/dict/get/type/' + dictType + '/?status=1',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/dict/get/type/" + dictType + "/?status=1",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增字典数据
|
||||
export function addData(data) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data' + '/',
|
||||
method: 'post',
|
||||
url: "/admin/system/dict/data" + "/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改字典数据
|
||||
export function updateData(data) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/system/dict/data/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除字典数据
|
||||
export function delData(dictCode) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data/' + dictCode + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/dict/data/" + dictCode + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出字典数据
|
||||
export function exportData(query) {
|
||||
return request({
|
||||
url: '/admin/system/dict/data/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/dict/data/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询字典类型列表
|
||||
export function listType(query) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/',
|
||||
method: 'get',
|
||||
url: "/admin/system/dict/type/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询字典类型详细
|
||||
export function getType(dictId) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/' + dictId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/dict/type/" + dictId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增字典类型
|
||||
export function addType(data) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/',
|
||||
method: 'post',
|
||||
url: "/admin/system/dict/type/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改字典类型
|
||||
export function updateType(data) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/system/dict/type/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除字典类型
|
||||
export function delType(dictId) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/' + dictId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/dict/type/" + dictId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清理参数缓存
|
||||
export function clearCache() {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/clearCache/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/dict/type/clearCache/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出字典类型
|
||||
export function exportType(query) {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/dict/type/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 获取字典选择框列表
|
||||
export function optionselect() {
|
||||
return request({
|
||||
url: '/admin/system/dict/type/optionselect',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/dict/type/optionselect",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,71 +1,70 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询通知列表
|
||||
export function listMessage(query) {
|
||||
return request({
|
||||
url: '/admin/system/message/',
|
||||
method: 'get',
|
||||
url: "/admin/system/message/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询通知详细
|
||||
export function getMessage(messageId) {
|
||||
return request({
|
||||
url: '/admin/system/message/' + messageId + '/',
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/message/" + messageId + "/",
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增通知配置
|
||||
export function addMessage(data) {
|
||||
return request({
|
||||
url: '/admin/system/message/',
|
||||
method: 'post',
|
||||
url: "/admin/system/message/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改通知配置
|
||||
export function updateMessage(data) {
|
||||
return request({
|
||||
url: '/admin/system/message/' + data.id + '/',
|
||||
method: 'put',
|
||||
url: "/admin/system/message/" + data.id + "/",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除通知配置
|
||||
export function delMessage(messageId) {
|
||||
return request({
|
||||
url: '/admin/system/message/' + messageId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/message/" + messageId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 导出通知
|
||||
export function exportMessage(query) {
|
||||
return request({
|
||||
url: '/admin/system/message/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/message/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 获取用户通知列表
|
||||
export function userMessage(query) {
|
||||
return request({
|
||||
url: '/admin/system/message/user_messages/',
|
||||
method: 'get',
|
||||
url: "/admin/system/message/user_messages/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改通知为已读
|
||||
export function updateIsRead(data) {
|
||||
return request({
|
||||
url: '/admin/system/message/is_read/'+ data.id + '/',
|
||||
method: 'put',
|
||||
})
|
||||
url: "/admin/system/message/is_read/" + data.id + "/",
|
||||
method: "put"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询公告列表
|
||||
export function listNotice(query) {
|
||||
return request({
|
||||
url: '/admin/system/notice/list',
|
||||
method: 'get',
|
||||
url: "/admin/system/notice/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询公告详细
|
||||
export function getNotice(noticeId) {
|
||||
return request({
|
||||
url: '/admin/system/notice/' + noticeId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/admin/system/notice/" + noticeId,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 新增公告
|
||||
export function addNotice(data) {
|
||||
return request({
|
||||
url: '/admin/system/notice',
|
||||
method: 'post',
|
||||
url: "/admin/system/notice",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 修改公告
|
||||
export function updateNotice(data) {
|
||||
return request({
|
||||
url: '/admin/system/notice',
|
||||
method: 'put',
|
||||
url: "/admin/system/notice",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除公告
|
||||
export function delNotice(noticeId) {
|
||||
return request({
|
||||
url: '/admin/system/notice/' + noticeId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/notice/" + noticeId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询操作日志列表
|
||||
export function list(query) {
|
||||
return request({
|
||||
url: '/admin/system/operation_log/',
|
||||
method: 'get',
|
||||
url: "/admin/system/operation_log/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除操作日志
|
||||
export function delOperationLog(operId) {
|
||||
return request({
|
||||
url: '/admin/system/operation_log/' + operId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/operation_log/" + operId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清空操作日志
|
||||
export function cleanOperationLog() {
|
||||
return request({
|
||||
url: '/admin/system/operation_log/clean/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/operation_log/clean/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 导出操作日志
|
||||
export function exportOperationLog(query) {
|
||||
return request({
|
||||
url: '/admin/system/operation_log/export/',
|
||||
method: 'get',
|
||||
url: "/admin/system/operation_log/export/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询文件列表
|
||||
export function listSaveFile(query) {
|
||||
return request({
|
||||
url: '/admin/system/savefile/',
|
||||
method: 'get',
|
||||
url: "/admin/system/savefile/",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 新增文件
|
||||
export function addSaveFile(data) {
|
||||
return request({
|
||||
url: '/admin/system/savefile/',
|
||||
method: 'post',
|
||||
url: "/admin/system/savefile/",
|
||||
method: "post",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 删除文件
|
||||
export function delSaveFile(menuId) {
|
||||
return request({
|
||||
url: '/admin/system/savefile/' + menuId + '/',
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/admin/system/savefile/" + menuId + "/",
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 清理废弃文件
|
||||
export function clearSaveFile() {
|
||||
return request({
|
||||
url: '/admin/system/clearsavefile/',
|
||||
method: 'post'
|
||||
})
|
||||
url: "/admin/system/clearsavefile/",
|
||||
method: "post"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
import request from '@/utils/request'
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询生成表数据
|
||||
export function listTable(query) {
|
||||
return request({
|
||||
url: '/tool/gen/list',
|
||||
method: 'get',
|
||||
url: "/tool/gen/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
// 查询db数据库列表
|
||||
export function listDbTable(query) {
|
||||
return request({
|
||||
url: '/tool/gen/db/list',
|
||||
method: 'get',
|
||||
url: "/tool/gen/db/list",
|
||||
method: "get",
|
||||
params: query
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 查询表详细信息
|
||||
export function getGenTable(tableId) {
|
||||
return request({
|
||||
url: '/tool/gen/' + tableId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/tool/gen/" + tableId,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 修改代码生成信息
|
||||
export function updateGenTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen',
|
||||
method: 'put',
|
||||
url: "/tool/gen",
|
||||
method: "put",
|
||||
data: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 导入表
|
||||
export function importTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen/importTable',
|
||||
method: 'post',
|
||||
url: "/tool/gen/importTable",
|
||||
method: "post",
|
||||
params: data
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 预览生成代码
|
||||
export function previewTable(tableId) {
|
||||
return request({
|
||||
url: '/tool/gen/preview/' + tableId,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/tool/gen/preview/" + tableId,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 删除表数据
|
||||
export function delTable(tableId) {
|
||||
return request({
|
||||
url: '/tool/gen/' + tableId,
|
||||
method: 'delete'
|
||||
})
|
||||
url: "/tool/gen/" + tableId,
|
||||
method: "delete"
|
||||
});
|
||||
}
|
||||
|
||||
// 生成代码(自定义路径)
|
||||
export function genCode(tableName) {
|
||||
return request({
|
||||
url: '/tool/gen/genCode/' + tableName,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/tool/gen/genCode/" + tableName,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
||||
// 同步数据库
|
||||
export function synchDb(tableName) {
|
||||
return request({
|
||||
url: '/tool/gen/synchDb/' + tableName,
|
||||
method: 'get'
|
||||
})
|
||||
url: "/tool/gen/synchDb/" + tableName,
|
||||
method: "get"
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,49 +14,49 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
levelList: null
|
||||
}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
$route(route) {
|
||||
// if you go to the redirect page, do not update the breadcrumbs
|
||||
if (route.path.startsWith('/redirect/')) {
|
||||
return
|
||||
if (route.path.startsWith("/redirect/")) {
|
||||
return;
|
||||
}
|
||||
this.getBreadcrumb()
|
||||
this.getBreadcrumb();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getBreadcrumb()
|
||||
this.getBreadcrumb();
|
||||
},
|
||||
methods: {
|
||||
getBreadcrumb() {
|
||||
// only show routes with meta.title
|
||||
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
|
||||
const first = matched[0]
|
||||
const matched = this.$route.matched.filter(item => item.meta && item.meta.title);
|
||||
const first = matched[0];
|
||||
|
||||
if (!this.isDashboard(first)) {
|
||||
// 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) {
|
||||
const name = route && route.name
|
||||
const name = route && route.name;
|
||||
if (!name) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return name.trim() === '首页'
|
||||
return name.trim() === "首页";
|
||||
},
|
||||
handleLink(item) {
|
||||
const { redirect, path } = item
|
||||
const { redirect, path } = item;
|
||||
if (redirect) {
|
||||
this.$router.push(redirect)
|
||||
return
|
||||
this.$router.push(redirect);
|
||||
return;
|
||||
}
|
||||
this.$router.push(path)
|
||||
this.$router.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -8,32 +8,32 @@
|
|||
<use :xlink:href="commonName"/>
|
||||
</svg>-->
|
||||
<span>
|
||||
<slot name="prepend"/>
|
||||
<slot name="prepend" />
|
||||
<svg v-if="iconType && iconType.toLocaleLowerCase() === 'svg'" :class="commonClass" aria-hidden="true">
|
||||
<use :xlink:href="commonName"/>
|
||||
<use :xlink:href="commonName" />
|
||||
</svg>
|
||||
<i v-if="iconType && iconType.toLocaleLowerCase() === 'el'" :class="commonClass"/>
|
||||
<i v-if="iconType && iconType.toLocaleLowerCase() === 'el'" :class="commonClass" />
|
||||
<span v-if="showTitle">{{ iconTitle }}</span>
|
||||
<slot name="append"/>
|
||||
<slot name="append" />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CommonIcon',
|
||||
name: "CommonIcon",
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
},
|
||||
iconTitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
},
|
||||
iconClass: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
default: ""
|
||||
},
|
||||
showTitle: {
|
||||
type: Boolean,
|
||||
|
@ -42,10 +42,10 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
iconType: '',
|
||||
iconName: '',
|
||||
commonName: '',
|
||||
commonClass: ''
|
||||
iconType: "",
|
||||
iconName: "",
|
||||
commonName: "",
|
||||
commonClass: ""
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -62,42 +62,42 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
change(val) {
|
||||
const arr = val.split(':');
|
||||
const arr = val.split(":");
|
||||
if (arr.length >= 2) {
|
||||
this.iconType = arr[0];
|
||||
this.iconName = arr[1];
|
||||
} else {
|
||||
this.iconType = '';
|
||||
this.iconName = '';
|
||||
this.iconType = "";
|
||||
this.iconName = "";
|
||||
}
|
||||
this.commonName = this.getCommonName();
|
||||
this.commonClass = this.getCommonClass();
|
||||
},
|
||||
getCommonName() {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === 'svg') {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === "svg") {
|
||||
return `#icon-${this.iconName}`;
|
||||
}
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === 'el') {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === "el") {
|
||||
return `${this.iconName}`;
|
||||
}
|
||||
return '';
|
||||
return "";
|
||||
},
|
||||
getCommonClass() {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === 'svg') {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === "svg") {
|
||||
if (this.className) {
|
||||
return 'svg-icon ' + this.className;
|
||||
return "svg-icon " + this.className;
|
||||
} else {
|
||||
return 'svg-icon';
|
||||
return "svg-icon";
|
||||
}
|
||||
}
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === 'el') {
|
||||
if (this.iconType && this.iconType.toLocaleLowerCase() === "el") {
|
||||
if (this.className) {
|
||||
return this.iconName + ' ' + this.className;
|
||||
return this.iconName + " " + this.className;
|
||||
} else {
|
||||
return this.iconName;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,13 +13,15 @@
|
|||
:placeholder="filterPlaceholder"
|
||||
clearable
|
||||
style="width: 200px;"
|
||||
@keyup.enter.native="handleSearchFormSubmit"/>
|
||||
@keyup.enter.native="handleSearchFormSubmit"
|
||||
/>
|
||||
<el-button
|
||||
:size="$ELEMENT.size"
|
||||
type="primary"
|
||||
title="过滤"
|
||||
@click="handleSearchFormSubmit">
|
||||
<common-icon value="svg:icon-filter"/>
|
||||
@click="handleSearchFormSubmit"
|
||||
>
|
||||
<common-icon value="svg:icon-filter" />
|
||||
</el-button>
|
||||
<el-button
|
||||
v-show="isFilter"
|
||||
|
@ -27,27 +29,30 @@
|
|||
type="info"
|
||||
title="取消过滤"
|
||||
style="margin-left: 0;"
|
||||
@click="handleCancelFilter">
|
||||
<common-icon value="svg:icon-unfilter"/>
|
||||
@click="handleCancelFilter"
|
||||
>
|
||||
<common-icon value="svg:icon-unfilter" />
|
||||
</el-button>
|
||||
<slot name="button"/>
|
||||
<slot name="button" />
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col v-if="topLayoutRight" :span="6">
|
||||
<div class="grid-content bg-purple-light" style="text-align: right">
|
||||
<slot name="tools"/>
|
||||
<slot name="tools" />
|
||||
<el-button
|
||||
:size="$ELEMENT.size"
|
||||
name="refresh"
|
||||
type="info"
|
||||
title="导出数据"
|
||||
@click="handleExportTableData">
|
||||
<svg-icon icon-class="icon-excel" style="font-size: 1em"/>
|
||||
@click="handleExportTableData"
|
||||
>
|
||||
<svg-icon icon-class="icon-excel" style="font-size: 1em" />
|
||||
</el-button>
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
width="200"
|
||||
trigger="click">
|
||||
trigger="click"
|
||||
>
|
||||
<div style="width: 50px;">
|
||||
<el-checkbox-group v-model="showFields">
|
||||
<el-checkbox
|
||||
|
@ -56,7 +61,8 @@
|
|||
:label="field"
|
||||
:checked="field.show"
|
||||
style="width: 100%"
|
||||
@change="handleSelectField($event, field)">{{ field.label }}</el-checkbox>
|
||||
@change="handleSelectField($event, field)"
|
||||
>{{ field.label }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
<el-button
|
||||
|
@ -65,14 +71,15 @@
|
|||
name="refresh"
|
||||
type="info"
|
||||
icon="el-icon-s-fold"
|
||||
title="设置显示的字段"/>
|
||||
title="设置显示的字段"
|
||||
/>
|
||||
</el-popover>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table
|
||||
v-loading="tableLoading"
|
||||
ref="table"
|
||||
v-loading="tableLoading"
|
||||
:data="filterData"
|
||||
:span-method="spanMethod"
|
||||
:max-height="maxHeight"
|
||||
|
@ -88,12 +95,14 @@
|
|||
@header-click="handleHeaderClick"
|
||||
@row-click="handleRowClick"
|
||||
@row-dblclick="handleRowDblClick"
|
||||
@selection-change="handleSelectionChange">
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column
|
||||
v-if="selection"
|
||||
:reserve-selection="true"
|
||||
type="selection"
|
||||
width="50"/>
|
||||
width="50"
|
||||
/>
|
||||
<template v-for="field in fields">
|
||||
<el-table-column
|
||||
v-if="field.show"
|
||||
|
@ -102,15 +111,16 @@
|
|||
:label="field.label"
|
||||
:sortable="field.sortable"
|
||||
:width="field.width || ''"
|
||||
show-overflow-tooltip>
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<slot :name="field.prop" :values="scope.row" :prop="field.prop" :field="field">
|
||||
<span v-html="formatColumnData(scope.row, field)"/>
|
||||
<span v-html="formatColumnData(scope.row, field)" />
|
||||
</slot>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<slot name="column"/>
|
||||
<slot name="column" />
|
||||
</el-table>
|
||||
<el-row>
|
||||
<el-col :span="6" style="margin-top: 20px">
|
||||
|
@ -120,7 +130,8 @@
|
|||
type="info"
|
||||
size="mini"
|
||||
title="清空多选"
|
||||
@click="clearMultipleSelection">清空</el-button>
|
||||
@click="clearMultipleSelection"
|
||||
>清空</el-button>
|
||||
</el-col>
|
||||
<el-col :span="18" style="margin-top: 20px; text-align: right">
|
||||
<span>总计:<span style="color: #ff00ff;font-weight: bold;">{{ filterData.length }}</span>条</span>
|
||||
|
@ -129,326 +140,326 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import * as Utils from '@/utils';
|
||||
export default {
|
||||
name: 'CommonStaticTable',
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
spanMethod: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
initSelected: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// eslint-disable-next-line vue/require-prop-types
|
||||
maxHeight: {
|
||||
default: 700
|
||||
},
|
||||
stripe: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
fit: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
highlightCurrentRow: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showOverflowTooltip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
emptyText: {
|
||||
type: String,
|
||||
default: '暂无数据'
|
||||
},
|
||||
topLayout: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return ['left', 'right'];
|
||||
}
|
||||
},
|
||||
bottomLayout: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return ['left', 'right'];
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
// 后端返回的字段
|
||||
type: Array,
|
||||
default: () => {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
selection: {
|
||||
// 开始开启多选(默认不开启, false)
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
// api 对象
|
||||
api: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {};
|
||||
}
|
||||
import moment from "moment";
|
||||
import * as Utils from "@/utils";
|
||||
export default {
|
||||
name: "CommonStaticTable",
|
||||
props: {
|
||||
value: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
spanMethod: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
initSelected: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
// eslint-disable-next-line vue/require-prop-types
|
||||
maxHeight: {
|
||||
default: 700
|
||||
},
|
||||
stripe: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
fit: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
highlightCurrentRow: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showOverflowTooltip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
border: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
emptyText: {
|
||||
type: String,
|
||||
default: "暂无数据"
|
||||
},
|
||||
topLayout: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return ["left", "right"];
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableEditable: true,
|
||||
showFields: [], // 显示的字段
|
||||
filterFields: [], // 过滤的字段
|
||||
filterPlaceholder: '过滤', // 过滤提示文字
|
||||
buttonTagList: [], // 所有按钮标签
|
||||
excelDialogVisible: false,
|
||||
tableLoading: false,
|
||||
advancedSearchForm: {},
|
||||
advancedSearchFields: [],
|
||||
rowKey: null,
|
||||
multipleSelection: [],
|
||||
excelHeader: [],
|
||||
excelData: [],
|
||||
searchForm: {
|
||||
search: ''
|
||||
},
|
||||
getRowKeys: row => {
|
||||
if (this.rowKey) {
|
||||
return row[this.rowKey];
|
||||
}
|
||||
return row.id || row.uuid;
|
||||
},
|
||||
exportFields: [],
|
||||
tableData: [],
|
||||
filterData: [],
|
||||
isFilter: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
topLayoutLeft() {
|
||||
return this.topLayout.indexOf('left') >= 0;
|
||||
},
|
||||
topLayoutRight() {
|
||||
return this.topLayout.indexOf('right') >= 0;
|
||||
bottomLayout: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return ["left", "right"];
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
data: {
|
||||
handler: function(newData, oldData) {
|
||||
this.handleChangeTableData(newData);
|
||||
},
|
||||
immediate: true
|
||||
fields: {
|
||||
// 后端返回的字段
|
||||
type: Array,
|
||||
default: () => {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
selection: {
|
||||
// 开始开启多选(默认不开启, false)
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
created() {
|
||||
this.initComponentData();
|
||||
this.initData();
|
||||
this.initSelect();
|
||||
// api 对象
|
||||
api: {
|
||||
type: Function,
|
||||
default: null
|
||||
},
|
||||
methods: {
|
||||
initData() {
|
||||
if (Utils.isFunction(this.api)) {
|
||||
this.listInterfaceData();
|
||||
}
|
||||
},
|
||||
initSelect() {
|
||||
for (const row of this.initSelected) {
|
||||
this.$refs['table'].toggleRowSelection(row, true);
|
||||
}
|
||||
},
|
||||
initComponentData() {
|
||||
this.fields.forEach(field => {
|
||||
field.show = (!!field.show);
|
||||
field.type = (field.type || 'string').toLocaleLowerCase();
|
||||
field.label = field.label || field.prop;
|
||||
field.search = (!!field.search);
|
||||
field.sortable = (!!field.sortable);
|
||||
field.unique = (!!field.unique);
|
||||
field.width = field.width || '';
|
||||
if (field.type === 'choices') {
|
||||
if (Utils.isArray(field.choices) && field.choices.length > 0) {
|
||||
if (!Utils.isObj(field.choices[0])) {
|
||||
field.choices = field.choices.map(value => {
|
||||
return {
|
||||
label: value,
|
||||
value: value
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
field.unique = (!!field.unique);
|
||||
if (field.unique) {
|
||||
this.rowKey = field.prop;
|
||||
}
|
||||
});
|
||||
this.filterFields = this.fields.filter(field => field.search).map(field => field.prop);
|
||||
if (this.filterFields.length) {
|
||||
const text = this.fields.filter(field => field.search).map(field => field.label).join('、');
|
||||
this.filterPlaceholder = `${text} 过滤`;
|
||||
}
|
||||
},
|
||||
listInterfaceData() {
|
||||
this.tableLoading = true;
|
||||
this.api(this.params).then(response => {
|
||||
this.tableLoading = false;
|
||||
this.handleChangeTableData(response.data);
|
||||
}).catch(() => {
|
||||
this.tableLoading = false;
|
||||
});
|
||||
},
|
||||
formatColumnData(row, field) {
|
||||
const type = field.type || 'string';
|
||||
const prop = field.prop;
|
||||
if (field.formatter && typeof field.formatter === 'function') {
|
||||
return field.formatter(row, prop, type);
|
||||
}
|
||||
if (type === 'string') {
|
||||
return row[prop];
|
||||
} else if (type === 'datetime') {
|
||||
return this.formatDatetime(row[prop]);
|
||||
} else if (type === 'date') {
|
||||
return this.formatDate(row[prop]);
|
||||
} else if (type === 'time') {
|
||||
return this.formatTime(row[prop]);
|
||||
} else if (type.startsWith('bool')) {
|
||||
return row[prop] ? '是' : '否';
|
||||
} else if (type === 'choices') {
|
||||
const choices = field.choices;
|
||||
return this.formatChoices(choices, row[prop]);
|
||||
} else {
|
||||
return row[prop];
|
||||
}
|
||||
},
|
||||
formatChoices(choices, value) {
|
||||
for (const choice of choices) {
|
||||
if (choice.value === value) {
|
||||
return choice.label;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
},
|
||||
formatDatetime(datetime) {
|
||||
return moment(datetime).format('YYYY-MM-DD HH:mm:ss');
|
||||
},
|
||||
formatDate(date) {
|
||||
return moment(date).format('YYYY-MM-DD');
|
||||
},
|
||||
formatTime(time) {
|
||||
return moment(time).format('HH:mm:ss');
|
||||
},
|
||||
getMultipleSelection() {
|
||||
return this.multipleSelection || [];
|
||||
},
|
||||
clearMultipleSelection() {
|
||||
this.$refs.table.clearSelection();
|
||||
},
|
||||
clearSelection() {
|
||||
this.$refs.table.clearSelection();
|
||||
},
|
||||
clearFilter() {
|
||||
// 重置过滤
|
||||
this.searchForm.search = '';
|
||||
this.filterData = Array.from(this.tableData);
|
||||
},
|
||||
handleSelectField(e, field) {
|
||||
field.show = e;
|
||||
},
|
||||
handleChangeTableData(data) {
|
||||
this.tableData = Array.from(data);
|
||||
this.filterData = Array.from(this.filterHandler(this.tableData));
|
||||
},
|
||||
// 导出表格的数据, 当前数据、当前列
|
||||
handleExportTableData() {
|
||||
this.excelDialogVisible = true;
|
||||
this.exportFields = this.fields.map(field => {
|
||||
return { prop: field.prop, label: field.label, show: field.show };
|
||||
});
|
||||
this.excelHeader = this.showFields.map(field => field['prop']);
|
||||
},
|
||||
// 处理修改多选的值
|
||||
handleSelectionChange(val) {
|
||||
this.$emit('selection-change', val);
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
handleSortChange(val) {
|
||||
this.sort.prop = val.prop;
|
||||
this.sort.order = val.order;
|
||||
this.getTableData();
|
||||
},
|
||||
filterHandler(data) {
|
||||
if (!data) {
|
||||
data = this.tableData || [];
|
||||
}
|
||||
const search = this.searchForm.search.trim();
|
||||
if (!search.length || !this.filterFields.length) {
|
||||
this.isFilter = false;
|
||||
return data;
|
||||
}
|
||||
const filterData = data.filter(row => {
|
||||
for (const field of this.filterFields) {
|
||||
if (row[field] && row[field].indexOf(search) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this.isFilter = true;
|
||||
return filterData;
|
||||
},
|
||||
handleCellClick(row, column, cell, event) {
|
||||
this.$emit('cell-click', row, column, cell, event);
|
||||
},
|
||||
handleCellDbClick(row, column, cell, event) {
|
||||
this.$emit('cell-dblclick', row, column, cell, event);
|
||||
},
|
||||
handleRowClick(row, column, event) {
|
||||
this.$emit('row-click', row, column, event);
|
||||
},
|
||||
handleRowDblClick(row, column, event) {
|
||||
this.$emit('row-dblclick', row, column, event);
|
||||
},
|
||||
handleHeaderClick(column, event) {
|
||||
this.$emit('header-click', column, event);
|
||||
},
|
||||
toggleRowSelection(row, selected = true) {
|
||||
this.$refs.table.toggleRowSelection(row, selected);
|
||||
},
|
||||
toggleFilter() {
|
||||
// 触发过滤
|
||||
this.filterData = Array.from(this.filterHandler());
|
||||
},
|
||||
handleSearchFormSubmit() {
|
||||
this.toggleFilter();
|
||||
},
|
||||
handleCancelFilter() {
|
||||
this.isFilter = false;
|
||||
this.clearFilter();
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableEditable: true,
|
||||
showFields: [], // 显示的字段
|
||||
filterFields: [], // 过滤的字段
|
||||
filterPlaceholder: "过滤", // 过滤提示文字
|
||||
buttonTagList: [], // 所有按钮标签
|
||||
excelDialogVisible: false,
|
||||
tableLoading: false,
|
||||
advancedSearchForm: {},
|
||||
advancedSearchFields: [],
|
||||
rowKey: null,
|
||||
multipleSelection: [],
|
||||
excelHeader: [],
|
||||
excelData: [],
|
||||
searchForm: {
|
||||
search: ""
|
||||
},
|
||||
getRowKeys: row => {
|
||||
if (this.rowKey) {
|
||||
return row[this.rowKey];
|
||||
}
|
||||
return row.id || row.uuid;
|
||||
},
|
||||
exportFields: [],
|
||||
tableData: [],
|
||||
filterData: [],
|
||||
isFilter: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
topLayoutLeft() {
|
||||
return this.topLayout.indexOf("left") >= 0;
|
||||
},
|
||||
topLayoutRight() {
|
||||
return this.topLayout.indexOf("right") >= 0;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
data: {
|
||||
handler: function(newData, oldData) {
|
||||
this.handleChangeTableData(newData);
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
created() {
|
||||
this.initComponentData();
|
||||
this.initData();
|
||||
this.initSelect();
|
||||
},
|
||||
methods: {
|
||||
initData() {
|
||||
if (Utils.isFunction(this.api)) {
|
||||
this.listInterfaceData();
|
||||
}
|
||||
},
|
||||
initSelect() {
|
||||
for (const row of this.initSelected) {
|
||||
this.$refs["table"].toggleRowSelection(row, true);
|
||||
}
|
||||
},
|
||||
initComponentData() {
|
||||
this.fields.forEach(field => {
|
||||
field.show = (!!field.show);
|
||||
field.type = (field.type || "string").toLocaleLowerCase();
|
||||
field.label = field.label || field.prop;
|
||||
field.search = (!!field.search);
|
||||
field.sortable = (!!field.sortable);
|
||||
field.unique = (!!field.unique);
|
||||
field.width = field.width || "";
|
||||
if (field.type === "choices") {
|
||||
if (Utils.isArray(field.choices) && field.choices.length > 0) {
|
||||
if (!Utils.isObj(field.choices[0])) {
|
||||
field.choices = field.choices.map(value => {
|
||||
return {
|
||||
label: value,
|
||||
value: value
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
field.unique = (!!field.unique);
|
||||
if (field.unique) {
|
||||
this.rowKey = field.prop;
|
||||
}
|
||||
});
|
||||
this.filterFields = this.fields.filter(field => field.search).map(field => field.prop);
|
||||
if (this.filterFields.length) {
|
||||
const text = this.fields.filter(field => field.search).map(field => field.label).join("、");
|
||||
this.filterPlaceholder = `${text} 过滤`;
|
||||
}
|
||||
},
|
||||
listInterfaceData() {
|
||||
this.tableLoading = true;
|
||||
this.api(this.params).then(response => {
|
||||
this.tableLoading = false;
|
||||
this.handleChangeTableData(response.data);
|
||||
}).catch(() => {
|
||||
this.tableLoading = false;
|
||||
});
|
||||
},
|
||||
formatColumnData(row, field) {
|
||||
const type = field.type || "string";
|
||||
const prop = field.prop;
|
||||
if (field.formatter && typeof field.formatter === "function") {
|
||||
return field.formatter(row, prop, type);
|
||||
}
|
||||
if (type === "string") {
|
||||
return row[prop];
|
||||
} else if (type === "datetime") {
|
||||
return this.formatDatetime(row[prop]);
|
||||
} else if (type === "date") {
|
||||
return this.formatDate(row[prop]);
|
||||
} else if (type === "time") {
|
||||
return this.formatTime(row[prop]);
|
||||
} else if (type.startsWith("bool")) {
|
||||
return row[prop] ? "是" : "否";
|
||||
} else if (type === "choices") {
|
||||
const choices = field.choices;
|
||||
return this.formatChoices(choices, row[prop]);
|
||||
} else {
|
||||
return row[prop];
|
||||
}
|
||||
},
|
||||
formatChoices(choices, value) {
|
||||
for (const choice of choices) {
|
||||
if (choice.value === value) {
|
||||
return choice.label;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
},
|
||||
formatDatetime(datetime) {
|
||||
return moment(datetime).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
formatDate(date) {
|
||||
return moment(date).format("YYYY-MM-DD");
|
||||
},
|
||||
formatTime(time) {
|
||||
return moment(time).format("HH:mm:ss");
|
||||
},
|
||||
getMultipleSelection() {
|
||||
return this.multipleSelection || [];
|
||||
},
|
||||
clearMultipleSelection() {
|
||||
this.$refs.table.clearSelection();
|
||||
},
|
||||
clearSelection() {
|
||||
this.$refs.table.clearSelection();
|
||||
},
|
||||
clearFilter() {
|
||||
// 重置过滤
|
||||
this.searchForm.search = "";
|
||||
this.filterData = Array.from(this.tableData);
|
||||
},
|
||||
handleSelectField(e, field) {
|
||||
field.show = e;
|
||||
},
|
||||
handleChangeTableData(data) {
|
||||
this.tableData = Array.from(data);
|
||||
this.filterData = Array.from(this.filterHandler(this.tableData));
|
||||
},
|
||||
// 导出表格的数据, 当前数据、当前列
|
||||
handleExportTableData() {
|
||||
this.excelDialogVisible = true;
|
||||
this.exportFields = this.fields.map(field => {
|
||||
return { prop: field.prop, label: field.label, show: field.show };
|
||||
});
|
||||
this.excelHeader = this.showFields.map(field => field["prop"]);
|
||||
},
|
||||
// 处理修改多选的值
|
||||
handleSelectionChange(val) {
|
||||
this.$emit("selection-change", val);
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
handleSortChange(val) {
|
||||
this.sort.prop = val.prop;
|
||||
this.sort.order = val.order;
|
||||
this.getTableData();
|
||||
},
|
||||
filterHandler(data) {
|
||||
if (!data) {
|
||||
data = this.tableData || [];
|
||||
}
|
||||
const search = this.searchForm.search.trim();
|
||||
if (!search.length || !this.filterFields.length) {
|
||||
this.isFilter = false;
|
||||
return data;
|
||||
}
|
||||
const filterData = data.filter(row => {
|
||||
for (const field of this.filterFields) {
|
||||
if (row[field] && row[field].indexOf(search) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this.isFilter = true;
|
||||
return filterData;
|
||||
},
|
||||
handleCellClick(row, column, cell, event) {
|
||||
this.$emit("cell-click", row, column, cell, event);
|
||||
},
|
||||
handleCellDbClick(row, column, cell, event) {
|
||||
this.$emit("cell-dblclick", row, column, cell, event);
|
||||
},
|
||||
handleRowClick(row, column, event) {
|
||||
this.$emit("row-click", row, column, event);
|
||||
},
|
||||
handleRowDblClick(row, column, event) {
|
||||
this.$emit("row-dblclick", row, column, event);
|
||||
},
|
||||
handleHeaderClick(column, event) {
|
||||
this.$emit("header-click", column, event);
|
||||
},
|
||||
toggleRowSelection(row, selected = true) {
|
||||
this.$refs.table.toggleRowSelection(row, selected);
|
||||
},
|
||||
toggleFilter() {
|
||||
// 触发过滤
|
||||
this.filterData = Array.from(this.filterHandler());
|
||||
},
|
||||
handleSearchFormSubmit() {
|
||||
this.toggleFilter();
|
||||
},
|
||||
handleCancelFilter() {
|
||||
this.isFilter = false;
|
||||
this.clearFilter();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -1,61 +1,68 @@
|
|||
<!-- 部门选择器 -->
|
||||
<template>
|
||||
<div>
|
||||
<treeselect v-model="dept_value" :options="deptTree" :multiple="multiple" :show-count="true"
|
||||
:placeholder="placeholder" :disable-branch-nodes="disable_branch_nodes"/>
|
||||
<treeselect
|
||||
v-model="dept_value"
|
||||
:options="deptTree"
|
||||
:multiple="multiple"
|
||||
:show-count="true"
|
||||
:placeholder="placeholder"
|
||||
:disable-branch-nodes="disable_branch_nodes"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import {treeselect} from '@/api/vadmin/permission/dept'
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { treeselect } from "@/api/vadmin/permission/dept";
|
||||
|
||||
export default {
|
||||
name: "DeptTree",
|
||||
props: {
|
||||
/* 选择器的内容 */
|
||||
value: {type: Number | Array,},
|
||||
/* 用于显示选项 */
|
||||
placeholder: {type: String, default: "请选择归属部门",},
|
||||
/* 是否多选 */
|
||||
multiple: {type: Boolean, default: false,},
|
||||
/* 是否只能选末级 */
|
||||
disable_branch_nodes: {type: Boolean, default: false,},
|
||||
export default {
|
||||
name: "DeptTree",
|
||||
components: { Treeselect },
|
||||
props: {
|
||||
/* 选择器的内容 */
|
||||
// eslint-disable-next-line vue/require-prop-type-constructor
|
||||
value: { type: Number | Array },
|
||||
/* 用于显示选项 */
|
||||
placeholder: { type: String, default: "请选择归属部门" },
|
||||
/* 是否多选 */
|
||||
multiple: { type: Boolean, default: false },
|
||||
/* 是否只能选末级 */
|
||||
disable_branch_nodes: { type: Boolean, default: false }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
deptOptions: [],
|
||||
deptTree: [],
|
||||
dept_value: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
dept_value(newValue) {
|
||||
this.$emit("update:value", newValue);
|
||||
},
|
||||
components: {Treeselect},
|
||||
data() {
|
||||
return {
|
||||
deptOptions: [],
|
||||
deptTree: [],
|
||||
dept_value: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dept_value(newValue) {
|
||||
this.$emit('update:value', newValue)
|
||||
},
|
||||
value: {
|
||||
handler: function (newValue) {
|
||||
this.dept_value = newValue
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTreeselect()
|
||||
},
|
||||
methods: {
|
||||
/** 查询部门下拉树结构 */
|
||||
getTreeselect() {
|
||||
treeselect().then(response => {
|
||||
this.deptOptions = response.data
|
||||
this.deptTree = this.handleTree(response.data, 'id')
|
||||
})
|
||||
value: {
|
||||
handler: function(newValue) {
|
||||
this.dept_value = newValue;
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTreeselect();
|
||||
},
|
||||
methods: {
|
||||
/** 查询部门下拉树结构 */
|
||||
getTreeselect() {
|
||||
treeselect().then(response => {
|
||||
this.deptOptions = response.data;
|
||||
this.deptTree = this.handleTree(response.data, "id");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="editor" ref="editor" :style="styles"></div>
|
||||
<div ref="editor" class="editor" :style="styles" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -14,18 +14,18 @@ export default {
|
|||
/* 编辑器的内容 */
|
||||
value: {
|
||||
type: String,
|
||||
default: "",
|
||||
default: ""
|
||||
},
|
||||
/* 高度 */
|
||||
height: {
|
||||
type: Number,
|
||||
default: null,
|
||||
default: null
|
||||
},
|
||||
/* 最小高度 */
|
||||
minHeight: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -38,26 +38,26 @@ export default {
|
|||
modules: {
|
||||
// 工具栏配置
|
||||
toolbar: [
|
||||
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
|
||||
["blockquote", "code-block"], // 引用 代码块
|
||||
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
|
||||
[{ indent: "-1" }, { indent: "+1" }], // 缩进
|
||||
[{ size: ["small", false, "large", "huge"] }], // 字体大小
|
||||
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
|
||||
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
|
||||
[{ align: [] }], // 对齐方式
|
||||
["clean"], // 清除文本格式
|
||||
["link", "image", "video"] // 链接、图片、视频
|
||||
],
|
||||
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
|
||||
["blockquote", "code-block"], // 引用 代码块
|
||||
[{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
|
||||
[{ indent: "-1" }, { indent: "+1" }], // 缩进
|
||||
[{ size: ["small", false, "large", "huge"] }], // 字体大小
|
||||
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
|
||||
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
|
||||
[{ align: [] }], // 对齐方式
|
||||
["clean"], // 清除文本格式
|
||||
["link", "image", "video"] // 链接、图片、视频
|
||||
]
|
||||
},
|
||||
placeholder: "请输入内容",
|
||||
readOnly: false,
|
||||
},
|
||||
readOnly: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
styles() {
|
||||
let style = {};
|
||||
const style = {};
|
||||
if (this.minHeight) {
|
||||
style.minHeight = `${this.minHeight}px`;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export default {
|
|||
style.height = `${this.height}px`;
|
||||
}
|
||||
return style;
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
|
@ -77,8 +77,8 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
|
@ -108,8 +108,8 @@ export default {
|
|||
this.Quill.on("editor-change", (eventName, ...args) => {
|
||||
this.$emit("on-editor-change", eventName, ...args);
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -192,4 +192,4 @@ export default {
|
|||
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
|
||||
content: "等宽字体";
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div class="upload-file">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="uploadFileUrl"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:file-list="fileList"
|
||||
|
@ -11,12 +12,11 @@
|
|||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
class="upload-file-uploader"
|
||||
ref="upload"
|
||||
>
|
||||
<!-- 上传按钮 -->
|
||||
<el-button size="mini" type="primary">选取文件</el-button>
|
||||
<!-- 上传提示 -->
|
||||
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||
<div v-if="showTip" slot="tip" class="el-upload__tip">
|
||||
请上传
|
||||
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||
|
@ -26,12 +26,12 @@
|
|||
|
||||
<!-- 文件列表 -->
|
||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
|
||||
<li v-for="(file, index) in list" :key="file.uid" class="el-upload-list__item ele-upload-list__item-content">
|
||||
<el-link :href="file.url" :underline="false" target="_blank">
|
||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||
</el-link>
|
||||
<div class="ele-upload-list__item-content-action">
|
||||
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||
<el-link :underline="false" type="danger" @click="handleDelete(index)">删除</el-link>
|
||||
</div>
|
||||
</li>
|
||||
</transition-group>
|
||||
|
@ -39,21 +39,22 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getToken} from "@/utils/auth";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
export default {
|
||||
name: "FileUpload",
|
||||
props: {
|
||||
// 值
|
||||
value: [String, Object, Array],
|
||||
// 大小限制(MB)
|
||||
fileSize: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
default: 5
|
||||
},
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
||||
default: () => ["doc", "xls", "ppt", "txt", "pdf"]
|
||||
},
|
||||
// 是否显示提示
|
||||
isShowTip: {
|
||||
|
@ -61,14 +62,13 @@
|
|||
default: true
|
||||
}
|
||||
},
|
||||
name:'FileUpload',
|
||||
data() {
|
||||
return {
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin/system/savefile/", // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
Authorization: "Bearer " + getToken()
|
||||
},
|
||||
fileList: [],
|
||||
fileList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -94,13 +94,16 @@
|
|||
this.fileList = [];
|
||||
return [];
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fileList = this.list;
|
||||
},
|
||||
methods: {
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
// 校检文件类型
|
||||
if (this.fileType && this.fileType[0] !== 'ALL') {
|
||||
if (this.fileType && this.fileType[0] !== "ALL") {
|
||||
let fileExtension = "";
|
||||
if (file.name.lastIndexOf(".") > -1) {
|
||||
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
||||
|
@ -130,7 +133,7 @@
|
|||
this.$message.error(`只允许上传单个文件`);
|
||||
},
|
||||
// 上传失败
|
||||
handleUploadError(err) {
|
||||
handleUploadError() {
|
||||
this.$message.error("上传失败, 请重试");
|
||||
},
|
||||
// 上传成功回调
|
||||
|
@ -145,7 +148,7 @@
|
|||
// 删除文件
|
||||
handleDelete(index) {
|
||||
this.fileList.splice(index, 1);
|
||||
this.$emit("input", '');
|
||||
this.$emit("input", "");
|
||||
},
|
||||
// 获取文件名称
|
||||
getFileName(name) {
|
||||
|
@ -155,10 +158,7 @@
|
|||
return "";
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fileList = this.list;
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Hamburger',
|
||||
name: "Hamburger",
|
||||
props: {
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
|
@ -24,10 +24,10 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
toggleClick() {
|
||||
this.$emit('toggleClick')
|
||||
this.$emit("toggleClick");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -20,67 +20,67 @@
|
|||
<script>
|
||||
// fuse is a lightweight fuzzy-search module
|
||||
// make search results more in line with expectations
|
||||
import Fuse from 'fuse.js/dist/fuse.min.js'
|
||||
import path from 'path'
|
||||
import Fuse from "fuse.js/dist/fuse.min.js";
|
||||
import path from "path";
|
||||
|
||||
export default {
|
||||
name: 'HeaderSearch',
|
||||
name: "HeaderSearch",
|
||||
data() {
|
||||
return {
|
||||
search: '',
|
||||
search: "",
|
||||
options: [],
|
||||
searchPool: [],
|
||||
show: false,
|
||||
fuse: undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
routes() {
|
||||
return this.$store.getters.permission_routes
|
||||
return this.$store.getters.permission_routes;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
routes() {
|
||||
this.searchPool = this.generateRoutes(this.routes)
|
||||
this.searchPool = this.generateRoutes(this.routes);
|
||||
},
|
||||
searchPool(list) {
|
||||
this.initFuse(list)
|
||||
this.initFuse(list);
|
||||
},
|
||||
show(value) {
|
||||
if (value) {
|
||||
document.body.addEventListener('click', this.close)
|
||||
document.body.addEventListener("click", this.close);
|
||||
} else {
|
||||
document.body.removeEventListener('click', this.close)
|
||||
document.body.removeEventListener("click", this.close);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.searchPool = this.generateRoutes(this.routes)
|
||||
this.searchPool = this.generateRoutes(this.routes);
|
||||
},
|
||||
methods: {
|
||||
click() {
|
||||
this.show = !this.show
|
||||
this.show = !this.show;
|
||||
if (this.show) {
|
||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus()
|
||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus();
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur()
|
||||
this.options = []
|
||||
this.show = false
|
||||
this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur();
|
||||
this.options = [];
|
||||
this.show = false;
|
||||
},
|
||||
change(val) {
|
||||
if(this.ishttp(val.path)) {
|
||||
if (this.ishttp(val.path)) {
|
||||
// http(s):// 路径新窗口打开
|
||||
window.open(val.path, "_blank");
|
||||
} else {
|
||||
this.$router.push(val.path)
|
||||
this.$router.push(val.path);
|
||||
}
|
||||
this.search = ''
|
||||
this.options = []
|
||||
this.search = "";
|
||||
this.options = [];
|
||||
this.$nextTick(() => {
|
||||
this.show = false
|
||||
})
|
||||
this.show = false;
|
||||
});
|
||||
},
|
||||
initFuse(list) {
|
||||
this.fuse = new Fuse(list, {
|
||||
|
@ -91,60 +91,60 @@ export default {
|
|||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: [{
|
||||
name: 'title',
|
||||
name: "title",
|
||||
weight: 0.7
|
||||
}, {
|
||||
name: 'path',
|
||||
name: "path",
|
||||
weight: 0.3
|
||||
}]
|
||||
})
|
||||
});
|
||||
},
|
||||
// Filter out the routes that can be displayed in the sidebar
|
||||
// And generate the internationalized title
|
||||
generateRoutes(routes, basePath = '/', prefixTitle = []) {
|
||||
let res = []
|
||||
generateRoutes(routes, basePath = "/", prefixTitle = []) {
|
||||
let res = [];
|
||||
|
||||
for (const router of routes) {
|
||||
// skip hidden router
|
||||
if (router.hidden) { continue }
|
||||
if (router.hidden) { continue; }
|
||||
|
||||
const data = {
|
||||
path: !this.ishttp(router.path) ? path.resolve(basePath, router.path) : router.path,
|
||||
title: [...prefixTitle]
|
||||
}
|
||||
};
|
||||
|
||||
if (router.meta && router.meta.title) {
|
||||
data.title = [...data.title, router.meta.title]
|
||||
data.title = [...data.title, router.meta.title];
|
||||
|
||||
if (router.redirect !== 'noRedirect') {
|
||||
if (router.redirect !== "noRedirect") {
|
||||
// only push the routes with title
|
||||
// special case: need to exclude parent router without redirect
|
||||
res.push(data)
|
||||
res.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
// recursive child routes
|
||||
if (router.children) {
|
||||
const tempRoutes = this.generateRoutes(router.children, data.path, data.title)
|
||||
const tempRoutes = this.generateRoutes(router.children, data.path, data.title);
|
||||
if (tempRoutes.length >= 1) {
|
||||
res = [...res, ...tempRoutes]
|
||||
res = [...res, ...tempRoutes];
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
return res;
|
||||
},
|
||||
querySearch(query) {
|
||||
if (query !== '') {
|
||||
this.options = this.fuse.search(query)
|
||||
if (query !== "") {
|
||||
this.options = this.fuse.search(query);
|
||||
} else {
|
||||
this.options = []
|
||||
this.options = [];
|
||||
}
|
||||
},
|
||||
ishttp(url) {
|
||||
return url.indexOf('http://') !== -1 || url.indexOf('https://') !== -1
|
||||
return url.indexOf("http://") !== -1 || url.indexOf("https://") !== -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -14,32 +14,32 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import icons from './requireIcons'
|
||||
import icons from "./requireIcons";
|
||||
export default {
|
||||
name: 'IconSelect',
|
||||
name: "IconSelect",
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
name: "",
|
||||
iconList: icons
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
filterIcons() {
|
||||
this.iconList = icons
|
||||
this.iconList = icons;
|
||||
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) {
|
||||
this.$emit('selected', name)
|
||||
document.body.click()
|
||||
this.$emit("selected", name);
|
||||
document.body.click();
|
||||
},
|
||||
reset() {
|
||||
this.name = ''
|
||||
this.iconList = icons
|
||||
this.name = "";
|
||||
this.iconList = icons;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
const req = require.context('../../assets/icons/svg', false, /\.svg$/)
|
||||
const requireAll = requireContext => requireContext.keys()
|
||||
const req = require.context("../../assets/icons/svg", false, /\.svg$/);
|
||||
const requireAll = requireContext => requireContext.keys();
|
||||
|
||||
const re = /\.\/(.*)\.svg/
|
||||
const re = /\.\/(.*)\.svg/;
|
||||
|
||||
const icons = requireAll(req).map(i => {
|
||||
return i.match(re)[1]
|
||||
})
|
||||
return i.match(re)[1];
|
||||
});
|
||||
|
||||
export default icons
|
||||
export default icons;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</div>
|
||||
</el-image>
|
||||
<div v-else class="image">
|
||||
<el-image :src="value" :style="`width:150px;height:150px;`" fit="fill"/>
|
||||
<el-image :src="value" :style="`width:150px;height:150px;`" fit="fill" />
|
||||
<div class="mask">
|
||||
<div class="actions">
|
||||
<span title="预览" @click.stop="dialogVisible = true">
|
||||
|
@ -40,21 +40,22 @@
|
|||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
},
|
||||
Authorization: "Bearer " + getToken()
|
||||
}
|
||||
};
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
methods: {
|
||||
removeImage() {
|
||||
this.$emit("input", "");
|
||||
|
@ -67,18 +68,17 @@ export default {
|
|||
this.loading = this.$loading({
|
||||
lock: true,
|
||||
text: "上传中",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
background: "rgba(0, 0, 0, 0.7)"
|
||||
});
|
||||
},
|
||||
handleUploadError() {
|
||||
this.$message({
|
||||
type: "error",
|
||||
message: "上传失败",
|
||||
message: "上传失败"
|
||||
});
|
||||
this.loading.close();
|
||||
},
|
||||
},
|
||||
watch: {},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -97,4 +97,4 @@ export default {
|
|||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
<template>
|
||||
<el-dialog :title="dialogTitle"
|
||||
:visible="openDetailModal"
|
||||
:width="modalWidth"
|
||||
@close="closeDetailFormDialog"
|
||||
append-to-body
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible="openDetailModal"
|
||||
:width="modalWidth"
|
||||
append-to-body
|
||||
@close="closeDetailFormDialog"
|
||||
>
|
||||
<el-form ref="form"
|
||||
:model="formData"
|
||||
:label-width="labelWidth"
|
||||
:size="formSize"
|
||||
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="formData"
|
||||
:label-width="labelWidth"
|
||||
:size="formSize"
|
||||
>
|
||||
<el-row>
|
||||
<template v-for="item in formItem">
|
||||
<el-col :span="item.singleLine? 24:12">
|
||||
<el-form-item :label="`${item.label}:`" :key="item.index" >
|
||||
<template v-for="(item,index) in formItem">
|
||||
<el-col :key="index" :span="item.singleLine? 24:12">
|
||||
<el-form-item :key="item.index" :label="`${item.label}:`">
|
||||
<template v-if="item.customRender">
|
||||
<slot :name="item.key" :item="item"></slot>
|
||||
<slot :name="item.key" :item="item" />
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ parseFormItemContent(item) }}
|
||||
|
@ -33,43 +34,43 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { parseTime } from '../../utils/ruoyi'
|
||||
import { parseTime } from "../../utils/ruoyi";
|
||||
|
||||
const labelTypeToFunction = {
|
||||
time: (item, formData) => {
|
||||
return parseTime(formData[item.key])
|
||||
},
|
||||
boolean: (item, formData) => {
|
||||
return item.labelChoices[formData[item.key]]
|
||||
}
|
||||
const labelTypeToFunction = {
|
||||
time: (item, formData) => {
|
||||
return parseTime(formData[item.key]);
|
||||
},
|
||||
boolean: (item, formData) => {
|
||||
return item.labelChoices[formData[item.key]];
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'DetailFormDialog',
|
||||
props: {
|
||||
dialogTitle: { type: String, required: true },
|
||||
openDetailModal: { type: Boolean, required: true },
|
||||
modalWidth: { type: String, default: '720px' },
|
||||
labelWidth: { type: String, default: '100px' },
|
||||
formSize: { type: String, default: 'mini' },
|
||||
formData: { type: Object, default: {} },
|
||||
formItem: { type: Array, default: [] }
|
||||
},
|
||||
methods: {
|
||||
parseFormItemContent(item) {
|
||||
let labelType = item.labelType
|
||||
if (labelType) {
|
||||
return labelTypeToFunction[labelType](item, this.formData)
|
||||
} else {
|
||||
return this.formData[item.key]
|
||||
}
|
||||
},
|
||||
closeDetailFormDialog() {
|
||||
this.$emit('closeDialog', false)
|
||||
export default {
|
||||
name: "DetailFormDialog",
|
||||
props: {
|
||||
dialogTitle: { type: String, required: true },
|
||||
openDetailModal: { type: Boolean, required: true },
|
||||
modalWidth: { type: String, default: "720px" },
|
||||
labelWidth: { type: String, default: "100px" },
|
||||
formSize: { type: String, default: "mini" },
|
||||
formData: { type: Object, default: {}},
|
||||
formItem: { type: Array, default: [] }
|
||||
},
|
||||
methods: {
|
||||
parseFormItemContent(item) {
|
||||
const labelType = item.labelType;
|
||||
if (labelType) {
|
||||
return labelTypeToFunction[labelType](item, this.formData);
|
||||
} else {
|
||||
return this.formData[item.key];
|
||||
}
|
||||
},
|
||||
closeDetailFormDialog() {
|
||||
this.$emit("closeDialog", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,72 +1,79 @@
|
|||
<!-- 通用选择器 -->
|
||||
<template>
|
||||
<treeselect v-model="select_value" :options="selectOptions" :multiple="multiple" :show-count="true"
|
||||
:placeholder="placeholder" :disable-branch-nodes="disable_branch_nodes" style="line-height:20px"/>
|
||||
<treeselect
|
||||
v-model="select_value"
|
||||
:options="selectOptions"
|
||||
:multiple="multiple"
|
||||
:show-count="true"
|
||||
:placeholder="placeholder"
|
||||
:disable-branch-nodes="disable_branch_nodes"
|
||||
style="line-height:20px"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
name: "ModelSelect",
|
||||
components: { Treeselect },
|
||||
props: {
|
||||
/* 选择器的内容 */
|
||||
value: {type: Number || Array,},
|
||||
prop: {type: String,},
|
||||
value: { type: Number || Array },
|
||||
prop: { type: String },
|
||||
/* 用于显示选项 */
|
||||
placeholder: {type: String, default: "请选择",},
|
||||
placeholder: { type: String, default: "请选择" },
|
||||
/* 是否多选 */
|
||||
multiple: {type: Boolean, default: false,},
|
||||
multiple: { type: Boolean, default: false },
|
||||
/* 是否只能选末级 */
|
||||
disable_branch_nodes: {type: Boolean, default: false,},
|
||||
disable_branch_nodes: { type: Boolean, default: false },
|
||||
/* 用于下拉显示名称的字段 */
|
||||
label_name: {type: String, default: 'name',},
|
||||
label_name: { type: String, default: "name" },
|
||||
/* 选择器信息 api 对象 */
|
||||
listApi: {type: Function, default: null},
|
||||
listApi: { type: Function, default: null },
|
||||
/* 选择器信息 selectOptions 对象 */
|
||||
select_options: {type: Array, default: null}
|
||||
select_options: { type: Array, default: null }
|
||||
},
|
||||
components: {Treeselect},
|
||||
data() {
|
||||
return {
|
||||
selectOptions: [],
|
||||
select_value: ''
|
||||
}
|
||||
select_value: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
select_value(newValue) {
|
||||
this.$emit('update:value', newValue)
|
||||
this.$emit("update:value", newValue);
|
||||
},
|
||||
value: {
|
||||
handler: function (newValue) {
|
||||
this.select_value = newValue
|
||||
handler: function(newValue) {
|
||||
this.select_value = newValue;
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
select_options: {
|
||||
handler: function (newValue) {
|
||||
handler: function(newValue) {
|
||||
if (newValue) {
|
||||
this.selectOptions = this.handleTree(newValue, 'id', 'parentId')
|
||||
this.selectOptions = this.handleTree(newValue, "id", "parentId");
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getData()
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
/** 查询所有选择器信息 **/
|
||||
getData() {
|
||||
if (this.select_options) return
|
||||
if (this.select_options) return;
|
||||
this.getModelSelect(this.prop, this.label_name, this.listApi).then(response => {
|
||||
this.selectOptions = response
|
||||
})
|
||||
},
|
||||
this.selectOptions = response;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { scrollTo } from '@/utils/scroll-to'
|
||||
import { scrollTo } from "@/utils/scroll-to";
|
||||
|
||||
export default {
|
||||
name: 'Pagination',
|
||||
name: "Pagination",
|
||||
props: {
|
||||
total: {
|
||||
required: true,
|
||||
|
@ -35,12 +35,12 @@ export default {
|
|||
pageSizes: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [10, 20, 30, 50]
|
||||
return [10, 20, 30, 50];
|
||||
}
|
||||
},
|
||||
layout: {
|
||||
type: String,
|
||||
default: 'total, sizes, prev, pager, next, jumper'
|
||||
default: "total, sizes, prev, pager, next, jumper"
|
||||
},
|
||||
background: {
|
||||
type: Boolean,
|
||||
|
@ -58,36 +58,36 @@ export default {
|
|||
computed: {
|
||||
currentPage: {
|
||||
get() {
|
||||
return this.page
|
||||
return this.page;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:page', val)
|
||||
this.$emit("update:page", val);
|
||||
}
|
||||
},
|
||||
pageSize: {
|
||||
get() {
|
||||
return this.limit
|
||||
return this.limit;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:limit', val)
|
||||
this.$emit("update:limit", val);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSizeChange(val) {
|
||||
this.$emit('pagination', { page: this.currentPage, limit: val })
|
||||
this.$emit("pagination", { page: this.currentPage, limit: val });
|
||||
if (this.autoScroll) {
|
||||
scrollTo(0, 800)
|
||||
scrollTo(0, 800);
|
||||
}
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.$emit('pagination', { page: val, limit: this.pageSize })
|
||||
this.$emit("pagination", { page: val, limit: this.pageSize });
|
||||
if (this.autoScroll) {
|
||||
scrollTo(0, 800)
|
||||
scrollTo(0, 800);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PanThumb',
|
||||
name: "PanThumb",
|
||||
props: {
|
||||
image: {
|
||||
type: String,
|
||||
|
@ -24,14 +24,14 @@ export default {
|
|||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: '150px'
|
||||
default: "150px"
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '150px'
|
||||
default: "150px"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<template >
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { addClass, removeClass } from '@/utils'
|
||||
import { addClass, removeClass } from "@/utils";
|
||||
|
||||
export default {
|
||||
name: 'RightPanel',
|
||||
name: "RightPanel",
|
||||
props: {
|
||||
clickNotClose: {
|
||||
default: false,
|
||||
|
@ -27,57 +27,57 @@ export default {
|
|||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.$store.state.settings.showSettings
|
||||
return this.$store.state.settings.showSettings;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'showSettings',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "showSettings",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
theme() {
|
||||
return this.$store.state.settings.theme
|
||||
},
|
||||
return this.$store.state.settings.theme;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show(value) {
|
||||
if (value && !this.clickNotClose) {
|
||||
this.addEventClick()
|
||||
this.addEventClick();
|
||||
}
|
||||
if (value) {
|
||||
addClass(document.body, 'showRightPanel')
|
||||
addClass(document.body, "showRightPanel");
|
||||
} else {
|
||||
removeClass(document.body, 'showRightPanel')
|
||||
removeClass(document.body, "showRightPanel");
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.insertToBody()
|
||||
this.addEventClick()
|
||||
this.insertToBody();
|
||||
this.addEventClick();
|
||||
},
|
||||
beforeDestroy() {
|
||||
const elx = this.$refs.rightPanel
|
||||
elx.remove()
|
||||
const elx = this.$refs.rightPanel;
|
||||
elx.remove();
|
||||
},
|
||||
methods: {
|
||||
addEventClick() {
|
||||
window.addEventListener('click', this.closeSidebar)
|
||||
window.addEventListener("click", this.closeSidebar);
|
||||
},
|
||||
closeSidebar(evt) {
|
||||
const parent = evt.target.closest('.rightPanel')
|
||||
const parent = evt.target.closest(".rightPanel");
|
||||
if (!parent) {
|
||||
this.show = false
|
||||
window.removeEventListener('click', this.closeSidebar)
|
||||
this.show = false;
|
||||
window.removeEventListener("click", this.closeSidebar);
|
||||
}
|
||||
},
|
||||
insertToBody() {
|
||||
const elx = this.$refs.rightPanel
|
||||
const body = document.querySelector('body')
|
||||
body.insertBefore(elx, body.firstChild)
|
||||
const elx = this.$refs.rightPanel;
|
||||
const body = document.querySelector("body");
|
||||
body.insertBefore(elx, body.firstChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -7,23 +7,32 @@
|
|||
<el-tooltip class="item" effect="dark" content="刷新" placement="top">
|
||||
<el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="显隐列" placement="top" v-if="columns">
|
||||
<el-tooltip v-if="columns" class="item" effect="dark" content="显隐列" placement="top">
|
||||
<el-button size="mini" circle icon="el-icon-menu" @click="showColumn()" />
|
||||
</el-tooltip>
|
||||
</el-row>
|
||||
<el-dialog :title="title" :visible.sync="open" append-to-body>
|
||||
<el-transfer
|
||||
:titles="['显示', '隐藏']"
|
||||
v-model="value"
|
||||
:titles="['显示', '隐藏']"
|
||||
:data="columns"
|
||||
@change="dataChange"
|
||||
></el-transfer>
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "RightToolbar",
|
||||
props: {
|
||||
showSearch: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
columns: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 显隐数据
|
||||
|
@ -31,18 +40,9 @@ export default {
|
|||
// 弹出层标题
|
||||
title: "显示/隐藏",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
open: false
|
||||
};
|
||||
},
|
||||
props: {
|
||||
showSearch: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 搜索
|
||||
|
@ -63,8 +63,8 @@ export default {
|
|||
// 打开显隐列dialog
|
||||
showColumn() {
|
||||
this.open = true;
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<template>
|
||||
<div>
|
||||
<svg-icon icon-class="question" @click="goto"/>
|
||||
<svg-icon icon-class="question" @click="goto" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'RuoYiDoc',
|
||||
name: "RuoYiDoc",
|
||||
data() {
|
||||
return {
|
||||
url: 'http://django-vue-admin.com'
|
||||
}
|
||||
url: "http://django-vue-admin.com"
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
goto() {
|
||||
window.open(this.url)
|
||||
window.open(this.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<template>
|
||||
<div>
|
||||
<svg-icon icon-class="gitee" @click="goto"/>
|
||||
<svg-icon icon-class="gitee" @click="goto" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'RuoYiGit',
|
||||
name: "RuoYiGit",
|
||||
data() {
|
||||
return {
|
||||
url: 'https://gitee.com/liqianglog/django-vue-admin'
|
||||
}
|
||||
url: "https://gitee.com/liqianglog/django-vue-admin"
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
goto() {
|
||||
window.open(this.url)
|
||||
window.open(this.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<template>
|
||||
<div>
|
||||
<svg-icon icon-class="github" @click="goto"/>
|
||||
<svg-icon icon-class="github" @click="goto" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'RuoYiMsg',
|
||||
name: "RuoYiMsg",
|
||||
data() {
|
||||
return {
|
||||
url: 'https://gitee.com/y_project/RuoYi-Vue'
|
||||
}
|
||||
url: "https://gitee.com/y_project/RuoYi-Vue"
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
goto() {
|
||||
window.open(this.url)
|
||||
window.open(this.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -5,44 +5,44 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import screenfull from 'screenfull'
|
||||
import screenfull from "screenfull";
|
||||
|
||||
export default {
|
||||
name: 'Screenfull',
|
||||
name: "Screenfull",
|
||||
data() {
|
||||
return {
|
||||
isFullscreen: false
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
this.init();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.destroy()
|
||||
this.destroy();
|
||||
},
|
||||
methods: {
|
||||
click() {
|
||||
if (!screenfull.isEnabled) {
|
||||
this.$message({ message: '你的浏览器不支持全屏', type: 'warning' })
|
||||
return false
|
||||
this.$message({ message: "你的浏览器不支持全屏", type: "warning" });
|
||||
return false;
|
||||
}
|
||||
screenfull.toggle()
|
||||
screenfull.toggle();
|
||||
},
|
||||
change() {
|
||||
this.isFullscreen = screenfull.isFullscreen
|
||||
this.isFullscreen = screenfull.isFullscreen;
|
||||
},
|
||||
init() {
|
||||
if (screenfull.isEnabled) {
|
||||
screenfull.on('change', this.change)
|
||||
screenfull.on("change", this.change);
|
||||
}
|
||||
},
|
||||
destroy() {
|
||||
if (screenfull.isEnabled) {
|
||||
screenfull.off('change', this.change)
|
||||
screenfull.off("change", this.change);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -17,41 +17,41 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
sizeOptions: [
|
||||
{ label: 'Default', value: 'default' },
|
||||
{ label: 'Medium', value: 'medium' },
|
||||
{ label: 'Small', value: 'small' },
|
||||
{ label: 'Mini', value: 'mini' }
|
||||
{ label: "Default", value: "default" },
|
||||
{ label: "Medium", value: "medium" },
|
||||
{ label: "Small", value: "small" },
|
||||
{ label: "Mini", value: "mini" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
size() {
|
||||
return this.$store.getters.size
|
||||
return this.$store.getters.size;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSetSize(size) {
|
||||
this.$ELEMENT.size = size
|
||||
this.$store.dispatch('app/setSize', size)
|
||||
this.refreshView()
|
||||
this.$ELEMENT.size = size;
|
||||
this.$store.dispatch("app/setSize", size);
|
||||
this.refreshView();
|
||||
this.$message({
|
||||
message: 'Switch Size Success',
|
||||
type: 'success'
|
||||
})
|
||||
message: "Switch Size Success",
|
||||
type: "success"
|
||||
});
|
||||
},
|
||||
refreshView() {
|
||||
// In order to make the cached page re-rendered
|
||||
this.$store.dispatch('tagsView/delAllCachedViews', this.$route)
|
||||
this.$store.dispatch("tagsView/delAllCachedViews", this.$route);
|
||||
|
||||
const { fullPath } = this.$route
|
||||
const { fullPath } = this.$route;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$router.replace({
|
||||
path: '/redirect' + fullPath
|
||||
})
|
||||
})
|
||||
path: "/redirect" + fullPath
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
>
|
||||
<el-row slot="title">
|
||||
<el-col :span="18" style="text-align: left;">
|
||||
<common-icon :icon-title="dialogTitle || 'Dialog组件'" :value="icon" style="font-size: 1.2em"/>
|
||||
<common-icon :icon-title="dialogTitle || 'Dialog组件'" :value="icon" style="font-size: 1.2em" />
|
||||
</el-col>
|
||||
<el-col :span="6" style="text-align: right">
|
||||
<i class="el-icon-close" style="font-size: 30px; cursor: pointer" title="关闭" @click="dialogClose"/>
|
||||
<i class="el-icon-close" style="font-size: 30px; cursor: pointer" title="关闭" @click="dialogClose" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="dialog-body">
|
||||
<slot/>
|
||||
<slot />
|
||||
</div>
|
||||
<slot name="footer">
|
||||
<div class="dialog-button">
|
||||
|
@ -38,62 +38,62 @@
|
|||
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'SmallDialog',
|
||||
props: {
|
||||
value: { type: Boolean, default: false },
|
||||
dialogTitle: { type: String, default: '' },
|
||||
width: { type: String, default: '50%' },
|
||||
icon: { type: String, default: 'el:el-icon-platform-eleme' },
|
||||
buttons: { type: Array, default: () => ['cancel', 'confirm'] },
|
||||
loading: { type: Boolean, default: false },
|
||||
appendToBody: { type: Boolean, default: false },
|
||||
destroyOnClose: { type: Boolean, default: false },
|
||||
closeOnClickModal: { type: Boolean, default: true }
|
||||
export default {
|
||||
name: "SmallDialog",
|
||||
props: {
|
||||
value: { type: Boolean, default: false },
|
||||
dialogTitle: { type: String, default: "" },
|
||||
width: { type: String, default: "50%" },
|
||||
icon: { type: String, default: "el:el-icon-platform-eleme" },
|
||||
buttons: { type: Array, default: () => ["cancel", "confirm"] },
|
||||
loading: { type: Boolean, default: false },
|
||||
appendToBody: { type: Boolean, default: false },
|
||||
destroyOnClose: { type: Boolean, default: false },
|
||||
closeOnClickModal: { type: Boolean, default: true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
size: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.visible = val;
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
size: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.visible = val;
|
||||
},
|
||||
visible(val) {
|
||||
this.$emit('input', val);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.$emit('open');
|
||||
},
|
||||
opened() {
|
||||
this.$emit('opened');
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
},
|
||||
closed() {
|
||||
this.$emit('closed');
|
||||
},
|
||||
confirm() {
|
||||
this.$emit('confirm');
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('cancel');
|
||||
this.dialogClose();
|
||||
},
|
||||
dialogOpen() {
|
||||
},
|
||||
dialogClose() {
|
||||
this.visible = false;
|
||||
}
|
||||
visible(val) {
|
||||
this.$emit("input", val);
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.$emit("open");
|
||||
},
|
||||
opened() {
|
||||
this.$emit("opened");
|
||||
},
|
||||
close() {
|
||||
this.$emit("close");
|
||||
},
|
||||
closed() {
|
||||
this.$emit("closed");
|
||||
},
|
||||
confirm() {
|
||||
this.$emit("confirm");
|
||||
},
|
||||
cancel() {
|
||||
this.$emit("cancel");
|
||||
this.dialogClose();
|
||||
},
|
||||
dialogOpen() {
|
||||
},
|
||||
dialogClose() {
|
||||
this.visible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss">
|
||||
.small-dialog {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { isExternal } from '@/utils/validate'
|
||||
import { isExternal } from "@/utils/validate";
|
||||
|
||||
export default {
|
||||
name: 'SvgIcon',
|
||||
name: "SvgIcon",
|
||||
props: {
|
||||
iconClass: {
|
||||
type: String,
|
||||
|
@ -17,31 +17,31 @@ export default {
|
|||
},
|
||||
className: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isExternal() {
|
||||
return isExternal(this.iconClass)
|
||||
return isExternal(this.iconClass);
|
||||
},
|
||||
iconName() {
|
||||
return `#icon-${this.iconClass}`
|
||||
return `#icon-${this.iconClass}`;
|
||||
},
|
||||
svgClass() {
|
||||
if (this.className) {
|
||||
return 'svg-icon ' + this.className
|
||||
return "svg-icon " + this.className;
|
||||
} else {
|
||||
return 'svg-icon'
|
||||
return "svg-icon";
|
||||
}
|
||||
},
|
||||
styleExternalIcon() {
|
||||
return {
|
||||
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%`
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -8,153 +8,153 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const version = require('element-ui/package.json').version // element-ui version from node_modules
|
||||
const ORIGINAL_THEME = '#409EFF' // default color
|
||||
const version = require("element-ui/package.json").version; // element-ui version from node_modules
|
||||
const ORIGINAL_THEME = "#409EFF"; // default color
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
chalk: '', // content of theme-chalk css
|
||||
theme: ''
|
||||
}
|
||||
chalk: "", // content of theme-chalk css
|
||||
theme: ""
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
defaultTheme() {
|
||||
return this.$store.state.settings.theme
|
||||
return this.$store.state.settings.theme;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
defaultTheme: {
|
||||
handler: function(val, oldVal) {
|
||||
this.theme = val
|
||||
this.theme = val;
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
async theme(val) {
|
||||
const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
|
||||
if (typeof val !== 'string') return
|
||||
const themeCluster = this.getThemeCluster(val.replace('#', ''))
|
||||
const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
|
||||
console.log(themeCluster, originalCluster)
|
||||
const oldVal = this.chalk ? this.theme : ORIGINAL_THEME;
|
||||
if (typeof val !== "string") return;
|
||||
const themeCluster = this.getThemeCluster(val.replace("#", ""));
|
||||
const originalCluster = this.getThemeCluster(oldVal.replace("#", ""));
|
||||
console.log(themeCluster, originalCluster);
|
||||
|
||||
const $message = this.$message({
|
||||
message: ' Compiling the theme',
|
||||
customClass: 'theme-message',
|
||||
type: 'success',
|
||||
message: " Compiling the theme",
|
||||
customClass: "theme-message",
|
||||
type: "success",
|
||||
duration: 0,
|
||||
iconClass: 'el-icon-loading'
|
||||
})
|
||||
iconClass: "el-icon-loading"
|
||||
});
|
||||
|
||||
const getHandler = (variable, id) => {
|
||||
return () => {
|
||||
const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace('#', ''))
|
||||
const newStyle = this.updateStyle(this[variable], originalCluster, themeCluster)
|
||||
const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace("#", ""));
|
||||
const newStyle = this.updateStyle(this[variable], originalCluster, themeCluster);
|
||||
|
||||
let styleTag = document.getElementById(id)
|
||||
let styleTag = document.getElementById(id);
|
||||
if (!styleTag) {
|
||||
styleTag = document.createElement('style')
|
||||
styleTag.setAttribute('id', id)
|
||||
document.head.appendChild(styleTag)
|
||||
styleTag = document.createElement("style");
|
||||
styleTag.setAttribute("id", id);
|
||||
document.head.appendChild(styleTag);
|
||||
}
|
||||
styleTag.innerText = newStyle
|
||||
}
|
||||
}
|
||||
styleTag.innerText = newStyle;
|
||||
};
|
||||
};
|
||||
|
||||
if (!this.chalk) {
|
||||
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`
|
||||
await this.getCSSString(url, 'chalk')
|
||||
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`;
|
||||
await this.getCSSString(url, "chalk");
|
||||
}
|
||||
|
||||
const chalkHandler = getHandler('chalk', 'chalk-style')
|
||||
const chalkHandler = getHandler("chalk", "chalk-style");
|
||||
|
||||
chalkHandler()
|
||||
chalkHandler();
|
||||
|
||||
const styles = [].slice.call(document.querySelectorAll('style'))
|
||||
const styles = [].slice.call(document.querySelectorAll("style"))
|
||||
.filter(style => {
|
||||
const text = style.innerText
|
||||
return new RegExp(oldVal, 'i').test(text) && !/Chalk Variables/.test(text)
|
||||
})
|
||||
const text = style.innerText;
|
||||
return new RegExp(oldVal, "i").test(text) && !/Chalk Variables/.test(text);
|
||||
});
|
||||
styles.forEach(style => {
|
||||
const { innerText } = style
|
||||
if (typeof innerText !== 'string') return
|
||||
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
|
||||
})
|
||||
const { innerText } = style;
|
||||
if (typeof innerText !== "string") return;
|
||||
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster);
|
||||
});
|
||||
|
||||
this.$emit('change', val)
|
||||
this.$emit("change", val);
|
||||
|
||||
$message.close()
|
||||
$message.close();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateStyle(style, oldCluster, newCluster) {
|
||||
let newStyle = style
|
||||
let newStyle = style;
|
||||
oldCluster.forEach((color, index) => {
|
||||
newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index])
|
||||
})
|
||||
return newStyle
|
||||
newStyle = newStyle.replace(new RegExp(color, "ig"), newCluster[index]);
|
||||
});
|
||||
return newStyle;
|
||||
},
|
||||
|
||||
getCSSString(url, variable) {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest()
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
|
||||
resolve()
|
||||
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, "");
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
xhr.open('GET', url)
|
||||
xhr.send()
|
||||
})
|
||||
};
|
||||
xhr.open("GET", url);
|
||||
xhr.send();
|
||||
});
|
||||
},
|
||||
|
||||
getThemeCluster(theme) {
|
||||
const tintColor = (color, tint) => {
|
||||
let red = parseInt(color.slice(0, 2), 16)
|
||||
let green = parseInt(color.slice(2, 4), 16)
|
||||
let blue = parseInt(color.slice(4, 6), 16)
|
||||
let red = parseInt(color.slice(0, 2), 16);
|
||||
let green = parseInt(color.slice(2, 4), 16);
|
||||
let blue = parseInt(color.slice(4, 6), 16);
|
||||
|
||||
if (tint === 0) { // when primary color is in its rgb space
|
||||
return [red, green, blue].join(',')
|
||||
return [red, green, blue].join(",");
|
||||
} else {
|
||||
red += Math.round(tint * (255 - red))
|
||||
green += Math.round(tint * (255 - green))
|
||||
blue += Math.round(tint * (255 - blue))
|
||||
red += Math.round(tint * (255 - red));
|
||||
green += Math.round(tint * (255 - green));
|
||||
blue += Math.round(tint * (255 - blue));
|
||||
|
||||
red = red.toString(16)
|
||||
green = green.toString(16)
|
||||
blue = blue.toString(16)
|
||||
red = red.toString(16);
|
||||
green = green.toString(16);
|
||||
blue = blue.toString(16);
|
||||
|
||||
return `#${red}${green}${blue}`
|
||||
return `#${red}${green}${blue}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const shadeColor = (color, shade) => {
|
||||
let red = parseInt(color.slice(0, 2), 16)
|
||||
let green = parseInt(color.slice(2, 4), 16)
|
||||
let blue = parseInt(color.slice(4, 6), 16)
|
||||
let red = parseInt(color.slice(0, 2), 16);
|
||||
let green = parseInt(color.slice(2, 4), 16);
|
||||
let blue = parseInt(color.slice(4, 6), 16);
|
||||
|
||||
red = Math.round((1 - shade) * red)
|
||||
green = Math.round((1 - shade) * green)
|
||||
blue = Math.round((1 - shade) * blue)
|
||||
red = Math.round((1 - shade) * red);
|
||||
green = Math.round((1 - shade) * green);
|
||||
blue = Math.round((1 - shade) * blue);
|
||||
|
||||
red = red.toString(16)
|
||||
green = green.toString(16)
|
||||
blue = blue.toString(16)
|
||||
red = red.toString(16);
|
||||
green = green.toString(16);
|
||||
blue = blue.toString(16);
|
||||
|
||||
return `#${red}${green}${blue}`
|
||||
}
|
||||
return `#${red}${green}${blue}`;
|
||||
};
|
||||
|
||||
const clusters = [theme]
|
||||
const clusters = [theme];
|
||||
for (let i = 0; i <= 9; i++) {
|
||||
clusters.push(tintColor(theme, Number((i / 10).toFixed(2))))
|
||||
clusters.push(tintColor(theme, Number((i / 10).toFixed(2))));
|
||||
}
|
||||
clusters.push(shadeColor(theme, 0.1))
|
||||
return clusters
|
||||
clusters.push(shadeColor(theme, 0.1));
|
||||
return clusters;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -1,60 +1,67 @@
|
|||
<!-- 用户选择器 -->
|
||||
<template>
|
||||
<div>
|
||||
<treeselect v-model="users_value" :options="usersOptions" :multiple="multiple" :show-count="true"
|
||||
:placeholder="placeholder" :disable-branch-nodes="disable_branch_nodes"/>
|
||||
<treeselect
|
||||
v-model="users_value"
|
||||
:options="usersOptions"
|
||||
:multiple="multiple"
|
||||
:show-count="true"
|
||||
:placeholder="placeholder"
|
||||
:disable-branch-nodes="disable_branch_nodes"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import {listUser} from '@/api/vadmin/permission/user'
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { listUser } from "@/api/vadmin/permission/user";
|
||||
|
||||
export default {
|
||||
name: "DeptTree",
|
||||
props: {
|
||||
/* 选择器的内容 */
|
||||
value: {type: Number | Array,},
|
||||
/* 用于显示选项 */
|
||||
placeholder: {type: String, default: "请选择用户",},
|
||||
/* 是否多选 */
|
||||
multiple: {type: Boolean, default: false,},
|
||||
/* 是否只能选末级 */
|
||||
disable_branch_nodes: {type: Boolean, default: false,},
|
||||
export default {
|
||||
name: "DeptTree",
|
||||
components: { Treeselect },
|
||||
props: {
|
||||
/* 选择器的内容 */
|
||||
// eslint-disable-next-line vue/require-prop-type-constructor
|
||||
value: { type: Number | Array },
|
||||
/* 用于显示选项 */
|
||||
placeholder: { type: String, default: "请选择用户" },
|
||||
/* 是否多选 */
|
||||
multiple: { type: Boolean, default: false },
|
||||
/* 是否只能选末级 */
|
||||
disable_branch_nodes: { type: Boolean, default: false }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
usersOptions: [],
|
||||
users_value: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
users_value(newValue) {
|
||||
this.$emit("update:value", newValue);
|
||||
},
|
||||
components: {Treeselect},
|
||||
data() {
|
||||
return {
|
||||
usersOptions: [],
|
||||
users_value: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
users_value(newValue) {
|
||||
this.$emit('update:value', newValue)
|
||||
},
|
||||
value: {
|
||||
handler: function(newValue) {
|
||||
this.users_value = newValue
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTreeselect()
|
||||
},
|
||||
methods: {
|
||||
/** 查询所有用户信息 **/
|
||||
getTreeselect() {
|
||||
listUser({pageNum: "all", _fields: "id,name"}).then(response => {
|
||||
response.data.map(val => { val["label"] = val['name'] })
|
||||
this.usersOptions = this.handleTree(response.data, 'id')
|
||||
})
|
||||
value: {
|
||||
handler: function(newValue) {
|
||||
this.users_value = newValue;
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTreeselect();
|
||||
},
|
||||
methods: {
|
||||
/** 查询所有用户信息 **/
|
||||
getTreeselect() {
|
||||
listUser({ pageNum: "all", _fields: "id,name" }).then(response => {
|
||||
response.data.map(val => { val["label"] = val["name"]; });
|
||||
this.usersOptions = this.handleTree(response.data, "id");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
/**
|
||||
/**
|
||||
* 操作权限处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
import store from '@/store'
|
||||
|
||||
import store from "@/store";
|
||||
|
||||
export default {
|
||||
inserted(el, binding, vnode) {
|
||||
const { value } = binding
|
||||
const { value } = binding;
|
||||
const all_permission = "*:*:*";
|
||||
const permissions = store.getters && store.getters.permissions
|
||||
const permissions = store.getters && store.getters.permissions;
|
||||
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const permissionFlag = value
|
||||
const permissionFlag = value;
|
||||
|
||||
const hasPermissions = permissions.some(permission => {
|
||||
return all_permission === permission || permissionFlag.includes(permission)
|
||||
})
|
||||
return all_permission === permission || permissionFlag.includes(permission);
|
||||
});
|
||||
|
||||
if (!hasPermissions) {
|
||||
el.parentNode && el.parentNode.removeChild(el)
|
||||
el.parentNode && el.parentNode.removeChild(el);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`请设置操作权限标签值`)
|
||||
throw new Error(`请设置操作权限标签值`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
/**
|
||||
/**
|
||||
* 角色权限处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
import store from '@/store'
|
||||
|
||||
import store from "@/store";
|
||||
|
||||
export default {
|
||||
inserted(el, binding, vnode) {
|
||||
const { value } = binding
|
||||
const { value } = binding;
|
||||
const super_admin = "admin";
|
||||
const roles = store.getters && store.getters.roles
|
||||
const roles = store.getters && store.getters.roles;
|
||||
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const roleFlag = value
|
||||
const roleFlag = value;
|
||||
|
||||
const hasRole = roles.some(role => {
|
||||
return super_admin === role || roleFlag.includes(role)
|
||||
})
|
||||
return super_admin === role || roleFlag.includes(role);
|
||||
});
|
||||
|
||||
if (!hasRole) {
|
||||
el.parentNode && el.parentNode.removeChild(el)
|
||||
el.parentNode && el.parentNode.removeChild(el);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`请设置角色权限标签值"`)
|
||||
throw new Error(`请设置角色权限标签值"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import hasRole from './hasRole'
|
||||
import hasPermi from './hasPermi'
|
||||
import hasRole from "./hasRole";
|
||||
import hasPermi from "./hasPermi";
|
||||
|
||||
const install = function(Vue) {
|
||||
Vue.directive('hasRole', hasRole)
|
||||
Vue.directive('hasPermi', hasPermi)
|
||||
}
|
||||
Vue.directive("hasRole", hasRole);
|
||||
Vue.directive("hasPermi", hasPermi);
|
||||
};
|
||||
|
||||
if (window.Vue) {
|
||||
window['hasRole'] = hasRole
|
||||
window['hasPermi'] = hasPermi
|
||||
window["hasRole"] = hasRole;
|
||||
window["hasPermi"] = hasPermi;
|
||||
Vue.use(install); // eslint-disable-line
|
||||
}
|
||||
|
||||
export default install
|
||||
export default install;
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AppMain',
|
||||
name: "AppMain",
|
||||
computed: {
|
||||
cachedViews() {
|
||||
return this.$store.state.tagsView.cachedViews
|
||||
return this.$store.state.tagsView.cachedViews;
|
||||
},
|
||||
key() {
|
||||
return this.$route.path
|
||||
return this.$route.path;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
<template v-if="device !== 'mobile'">
|
||||
<div class="right-menu-item hover-effect">
|
||||
<router-link to="/user/msg">
|
||||
<i class="el-icon-message-solid badge-item-icon"></i>
|
||||
<el-badge :value="unread_msg_count" :max="99" style="margin-left: -4px;" v-if="unread_msg_count">
|
||||
</el-badge>
|
||||
<i class="el-icon-message-solid badge-item-icon" />
|
||||
<el-badge v-if="unread_msg_count" :value="unread_msg_count" :max="99" style="margin-left: -4px;" />
|
||||
</router-link>
|
||||
</div>
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
|
@ -39,7 +38,7 @@
|
|||
trigger="click"
|
||||
>
|
||||
<div class="avatar-wrapper">
|
||||
<img :src="avatar" class="user-avatar" />
|
||||
<img :src="avatar" class="user-avatar">
|
||||
<i class="el-icon-caret-bottom" />
|
||||
</div>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
|
@ -77,11 +76,11 @@ export default {
|
|||
SizeSelect,
|
||||
Search,
|
||||
RuoYiGit,
|
||||
RuoYiDoc,
|
||||
RuoYiDoc
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
count: store.unread_msg_count,
|
||||
count: store.unread_msg_count
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -93,10 +92,10 @@ export default {
|
|||
set(val) {
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "showSettings",
|
||||
value: val,
|
||||
value: val
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggleSideBar() {
|
||||
|
@ -106,14 +105,14 @@ export default {
|
|||
this.$confirm("确定注销并退出系统吗?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
this.$store.dispatch("LogOut").then(() => {
|
||||
location.href = "/index";
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -10,10 +10,19 @@
|
|||
<img src="@/assets/images/dark.svg" alt="dark">
|
||||
<div v-if="sideTheme === 'theme-dark'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
|
||||
<i aria-label="图标: check" class="anticon anticon-check">
|
||||
<svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true"
|
||||
focusable="false" class="">
|
||||
<svg
|
||||
viewBox="64 64 896 896"
|
||||
data-icon="check"
|
||||
width="1em"
|
||||
height="1em"
|
||||
:fill="theme"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
class=""
|
||||
>
|
||||
<path
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"/>
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"
|
||||
/>
|
||||
</svg>
|
||||
</i>
|
||||
</div>
|
||||
|
@ -22,10 +31,19 @@
|
|||
<img src="@/assets/images/light.svg" alt="light">
|
||||
<div v-if="sideTheme === 'theme-light'" class="setting-drawer-block-checbox-selectIcon" style="display: block;">
|
||||
<i aria-label="图标: check" class="anticon anticon-check">
|
||||
<svg viewBox="64 64 896 896" data-icon="check" width="1em" height="1em" :fill="theme" aria-hidden="true"
|
||||
focusable="false" class="">
|
||||
<svg
|
||||
viewBox="64 64 896 896"
|
||||
data-icon="check"
|
||||
width="1em"
|
||||
height="1em"
|
||||
:fill="theme"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
class=""
|
||||
>
|
||||
<path
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"/>
|
||||
d="M912 190h-69.9c-9.8 0-19.1 4.5-25.1 12.2L404.7 724.5 207 474a32 32 0 0 0-25.1-12.2H112c-6.7 0-10.4 7.7-6.3 12.9l273.9 347c12.8 16.2 37.4 16.2 50.3 0l488.4-618.9c4.1-5.1.4-12.8-6.3-12.8z"
|
||||
/>
|
||||
</svg>
|
||||
</i>
|
||||
</div>
|
||||
|
@ -38,7 +56,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<el-divider/>
|
||||
<el-divider />
|
||||
|
||||
<h3 class="drawer-title">系统布局配置</h3>
|
||||
|
||||
|
@ -62,69 +80,69 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import ThemePicker from '@/components/ThemePicker'
|
||||
import ThemePicker from "@/components/ThemePicker";
|
||||
|
||||
export default {
|
||||
components: { ThemePicker },
|
||||
data() {
|
||||
return {}
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
theme() {
|
||||
return this.$store.state.settings.theme
|
||||
return this.$store.state.settings.theme;
|
||||
},
|
||||
sideTheme() {
|
||||
return this.$store.state.settings.sideTheme
|
||||
return this.$store.state.settings.sideTheme;
|
||||
},
|
||||
fixedHeader: {
|
||||
get() {
|
||||
return this.$store.state.settings.fixedHeader
|
||||
return this.$store.state.settings.fixedHeader;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'fixedHeader',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "fixedHeader",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
tagsView: {
|
||||
get() {
|
||||
return this.$store.state.settings.tagsView
|
||||
return this.$store.state.settings.tagsView;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'tagsView',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "tagsView",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
sidebarLogo: {
|
||||
get() {
|
||||
return this.$store.state.settings.sidebarLogo
|
||||
return this.$store.state.settings.sidebarLogo;
|
||||
},
|
||||
set(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'sidebarLogo',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "sidebarLogo",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
themeChange(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'theme',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "theme",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
},
|
||||
handleTheme(val) {
|
||||
this.$store.dispatch('settings/changeSetting', {
|
||||
key: 'sideTheme',
|
||||
this.$store.dispatch("settings/changeSetting", {
|
||||
key: "sideTheme",
|
||||
value: val
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
export default {
|
||||
computed: {
|
||||
device() {
|
||||
return this.$store.state.app.device
|
||||
return this.$store.state.app.device;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// In order to fix the click on menu on the ios device will trigger the mouseleave bug
|
||||
this.fixBugIniOS()
|
||||
this.fixBugIniOS();
|
||||
},
|
||||
methods: {
|
||||
fixBugIniOS() {
|
||||
const $subMenu = this.$refs.subMenu
|
||||
const $subMenu = this.$refs.subMenu;
|
||||
if ($subMenu) {
|
||||
const handleMouseleave = $subMenu.handleMouseleave
|
||||
const handleMouseleave = $subMenu.handleMouseleave;
|
||||
$subMenu.handleMouseleave = (e) => {
|
||||
if (this.device === 'mobile') {
|
||||
return
|
||||
if (this.device === "mobile") {
|
||||
return;
|
||||
}
|
||||
handleMouseleave(e)
|
||||
}
|
||||
handleMouseleave(e);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
<script>
|
||||
export default {
|
||||
name: 'MenuItem',
|
||||
name: "MenuItem",
|
||||
functional: true,
|
||||
props: {
|
||||
icon: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
render(h, context) {
|
||||
const { icon, title } = context.props
|
||||
const vnodes = []
|
||||
const { icon, title } = context.props;
|
||||
const vnodes = [];
|
||||
|
||||
if (icon) {
|
||||
vnodes.push(<svg-icon icon-class={icon}/>)
|
||||
vnodes.push(<svg-icon icon-class={icon}/>);
|
||||
}
|
||||
|
||||
if (title) {
|
||||
vnodes.push(<span slot='title'>{(title)}</span>)
|
||||
vnodes.push(<span slot='title'>{(title)}</span>);
|
||||
}
|
||||
return vnodes
|
||||
return vnodes;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { isExternal } from '@/utils/validate'
|
||||
import { isExternal } from "@/utils/validate";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
@ -16,13 +16,13 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isExternal() {
|
||||
return isExternal(this.to)
|
||||
return isExternal(this.to);
|
||||
},
|
||||
type() {
|
||||
if (this.isExternal) {
|
||||
return 'a'
|
||||
return "a";
|
||||
}
|
||||
return 'router-link'
|
||||
return "router-link";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -30,14 +30,14 @@ export default {
|
|||
if (this.isExternal) {
|
||||
return {
|
||||
href: to,
|
||||
target: '_blank',
|
||||
rel: 'noopener'
|
||||
}
|
||||
target: "_blank",
|
||||
rel: "noopener"
|
||||
};
|
||||
}
|
||||
return {
|
||||
to: to
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -14,32 +14,32 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import logoImg from '@/assets/logo/logo.png'
|
||||
import variables from '@/assets/styles/variables.scss'
|
||||
import logoImg from "@/assets/logo/logo.png";
|
||||
import variables from "@/assets/styles/variables.scss";
|
||||
|
||||
export default {
|
||||
name: 'SidebarLogo',
|
||||
name: "SidebarLogo",
|
||||
props: {
|
||||
collapse: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: process.env.VUE_APP_TITLE || "dvAdmin管理系统",
|
||||
logo: logoImg
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
variables() {
|
||||
return variables;
|
||||
},
|
||||
sideTheme() {
|
||||
return this.$store.state.settings.sideTheme
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: process.env.VUE_APP_TITLE || 'dvAdmin管理系统',
|
||||
logo: logoImg
|
||||
sideTheme() {
|
||||
return this.$store.state.settings.sideTheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import path from 'path'
|
||||
import { isExternal } from '@/utils/validate'
|
||||
import Item from './Item'
|
||||
import AppLink from './Link'
|
||||
import FixiOSBug from './FixiOSBug'
|
||||
import path from "path";
|
||||
import { isExternal } from "@/utils/validate";
|
||||
import Item from "./Item";
|
||||
import AppLink from "./Link";
|
||||
import FixiOSBug from "./FixiOSBug";
|
||||
|
||||
export default {
|
||||
name: 'SidebarItem',
|
||||
name: "SidebarItem",
|
||||
components: { Item, AppLink },
|
||||
mixins: [FixiOSBug],
|
||||
props: {
|
||||
|
@ -47,12 +47,12 @@ export default {
|
|||
},
|
||||
basePath: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
this.onlyOneChild = null
|
||||
return {}
|
||||
this.onlyOneChild = null;
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
hasOneShowingChild(children = [], parent) {
|
||||
|
@ -61,36 +61,36 @@ export default {
|
|||
}
|
||||
const showingChildren = children.filter(item => {
|
||||
if (item.hidden) {
|
||||
return false
|
||||
return false;
|
||||
} else {
|
||||
// Temp set(will be used if only has one showing child)
|
||||
this.onlyOneChild = item
|
||||
return true
|
||||
this.onlyOneChild = item;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// When there is only one child router, the child router is displayed by default
|
||||
if (showingChildren.length === 1) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
// Show parent if there are no child router to display
|
||||
if (showingChildren.length === 0) {
|
||||
this.onlyOneChild = { ... parent, path: '', noShowingChildren: true }
|
||||
return true
|
||||
this.onlyOneChild = { ... parent, path: "", noShowingChildren: true };
|
||||
return true;
|
||||
}
|
||||
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
resolvePath(routePath) {
|
||||
if (isExternal(routePath)) {
|
||||
return routePath
|
||||
return routePath;
|
||||
}
|
||||
if (isExternal(this.basePath)) {
|
||||
return this.basePath
|
||||
return this.basePath;
|
||||
}
|
||||
return path.resolve(this.basePath, routePath)
|
||||
return path.resolve(this.basePath, routePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<template>
|
||||
<div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
|
||||
<logo v-if="showLogo" :collapse="isCollapse" />
|
||||
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
||||
<el-menu
|
||||
:default-active="activeMenu"
|
||||
:collapse="isCollapse"
|
||||
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
|
||||
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
|
||||
:unique-opened="true"
|
||||
:active-text-color="settings.theme"
|
||||
:collapse-transition="false"
|
||||
mode="vertical"
|
||||
>
|
||||
<sidebar-item
|
||||
v-for="(route, index) in sidebarRouters"
|
||||
:key="route.path + index"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
/>
|
||||
</el-menu>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
<div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
|
||||
<logo v-if="showLogo" :collapse="isCollapse" />
|
||||
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
|
||||
<el-menu
|
||||
:default-active="activeMenu"
|
||||
:collapse="isCollapse"
|
||||
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
|
||||
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
|
||||
:unique-opened="true"
|
||||
:active-text-color="settings.theme"
|
||||
:collapse-transition="false"
|
||||
mode="vertical"
|
||||
>
|
||||
<sidebar-item
|
||||
v-for="(route, index) in sidebarRouters"
|
||||
:key="route.path + index"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
/>
|
||||
</el-menu>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -30,28 +30,28 @@ import SidebarItem from "./SidebarItem";
|
|||
import variables from "@/assets/styles/variables.scss";
|
||||
|
||||
export default {
|
||||
components: { SidebarItem, Logo },
|
||||
computed: {
|
||||
...mapState(["settings"]),
|
||||
...mapGetters(["sidebarRouters", "sidebar"]),
|
||||
activeMenu() {
|
||||
const route = this.$route;
|
||||
const { meta, path } = route;
|
||||
// if set path, the sidebar will highlight the path you set
|
||||
if (meta.activeMenu) {
|
||||
return meta.activeMenu;
|
||||
}
|
||||
return path;
|
||||
},
|
||||
showLogo() {
|
||||
return this.$store.state.settings.sidebarLogo;
|
||||
},
|
||||
variables() {
|
||||
return variables;
|
||||
},
|
||||
isCollapse() {
|
||||
return !this.sidebar.opened;
|
||||
}
|
||||
components: { SidebarItem, Logo },
|
||||
computed: {
|
||||
...mapState(["settings"]),
|
||||
...mapGetters(["sidebarRouters", "sidebar"]),
|
||||
activeMenu() {
|
||||
const route = this.$route;
|
||||
const { meta, path } = route;
|
||||
// if set path, the sidebar will highlight the path you set
|
||||
if (meta.activeMenu) {
|
||||
return meta.activeMenu;
|
||||
}
|
||||
return path;
|
||||
},
|
||||
showLogo() {
|
||||
return this.$store.state.settings.sidebarLogo;
|
||||
},
|
||||
variables() {
|
||||
return variables;
|
||||
},
|
||||
isCollapse() {
|
||||
return !this.sidebar.opened;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -5,75 +5,75 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const tagAndTagSpacing = 4 // tagAndTagSpacing
|
||||
const tagAndTagSpacing = 4; // tagAndTagSpacing
|
||||
|
||||
export default {
|
||||
name: 'ScrollPane',
|
||||
name: "ScrollPane",
|
||||
data() {
|
||||
return {
|
||||
left: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
scrollWrapper() {
|
||||
return this.$refs.scrollContainer.$refs.wrap
|
||||
return this.$refs.scrollContainer.$refs.wrap;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.scrollWrapper.addEventListener('scroll', this.emitScroll, true)
|
||||
this.scrollWrapper.addEventListener("scroll", this.emitScroll, true);
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.scrollWrapper.removeEventListener('scroll', this.emitScroll)
|
||||
this.scrollWrapper.removeEventListener("scroll", this.emitScroll);
|
||||
},
|
||||
methods: {
|
||||
handleScroll(e) {
|
||||
const eventDelta = e.wheelDelta || -e.deltaY * 40
|
||||
const $scrollWrapper = this.scrollWrapper
|
||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4
|
||||
const eventDelta = e.wheelDelta || -e.deltaY * 40;
|
||||
const $scrollWrapper = this.scrollWrapper;
|
||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4;
|
||||
},
|
||||
emitScroll() {
|
||||
this.$emit('scroll')
|
||||
this.$emit("scroll");
|
||||
},
|
||||
moveToTarget(currentTag) {
|
||||
const $container = this.$refs.scrollContainer.$el
|
||||
const $containerWidth = $container.offsetWidth
|
||||
const $scrollWrapper = this.scrollWrapper
|
||||
const tagList = this.$parent.$refs.tag
|
||||
const $container = this.$refs.scrollContainer.$el;
|
||||
const $containerWidth = $container.offsetWidth;
|
||||
const $scrollWrapper = this.scrollWrapper;
|
||||
const tagList = this.$parent.$refs.tag;
|
||||
|
||||
let firstTag = null
|
||||
let lastTag = null
|
||||
let firstTag = null;
|
||||
let lastTag = null;
|
||||
|
||||
// find first tag and last tag
|
||||
if (tagList.length > 0) {
|
||||
firstTag = tagList[0]
|
||||
lastTag = tagList[tagList.length - 1]
|
||||
firstTag = tagList[0];
|
||||
lastTag = tagList[tagList.length - 1];
|
||||
}
|
||||
|
||||
if (firstTag === currentTag) {
|
||||
$scrollWrapper.scrollLeft = 0
|
||||
$scrollWrapper.scrollLeft = 0;
|
||||
} else if (lastTag === currentTag) {
|
||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth
|
||||
$scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth;
|
||||
} else {
|
||||
// find preTag and nextTag
|
||||
const currentIndex = tagList.findIndex(item => item === currentTag)
|
||||
const prevTag = tagList[currentIndex - 1]
|
||||
const nextTag = tagList[currentIndex + 1]
|
||||
const currentIndex = tagList.findIndex(item => item === currentTag);
|
||||
const prevTag = tagList[currentIndex - 1];
|
||||
const nextTag = tagList[currentIndex + 1];
|
||||
|
||||
// the tag's offsetLeft after of nextTag
|
||||
const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing
|
||||
const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing;
|
||||
|
||||
// the tag's offsetLeft before of prevTag
|
||||
const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing
|
||||
const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing;
|
||||
|
||||
if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) {
|
||||
$scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth
|
||||
$scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth;
|
||||
} else if (beforePrevTagOffsetLeft < $scrollWrapper.scrollLeft) {
|
||||
$scrollWrapper.scrollLeft = beforePrevTagOffsetLeft
|
||||
$scrollWrapper.scrollLeft = beforePrevTagOffsetLeft;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import ScrollPane from './ScrollPane'
|
||||
import path from 'path'
|
||||
import ScrollPane from "./ScrollPane";
|
||||
import path from "path";
|
||||
|
||||
export default {
|
||||
components: { ScrollPane },
|
||||
|
@ -39,14 +39,14 @@ export default {
|
|||
left: 0,
|
||||
selectedTag: {},
|
||||
affixTags: []
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
visitedViews() {
|
||||
return this.$store.state.tagsView.visitedViews
|
||||
return this.$store.state.tagsView.visitedViews;
|
||||
},
|
||||
routes() {
|
||||
return this.$store.state.permission.routes
|
||||
return this.$store.state.permission.routes;
|
||||
},
|
||||
theme() {
|
||||
return this.$store.state.settings.theme;
|
||||
|
@ -54,24 +54,24 @@ export default {
|
|||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.addTags()
|
||||
this.moveToCurrentTag()
|
||||
this.addTags();
|
||||
this.moveToCurrentTag();
|
||||
},
|
||||
visible(value) {
|
||||
if (value) {
|
||||
document.body.addEventListener('click', this.closeMenu)
|
||||
document.body.addEventListener("click", this.closeMenu);
|
||||
} else {
|
||||
document.body.removeEventListener('click', this.closeMenu)
|
||||
document.body.removeEventListener("click", this.closeMenu);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initTags()
|
||||
this.addTags()
|
||||
this.initTags();
|
||||
this.addTags();
|
||||
},
|
||||
methods: {
|
||||
isActive(route) {
|
||||
return route.path === this.$route.path
|
||||
return route.path === this.$route.path;
|
||||
},
|
||||
activeStyle(tag) {
|
||||
if (!this.isActive(tag)) return {};
|
||||
|
@ -81,131 +81,131 @@ export default {
|
|||
};
|
||||
},
|
||||
isAffix(tag) {
|
||||
return tag.meta && tag.meta.affix
|
||||
return tag.meta && tag.meta.affix;
|
||||
},
|
||||
filterAffixTags(routes, basePath = '/') {
|
||||
let tags = []
|
||||
filterAffixTags(routes, basePath = "/") {
|
||||
let tags = [];
|
||||
routes.forEach(route => {
|
||||
if (route.meta && route.meta.affix) {
|
||||
const tagPath = path.resolve(basePath, route.path)
|
||||
const tagPath = path.resolve(basePath, route.path);
|
||||
tags.push({
|
||||
fullPath: tagPath,
|
||||
path: tagPath,
|
||||
name: route.name,
|
||||
meta: { ...route.meta }
|
||||
})
|
||||
});
|
||||
}
|
||||
if (route.children) {
|
||||
const tempTags = this.filterAffixTags(route.children, route.path)
|
||||
const tempTags = this.filterAffixTags(route.children, route.path);
|
||||
if (tempTags.length >= 1) {
|
||||
tags = [...tags, ...tempTags]
|
||||
tags = [...tags, ...tempTags];
|
||||
}
|
||||
}
|
||||
})
|
||||
return tags
|
||||
});
|
||||
return tags;
|
||||
},
|
||||
initTags() {
|
||||
const affixTags = this.affixTags = this.filterAffixTags(this.routes)
|
||||
const affixTags = this.affixTags = this.filterAffixTags(this.routes);
|
||||
for (const tag of affixTags) {
|
||||
// Must have tag name
|
||||
if (tag.name) {
|
||||
this.$store.dispatch('tagsView/addVisitedView', tag)
|
||||
this.$store.dispatch("tagsView/addVisitedView", tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
addTags() {
|
||||
const { name } = this.$route
|
||||
const { name } = this.$route;
|
||||
if (name) {
|
||||
this.$store.dispatch('tagsView/addView', this.$route)
|
||||
this.$store.dispatch("tagsView/addView", this.$route);
|
||||
}
|
||||
return false
|
||||
return false;
|
||||
},
|
||||
moveToCurrentTag() {
|
||||
const tags = this.$refs.tag
|
||||
const tags = this.$refs.tag;
|
||||
this.$nextTick(() => {
|
||||
for (const tag of tags) {
|
||||
if (tag.to.path === this.$route.path) {
|
||||
this.$refs.scrollPane.moveToTarget(tag)
|
||||
this.$refs.scrollPane.moveToTarget(tag);
|
||||
// when query is different then update
|
||||
if (tag.to.fullPath !== this.$route.fullPath) {
|
||||
this.$store.dispatch('tagsView/updateVisitedView', this.$route)
|
||||
this.$store.dispatch("tagsView/updateVisitedView", this.$route);
|
||||
}
|
||||
break
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
refreshSelectedTag(view) {
|
||||
this.$store.dispatch('tagsView/delCachedView', view).then(() => {
|
||||
const { fullPath } = view
|
||||
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
||||
const { fullPath } = view;
|
||||
this.$nextTick(() => {
|
||||
this.$router.replace({
|
||||
path: '/redirect' + fullPath
|
||||
})
|
||||
})
|
||||
})
|
||||
path: "/redirect" + fullPath
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
closeSelectedTag(view) {
|
||||
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
|
||||
this.$store.dispatch("tagsView/delView", view).then(({ visitedViews }) => {
|
||||
if (this.isActive(view)) {
|
||||
this.toLastView(visitedViews, view)
|
||||
this.toLastView(visitedViews, view);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
closeOthersTags() {
|
||||
this.$router.push(this.selectedTag).catch(()=>{});
|
||||
this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => {
|
||||
this.moveToCurrentTag()
|
||||
})
|
||||
this.$router.push(this.selectedTag).catch(() => {});
|
||||
this.$store.dispatch("tagsView/delOthersViews", this.selectedTag).then(() => {
|
||||
this.moveToCurrentTag();
|
||||
});
|
||||
},
|
||||
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)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
this.toLastView(visitedViews, view)
|
||||
})
|
||||
this.toLastView(visitedViews, view);
|
||||
});
|
||||
},
|
||||
toLastView(visitedViews, view) {
|
||||
const latestView = visitedViews.slice(-1)[0]
|
||||
const latestView = visitedViews.slice(-1)[0];
|
||||
if (latestView) {
|
||||
this.$router.push(latestView.fullPath)
|
||||
this.$router.push(latestView.fullPath);
|
||||
} else {
|
||||
// now the default is to redirect to the home page if there is no tags-view,
|
||||
// you can adjust it according to your needs.
|
||||
if (view.name === 'Dashboard') {
|
||||
if (view.name === "Dashboard") {
|
||||
// to reload home page
|
||||
this.$router.replace({ path: '/redirect' + view.fullPath })
|
||||
this.$router.replace({ path: "/redirect" + view.fullPath });
|
||||
} else {
|
||||
this.$router.push('/')
|
||||
this.$router.push("/");
|
||||
}
|
||||
}
|
||||
},
|
||||
openMenu(tag, e) {
|
||||
const menuMinWidth = 105
|
||||
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
||||
const offsetWidth = this.$el.offsetWidth // container width
|
||||
const maxLeft = offsetWidth - menuMinWidth // left boundary
|
||||
const left = e.clientX - offsetLeft + 15 // 15: margin right
|
||||
const menuMinWidth = 105;
|
||||
const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
|
||||
const offsetWidth = this.$el.offsetWidth; // container width
|
||||
const maxLeft = offsetWidth - menuMinWidth; // left boundary
|
||||
const left = e.clientX - offsetLeft + 15; // 15: margin right
|
||||
|
||||
if (left > maxLeft) {
|
||||
this.left = maxLeft
|
||||
this.left = maxLeft;
|
||||
} else {
|
||||
this.left = left
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
this.top = e.clientY
|
||||
this.visible = true
|
||||
this.selectedTag = tag
|
||||
this.top = e.clientY;
|
||||
this.visible = true;
|
||||
this.selectedTag = tag;
|
||||
},
|
||||
closeMenu() {
|
||||
this.visible = false
|
||||
this.visible = false;
|
||||
},
|
||||
handleScroll() {
|
||||
this.closeMenu()
|
||||
this.closeMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export { default as AppMain } from './AppMain'
|
||||
export { default as Navbar } from './Navbar'
|
||||
export { default as Settings } from './Settings'
|
||||
export { default as Sidebar } from './Sidebar/index.vue'
|
||||
export { default as TagsView } from './TagsView/index.vue'
|
||||
export { default as AppMain } from "./AppMain";
|
||||
export { default as Navbar } from "./Navbar";
|
||||
export { default as Settings } from "./Settings";
|
||||
export { default as Sidebar } from "./Sidebar/index.vue";
|
||||
export { default as TagsView } from "./TagsView/index.vue";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div :class="classObj" class="app-wrapper" :style="{'--current-color': theme}">
|
||||
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside"/>
|
||||
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
|
||||
<sidebar class="sidebar-container" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }" />
|
||||
<div :class="{hasTagsView:needTagsView}" class="main-container">
|
||||
<div :class="{'fixed-header':fixedHeader}">
|
||||
|
@ -16,14 +16,14 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import RightPanel from '@/components/RightPanel'
|
||||
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
|
||||
import ResizeMixin from './mixin/ResizeHandler'
|
||||
import { mapState } from 'vuex'
|
||||
import variables from '@/assets/styles/variables.scss'
|
||||
import RightPanel from "@/components/RightPanel";
|
||||
import { AppMain, Navbar, Settings, Sidebar, TagsView } from "./components";
|
||||
import ResizeMixin from "./mixin/ResizeHandler";
|
||||
import { mapState } from "vuex";
|
||||
import variables from "@/assets/styles/variables.scss";
|
||||
|
||||
export default {
|
||||
name: 'Layout',
|
||||
name: "Layout",
|
||||
components: {
|
||||
AppMain,
|
||||
Navbar,
|
||||
|
@ -48,8 +48,8 @@ export default {
|
|||
hideSidebar: !this.sidebar.opened,
|
||||
openSidebar: this.sidebar.opened,
|
||||
withoutAnimation: this.sidebar.withoutAnimation,
|
||||
mobile: this.device === 'mobile'
|
||||
}
|
||||
mobile: this.device === "mobile"
|
||||
};
|
||||
},
|
||||
variables() {
|
||||
return variables;
|
||||
|
@ -57,10 +57,10 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
handleClickOutside() {
|
||||
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
||||
this.$store.dispatch("app/closeSideBar", { withoutAnimation: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
import store from '@/store'
|
||||
import store from "@/store";
|
||||
|
||||
const { body } = document
|
||||
const WIDTH = 992 // refer to Bootstrap's responsive design
|
||||
const { body } = document;
|
||||
const WIDTH = 992; // refer to Bootstrap's responsive design
|
||||
|
||||
export default {
|
||||
watch: {
|
||||
$route(route) {
|
||||
if (this.device === 'mobile' && this.sidebar.opened) {
|
||||
store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
||||
if (this.device === "mobile" && this.sidebar.opened) {
|
||||
store.dispatch("app/closeSideBar", { withoutAnimation: false });
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
window.addEventListener('resize', this.$_resizeHandler)
|
||||
window.addEventListener("resize", this.$_resizeHandler);
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.$_resizeHandler)
|
||||
window.removeEventListener("resize", this.$_resizeHandler);
|
||||
},
|
||||
mounted() {
|
||||
const isMobile = this.$_isMobile()
|
||||
const isMobile = this.$_isMobile();
|
||||
if (isMobile) {
|
||||
store.dispatch('app/toggleDevice', 'mobile')
|
||||
store.dispatch('app/closeSideBar', { withoutAnimation: true })
|
||||
store.dispatch("app/toggleDevice", "mobile");
|
||||
store.dispatch("app/closeSideBar", { withoutAnimation: true });
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// use $_ for mixins properties
|
||||
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
|
||||
$_isMobile() {
|
||||
const rect = body.getBoundingClientRect()
|
||||
return rect.width - 1 < WIDTH
|
||||
const rect = body.getBoundingClientRect();
|
||||
return rect.width - 1 < WIDTH;
|
||||
},
|
||||
$_resizeHandler() {
|
||||
if (!document.hidden) {
|
||||
const isMobile = this.$_isMobile()
|
||||
store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
|
||||
const isMobile = this.$_isMobile();
|
||||
store.dispatch("app/toggleDevice", isMobile ? "mobile" : "desktop");
|
||||
|
||||
if (isMobile) {
|
||||
store.dispatch('app/closeSideBar', { withoutAnimation: true })
|
||||
store.dispatch("app/closeSideBar", { withoutAnimation: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import Vue from 'vue'
|
||||
import Vue from "vue";
|
||||
|
||||
import Cookies from 'js-cookie'
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
import Element from 'element-ui'
|
||||
import './assets/styles/element-variables.scss'
|
||||
import Element from "element-ui";
|
||||
import "./assets/styles/element-variables.scss";
|
||||
|
||||
import '@/assets/styles/index.scss' // global css
|
||||
import '@/assets/styles/ruoyi.scss' // ruoyi css
|
||||
import App from './App'
|
||||
import store from './store'
|
||||
import router from './router'
|
||||
import permission from './directive/permission'
|
||||
import "@/assets/styles/index.scss"; // global css
|
||||
import "@/assets/styles/ruoyi.scss"; // ruoyi css
|
||||
import App from "./App";
|
||||
import store from "./store";
|
||||
import router from "./router";
|
||||
import permission from "./directive/permission";
|
||||
|
||||
import './assets/icons' // icon
|
||||
import './permission' // permission control
|
||||
import {getDicts} from "@/api/vadmin/system/dict/data";
|
||||
import {getConfigKey} from "@/api/vadmin/system/config";
|
||||
import "./assets/icons"; // icon
|
||||
import "./permission"; // permission control
|
||||
import { getDicts } from "@/api/vadmin/system/dict/data";
|
||||
import { getConfigKey } from "@/api/vadmin/system/config";
|
||||
import {
|
||||
addDateRange,
|
||||
download,
|
||||
|
@ -28,60 +28,60 @@ import {
|
|||
} from "@/utils/ruoyi";
|
||||
import Pagination from "@/components/Pagination";
|
||||
// 自定义表格工具扩展
|
||||
import RightToolbar from "@/components/RightToolbar"
|
||||
import SmallDialog from '@/components/SmallDialog';
|
||||
import DeptTree from '@/components/DeptTree';
|
||||
import UsersTree from '@/components/UsersTree';
|
||||
import ModelDisplay from '@/components/ModelDisplay';
|
||||
import CommonIcon from '@/components/CommonIcon';
|
||||
import CommonStaticTable from '@/components/CommonStaticTable';
|
||||
import {getCrontabData, getIntervalData} from "./utils/validate"; // 通用图标组件
|
||||
import {getModelSelect} from "@/utils/modelSelect";
|
||||
import RightToolbar from "@/components/RightToolbar";
|
||||
import SmallDialog from "@/components/SmallDialog";
|
||||
import DeptTree from "@/components/DeptTree";
|
||||
import UsersTree from "@/components/UsersTree";
|
||||
import ModelDisplay from "@/components/ModelDisplay";
|
||||
import CommonIcon from "@/components/CommonIcon";
|
||||
import CommonStaticTable from "@/components/CommonStaticTable";
|
||||
import { getCrontabData, getIntervalData } from "./utils/validate"; // 通用图标组件
|
||||
import { getModelSelect } from "@/utils/modelSelect";
|
||||
|
||||
// 全局方法挂载
|
||||
Vue.prototype.getDicts = getDicts
|
||||
Vue.prototype.getConfigKey = getConfigKey
|
||||
Vue.prototype.getModelSelect = getModelSelect
|
||||
Vue.prototype.parseTime = parseTime
|
||||
Vue.prototype.resetForm = resetForm
|
||||
Vue.prototype.addDateRange = addDateRange
|
||||
Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictDefault = selectDictDefault
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.getCrontabData = getCrontabData
|
||||
Vue.prototype.getIntervalData = getIntervalData
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.hasPermi = function (values) {
|
||||
const permissions = store.getters && store.getters.permissions
|
||||
Vue.prototype.getDicts = getDicts;
|
||||
Vue.prototype.getConfigKey = getConfigKey;
|
||||
Vue.prototype.getModelSelect = getModelSelect;
|
||||
Vue.prototype.parseTime = parseTime;
|
||||
Vue.prototype.resetForm = resetForm;
|
||||
Vue.prototype.addDateRange = addDateRange;
|
||||
Vue.prototype.selectDictLabel = selectDictLabel;
|
||||
Vue.prototype.selectDictDefault = selectDictDefault;
|
||||
Vue.prototype.selectDictLabels = selectDictLabels;
|
||||
Vue.prototype.getCrontabData = getCrontabData;
|
||||
Vue.prototype.getIntervalData = getIntervalData;
|
||||
Vue.prototype.download = download;
|
||||
Vue.prototype.handleTree = handleTree;
|
||||
Vue.prototype.hasPermi = function(values) {
|
||||
const permissions = store.getters && store.getters.permissions;
|
||||
return permissions.some(permission => {
|
||||
return "*:*:*" === permission || values.includes(permission)
|
||||
})
|
||||
return permission === "*:*:*" || values.includes(permission);
|
||||
});
|
||||
};
|
||||
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
this.$message({showClose: true, message: msg, type: "success"});
|
||||
}
|
||||
Vue.prototype.msgSuccess = function(msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "success" });
|
||||
};
|
||||
|
||||
Vue.prototype.msgError = function (msg) {
|
||||
this.$message({showClose: true, message: msg, type: "error"});
|
||||
}
|
||||
Vue.prototype.msgError = function(msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "error" });
|
||||
};
|
||||
|
||||
Vue.prototype.msgInfo = function (msg) {
|
||||
Vue.prototype.msgInfo = function(msg) {
|
||||
this.$message.info(msg);
|
||||
}
|
||||
};
|
||||
// 自定义组件
|
||||
Vue.component('small-dialog', SmallDialog);
|
||||
Vue.component('dept-tree', DeptTree);
|
||||
Vue.component('users-tree', UsersTree);
|
||||
Vue.component('model-display', ModelDisplay);
|
||||
Vue.component("SmallDialog", SmallDialog);
|
||||
Vue.component("DeptTree", DeptTree);
|
||||
Vue.component("UsersTree", UsersTree);
|
||||
Vue.component("ModelDisplay", ModelDisplay);
|
||||
// 全局组件挂载
|
||||
Vue.component('Pagination', Pagination)
|
||||
Vue.component('RightToolbar', RightToolbar)
|
||||
Vue.component('common-icon', CommonIcon);
|
||||
Vue.component('common-static-table', CommonStaticTable);
|
||||
Vue.component("Pagination", Pagination);
|
||||
Vue.component("RightToolbar", RightToolbar);
|
||||
Vue.component("CommonIcon", CommonIcon);
|
||||
Vue.component("CommonStaticTable", CommonStaticTable);
|
||||
|
||||
Vue.use(permission)
|
||||
Vue.use(permission);
|
||||
|
||||
/**
|
||||
* If you don't want to use mock-server
|
||||
|
@ -93,14 +93,14 @@ Vue.use(permission)
|
|||
*/
|
||||
|
||||
Vue.use(Element, {
|
||||
size: Cookies.get('size') || 'medium' // set element-ui default size
|
||||
})
|
||||
size: Cookies.get("size") || "medium" // set element-ui default size
|
||||
});
|
||||
|
||||
Vue.config.productionTip = false
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
el: "#app",
|
||||
router,
|
||||
store,
|
||||
render: h => h(App)
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
import router from './router'
|
||||
import store from './store'
|
||||
import { Message } from 'element-ui'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import router from "./router";
|
||||
import store from "./store";
|
||||
import { Message } from "element-ui";
|
||||
import NProgress from "nprogress";
|
||||
import "nprogress/nprogress.css";
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
NProgress.configure({ showSpinner: false });
|
||||
|
||||
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
|
||||
const whiteList = ["/login", "/auth-redirect", "/bind", "/register"];
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start()
|
||||
NProgress.start();
|
||||
if (getToken()) {
|
||||
/* has token*/
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
if (to.path === "/login") {
|
||||
next({ path: "/" });
|
||||
NProgress.done();
|
||||
} else {
|
||||
if (store.getters.roles.length === 0) {
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
store.dispatch('GetInfo').then(res => {
|
||||
store.dispatch("GetInfo").then(res => {
|
||||
// 拉取user_info
|
||||
const roles = res.roles
|
||||
store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
|
||||
const roles = res.roles;
|
||||
store.dispatch("GenerateRoutes", { roles }).then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
})
|
||||
router.addRoutes(accessRoutes); // 动态添加可访问路由表
|
||||
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
|
||||
});
|
||||
}).catch(err => {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
Message.error(err)
|
||||
next({ path: '/' })
|
||||
})
|
||||
})
|
||||
store.dispatch("LogOut").then(() => {
|
||||
Message.error(err);
|
||||
next({ path: "/" });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
next()
|
||||
next();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有token
|
||||
if (whiteList.indexOf(to.path) !== -1) {
|
||||
// 在免登录白名单,直接进入
|
||||
next()
|
||||
next();
|
||||
} else {
|
||||
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||
NProgress.done()
|
||||
next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
|
||||
NProgress.done();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done()
|
||||
})
|
||||
NProgress.done();
|
||||
});
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import Vue from "vue";
|
||||
import Router from "vue-router";
|
||||
|
||||
Vue.use(Router)
|
||||
Vue.use(Router);
|
||||
|
||||
/* Layout */
|
||||
import Layout from '@/layout'
|
||||
import ParentView from '@/components/ParentView';
|
||||
import Layout from "@/layout";
|
||||
|
||||
/**
|
||||
* Note: 路由配置项
|
||||
|
@ -28,35 +27,35 @@ import ParentView from '@/components/ParentView';
|
|||
// 公共路由
|
||||
export const constantRoutes = [
|
||||
{
|
||||
path: '/redirect',
|
||||
path: "/redirect",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: '/redirect/:path(.*)',
|
||||
component: (resolve) => require(['@/views/redirect'], resolve)
|
||||
path: "/redirect/:path(.*)",
|
||||
component: (resolve) => require(["@/views/redirect"], resolve)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: (resolve) => require(['@/views/login'], resolve),
|
||||
path: "/login",
|
||||
component: (resolve) => require(["@/views/login"], resolve),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||
path: "/404",
|
||||
component: (resolve) => require(["@/views/error/404"], resolve),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/401',
|
||||
component: (resolve) => require(['@/views/error/401'], resolve),
|
||||
path: "/401",
|
||||
component: (resolve) => require(["@/views/error/401"], resolve),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
path: "",
|
||||
component: Layout,
|
||||
redirect: '/index',
|
||||
redirect: "/index",
|
||||
children: [
|
||||
// {
|
||||
// path: 'index',
|
||||
|
@ -67,42 +66,42 @@ export const constantRoutes = [
|
|||
]
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
path: "/user",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
redirect: "noredirect",
|
||||
children: [
|
||||
{
|
||||
path: 'profile',
|
||||
component: (resolve) => require(['@/views/vadmin/permission/user/profile/index'], resolve),
|
||||
name: 'Profile',
|
||||
meta: { title: '个人中心', icon: 'user' }
|
||||
path: "profile",
|
||||
component: (resolve) => require(["@/views/vadmin/permission/user/profile/index"], resolve),
|
||||
name: "Profile",
|
||||
meta: { title: "个人中心", icon: "user" }
|
||||
},
|
||||
{
|
||||
path: 'msg',
|
||||
component: (resolve) => require(['@/views/vadmin/system/message/Mymessage'], resolve),
|
||||
name: 'msg',
|
||||
meta: { title: '消息通知', icon: 'user' }
|
||||
path: "msg",
|
||||
component: (resolve) => require(["@/views/vadmin/system/message/Mymessage"], resolve),
|
||||
name: "msg",
|
||||
meta: { title: "消息通知", icon: "user" }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/dict',
|
||||
path: "/dict",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'type/data/:dictId(\\d+)',
|
||||
component: (resolve) => require(['@/views/vadmin/system/dict/data'], resolve),
|
||||
name: 'Data',
|
||||
meta: { title: '字典数据', icon: '' }
|
||||
path: "type/data/:dictId(\\d+)",
|
||||
component: (resolve) => require(["@/views/vadmin/system/dict/data"], resolve),
|
||||
name: "Data",
|
||||
meta: { title: "字典数据", icon: "" }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
export default new Router({
|
||||
mode: 'history', // 去掉url中的#
|
||||
mode: "history", // 去掉url中的#
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRoutes
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
module.exports = {
|
||||
title: process.env.VUE_APP_TITLE || 'dvAdmin管理系统',
|
||||
title: process.env.VUE_APP_TITLE || "dvAdmin管理系统",
|
||||
|
||||
/**
|
||||
* 侧边栏主题 深色主题theme-dark,浅色主题theme-light
|
||||
*/
|
||||
sideTheme: 'theme-dark',
|
||||
sideTheme: "theme-dark",
|
||||
|
||||
/**
|
||||
* 是否系统布局配置
|
||||
|
@ -32,5 +32,5 @@ module.exports = {
|
|||
* The default is only used in the production env
|
||||
* If you want to also use it in dev, you can pass ['production', 'development']
|
||||
*/
|
||||
errorLog: 'production'
|
||||
}
|
||||
errorLog: "production"
|
||||
};
|
||||
|
|
|
@ -12,6 +12,6 @@ const getters = {
|
|||
roles: state => state.user.roles,
|
||||
permissions: state => state.user.permissions,
|
||||
permission_routes: state => state.permission.routes,
|
||||
sidebarRouters:state => state.permission.sidebarRouters,
|
||||
}
|
||||
export default getters
|
||||
sidebarRouters: state => state.permission.sidebarRouters
|
||||
};
|
||||
export default getters;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import app from './modules/app'
|
||||
import user from './modules/user'
|
||||
import tagsView from './modules/tagsView'
|
||||
import permission from './modules/permission'
|
||||
import settings from './modules/settings'
|
||||
import modelSelect from './modules/modelSelect'
|
||||
import getters from './getters'
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
import app from "./modules/app";
|
||||
import user from "./modules/user";
|
||||
import tagsView from "./modules/tagsView";
|
||||
import permission from "./modules/permission";
|
||||
import settings from "./modules/settings";
|
||||
import modelSelect from "./modules/modelSelect";
|
||||
import getters from "./getters";
|
||||
|
||||
Vue.use(Vuex)
|
||||
Vue.use(Vuex);
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
|
@ -20,6 +20,6 @@ const store = new Vuex.Store({
|
|||
modelSelect
|
||||
},
|
||||
getters
|
||||
})
|
||||
});
|
||||
|
||||
export default store
|
||||
export default store;
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
import Cookies from 'js-cookie'
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const state = {
|
||||
sidebar: {
|
||||
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
|
||||
opened: Cookies.get("sidebarStatus") ? !!+Cookies.get("sidebarStatus") : true,
|
||||
withoutAnimation: false
|
||||
},
|
||||
device: 'desktop',
|
||||
size: Cookies.get('size') || 'medium'
|
||||
}
|
||||
device: "desktop",
|
||||
size: Cookies.get("size") || "medium"
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
TOGGLE_SIDEBAR: state => {
|
||||
state.sidebar.opened = !state.sidebar.opened
|
||||
state.sidebar.withoutAnimation = false
|
||||
state.sidebar.opened = !state.sidebar.opened;
|
||||
state.sidebar.withoutAnimation = false;
|
||||
if (state.sidebar.opened) {
|
||||
Cookies.set('sidebarStatus', 1)
|
||||
Cookies.set("sidebarStatus", 1);
|
||||
} else {
|
||||
Cookies.set('sidebarStatus', 0)
|
||||
Cookies.set("sidebarStatus", 0);
|
||||
}
|
||||
},
|
||||
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
||||
Cookies.set('sidebarStatus', 0)
|
||||
state.sidebar.opened = false
|
||||
state.sidebar.withoutAnimation = withoutAnimation
|
||||
Cookies.set("sidebarStatus", 0);
|
||||
state.sidebar.opened = false;
|
||||
state.sidebar.withoutAnimation = withoutAnimation;
|
||||
},
|
||||
TOGGLE_DEVICE: (state, device) => {
|
||||
state.device = device
|
||||
state.device = device;
|
||||
},
|
||||
SET_SIZE: (state, size) => {
|
||||
state.size = size
|
||||
Cookies.set('size', size)
|
||||
state.size = size;
|
||||
Cookies.set("size", size);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
toggleSideBar({ commit }) {
|
||||
commit('TOGGLE_SIDEBAR')
|
||||
commit("TOGGLE_SIDEBAR");
|
||||
},
|
||||
closeSideBar({ commit }, { withoutAnimation }) {
|
||||
commit('CLOSE_SIDEBAR', withoutAnimation)
|
||||
commit("CLOSE_SIDEBAR", withoutAnimation);
|
||||
},
|
||||
toggleDevice({ commit }, device) {
|
||||
commit('TOGGLE_DEVICE', device)
|
||||
commit("TOGGLE_DEVICE", device);
|
||||
},
|
||||
setSize({ commit }, size) {
|
||||
commit('SET_SIZE', size)
|
||||
commit("SET_SIZE", size);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
const modelSelect = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
modelSelectMap: {},
|
||||
modelSelectMap: {}
|
||||
},
|
||||
mutations: {
|
||||
setModelSelectMap(state, modelSelectMap) {
|
||||
state.modelSelectMap = {...state.modelSelectMap, ...modelSelectMap}
|
||||
},
|
||||
state.modelSelectMap = { ...state.modelSelectMap, ...modelSelectMap };
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 从后台获取需要 select 选择数据
|
||||
// modelName : 模型 name
|
||||
// labelName : 后端接口返回时,配置下拉选择时显示的名字字段,如:name/title/nickName
|
||||
// listApi : 查询列表的api
|
||||
async getModelSelect({commit, state}, paramsMap) {
|
||||
let modelName = paramsMap["modelName"]
|
||||
let labelName = paramsMap["labelName"]
|
||||
let listApi = paramsMap["listApi"]
|
||||
let params = paramsMap["params"]
|
||||
let reset = paramsMap["reset"]
|
||||
async getModelSelect({ commit, state }, paramsMap) {
|
||||
const modelName = paramsMap["modelName"];
|
||||
const labelName = paramsMap["labelName"];
|
||||
const listApi = paramsMap["listApi"];
|
||||
const params = paramsMap["params"];
|
||||
const reset = paramsMap["reset"];
|
||||
if (!reset && state.modelSelectMap[modelName]) {
|
||||
return state.modelSelectMap[modelName]
|
||||
return state.modelSelectMap[modelName];
|
||||
} else {
|
||||
const res = await listApi({pageNum: "all", ...params})
|
||||
const res = await listApi({ pageNum: "all", ...params });
|
||||
if (res.code === 200) {
|
||||
const modelSelectMap = {}
|
||||
const dict = []
|
||||
const modelSelectMap = {};
|
||||
const dict = [];
|
||||
res.data && res.data.map(item => {
|
||||
dict.push({
|
||||
label: item[labelName],
|
||||
value: item.id,
|
||||
id: item.id,
|
||||
parentId: item.parentId
|
||||
})
|
||||
})
|
||||
modelSelectMap[modelName] = dict
|
||||
commit("setModelSelectMap", modelSelectMap)
|
||||
return state.modelSelectMap[modelName]
|
||||
});
|
||||
});
|
||||
modelSelectMap[modelName] = dict;
|
||||
commit("setModelSelectMap", modelSelectMap);
|
||||
return state.modelSelectMap[modelName];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getModelSelect(state) {
|
||||
return state.modelSelectMap
|
||||
return state.modelSelectMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
export default modelSelect
|
||||
};
|
||||
export default modelSelect;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { constantRoutes } from '@/router'
|
||||
import { getRouters } from '@/api/vadmin/menu'
|
||||
import Layout from '@/layout/index'
|
||||
import ParentView from '@/components/ParentView';
|
||||
import { constantRoutes } from "@/router";
|
||||
import { getRouters } from "@/api/vadmin/menu";
|
||||
import Layout from "@/layout/index";
|
||||
import ParentView from "@/components/ParentView";
|
||||
import { handleTree } from "@/utils/ruoyi";
|
||||
import de from 'element-ui/src/locale/lang/de'
|
||||
|
||||
const permission = {
|
||||
state: {
|
||||
routes: [],
|
||||
|
@ -12,12 +12,12 @@ const permission = {
|
|||
},
|
||||
mutations: {
|
||||
SET_ROUTES: (state, routes) => {
|
||||
state.addRoutes = routes
|
||||
state.routes = constantRoutes.concat(routes)
|
||||
state.addRoutes = routes;
|
||||
state.routes = constantRoutes.concat(routes);
|
||||
},
|
||||
SET_SIDEBAR_ROUTERS: (state, routers) => {
|
||||
state.sidebarRouters = constantRoutes.concat(routers)
|
||||
},
|
||||
state.sidebarRouters = constantRoutes.concat(routers);
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 生成路由
|
||||
|
@ -26,92 +26,92 @@ const permission = {
|
|||
// 向后端请求路由数据
|
||||
getRouters().then(res => {
|
||||
const data = handleTree(res.data, "id");
|
||||
const sdata = JSON.parse(JSON.stringify(data))
|
||||
const rdata = JSON.parse(JSON.stringify(data))
|
||||
const sidebarRoutes = filterAsyncRouter(sdata)
|
||||
const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
||||
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
||||
commit('SET_ROUTES', rewriteRoutes)
|
||||
commit('SET_SIDEBAR_ROUTERS', sidebarRoutes)
|
||||
resolve(rewriteRoutes)
|
||||
})
|
||||
})
|
||||
const sdata = JSON.parse(JSON.stringify(data));
|
||||
const rdata = JSON.parse(JSON.stringify(data));
|
||||
const sidebarRoutes = filterAsyncRouter(sdata);
|
||||
const rewriteRoutes = filterAsyncRouter(rdata, false, true);
|
||||
rewriteRoutes.push({ path: "*", redirect: "/404", hidden: true });
|
||||
commit("SET_ROUTES", rewriteRoutes);
|
||||
commit("SET_SIDEBAR_ROUTERS", sidebarRoutes);
|
||||
resolve(rewriteRoutes);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 遍历后台传来的路由字符串,转换为组件对象
|
||||
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
||||
return asyncRouterMap.filter(route => {
|
||||
if (type && route.children) {
|
||||
route.children = filterChildren(route.children)
|
||||
route.children = filterChildren(route.children);
|
||||
}
|
||||
if (route.component) {
|
||||
// Layout ParentView 组件特殊处理
|
||||
if (route.component === 'Layout') {
|
||||
route.component = Layout
|
||||
} else if (route.component === 'ParentView') {
|
||||
route.component = ParentView
|
||||
} else if (typeof route.component === "string" && route.component === 'Layout/index' && !route.children) { // 首页定制
|
||||
route.meta.affix = true
|
||||
if (route.component === "Layout") {
|
||||
route.component = Layout;
|
||||
} else if (route.component === "ParentView") {
|
||||
route.component = ParentView;
|
||||
} else if (typeof route.component === "string" && route.component === "Layout/index" && !route.children) { // 首页定制
|
||||
route.meta.affix = true;
|
||||
route.children = [
|
||||
{
|
||||
path: 'index',
|
||||
component: 'index',
|
||||
path: "index",
|
||||
component: "index",
|
||||
name: route.name,
|
||||
meta: route.meta
|
||||
}
|
||||
]
|
||||
route.path = ''
|
||||
route.name = ''
|
||||
route.redirect = '/index'
|
||||
route.alwaysShow = false
|
||||
route.component = Layout
|
||||
];
|
||||
route.path = "";
|
||||
route.name = "";
|
||||
route.redirect = "/index";
|
||||
route.alwaysShow = false;
|
||||
route.component = Layout;
|
||||
} else {
|
||||
route.component = loadView(route.component)
|
||||
route.component = loadView(route.component);
|
||||
}
|
||||
}
|
||||
if (route.children != null && route.children && route.children.length) {
|
||||
route.children = filterAsyncRouter(route.children, route, type)
|
||||
if (route.children.length === 1 && route.children[0].path === 'index') {
|
||||
route.alwaysShow = false
|
||||
if (route.children !== null && route.children && route.children.length) {
|
||||
route.children = filterAsyncRouter(route.children, route, type);
|
||||
if (route.children.length === 1 && route.children[0].path === "index") {
|
||||
route.alwaysShow = false;
|
||||
} else {
|
||||
route.alwaysShow = true
|
||||
route.alwaysShow = true;
|
||||
}
|
||||
} else {
|
||||
delete route['children']
|
||||
delete route['redirect']
|
||||
delete route["children"];
|
||||
delete route["redirect"];
|
||||
}
|
||||
return true
|
||||
})
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function filterChildren(childrenMap, lastRouter = false) {
|
||||
var children = []
|
||||
var children = [];
|
||||
childrenMap.forEach((el, index) => {
|
||||
if (el.children && el.children.length) {
|
||||
if (el.component === 'ParentView') {
|
||||
if (el.component === "ParentView") {
|
||||
el.children.forEach(c => {
|
||||
c.path = el.path + '/' + c.path
|
||||
c.path = el.path + "/" + c.path;
|
||||
if (c.children && c.children.length) {
|
||||
children = children.concat(filterChildren(c.children, c))
|
||||
return
|
||||
children = children.concat(filterChildren(c.children, c));
|
||||
return;
|
||||
}
|
||||
children.push(c)
|
||||
})
|
||||
return
|
||||
children.push(c);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (lastRouter) {
|
||||
el.path = lastRouter.path + '/' + el.path
|
||||
el.path = lastRouter.path + "/" + el.path;
|
||||
}
|
||||
children = children.concat(el)
|
||||
})
|
||||
return children
|
||||
children = children.concat(el);
|
||||
});
|
||||
return children;
|
||||
}
|
||||
|
||||
export const loadView = (view) => { // 路由懒加载
|
||||
return (resolve) => require([`@/views/${view}`], resolve)
|
||||
}
|
||||
return (resolve) => require([`@/views/${view}`], resolve);
|
||||
};
|
||||
|
||||
export default permission
|
||||
export default permission;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import variables from '@/assets/styles/element-variables.scss'
|
||||
import defaultSettings from '@/settings'
|
||||
import variables from "@/assets/styles/element-variables.scss";
|
||||
import defaultSettings from "@/settings";
|
||||
|
||||
const { sideTheme, showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings
|
||||
const { sideTheme, showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings;
|
||||
|
||||
const state = {
|
||||
theme: variables.theme,
|
||||
|
@ -10,26 +10,27 @@ const state = {
|
|||
tagsView: tagsView,
|
||||
fixedHeader: fixedHeader,
|
||||
sidebarLogo: sidebarLogo
|
||||
}
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
CHANGE_SETTING: (state, { key, value }) => {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (state.hasOwnProperty(key)) {
|
||||
state[key] = value
|
||||
state[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
changeSetting({ commit }, data) {
|
||||
commit('CHANGE_SETTING', data)
|
||||
commit("CHANGE_SETTING", data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,159 +1,159 @@
|
|||
const state = {
|
||||
visitedViews: [],
|
||||
cachedViews: []
|
||||
}
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
ADD_VISITED_VIEW: (state, view) => {
|
||||
if (state.visitedViews.some(v => v.path === view.path)) return
|
||||
if (state.visitedViews.some(v => v.path === view.path)) return;
|
||||
state.visitedViews.push(
|
||||
Object.assign({}, view, {
|
||||
title: view.meta.title || 'no-name'
|
||||
title: view.meta.title || "no-name"
|
||||
})
|
||||
)
|
||||
);
|
||||
},
|
||||
ADD_CACHED_VIEW: (state, view) => {
|
||||
if (state.cachedViews.includes(view.name)) return
|
||||
if (state.cachedViews.includes(view.name)) return;
|
||||
if (!view.meta.noCache) {
|
||||
state.cachedViews.push(view.name)
|
||||
state.cachedViews.push(view.name);
|
||||
}
|
||||
},
|
||||
|
||||
DEL_VISITED_VIEW: (state, view) => {
|
||||
for (const [i, v] of state.visitedViews.entries()) {
|
||||
if (v.path === view.path) {
|
||||
state.visitedViews.splice(i, 1)
|
||||
break
|
||||
state.visitedViews.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
DEL_CACHED_VIEW: (state, view) => {
|
||||
const index = state.cachedViews.indexOf(view.name)
|
||||
index > -1 && state.cachedViews.splice(index, 1)
|
||||
const index = state.cachedViews.indexOf(view.name);
|
||||
index > -1 && state.cachedViews.splice(index, 1);
|
||||
},
|
||||
|
||||
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
||||
state.visitedViews = state.visitedViews.filter(v => {
|
||||
return v.meta.affix || v.path === view.path
|
||||
})
|
||||
return v.meta.affix || v.path === view.path;
|
||||
});
|
||||
},
|
||||
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
||||
const index = state.cachedViews.indexOf(view.name)
|
||||
const index = state.cachedViews.indexOf(view.name);
|
||||
if (index > -1) {
|
||||
state.cachedViews = state.cachedViews.slice(index, index + 1)
|
||||
state.cachedViews = state.cachedViews.slice(index, index + 1);
|
||||
} else {
|
||||
state.cachedViews = []
|
||||
state.cachedViews = [];
|
||||
}
|
||||
},
|
||||
|
||||
DEL_ALL_VISITED_VIEWS: state => {
|
||||
// keep affix tags
|
||||
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
|
||||
state.visitedViews = affixTags
|
||||
const affixTags = state.visitedViews.filter(tag => tag.meta.affix);
|
||||
state.visitedViews = affixTags;
|
||||
},
|
||||
DEL_ALL_CACHED_VIEWS: state => {
|
||||
state.cachedViews = []
|
||||
state.cachedViews = [];
|
||||
},
|
||||
|
||||
UPDATE_VISITED_VIEW: (state, view) => {
|
||||
for (let v of state.visitedViews) {
|
||||
if (v.path === view.path) {
|
||||
v = Object.assign(v, view)
|
||||
break
|
||||
v = Object.assign(v, view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
addView({ dispatch }, view) {
|
||||
dispatch('addVisitedView', view)
|
||||
dispatch('addCachedView', view)
|
||||
dispatch("addVisitedView", view);
|
||||
dispatch("addCachedView", view);
|
||||
},
|
||||
addVisitedView({ commit }, view) {
|
||||
commit('ADD_VISITED_VIEW', view)
|
||||
commit("ADD_VISITED_VIEW", view);
|
||||
},
|
||||
addCachedView({ commit }, view) {
|
||||
commit('ADD_CACHED_VIEW', view)
|
||||
commit("ADD_CACHED_VIEW", view);
|
||||
},
|
||||
|
||||
delView({ dispatch, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
dispatch('delVisitedView', view)
|
||||
dispatch('delCachedView', view)
|
||||
dispatch("delVisitedView", view);
|
||||
dispatch("delCachedView", view);
|
||||
resolve({
|
||||
visitedViews: [...state.visitedViews],
|
||||
cachedViews: [...state.cachedViews]
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
delVisitedView({ commit, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_VISITED_VIEW', view)
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
commit("DEL_VISITED_VIEW", view);
|
||||
resolve([...state.visitedViews]);
|
||||
});
|
||||
},
|
||||
delCachedView({ commit, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_CACHED_VIEW', view)
|
||||
resolve([...state.cachedViews])
|
||||
})
|
||||
commit("DEL_CACHED_VIEW", view);
|
||||
resolve([...state.cachedViews]);
|
||||
});
|
||||
},
|
||||
|
||||
delOthersViews({ dispatch, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
dispatch('delOthersVisitedViews', view)
|
||||
dispatch('delOthersCachedViews', view)
|
||||
dispatch("delOthersVisitedViews", view);
|
||||
dispatch("delOthersCachedViews", view);
|
||||
resolve({
|
||||
visitedViews: [...state.visitedViews],
|
||||
cachedViews: [...state.cachedViews]
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
delOthersVisitedViews({ commit, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_OTHERS_VISITED_VIEWS', view)
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
commit("DEL_OTHERS_VISITED_VIEWS", view);
|
||||
resolve([...state.visitedViews]);
|
||||
});
|
||||
},
|
||||
delOthersCachedViews({ commit, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_OTHERS_CACHED_VIEWS', view)
|
||||
resolve([...state.cachedViews])
|
||||
})
|
||||
commit("DEL_OTHERS_CACHED_VIEWS", view);
|
||||
resolve([...state.cachedViews]);
|
||||
});
|
||||
},
|
||||
|
||||
delAllViews({ dispatch, state }, view) {
|
||||
return new Promise(resolve => {
|
||||
dispatch('delAllVisitedViews', view)
|
||||
dispatch('delAllCachedViews', view)
|
||||
dispatch("delAllVisitedViews", view);
|
||||
dispatch("delAllCachedViews", view);
|
||||
resolve({
|
||||
visitedViews: [...state.visitedViews],
|
||||
cachedViews: [...state.cachedViews]
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
delAllVisitedViews({ commit, state }) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_ALL_VISITED_VIEWS')
|
||||
resolve([...state.visitedViews])
|
||||
})
|
||||
commit("DEL_ALL_VISITED_VIEWS");
|
||||
resolve([...state.visitedViews]);
|
||||
});
|
||||
},
|
||||
delAllCachedViews({ commit, state }) {
|
||||
return new Promise(resolve => {
|
||||
commit('DEL_ALL_CACHED_VIEWS')
|
||||
resolve([...state.cachedViews])
|
||||
})
|
||||
commit("DEL_ALL_CACHED_VIEWS");
|
||||
resolve([...state.cachedViews]);
|
||||
});
|
||||
},
|
||||
|
||||
updateVisitedView({ commit }, view) {
|
||||
commit('UPDATE_VISITED_VIEW', view)
|
||||
commit("UPDATE_VISITED_VIEW", view);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {getInfo, login, logout} from '@/api/vadmin/login'
|
||||
import {getToken, removeToken, setToken} from '@/utils/auth'
|
||||
import { getInfo, login, logout } from "@/api/vadmin/login";
|
||||
import { getToken, removeToken, setToken } from "@/utils/auth";
|
||||
|
||||
const user = {
|
||||
state: {
|
||||
token: getToken(),
|
||||
name: '',
|
||||
avatar: '',
|
||||
name: "",
|
||||
avatar: "",
|
||||
roles: [],
|
||||
permissions: [],
|
||||
unread_msg_count: 0
|
||||
|
@ -13,89 +13,89 @@ const user = {
|
|||
|
||||
mutations: {
|
||||
SET_TOKEN: (state, token) => {
|
||||
state.token = token
|
||||
state.token = token;
|
||||
},
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
state.name = name;
|
||||
},
|
||||
SET_AVATAR: (state, avatar) => {
|
||||
state.avatar = avatar
|
||||
state.avatar = avatar;
|
||||
},
|
||||
SET_ROLES: (state, roles) => {
|
||||
state.roles = roles
|
||||
state.roles = roles;
|
||||
},
|
||||
SET_PERMISSIONS: (state, permissions) => {
|
||||
state.permissions = permissions
|
||||
state.permissions = permissions;
|
||||
},
|
||||
SET_UNREAD_MSG_COUNT: (state, unread_msg_count) => {
|
||||
state.unread_msg_count = unread_msg_count
|
||||
state.unread_msg_count = unread_msg_count;
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
const uuid = userInfo.uuid
|
||||
const username = userInfo.username.trim();
|
||||
const password = userInfo.password;
|
||||
const code = userInfo.code;
|
||||
const uuid = userInfo.uuid;
|
||||
return new Promise((resolve, reject) => {
|
||||
login(username, password, code, uuid).then(res => {
|
||||
setToken(res.data.token)
|
||||
commit('SET_TOKEN', res.data.token)
|
||||
resolve()
|
||||
setToken(res.data.token);
|
||||
commit("SET_TOKEN", res.data.token);
|
||||
resolve();
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo(state.token).then(res => {
|
||||
const user = res.data.user
|
||||
const user = res.data.user;
|
||||
const avatar = user.avatar ? process.env.VUE_APP_BASE_API + user.avatar : require("@/assets/images/profile.jpg");
|
||||
if (res.data.roles && res.data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
commit('SET_ROLES', res.data.roles)
|
||||
commit('SET_PERMISSIONS', res.data.permissions)
|
||||
commit("SET_ROLES", res.data.roles);
|
||||
commit("SET_PERMISSIONS", res.data.permissions);
|
||||
} else {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||
commit("SET_ROLES", ["ROLE_DEFAULT"]);
|
||||
}
|
||||
commit('SET_NAME', user.name)
|
||||
commit('SET_UNREAD_MSG_COUNT', user.unread_msg_count)
|
||||
commit('SET_AVATAR', avatar)
|
||||
resolve(res.data)
|
||||
commit("SET_NAME", user.name);
|
||||
commit("SET_UNREAD_MSG_COUNT", user.unread_msg_count);
|
||||
commit("SET_AVATAR", avatar);
|
||||
resolve(res.data);
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_PERMISSIONS', [])
|
||||
removeToken()
|
||||
resolve()
|
||||
commit("SET_TOKEN", "");
|
||||
commit("SET_ROLES", []);
|
||||
commit("SET_PERMISSIONS", []);
|
||||
removeToken();
|
||||
resolve();
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// 前端 登出
|
||||
FedLogOut({ commit }) {
|
||||
return new Promise(resolve => {
|
||||
commit('SET_TOKEN', '')
|
||||
removeToken()
|
||||
resolve()
|
||||
})
|
||||
commit("SET_TOKEN", "");
|
||||
removeToken();
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default user
|
||||
export default user;
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import Cookies from 'js-cookie'
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const TokenKey = 'Admin-Token'
|
||||
const TokenKey = "Admin-Token";
|
||||
|
||||
export function getToken() {
|
||||
return Cookies.get(TokenKey)
|
||||
return Cookies.get(TokenKey);
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return Cookies.set(TokenKey, token)
|
||||
return Cookies.set(TokenKey, token);
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return Cookies.remove(TokenKey)
|
||||
return Cookies.remove(TokenKey);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export default {
|
||||
'401': '认证失败,无法访问系统资源',
|
||||
'403': '当前操作没有权限',
|
||||
'404': '访问资源不存在',
|
||||
'default': '系统未知错误,请反馈给管理员'
|
||||
}
|
||||
"401": "认证失败,无法访问系统资源",
|
||||
"403": "当前操作没有权限",
|
||||
"404": "访问资源不存在",
|
||||
"default": "系统未知错误,请反馈给管理员"
|
||||
};
|
||||
|
|
|
@ -1,46 +1,46 @@
|
|||
export const formConf = {
|
||||
formRef: 'elForm',
|
||||
formModel: 'formData',
|
||||
size: 'medium',
|
||||
labelPosition: 'right',
|
||||
formRef: "elForm",
|
||||
formModel: "formData",
|
||||
size: "medium",
|
||||
labelPosition: "right",
|
||||
labelWidth: 100,
|
||||
formRules: 'rules',
|
||||
formRules: "rules",
|
||||
gutter: 15,
|
||||
disabled: false,
|
||||
span: 24,
|
||||
formBtns: true
|
||||
}
|
||||
};
|
||||
|
||||
export const inputComponents = [
|
||||
{
|
||||
label: '单行文本',
|
||||
tag: 'el-input',
|
||||
tagIcon: 'input',
|
||||
placeholder: '请输入',
|
||||
label: "单行文本",
|
||||
tag: "el-input",
|
||||
tagIcon: "input",
|
||||
placeholder: "请输入",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
clearable: true,
|
||||
prepend: '',
|
||||
append: '',
|
||||
'prefix-icon': '',
|
||||
'suffix-icon': '',
|
||||
prepend: "",
|
||||
append: "",
|
||||
"prefix-icon": "",
|
||||
"suffix-icon": "",
|
||||
maxlength: null,
|
||||
'show-word-limit': false,
|
||||
"show-word-limit": false,
|
||||
readonly: false,
|
||||
disabled: false,
|
||||
required: true,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/input'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/input"
|
||||
},
|
||||
{
|
||||
label: '多行文本',
|
||||
tag: 'el-input',
|
||||
tagIcon: 'textarea',
|
||||
type: 'textarea',
|
||||
placeholder: '请输入',
|
||||
label: "多行文本",
|
||||
tag: "el-input",
|
||||
tagIcon: "textarea",
|
||||
type: "textarea",
|
||||
placeholder: "请输入",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
|
@ -48,103 +48,103 @@ export const inputComponents = [
|
|||
minRows: 4,
|
||||
maxRows: 4
|
||||
},
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
maxlength: null,
|
||||
'show-word-limit': false,
|
||||
"show-word-limit": false,
|
||||
readonly: false,
|
||||
disabled: false,
|
||||
required: true,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/input'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/input"
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
tag: 'el-input',
|
||||
tagIcon: 'password',
|
||||
placeholder: '请输入',
|
||||
label: "密码",
|
||||
tag: "el-input",
|
||||
tagIcon: "password",
|
||||
placeholder: "请输入",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
'show-password': true,
|
||||
"show-password": true,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
clearable: true,
|
||||
prepend: '',
|
||||
append: '',
|
||||
'prefix-icon': '',
|
||||
'suffix-icon': '',
|
||||
prepend: "",
|
||||
append: "",
|
||||
"prefix-icon": "",
|
||||
"suffix-icon": "",
|
||||
maxlength: null,
|
||||
'show-word-limit': false,
|
||||
"show-word-limit": false,
|
||||
readonly: false,
|
||||
disabled: false,
|
||||
required: true,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/input'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/input"
|
||||
},
|
||||
{
|
||||
label: '计数器',
|
||||
tag: 'el-input-number',
|
||||
tagIcon: 'number',
|
||||
placeholder: '',
|
||||
label: "计数器",
|
||||
tag: "el-input-number",
|
||||
tagIcon: "number",
|
||||
placeholder: "",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
step: undefined,
|
||||
'step-strictly': false,
|
||||
"step-strictly": false,
|
||||
precision: undefined,
|
||||
'controls-position': '',
|
||||
"controls-position": "",
|
||||
disabled: false,
|
||||
required: true,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/input-number'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/input-number"
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
export const selectComponents = [
|
||||
{
|
||||
label: '下拉选择',
|
||||
tag: 'el-select',
|
||||
tagIcon: 'select',
|
||||
placeholder: '请选择',
|
||||
label: "下拉选择",
|
||||
tag: "el-select",
|
||||
tagIcon: "select",
|
||||
placeholder: "请选择",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
clearable: true,
|
||||
disabled: false,
|
||||
required: true,
|
||||
filterable: false,
|
||||
multiple: false,
|
||||
options: [{
|
||||
label: '选项一',
|
||||
label: "选项一",
|
||||
value: 1
|
||||
}, {
|
||||
label: '选项二',
|
||||
label: "选项二",
|
||||
value: 2
|
||||
}],
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/select'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/select"
|
||||
},
|
||||
{
|
||||
label: '级联选择',
|
||||
tag: 'el-cascader',
|
||||
tagIcon: 'cascader',
|
||||
placeholder: '请选择',
|
||||
label: "级联选择",
|
||||
tag: "el-cascader",
|
||||
tagIcon: "cascader",
|
||||
placeholder: "请选择",
|
||||
defaultValue: [],
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
props: {
|
||||
props: {
|
||||
multiple: false
|
||||
}
|
||||
},
|
||||
'show-all-levels': true,
|
||||
"show-all-levels": true,
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
filterable: false,
|
||||
|
@ -152,94 +152,94 @@ export const selectComponents = [
|
|||
options: [{
|
||||
id: 1,
|
||||
value: 1,
|
||||
label: '选项1',
|
||||
label: "选项1",
|
||||
children: [{
|
||||
id: 2,
|
||||
value: 2,
|
||||
label: '选项1-1'
|
||||
label: "选项1-1"
|
||||
}]
|
||||
}],
|
||||
dataType: 'dynamic',
|
||||
labelKey: 'label',
|
||||
valueKey: 'value',
|
||||
childrenKey: 'children',
|
||||
separator: '/',
|
||||
dataType: "dynamic",
|
||||
labelKey: "label",
|
||||
valueKey: "value",
|
||||
childrenKey: "children",
|
||||
separator: "/",
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/cascader'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/cascader"
|
||||
},
|
||||
{
|
||||
label: '单选框组',
|
||||
tag: 'el-radio-group',
|
||||
tagIcon: 'radio',
|
||||
label: "单选框组",
|
||||
tag: "el-radio-group",
|
||||
tagIcon: "radio",
|
||||
defaultValue: undefined,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: {},
|
||||
optionType: 'default',
|
||||
optionType: "default",
|
||||
border: false,
|
||||
size: 'medium',
|
||||
size: "medium",
|
||||
disabled: false,
|
||||
required: true,
|
||||
options: [{
|
||||
label: '选项一',
|
||||
label: "选项一",
|
||||
value: 1
|
||||
}, {
|
||||
label: '选项二',
|
||||
label: "选项二",
|
||||
value: 2
|
||||
}],
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/radio'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/radio"
|
||||
},
|
||||
{
|
||||
label: '多选框组',
|
||||
tag: 'el-checkbox-group',
|
||||
tagIcon: 'checkbox',
|
||||
label: "多选框组",
|
||||
tag: "el-checkbox-group",
|
||||
tagIcon: "checkbox",
|
||||
defaultValue: [],
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: {},
|
||||
optionType: 'default',
|
||||
optionType: "default",
|
||||
border: false,
|
||||
size: 'medium',
|
||||
size: "medium",
|
||||
disabled: false,
|
||||
required: true,
|
||||
options: [{
|
||||
label: '选项一',
|
||||
label: "选项一",
|
||||
value: 1
|
||||
}, {
|
||||
label: '选项二',
|
||||
label: "选项二",
|
||||
value: 2
|
||||
}],
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/checkbox'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/checkbox"
|
||||
},
|
||||
{
|
||||
label: '开关',
|
||||
tag: 'el-switch',
|
||||
tagIcon: 'switch',
|
||||
label: "开关",
|
||||
tag: "el-switch",
|
||||
tagIcon: "switch",
|
||||
defaultValue: false,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: {},
|
||||
disabled: false,
|
||||
required: true,
|
||||
'active-text': '',
|
||||
'inactive-text': '',
|
||||
'active-color': null,
|
||||
'inactive-color': null,
|
||||
'active-value': true,
|
||||
'inactive-value': false,
|
||||
"active-text": "",
|
||||
"inactive-text": "",
|
||||
"active-color": null,
|
||||
"inactive-color": null,
|
||||
"active-value": true,
|
||||
"inactive-value": false,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/switch'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/switch"
|
||||
},
|
||||
{
|
||||
label: '滑块',
|
||||
tag: 'el-slider',
|
||||
tagIcon: 'slider',
|
||||
label: "滑块",
|
||||
tag: "el-slider",
|
||||
tagIcon: "slider",
|
||||
defaultValue: null,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
|
@ -248,191 +248,191 @@ export const selectComponents = [
|
|||
min: 0,
|
||||
max: 100,
|
||||
step: 1,
|
||||
'show-stops': false,
|
||||
"show-stops": false,
|
||||
range: false,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/slider'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/slider"
|
||||
},
|
||||
{
|
||||
label: '时间选择',
|
||||
tag: 'el-time-picker',
|
||||
tagIcon: 'time',
|
||||
placeholder: '请选择',
|
||||
label: "时间选择",
|
||||
tag: "el-time-picker",
|
||||
tagIcon: "time",
|
||||
placeholder: "请选择",
|
||||
defaultValue: null,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
required: true,
|
||||
'picker-options': {
|
||||
selectableRange: '00:00:00-23:59:59'
|
||||
"picker-options": {
|
||||
selectableRange: "00:00:00-23:59:59"
|
||||
},
|
||||
format: 'HH:mm:ss',
|
||||
'value-format': 'HH:mm:ss',
|
||||
format: "HH:mm:ss",
|
||||
"value-format": "HH:mm:ss",
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/time-picker"
|
||||
},
|
||||
{
|
||||
label: '时间范围',
|
||||
tag: 'el-time-picker',
|
||||
tagIcon: 'time-range',
|
||||
label: "时间范围",
|
||||
tag: "el-time-picker",
|
||||
tagIcon: "time-range",
|
||||
defaultValue: null,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
required: true,
|
||||
'is-range': true,
|
||||
'range-separator': '至',
|
||||
'start-placeholder': '开始时间',
|
||||
'end-placeholder': '结束时间',
|
||||
format: 'HH:mm:ss',
|
||||
'value-format': 'HH:mm:ss',
|
||||
"is-range": true,
|
||||
"range-separator": "至",
|
||||
"start-placeholder": "开始时间",
|
||||
"end-placeholder": "结束时间",
|
||||
format: "HH:mm:ss",
|
||||
"value-format": "HH:mm:ss",
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/time-picker"
|
||||
},
|
||||
{
|
||||
label: '日期选择',
|
||||
tag: 'el-date-picker',
|
||||
tagIcon: 'date',
|
||||
placeholder: '请选择',
|
||||
label: "日期选择",
|
||||
tag: "el-date-picker",
|
||||
tagIcon: "date",
|
||||
placeholder: "请选择",
|
||||
defaultValue: null,
|
||||
type: 'date',
|
||||
type: "date",
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
required: true,
|
||||
format: 'yyyy-MM-dd',
|
||||
'value-format': 'yyyy-MM-dd',
|
||||
format: "yyyy-MM-dd",
|
||||
"value-format": "yyyy-MM-dd",
|
||||
readonly: false,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/date-picker"
|
||||
},
|
||||
{
|
||||
label: '日期范围',
|
||||
tag: 'el-date-picker',
|
||||
tagIcon: 'date-range',
|
||||
label: "日期范围",
|
||||
tag: "el-date-picker",
|
||||
tagIcon: "date-range",
|
||||
defaultValue: null,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: { width: '100%' },
|
||||
type: 'daterange',
|
||||
'range-separator': '至',
|
||||
'start-placeholder': '开始日期',
|
||||
'end-placeholder': '结束日期',
|
||||
style: { width: "100%" },
|
||||
type: "daterange",
|
||||
"range-separator": "至",
|
||||
"start-placeholder": "开始日期",
|
||||
"end-placeholder": "结束日期",
|
||||
disabled: false,
|
||||
clearable: true,
|
||||
required: true,
|
||||
format: 'yyyy-MM-dd',
|
||||
'value-format': 'yyyy-MM-dd',
|
||||
format: "yyyy-MM-dd",
|
||||
"value-format": "yyyy-MM-dd",
|
||||
readonly: false,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/date-picker"
|
||||
},
|
||||
{
|
||||
label: '评分',
|
||||
tag: 'el-rate',
|
||||
tagIcon: 'rate',
|
||||
label: "评分",
|
||||
tag: "el-rate",
|
||||
tagIcon: "rate",
|
||||
defaultValue: 0,
|
||||
span: 24,
|
||||
labelWidth: null,
|
||||
style: {},
|
||||
max: 5,
|
||||
'allow-half': false,
|
||||
'show-text': false,
|
||||
'show-score': false,
|
||||
"allow-half": false,
|
||||
"show-text": false,
|
||||
"show-score": false,
|
||||
disabled: false,
|
||||
required: true,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/rate'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/rate"
|
||||
},
|
||||
{
|
||||
label: '颜色选择',
|
||||
tag: 'el-color-picker',
|
||||
tagIcon: 'color',
|
||||
label: "颜色选择",
|
||||
tag: "el-color-picker",
|
||||
tagIcon: "color",
|
||||
defaultValue: null,
|
||||
labelWidth: null,
|
||||
'show-alpha': false,
|
||||
'color-format': '',
|
||||
"show-alpha": false,
|
||||
"color-format": "",
|
||||
disabled: false,
|
||||
required: true,
|
||||
size: 'medium',
|
||||
size: "medium",
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/color-picker'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/color-picker"
|
||||
},
|
||||
{
|
||||
label: '上传',
|
||||
tag: 'el-upload',
|
||||
tagIcon: 'upload',
|
||||
action: 'https://jsonplaceholder.typicode.com/posts/',
|
||||
label: "上传",
|
||||
tag: "el-upload",
|
||||
tagIcon: "upload",
|
||||
action: "https://jsonplaceholder.typicode.com/posts/",
|
||||
defaultValue: null,
|
||||
labelWidth: null,
|
||||
disabled: false,
|
||||
required: true,
|
||||
accept: '',
|
||||
name: 'file',
|
||||
'auto-upload': true,
|
||||
accept: "",
|
||||
name: "file",
|
||||
"auto-upload": true,
|
||||
showTip: false,
|
||||
buttonText: '点击上传',
|
||||
buttonText: "点击上传",
|
||||
fileSize: 2,
|
||||
sizeUnit: 'MB',
|
||||
'list-type': 'text',
|
||||
sizeUnit: "MB",
|
||||
"list-type": "text",
|
||||
multiple: false,
|
||||
regList: [],
|
||||
changeTag: true,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/upload'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/upload"
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
export const layoutComponents = [
|
||||
{
|
||||
layout: 'rowFormItem',
|
||||
tagIcon: 'row',
|
||||
type: 'default',
|
||||
justify: 'start',
|
||||
align: 'top',
|
||||
label: '行容器',
|
||||
layout: "rowFormItem",
|
||||
tagIcon: "row",
|
||||
type: "default",
|
||||
justify: "start",
|
||||
align: "top",
|
||||
label: "行容器",
|
||||
layoutTree: true,
|
||||
children: [],
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/layout'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/layout"
|
||||
},
|
||||
{
|
||||
layout: 'colFormItem',
|
||||
label: '按钮',
|
||||
layout: "colFormItem",
|
||||
label: "按钮",
|
||||
changeTag: true,
|
||||
labelWidth: null,
|
||||
tag: 'el-button',
|
||||
tagIcon: 'button',
|
||||
tag: "el-button",
|
||||
tagIcon: "button",
|
||||
span: 24,
|
||||
default: '主要按钮',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-search',
|
||||
size: 'medium',
|
||||
default: "主要按钮",
|
||||
type: "primary",
|
||||
icon: "el-icon-search",
|
||||
size: "medium",
|
||||
disabled: false,
|
||||
document: 'https://element.eleme.cn/#/zh-CN/component/button'
|
||||
document: "https://element.eleme.cn/#/zh-CN/component/button"
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
// 组件rule的触发方式,无触发方式的组件不生成rule
|
||||
export const trigger = {
|
||||
'el-input': 'blur',
|
||||
'el-input-number': 'blur',
|
||||
'el-select': 'change',
|
||||
'el-radio-group': 'change',
|
||||
'el-checkbox-group': 'change',
|
||||
'el-cascader': 'change',
|
||||
'el-time-picker': 'change',
|
||||
'el-date-picker': 'change',
|
||||
'el-rate': 'change'
|
||||
}
|
||||
"el-input": "blur",
|
||||
"el-input-number": "blur",
|
||||
"el-select": "change",
|
||||
"el-radio-group": "change",
|
||||
"el-checkbox-group": "change",
|
||||
"el-cascader": "change",
|
||||
"el-time-picker": "change",
|
||||
"el-date-picker": "change",
|
||||
"el-rate": "change"
|
||||
};
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
const styles = {
|
||||
'el-rate': '.el-rate{display: inline-block; vertical-align: text-top;}',
|
||||
'el-upload': '.el-upload__tip{line-height: 1.2;}'
|
||||
}
|
||||
"el-rate": ".el-rate{display: inline-block; vertical-align: text-top;}",
|
||||
"el-upload": ".el-upload__tip{line-height: 1.2;}"
|
||||
};
|
||||
|
||||
function addCss(cssList, el) {
|
||||
const css = styles[el.tag]
|
||||
css && cssList.indexOf(css) === -1 && cssList.push(css)
|
||||
const css = styles[el.tag];
|
||||
css && cssList.indexOf(css) === -1 && cssList.push(css);
|
||||
if (el.children) {
|
||||
el.children.forEach(el2 => addCss(cssList, el2))
|
||||
el.children.forEach(el2 => addCss(cssList, el2));
|
||||
}
|
||||
}
|
||||
|
||||
export function makeUpCss(conf) {
|
||||
const cssList = []
|
||||
conf.fields.forEach(el => addCss(cssList, el))
|
||||
return cssList.join('\n')
|
||||
const cssList = [];
|
||||
conf.fields.forEach(el => addCss(cssList, el));
|
||||
return cssList.join("\n");
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
export default [
|
||||
{
|
||||
layout: 'colFormItem',
|
||||
tagIcon: 'input',
|
||||
label: '手机号',
|
||||
vModel: 'mobile',
|
||||
layout: "colFormItem",
|
||||
tagIcon: "input",
|
||||
label: "手机号",
|
||||
vModel: "mobile",
|
||||
formId: 6,
|
||||
tag: 'el-input',
|
||||
placeholder: '请输入手机号',
|
||||
defaultValue: '',
|
||||
tag: "el-input",
|
||||
placeholder: "请输入手机号",
|
||||
defaultValue: "",
|
||||
span: 24,
|
||||
style: { width: '100%' },
|
||||
style: { width: "100%" },
|
||||
clearable: true,
|
||||
prepend: '',
|
||||
append: '',
|
||||
'prefix-icon': 'el-icon-mobile',
|
||||
'suffix-icon': '',
|
||||
prepend: "",
|
||||
append: "",
|
||||
"prefix-icon": "el-icon-mobile",
|
||||
"suffix-icon": "",
|
||||
maxlength: 11,
|
||||
'show-word-limit': true,
|
||||
"show-word-limit": true,
|
||||
readonly: false,
|
||||
disabled: false,
|
||||
required: true,
|
||||
changeTag: true,
|
||||
regList: [{
|
||||
pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
|
||||
message: '手机号格式错误'
|
||||
pattern: "/^1(3|4|5|7|8|9)\\d{9}$/",
|
||||
message: "手机号格式错误"
|
||||
}]
|
||||
}
|
||||
]
|
||||
];
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* eslint-disable max-len */
|
||||
import { trigger } from './config'
|
||||
import { trigger } from "./config";
|
||||
|
||||
let confGlobal
|
||||
let someSpanIsNot24
|
||||
let confGlobal;
|
||||
let someSpanIsNot24;
|
||||
|
||||
export function dialogWrapper(str) {
|
||||
return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
|
||||
|
@ -11,7 +11,7 @@ export function dialogWrapper(str) {
|
|||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="handelConfirm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>`
|
||||
</el-dialog>`;
|
||||
}
|
||||
|
||||
export function vueTemplate(str) {
|
||||
|
@ -19,53 +19,53 @@ export function vueTemplate(str) {
|
|||
<div>
|
||||
${str}
|
||||
</div>
|
||||
</template>`
|
||||
</template>`;
|
||||
}
|
||||
|
||||
export function vueScript(str) {
|
||||
return `<script>
|
||||
${str}
|
||||
</script>`
|
||||
</script>`;
|
||||
}
|
||||
|
||||
export function cssStyle(cssStr) {
|
||||
return `<style>
|
||||
${cssStr}
|
||||
</style>`
|
||||
</style>`;
|
||||
}
|
||||
|
||||
function buildFormTemplate(conf, child, type) {
|
||||
let labelPosition = ''
|
||||
if (conf.labelPosition !== 'right') {
|
||||
labelPosition = `label-position="${conf.labelPosition}"`
|
||||
let labelPosition = "";
|
||||
if (conf.labelPosition !== "right") {
|
||||
labelPosition = `label-position="${conf.labelPosition}"`;
|
||||
}
|
||||
const disabled = conf.disabled ? `:disabled="${conf.disabled}"` : ''
|
||||
const disabled = conf.disabled ? `:disabled="${conf.disabled}"` : "";
|
||||
let str = `<el-form ref="${conf.formRef}" :model="${conf.formModel}" :rules="${conf.formRules}" size="${conf.size}" ${disabled} label-width="${conf.labelWidth}px" ${labelPosition}>
|
||||
${child}
|
||||
${buildFromBtns(conf, type)}
|
||||
</el-form>`
|
||||
</el-form>`;
|
||||
if (someSpanIsNot24) {
|
||||
str = `<el-row :gutter="${conf.gutter}">
|
||||
${str}
|
||||
</el-row>`
|
||||
</el-row>`;
|
||||
}
|
||||
return str
|
||||
return str;
|
||||
}
|
||||
|
||||
function buildFromBtns(conf, type) {
|
||||
let str = ''
|
||||
if (conf.formBtns && type === 'file') {
|
||||
let str = "";
|
||||
if (conf.formBtns && type === "file") {
|
||||
str = `<el-form-item size="large">
|
||||
<el-button type="primary" @click="submitForm">提交</el-button>
|
||||
<el-button @click="resetForm">重置</el-button>
|
||||
</el-form-item>`
|
||||
</el-form-item>`;
|
||||
if (someSpanIsNot24) {
|
||||
str = `<el-col :span="24">
|
||||
${str}
|
||||
</el-col>`
|
||||
</el-col>`;
|
||||
}
|
||||
}
|
||||
return str
|
||||
return str;
|
||||
}
|
||||
|
||||
// span不为24的用el-col包裹
|
||||
|
@ -73,287 +73,286 @@ function colWrapper(element, str) {
|
|||
if (someSpanIsNot24 || element.span !== 24) {
|
||||
return `<el-col :span="${element.span}">
|
||||
${str}
|
||||
</el-col>`
|
||||
</el-col>`;
|
||||
}
|
||||
return str
|
||||
return str;
|
||||
}
|
||||
|
||||
const layouts = {
|
||||
colFormItem(element) {
|
||||
let labelWidth = ''
|
||||
let labelWidth = "";
|
||||
if (element.labelWidth && element.labelWidth !== confGlobal.labelWidth) {
|
||||
labelWidth = `label-width="${element.labelWidth}px"`
|
||||
labelWidth = `label-width="${element.labelWidth}px"`;
|
||||
}
|
||||
const required = !trigger[element.tag] && element.required ? 'required' : ''
|
||||
const tagDom = tags[element.tag] ? tags[element.tag](element) : null
|
||||
const required = !trigger[element.tag] && element.required ? "required" : "";
|
||||
const tagDom = tags[element.tag] ? tags[element.tag](element) : null;
|
||||
let str = `<el-form-item ${labelWidth} label="${element.label}" prop="${element.vModel}" ${required}>
|
||||
${tagDom}
|
||||
</el-form-item>`
|
||||
str = colWrapper(element, str)
|
||||
return str
|
||||
</el-form-item>`;
|
||||
str = colWrapper(element, str);
|
||||
return str;
|
||||
},
|
||||
rowFormItem(element) {
|
||||
const type = element.type === 'default' ? '' : `type="${element.type}"`
|
||||
const justify = element.type === 'default' ? '' : `justify="${element.justify}"`
|
||||
const align = element.type === 'default' ? '' : `align="${element.align}"`
|
||||
const gutter = element.gutter ? `gutter="${element.gutter}"` : ''
|
||||
const children = element.children.map(el => layouts[el.layout](el))
|
||||
const type = element.type === "default" ? "" : `type="${element.type}"`;
|
||||
const justify = element.type === "default" ? "" : `justify="${element.justify}"`;
|
||||
const align = element.type === "default" ? "" : `align="${element.align}"`;
|
||||
const gutter = element.gutter ? `gutter="${element.gutter}"` : "";
|
||||
const children = element.children.map(el => layouts[el.layout](el));
|
||||
let str = `<el-row ${type} ${justify} ${align} ${gutter}>
|
||||
${children.join('\n')}
|
||||
</el-row>`
|
||||
str = colWrapper(element, str)
|
||||
return str
|
||||
${children.join("\n")}
|
||||
</el-row>`;
|
||||
str = colWrapper(element, str);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const tags = {
|
||||
'el-button': el => {
|
||||
"el-button": el => {
|
||||
const {
|
||||
tag, disabled
|
||||
} = attrBuilder(el)
|
||||
const type = el.type ? `type="${el.type}"` : ''
|
||||
const icon = el.icon ? `icon="${el.icon}"` : ''
|
||||
const size = el.size ? `size="${el.size}"` : ''
|
||||
let child = buildElButtonChild(el)
|
||||
disabled
|
||||
} = attrBuilder(el);
|
||||
const type = el.type ? `type="${el.type}"` : "";
|
||||
const icon = el.icon ? `icon="${el.icon}"` : "";
|
||||
const size = el.size ? `size="${el.size}"` : "";
|
||||
let child = buildElButtonChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${type} ${icon} ${size} ${disabled}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${type} ${icon} ${size} ${disabled}>${child}</${el.tag}>`;
|
||||
},
|
||||
'el-input': el => {
|
||||
"el-input": el => {
|
||||
const {
|
||||
disabled, vModel, clearable, placeholder, width
|
||||
} = attrBuilder(el)
|
||||
const maxlength = el.maxlength ? `:maxlength="${el.maxlength}"` : ''
|
||||
const showWordLimit = el['show-word-limit'] ? 'show-word-limit' : ''
|
||||
const readonly = el.readonly ? 'readonly' : ''
|
||||
const prefixIcon = el['prefix-icon'] ? `prefix-icon='${el['prefix-icon']}'` : ''
|
||||
const suffixIcon = el['suffix-icon'] ? `suffix-icon='${el['suffix-icon']}'` : ''
|
||||
const showPassword = el['show-password'] ? 'show-password' : ''
|
||||
const type = el.type ? `type="${el.type}"` : ''
|
||||
} = attrBuilder(el);
|
||||
const maxlength = el.maxlength ? `:maxlength="${el.maxlength}"` : "";
|
||||
const showWordLimit = el["show-word-limit"] ? "show-word-limit" : "";
|
||||
const readonly = el.readonly ? "readonly" : "";
|
||||
const prefixIcon = el["prefix-icon"] ? `prefix-icon='${el["prefix-icon"]}'` : "";
|
||||
const suffixIcon = el["suffix-icon"] ? `suffix-icon='${el["suffix-icon"]}'` : "";
|
||||
const showPassword = el["show-password"] ? "show-password" : "";
|
||||
const type = el.type ? `type="${el.type}"` : "";
|
||||
const autosize = el.autosize && el.autosize.minRows
|
||||
? `:autosize="{minRows: ${el.autosize.minRows}, maxRows: ${el.autosize.maxRows}}"`
|
||||
: ''
|
||||
let child = buildElInputChild(el)
|
||||
: "";
|
||||
let child = buildElInputChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${vModel} ${type} ${placeholder} ${maxlength} ${showWordLimit} ${readonly} ${disabled} ${clearable} ${prefixIcon} ${suffixIcon} ${showPassword} ${autosize} ${width}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${vModel} ${type} ${placeholder} ${maxlength} ${showWordLimit} ${readonly} ${disabled} ${clearable} ${prefixIcon} ${suffixIcon} ${showPassword} ${autosize} ${width}>${child}</${el.tag}>`;
|
||||
},
|
||||
'el-input-number': el => {
|
||||
const { disabled, vModel, placeholder } = attrBuilder(el)
|
||||
const controlsPosition = el['controls-position'] ? `controls-position=${el['controls-position']}` : ''
|
||||
const min = el.min ? `:min='${el.min}'` : ''
|
||||
const max = el.max ? `:max='${el.max}'` : ''
|
||||
const step = el.step ? `:step='${el.step}'` : ''
|
||||
const stepStrictly = el['step-strictly'] ? 'step-strictly' : ''
|
||||
const precision = el.precision ? `:precision='${el.precision}'` : ''
|
||||
"el-input-number": el => {
|
||||
const { disabled, vModel, placeholder } = attrBuilder(el);
|
||||
const controlsPosition = el["controls-position"] ? `controls-position=${el["controls-position"]}` : "";
|
||||
const min = el.min ? `:min='${el.min}'` : "";
|
||||
const max = el.max ? `:max='${el.max}'` : "";
|
||||
const step = el.step ? `:step='${el.step}'` : "";
|
||||
const stepStrictly = el["step-strictly"] ? "step-strictly" : "";
|
||||
const precision = el.precision ? `:precision='${el.precision}'` : "";
|
||||
|
||||
return `<${el.tag} ${vModel} ${placeholder} ${step} ${stepStrictly} ${precision} ${controlsPosition} ${min} ${max} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${placeholder} ${step} ${stepStrictly} ${precision} ${controlsPosition} ${min} ${max} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-select': el => {
|
||||
"el-select": el => {
|
||||
const {
|
||||
disabled, vModel, clearable, placeholder, width
|
||||
} = attrBuilder(el)
|
||||
const filterable = el.filterable ? 'filterable' : ''
|
||||
const multiple = el.multiple ? 'multiple' : ''
|
||||
let child = buildElSelectChild(el)
|
||||
} = attrBuilder(el);
|
||||
const filterable = el.filterable ? "filterable" : "";
|
||||
const multiple = el.multiple ? "multiple" : "";
|
||||
let child = buildElSelectChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${vModel} ${placeholder} ${disabled} ${multiple} ${filterable} ${clearable} ${width}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${vModel} ${placeholder} ${disabled} ${multiple} ${filterable} ${clearable} ${width}>${child}</${el.tag}>`;
|
||||
},
|
||||
'el-radio-group': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const size = `size="${el.size}"`
|
||||
let child = buildElRadioGroupChild(el)
|
||||
"el-radio-group": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const size = `size="${el.size}"`;
|
||||
let child = buildElRadioGroupChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${vModel} ${size} ${disabled}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${vModel} ${size} ${disabled}>${child}</${el.tag}>`;
|
||||
},
|
||||
'el-checkbox-group': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const size = `size="${el.size}"`
|
||||
const min = el.min ? `:min="${el.min}"` : ''
|
||||
const max = el.max ? `:max="${el.max}"` : ''
|
||||
let child = buildElCheckboxGroupChild(el)
|
||||
"el-checkbox-group": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const size = `size="${el.size}"`;
|
||||
const min = el.min ? `:min="${el.min}"` : "";
|
||||
const max = el.max ? `:max="${el.max}"` : "";
|
||||
let child = buildElCheckboxGroupChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${vModel} ${min} ${max} ${size} ${disabled}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${vModel} ${min} ${max} ${size} ${disabled}>${child}</${el.tag}>`;
|
||||
},
|
||||
'el-switch': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const activeText = el['active-text'] ? `active-text="${el['active-text']}"` : ''
|
||||
const inactiveText = el['inactive-text'] ? `inactive-text="${el['inactive-text']}"` : ''
|
||||
const activeColor = el['active-color'] ? `active-color="${el['active-color']}"` : ''
|
||||
const inactiveColor = el['inactive-color'] ? `inactive-color="${el['inactive-color']}"` : ''
|
||||
const activeValue = el['active-value'] !== true ? `:active-value='${JSON.stringify(el['active-value'])}'` : ''
|
||||
const inactiveValue = el['inactive-value'] !== false ? `:inactive-value='${JSON.stringify(el['inactive-value'])}'` : ''
|
||||
"el-switch": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const activeText = el["active-text"] ? `active-text="${el["active-text"]}"` : "";
|
||||
const inactiveText = el["inactive-text"] ? `inactive-text="${el["inactive-text"]}"` : "";
|
||||
const activeColor = el["active-color"] ? `active-color="${el["active-color"]}"` : "";
|
||||
const inactiveColor = el["inactive-color"] ? `inactive-color="${el["inactive-color"]}"` : "";
|
||||
const activeValue = el["active-value"] !== true ? `:active-value='${JSON.stringify(el["active-value"])}'` : "";
|
||||
const inactiveValue = el["inactive-value"] !== false ? `:inactive-value='${JSON.stringify(el["inactive-value"])}'` : "";
|
||||
|
||||
return `<${el.tag} ${vModel} ${activeText} ${inactiveText} ${activeColor} ${inactiveColor} ${activeValue} ${inactiveValue} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${activeText} ${inactiveText} ${activeColor} ${inactiveColor} ${activeValue} ${inactiveValue} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-cascader': el => {
|
||||
"el-cascader": el => {
|
||||
const {
|
||||
disabled, vModel, clearable, placeholder, width
|
||||
} = attrBuilder(el)
|
||||
const options = el.options ? `:options="${el.vModel}Options"` : ''
|
||||
const props = el.props ? `:props="${el.vModel}Props"` : ''
|
||||
const showAllLevels = el['show-all-levels'] ? '' : ':show-all-levels="false"'
|
||||
const filterable = el.filterable ? 'filterable' : ''
|
||||
const separator = el.separator === '/' ? '' : `separator="${el.separator}"`
|
||||
} = attrBuilder(el);
|
||||
const options = el.options ? `:options="${el.vModel}Options"` : "";
|
||||
const props = el.props ? `:props="${el.vModel}Props"` : "";
|
||||
const showAllLevels = el["show-all-levels"] ? "" : ':show-all-levels="false"';
|
||||
const filterable = el.filterable ? "filterable" : "";
|
||||
const separator = el.separator === "/" ? "" : `separator="${el.separator}"`;
|
||||
|
||||
return `<${el.tag} ${vModel} ${options} ${props} ${width} ${showAllLevels} ${placeholder} ${separator} ${filterable} ${clearable} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${options} ${props} ${width} ${showAllLevels} ${placeholder} ${separator} ${filterable} ${clearable} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-slider': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const min = el.min ? `:min='${el.min}'` : ''
|
||||
const max = el.max ? `:max='${el.max}'` : ''
|
||||
const step = el.step ? `:step='${el.step}'` : ''
|
||||
const range = el.range ? 'range' : ''
|
||||
const showStops = el['show-stops'] ? `:show-stops="${el['show-stops']}"` : ''
|
||||
"el-slider": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const min = el.min ? `:min='${el.min}'` : "";
|
||||
const max = el.max ? `:max='${el.max}'` : "";
|
||||
const step = el.step ? `:step='${el.step}'` : "";
|
||||
const range = el.range ? "range" : "";
|
||||
const showStops = el["show-stops"] ? `:show-stops="${el["show-stops"]}"` : "";
|
||||
|
||||
return `<${el.tag} ${min} ${max} ${step} ${vModel} ${range} ${showStops} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${min} ${max} ${step} ${vModel} ${range} ${showStops} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-time-picker': el => {
|
||||
"el-time-picker": el => {
|
||||
const {
|
||||
disabled, vModel, clearable, placeholder, width
|
||||
} = attrBuilder(el)
|
||||
const startPlaceholder = el['start-placeholder'] ? `start-placeholder="${el['start-placeholder']}"` : ''
|
||||
const endPlaceholder = el['end-placeholder'] ? `end-placeholder="${el['end-placeholder']}"` : ''
|
||||
const rangeSeparator = el['range-separator'] ? `range-separator="${el['range-separator']}"` : ''
|
||||
const isRange = el['is-range'] ? 'is-range' : ''
|
||||
const format = el.format ? `format="${el.format}"` : ''
|
||||
const valueFormat = el['value-format'] ? `value-format="${el['value-format']}"` : ''
|
||||
const pickerOptions = el['picker-options'] ? `:picker-options='${JSON.stringify(el['picker-options'])}'` : ''
|
||||
} = attrBuilder(el);
|
||||
const startPlaceholder = el["start-placeholder"] ? `start-placeholder="${el["start-placeholder"]}"` : "";
|
||||
const endPlaceholder = el["end-placeholder"] ? `end-placeholder="${el["end-placeholder"]}"` : "";
|
||||
const rangeSeparator = el["range-separator"] ? `range-separator="${el["range-separator"]}"` : "";
|
||||
const isRange = el["is-range"] ? "is-range" : "";
|
||||
const format = el.format ? `format="${el.format}"` : "";
|
||||
const valueFormat = el["value-format"] ? `value-format="${el["value-format"]}"` : "";
|
||||
const pickerOptions = el["picker-options"] ? `:picker-options='${JSON.stringify(el["picker-options"])}'` : "";
|
||||
|
||||
return `<${el.tag} ${vModel} ${isRange} ${format} ${valueFormat} ${pickerOptions} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${isRange} ${format} ${valueFormat} ${pickerOptions} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-date-picker': el => {
|
||||
"el-date-picker": el => {
|
||||
const {
|
||||
disabled, vModel, clearable, placeholder, width
|
||||
} = attrBuilder(el)
|
||||
const startPlaceholder = el['start-placeholder'] ? `start-placeholder="${el['start-placeholder']}"` : ''
|
||||
const endPlaceholder = el['end-placeholder'] ? `end-placeholder="${el['end-placeholder']}"` : ''
|
||||
const rangeSeparator = el['range-separator'] ? `range-separator="${el['range-separator']}"` : ''
|
||||
const format = el.format ? `format="${el.format}"` : ''
|
||||
const valueFormat = el['value-format'] ? `value-format="${el['value-format']}"` : ''
|
||||
const type = el.type === 'date' ? '' : `type="${el.type}"`
|
||||
const readonly = el.readonly ? 'readonly' : ''
|
||||
} = attrBuilder(el);
|
||||
const startPlaceholder = el["start-placeholder"] ? `start-placeholder="${el["start-placeholder"]}"` : "";
|
||||
const endPlaceholder = el["end-placeholder"] ? `end-placeholder="${el["end-placeholder"]}"` : "";
|
||||
const rangeSeparator = el["range-separator"] ? `range-separator="${el["range-separator"]}"` : "";
|
||||
const format = el.format ? `format="${el.format}"` : "";
|
||||
const valueFormat = el["value-format"] ? `value-format="${el["value-format"]}"` : "";
|
||||
const type = el.type === "date" ? "" : `type="${el.type}"`;
|
||||
const readonly = el.readonly ? "readonly" : "";
|
||||
|
||||
return `<${el.tag} ${type} ${vModel} ${format} ${valueFormat} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${readonly} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${type} ${vModel} ${format} ${valueFormat} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${readonly} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-rate': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const max = el.max ? `:max='${el.max}'` : ''
|
||||
const allowHalf = el['allow-half'] ? 'allow-half' : ''
|
||||
const showText = el['show-text'] ? 'show-text' : ''
|
||||
const showScore = el['show-score'] ? 'show-score' : ''
|
||||
"el-rate": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const allowHalf = el["allow-half"] ? "allow-half" : "";
|
||||
const showText = el["show-text"] ? "show-text" : "";
|
||||
const showScore = el["show-score"] ? "show-score" : "";
|
||||
|
||||
return `<${el.tag} ${vModel} ${allowHalf} ${showText} ${showScore} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${allowHalf} ${showText} ${showScore} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-color-picker': el => {
|
||||
const { disabled, vModel } = attrBuilder(el)
|
||||
const size = `size="${el.size}"`
|
||||
const showAlpha = el['show-alpha'] ? 'show-alpha' : ''
|
||||
const colorFormat = el['color-format'] ? `color-format="${el['color-format']}"` : ''
|
||||
"el-color-picker": el => {
|
||||
const { disabled, vModel } = attrBuilder(el);
|
||||
const size = `size="${el.size}"`;
|
||||
const showAlpha = el["show-alpha"] ? "show-alpha" : "";
|
||||
const colorFormat = el["color-format"] ? `color-format="${el["color-format"]}"` : "";
|
||||
|
||||
return `<${el.tag} ${vModel} ${size} ${showAlpha} ${colorFormat} ${disabled}></${el.tag}>`
|
||||
return `<${el.tag} ${vModel} ${size} ${showAlpha} ${colorFormat} ${disabled}></${el.tag}>`;
|
||||
},
|
||||
'el-upload': el => {
|
||||
const disabled = el.disabled ? ':disabled=\'true\'' : ''
|
||||
const action = el.action ? `:action="${el.vModel}Action"` : ''
|
||||
const multiple = el.multiple ? 'multiple' : ''
|
||||
const listType = el['list-type'] !== 'text' ? `list-type="${el['list-type']}"` : ''
|
||||
const accept = el.accept ? `accept="${el.accept}"` : ''
|
||||
const name = el.name !== 'file' ? `name="${el.name}"` : ''
|
||||
const autoUpload = el['auto-upload'] === false ? ':auto-upload="false"' : ''
|
||||
const beforeUpload = `:before-upload="${el.vModel}BeforeUpload"`
|
||||
const fileList = `:file-list="${el.vModel}fileList"`
|
||||
const ref = `ref="${el.vModel}"`
|
||||
let child = buildElUploadChild(el)
|
||||
"el-upload": el => {
|
||||
const disabled = el.disabled ? ":disabled='true'" : "";
|
||||
const action = el.action ? `:action="${el.vModel}Action"` : "";
|
||||
const multiple = el.multiple ? "multiple" : "";
|
||||
const listType = el["list-type"] !== "text" ? `list-type="${el["list-type"]}"` : "";
|
||||
const accept = el.accept ? `accept="${el.accept}"` : "";
|
||||
const name = el.name !== "file" ? `name="${el.name}"` : "";
|
||||
const autoUpload = el["auto-upload"] === false ? ':auto-upload="false"' : "";
|
||||
const beforeUpload = `:before-upload="${el.vModel}BeforeUpload"`;
|
||||
const fileList = `:file-list="${el.vModel}fileList"`;
|
||||
const ref = `ref="${el.vModel}"`;
|
||||
let child = buildElUploadChild(el);
|
||||
|
||||
if (child) child = `\n${child}\n` // 换行
|
||||
return `<${el.tag} ${ref} ${fileList} ${action} ${autoUpload} ${multiple} ${beforeUpload} ${listType} ${accept} ${name} ${disabled}>${child}</${el.tag}>`
|
||||
if (child) child = `\n${child}\n`; // 换行
|
||||
return `<${el.tag} ${ref} ${fileList} ${action} ${autoUpload} ${multiple} ${beforeUpload} ${listType} ${accept} ${name} ${disabled}>${child}</${el.tag}>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function attrBuilder(el) {
|
||||
return {
|
||||
vModel: `v-model="${confGlobal.formModel}.${el.vModel}"`,
|
||||
clearable: el.clearable ? 'clearable' : '',
|
||||
placeholder: el.placeholder ? `placeholder="${el.placeholder}"` : '',
|
||||
width: el.style && el.style.width ? ':style="{width: \'100%\'}"' : '',
|
||||
disabled: el.disabled ? ':disabled=\'true\'' : ''
|
||||
}
|
||||
clearable: el.clearable ? "clearable" : "",
|
||||
placeholder: el.placeholder ? `placeholder="${el.placeholder}"` : "",
|
||||
width: el.style && el.style.width ? ':style="{width: \'100%\'}"' : "",
|
||||
disabled: el.disabled ? ":disabled='true'" : ""
|
||||
};
|
||||
}
|
||||
|
||||
// el-buttin 子级
|
||||
function buildElButtonChild(conf) {
|
||||
const children = []
|
||||
const children = [];
|
||||
if (conf.default) {
|
||||
children.push(conf.default)
|
||||
children.push(conf.default);
|
||||
}
|
||||
return children.join('\n')
|
||||
return children.join("\n");
|
||||
}
|
||||
|
||||
// el-input innerHTML
|
||||
function buildElInputChild(conf) {
|
||||
const children = []
|
||||
const children = [];
|
||||
if (conf.prepend) {
|
||||
children.push(`<template slot="prepend">${conf.prepend}</template>`)
|
||||
children.push(`<template slot="prepend">${conf.prepend}</template>`);
|
||||
}
|
||||
if (conf.append) {
|
||||
children.push(`<template slot="append">${conf.append}</template>`)
|
||||
children.push(`<template slot="append">${conf.append}</template>`);
|
||||
}
|
||||
return children.join('\n')
|
||||
return children.join("\n");
|
||||
}
|
||||
|
||||
function buildElSelectChild(conf) {
|
||||
const children = []
|
||||
const children = [];
|
||||
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>`);
|
||||
}
|
||||
return children.join('\n')
|
||||
return children.join("\n");
|
||||
}
|
||||
|
||||
function buildElRadioGroupChild(conf) {
|
||||
const children = []
|
||||
const children = [];
|
||||
if (conf.options && conf.options.length) {
|
||||
const tag = conf.optionType === 'button' ? 'el-radio-button' : 'el-radio'
|
||||
const border = conf.border ? 'border' : ''
|
||||
children.push(`<${tag} v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`)
|
||||
const tag = conf.optionType === "button" ? "el-radio-button" : "el-radio";
|
||||
const border = conf.border ? "border" : "";
|
||||
children.push(`<${tag} v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`);
|
||||
}
|
||||
return children.join('\n')
|
||||
return children.join("\n");
|
||||
}
|
||||
|
||||
function buildElCheckboxGroupChild(conf) {
|
||||
const children = []
|
||||
const children = [];
|
||||
if (conf.options && conf.options.length) {
|
||||
const tag = conf.optionType === 'button' ? 'el-checkbox-button' : 'el-checkbox'
|
||||
const border = conf.border ? 'border' : ''
|
||||
children.push(`<${tag} v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`)
|
||||
const tag = conf.optionType === "button" ? "el-checkbox-button" : "el-checkbox";
|
||||
const border = conf.border ? "border" : "";
|
||||
children.push(`<${tag} v-for="(item, index) in ${conf.vModel}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`);
|
||||
}
|
||||
return children.join('\n')
|
||||
return children.join("\n");
|
||||
}
|
||||
|
||||
function buildElUploadChild(conf) {
|
||||
const list = []
|
||||
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>`)
|
||||
if (conf.showTip) list.push(`<div slot="tip" class="el-upload__tip">只能上传不超过 ${conf.fileSize}${conf.sizeUnit} 的${conf.accept}文件</div>`)
|
||||
return list.join('\n')
|
||||
const list = [];
|
||||
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>`);
|
||||
if (conf.showTip) list.push(`<div slot="tip" class="el-upload__tip">只能上传不超过 ${conf.fileSize}${conf.sizeUnit} 的${conf.accept}文件</div>`);
|
||||
return list.join("\n");
|
||||
}
|
||||
|
||||
export function makeUpHtml(conf, type) {
|
||||
const htmlList = []
|
||||
confGlobal = conf
|
||||
someSpanIsNot24 = conf.fields.some(item => item.span !== 24)
|
||||
const htmlList = [];
|
||||
confGlobal = conf;
|
||||
someSpanIsNot24 = conf.fields.some(item => item.span !== 24);
|
||||
conf.fields.forEach(el => {
|
||||
htmlList.push(layouts[el.layout](el))
|
||||
})
|
||||
const htmlStr = htmlList.join('\n')
|
||||
htmlList.push(layouts[el.layout](el));
|
||||
});
|
||||
const htmlStr = htmlList.join("\n");
|
||||
|
||||
let temp = buildFormTemplate(conf, htmlStr, type)
|
||||
if (type === 'dialog') {
|
||||
temp = dialogWrapper(temp)
|
||||
let temp = buildFormTemplate(conf, htmlStr, type);
|
||||
if (type === "dialog") {
|
||||
temp = dialogWrapper(temp);
|
||||
}
|
||||
confGlobal = null
|
||||
return temp
|
||||
confGlobal = null;
|
||||
return temp;
|
||||
}
|
||||
|
|
|
@ -1,78 +1,77 @@
|
|||
import { isArray } from 'util'
|
||||
import { exportDefault, titleCase } from '@/utils/index'
|
||||
import { trigger } from './config'
|
||||
import { isArray } from "util";
|
||||
import { exportDefault, titleCase } from "@/utils/index";
|
||||
import { trigger } from "./config";
|
||||
|
||||
const units = {
|
||||
KB: '1024',
|
||||
MB: '1024 / 1024',
|
||||
GB: '1024 / 1024 / 1024'
|
||||
}
|
||||
let confGlobal
|
||||
KB: "1024",
|
||||
MB: "1024 / 1024",
|
||||
GB: "1024 / 1024 / 1024"
|
||||
};
|
||||
let confGlobal;
|
||||
const inheritAttrs = {
|
||||
file: '',
|
||||
dialog: 'inheritAttrs: false,'
|
||||
}
|
||||
|
||||
file: "",
|
||||
dialog: "inheritAttrs: false,"
|
||||
};
|
||||
|
||||
export function makeUpJs(conf, type) {
|
||||
confGlobal = conf = JSON.parse(JSON.stringify(conf))
|
||||
const dataList = []
|
||||
const ruleList = []
|
||||
const optionsList = []
|
||||
const propsList = []
|
||||
const methodList = mixinMethod(type)
|
||||
const uploadVarList = []
|
||||
confGlobal = conf = JSON.parse(JSON.stringify(conf));
|
||||
const dataList = [];
|
||||
const ruleList = [];
|
||||
const optionsList = [];
|
||||
const propsList = [];
|
||||
const methodList = mixinMethod(type);
|
||||
const uploadVarList = [];
|
||||
|
||||
conf.fields.forEach(el => {
|
||||
buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList)
|
||||
})
|
||||
buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList);
|
||||
});
|
||||
|
||||
const script = buildexport(
|
||||
conf,
|
||||
type,
|
||||
dataList.join('\n'),
|
||||
ruleList.join('\n'),
|
||||
optionsList.join('\n'),
|
||||
uploadVarList.join('\n'),
|
||||
propsList.join('\n'),
|
||||
methodList.join('\n')
|
||||
)
|
||||
confGlobal = null
|
||||
return script
|
||||
dataList.join("\n"),
|
||||
ruleList.join("\n"),
|
||||
optionsList.join("\n"),
|
||||
uploadVarList.join("\n"),
|
||||
propsList.join("\n"),
|
||||
methodList.join("\n")
|
||||
);
|
||||
confGlobal = null;
|
||||
return script;
|
||||
}
|
||||
|
||||
function buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList) {
|
||||
buildData(el, dataList)
|
||||
buildRules(el, ruleList)
|
||||
buildData(el, dataList);
|
||||
buildRules(el, ruleList);
|
||||
|
||||
if (el.options && el.options.length) {
|
||||
buildOptions(el, optionsList)
|
||||
if (el.dataType === 'dynamic') {
|
||||
const model = `${el.vModel}Options`
|
||||
const options = titleCase(model)
|
||||
buildOptionMethod(`get${options}`, model, methodList)
|
||||
buildOptions(el, optionsList);
|
||||
if (el.dataType === "dynamic") {
|
||||
const model = `${el.vModel}Options`;
|
||||
const options = titleCase(model);
|
||||
buildOptionMethod(`get${options}`, model, methodList);
|
||||
}
|
||||
}
|
||||
|
||||
if (el.props && el.props.props) {
|
||||
buildProps(el, propsList)
|
||||
buildProps(el, propsList);
|
||||
}
|
||||
|
||||
if (el.action && el.tag === 'el-upload') {
|
||||
if (el.action && el.tag === "el-upload") {
|
||||
uploadVarList.push(
|
||||
`${el.vModel}Action: '${el.action}',
|
||||
${el.vModel}fileList: [],`
|
||||
)
|
||||
methodList.push(buildBeforeUpload(el))
|
||||
if (!el['auto-upload']) {
|
||||
methodList.push(buildSubmitUpload(el))
|
||||
);
|
||||
methodList.push(buildBeforeUpload(el));
|
||||
if (!el["auto-upload"]) {
|
||||
methodList.push(buildSubmitUpload(el));
|
||||
}
|
||||
}
|
||||
|
||||
if (el.children) {
|
||||
el.children.forEach(el2 => {
|
||||
buildAttributes(el2, dataList, ruleList, optionsList, methodList, propsList, uploadVarList)
|
||||
})
|
||||
buildAttributes(el2, dataList, ruleList, optionsList, methodList, propsList, uploadVarList);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +90,7 @@ function mixinMethod(type) {
|
|||
},`
|
||||
} : null,
|
||||
dialog: {
|
||||
onOpen: 'onOpen() {},',
|
||||
onOpen: "onOpen() {},",
|
||||
onClose: `onClose() {
|
||||
this.$refs['${confGlobal.formRef}'].resetFields()
|
||||
},`,
|
||||
|
@ -105,105 +104,106 @@ function mixinMethod(type) {
|
|||
})
|
||||
},`
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const methods = minxins[type]
|
||||
const methods = minxins[type];
|
||||
if (methods) {
|
||||
Object.keys(methods).forEach(key => {
|
||||
list.push(methods[key])
|
||||
})
|
||||
list.push(methods[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return list
|
||||
return list;
|
||||
}
|
||||
|
||||
function buildData(conf, dataList) {
|
||||
if (conf.vModel === undefined) return
|
||||
let defaultValue
|
||||
if (typeof (conf.defaultValue) === 'string' && !conf.multiple) {
|
||||
defaultValue = `'${conf.defaultValue}'`
|
||||
if (conf.vModel === undefined) return;
|
||||
let defaultValue;
|
||||
if (typeof (conf.defaultValue) === "string" && !conf.multiple) {
|
||||
defaultValue = `'${conf.defaultValue}'`;
|
||||
} else {
|
||||
defaultValue = `${JSON.stringify(conf.defaultValue)}`
|
||||
defaultValue = `${JSON.stringify(conf.defaultValue)}`;
|
||||
}
|
||||
dataList.push(`${conf.vModel}: ${defaultValue},`)
|
||||
dataList.push(`${conf.vModel}: ${defaultValue},`);
|
||||
}
|
||||
|
||||
function buildRules(conf, ruleList) {
|
||||
if (conf.vModel === undefined) return
|
||||
const rules = []
|
||||
if (conf.vModel === undefined) return;
|
||||
const rules = [];
|
||||
if (trigger[conf.tag]) {
|
||||
if (conf.required) {
|
||||
const type = isArray(conf.defaultValue) ? 'type: \'array\',' : ''
|
||||
let message = isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder
|
||||
if (message === undefined) message = `${conf.label}不能为空`
|
||||
rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`)
|
||||
const type = isArray(conf.defaultValue) ? "type: 'array'," : "";
|
||||
let message = isArray(conf.defaultValue) ? `请至少选择一个${conf.vModel}` : conf.placeholder;
|
||||
if (message === undefined) message = `${conf.label}不能为空`;
|
||||
rules.push(`{ required: true, ${type} message: '${message}', trigger: '${trigger[conf.tag]}' }`);
|
||||
}
|
||||
if (conf.regList && isArray(conf.regList)) {
|
||||
conf.regList.forEach(item => {
|
||||
if (item.pattern) {
|
||||
rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`)
|
||||
// eslint-disable-next-line no-eval
|
||||
rules.push(`{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${trigger[conf.tag]}' }`);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
ruleList.push(`${conf.vModel}: [${rules.join(',')}],`)
|
||||
ruleList.push(`${conf.vModel}: [${rules.join(",")}],`);
|
||||
}
|
||||
}
|
||||
|
||||
function buildOptions(conf, optionsList) {
|
||||
if (conf.vModel === undefined) return
|
||||
if (conf.dataType === 'dynamic') { conf.options = [] }
|
||||
const str = `${conf.vModel}Options: ${JSON.stringify(conf.options)},`
|
||||
optionsList.push(str)
|
||||
if (conf.vModel === undefined) return;
|
||||
if (conf.dataType === "dynamic") { conf.options = []; }
|
||||
const str = `${conf.vModel}Options: ${JSON.stringify(conf.options)},`;
|
||||
optionsList.push(str);
|
||||
}
|
||||
|
||||
function buildProps(conf, propsList) {
|
||||
if (conf.dataType === 'dynamic') {
|
||||
conf.valueKey !== 'value' && (conf.props.props.value = conf.valueKey)
|
||||
conf.labelKey !== 'label' && (conf.props.props.label = conf.labelKey)
|
||||
conf.childrenKey !== 'children' && (conf.props.props.children = conf.childrenKey)
|
||||
if (conf.dataType === "dynamic") {
|
||||
conf.valueKey !== "value" && (conf.props.props.value = conf.valueKey);
|
||||
conf.labelKey !== "label" && (conf.props.props.label = conf.labelKey);
|
||||
conf.childrenKey !== "children" && (conf.props.props.children = conf.childrenKey);
|
||||
}
|
||||
const str = `${conf.vModel}Props: ${JSON.stringify(conf.props.props)},`
|
||||
propsList.push(str)
|
||||
const str = `${conf.vModel}Props: ${JSON.stringify(conf.props.props)},`;
|
||||
propsList.push(str);
|
||||
}
|
||||
|
||||
function buildBeforeUpload(conf) {
|
||||
const unitNum = units[conf.sizeUnit]; let rightSizeCode = ''; let acceptCode = ''; const
|
||||
returnList = []
|
||||
const unitNum = units[conf.sizeUnit]; let rightSizeCode = ""; let acceptCode = ""; const
|
||||
returnList = [];
|
||||
if (conf.fileSize) {
|
||||
rightSizeCode = `let isRightSize = file.size / ${unitNum} < ${conf.fileSize}
|
||||
if(!isRightSize){
|
||||
this.$message.error('文件大小超过 ${conf.fileSize}${conf.sizeUnit}')
|
||||
}`
|
||||
returnList.push('isRightSize')
|
||||
}`;
|
||||
returnList.push("isRightSize");
|
||||
}
|
||||
if (conf.accept) {
|
||||
acceptCode = `let isAccept = new RegExp('${conf.accept}').test(file.type)
|
||||
if(!isAccept){
|
||||
this.$message.error('应该选择${conf.accept}类型的文件')
|
||||
}`
|
||||
returnList.push('isAccept')
|
||||
}`;
|
||||
returnList.push("isAccept");
|
||||
}
|
||||
const str = `${conf.vModel}BeforeUpload(file) {
|
||||
${rightSizeCode}
|
||||
${acceptCode}
|
||||
return ${returnList.join('&&')}
|
||||
},`
|
||||
return returnList.length ? str : ''
|
||||
return ${returnList.join("&&")}
|
||||
},`;
|
||||
return returnList.length ? str : "";
|
||||
}
|
||||
|
||||
function buildSubmitUpload(conf) {
|
||||
const str = `submitUpload() {
|
||||
this.$refs['${conf.vModel}'].submit()
|
||||
},`
|
||||
return str
|
||||
},`;
|
||||
return str;
|
||||
}
|
||||
|
||||
function buildOptionMethod(methodName, model, methodList) {
|
||||
const str = `${methodName}() {
|
||||
// TODO 发起请求获取数据
|
||||
this.${model}
|
||||
},`
|
||||
methodList.push(str)
|
||||
},`;
|
||||
methodList.push(str);
|
||||
}
|
||||
|
||||
function buildexport(conf, type, data, rules, selectOptions, uploadVar, props, methods) {
|
||||
|
@ -231,6 +231,6 @@ function buildexport(conf, type, data, rules, selectOptions, uploadVar, props, m
|
|||
methods: {
|
||||
${methods}
|
||||
}
|
||||
}`
|
||||
return str
|
||||
}`;
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -1,91 +1,91 @@
|
|||
import { makeMap } from '@/utils/index'
|
||||
import { makeMap } from "@/utils/index";
|
||||
|
||||
// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js
|
||||
const isAttr = makeMap(
|
||||
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,'
|
||||
+ 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,'
|
||||
+ 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,'
|
||||
+ 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,'
|
||||
+ 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,'
|
||||
+ 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,'
|
||||
+ 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,'
|
||||
+ 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,'
|
||||
+ 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,'
|
||||
+ 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,'
|
||||
+ 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,'
|
||||
+ 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,'
|
||||
+ 'target,title,type,usemap,value,width,wrap'
|
||||
)
|
||||
"accept,accept-charset,accesskey,action,align,alt,async,autocomplete," +
|
||||
"autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset," +
|
||||
"checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv," +
|
||||
"name,contenteditable,contextmenu,controls,coords,data,datetime,default," +
|
||||
"defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for," +
|
||||
"form,formaction,headers,height,hidden,high,href,hreflang,http-equiv," +
|
||||
"icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low," +
|
||||
"manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file," +
|
||||
"muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster," +
|
||||
"preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox," +
|
||||
"scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span," +
|
||||
"spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex," +
|
||||
"target,title,type,usemap,value,width,wrap"
|
||||
);
|
||||
|
||||
function vModel(self, dataObject, defaultValue) {
|
||||
dataObject.props.value = defaultValue
|
||||
dataObject.props.value = defaultValue;
|
||||
|
||||
dataObject.on.input = val => {
|
||||
self.$emit('input', val)
|
||||
}
|
||||
self.$emit("input", val);
|
||||
};
|
||||
}
|
||||
|
||||
const componentChild = {
|
||||
'el-button': {
|
||||
"el-button": {
|
||||
default(h, conf, key) {
|
||||
return conf[key]
|
||||
},
|
||||
return conf[key];
|
||||
}
|
||||
},
|
||||
'el-input': {
|
||||
"el-input": {
|
||||
prepend(h, conf, key) {
|
||||
return <template slot="prepend">{conf[key]}</template>
|
||||
return <template slot='prepend'>{conf[key]}</template>;
|
||||
},
|
||||
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) {
|
||||
const list = []
|
||||
const list = [];
|
||||
conf.options.forEach(item => {
|
||||
list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>)
|
||||
})
|
||||
return list
|
||||
list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
},
|
||||
'el-radio-group': {
|
||||
"el-radio-group": {
|
||||
options(h, conf, key) {
|
||||
const list = []
|
||||
const list = [];
|
||||
conf.options.forEach(item => {
|
||||
if (conf.optionType === 'button') list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>)
|
||||
else list.push(<el-radio label={item.value} border={conf.border}>{item.label}</el-radio>)
|
||||
})
|
||||
return list
|
||||
if (conf.optionType === "button") list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>);
|
||||
else list.push(<el-radio label={item.value} border={conf.border}>{item.label}</el-radio>);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
},
|
||||
'el-checkbox-group': {
|
||||
"el-checkbox-group": {
|
||||
options(h, conf, key) {
|
||||
const list = []
|
||||
const list = [];
|
||||
conf.options.forEach(item => {
|
||||
if (conf.optionType === 'button') {
|
||||
list.push(<el-checkbox-button label={item.value}>{item.label}</el-checkbox-button>)
|
||||
if (conf.optionType === "button") {
|
||||
list.push(<el-checkbox-button label={item.value}>{item.label}</el-checkbox-button>);
|
||||
} else {
|
||||
list.push(<el-checkbox label={item.value} border={conf.border}>{item.label}</el-checkbox>)
|
||||
list.push(<el-checkbox label={item.value} border={conf.border}>{item.label}</el-checkbox>);
|
||||
}
|
||||
})
|
||||
return list
|
||||
});
|
||||
return list;
|
||||
}
|
||||
},
|
||||
'el-upload': {
|
||||
'list-type': (h, conf, key) => {
|
||||
const list = []
|
||||
if (conf['list-type'] === 'picture-card') {
|
||||
list.push(<i class="el-icon-plus"></i>)
|
||||
"el-upload": {
|
||||
"list-type": (h, conf, key) => {
|
||||
const list = [];
|
||||
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>)
|
||||
list.push(<el-button size='small' type='primary' icon='el-icon-upload'>{conf.buttonText}</el-button>);
|
||||
}
|
||||
if (conf.showTip) {
|
||||
list.push(<div slot="tip" class="el-upload__tip">只能上传不超过 {conf.fileSize}{conf.sizeUnit} 的{conf.accept}文件</div>)
|
||||
list.push(<div slot='tip' class='el-upload__tip'>只能上传不超过 {conf.fileSize}{conf.sizeUnit} 的{conf.accept}文件</div>);
|
||||
}
|
||||
return list
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
render(h) {
|
||||
|
@ -94,33 +94,33 @@ export default {
|
|||
props: {},
|
||||
on: {},
|
||||
style: {}
|
||||
}
|
||||
const confClone = JSON.parse(JSON.stringify(this.conf))
|
||||
const children = []
|
||||
};
|
||||
const confClone = JSON.parse(JSON.stringify(this.conf));
|
||||
const children = [];
|
||||
|
||||
const childObjs = componentChild[confClone.tag]
|
||||
const childObjs = componentChild[confClone.tag];
|
||||
if (childObjs) {
|
||||
Object.keys(childObjs).forEach(key => {
|
||||
const childFunc = childObjs[key]
|
||||
const childFunc = childObjs[key];
|
||||
if (confClone[key]) {
|
||||
children.push(childFunc(h, confClone, key))
|
||||
children.push(childFunc(h, confClone, key));
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys(confClone).forEach(key => {
|
||||
const val = confClone[key]
|
||||
if (key === 'vModel') {
|
||||
vModel(this, dataObject, confClone.defaultValue)
|
||||
const val = confClone[key];
|
||||
if (key === "vModel") {
|
||||
vModel(this, dataObject, confClone.defaultValue);
|
||||
} else if (dataObject[key]) {
|
||||
dataObject[key] = val
|
||||
dataObject[key] = val;
|
||||
} else if (!isAttr(key)) {
|
||||
dataObject.props[key] = val
|
||||
dataObject.props[key] = val;
|
||||
} else {
|
||||
dataObject.attrs[key] = val
|
||||
dataObject.attrs[key] = val;
|
||||
}
|
||||
})
|
||||
return h(this.conf.tag, dataObject, children)
|
||||
});
|
||||
return h(this.conf.tag, dataObject, children);
|
||||
},
|
||||
props: ['conf']
|
||||
}
|
||||
props: ["conf"]
|
||||
};
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import { parseTime } from './ruoyi'
|
||||
import { parseTime } from "./ruoyi";
|
||||
|
||||
/**
|
||||
* 表格时间格式化
|
||||
*/
|
||||
export function formatDate(cellValue) {
|
||||
if (cellValue == null || cellValue == "") return "";
|
||||
var date = new Date(cellValue)
|
||||
var year = date.getFullYear()
|
||||
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
||||
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
||||
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
||||
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
||||
var date = new Date(cellValue);
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
|
||||
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
||||
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||
return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,40 +21,40 @@ export function formatDate(cellValue) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function formatTime(time, option) {
|
||||
if (('' + time).length === 10) {
|
||||
time = parseInt(time) * 1000
|
||||
if (("" + time).length === 10) {
|
||||
time = parseInt(time) * 1000;
|
||||
} else {
|
||||
time = +time
|
||||
time = +time;
|
||||
}
|
||||
const d = new Date(time)
|
||||
const now = Date.now()
|
||||
const d = new Date(time);
|
||||
const now = Date.now();
|
||||
|
||||
const diff = (now - d) / 1000
|
||||
const diff = (now - d) / 1000;
|
||||
|
||||
if (diff < 30) {
|
||||
return '刚刚'
|
||||
return "刚刚";
|
||||
} else if (diff < 3600) {
|
||||
// less 1 hour
|
||||
return Math.ceil(diff / 60) + '分钟前'
|
||||
return Math.ceil(diff / 60) + "分钟前";
|
||||
} else if (diff < 3600 * 24) {
|
||||
return Math.ceil(diff / 3600) + '小时前'
|
||||
return Math.ceil(diff / 3600) + "小时前";
|
||||
} else if (diff < 3600 * 24 * 2) {
|
||||
return '1天前'
|
||||
return "1天前";
|
||||
}
|
||||
if (option) {
|
||||
return parseTime(time, option)
|
||||
return parseTime(time, option);
|
||||
} else {
|
||||
return (
|
||||
d.getMonth() +
|
||||
1 +
|
||||
'月' +
|
||||
"月" +
|
||||
d.getDate() +
|
||||
'日' +
|
||||
"日" +
|
||||
d.getHours() +
|
||||
'时' +
|
||||
"时" +
|
||||
d.getMinutes() +
|
||||
'分'
|
||||
)
|
||||
"分"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,18 +63,18 @@ export function formatTime(time, option) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function getQueryObject(url) {
|
||||
url = url == null ? window.location.href : url
|
||||
const search = url.substring(url.lastIndexOf('?') + 1)
|
||||
const obj = {}
|
||||
const reg = /([^?&=]+)=([^?&=]*)/g
|
||||
url = url == null ? window.location.href : url;
|
||||
const search = url.substring(url.lastIndexOf("?") + 1);
|
||||
const obj = {};
|
||||
const reg = /([^?&=]+)=([^?&=]*)/g;
|
||||
search.replace(reg, (rs, $1, $2) => {
|
||||
const name = decodeURIComponent($1)
|
||||
let val = decodeURIComponent($2)
|
||||
val = String(val)
|
||||
obj[name] = val
|
||||
return rs
|
||||
})
|
||||
return obj
|
||||
const name = decodeURIComponent($1);
|
||||
let val = decodeURIComponent($2);
|
||||
val = String(val);
|
||||
obj[name] = val;
|
||||
return rs;
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,14 +83,14 @@ export function getQueryObject(url) {
|
|||
*/
|
||||
export function byteLength(str) {
|
||||
// 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--) {
|
||||
const code = str.charCodeAt(i)
|
||||
if (code > 0x7f && code <= 0x7ff) s++
|
||||
else if (code > 0x7ff && code <= 0xffff) s += 2
|
||||
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
||||
const code = str.charCodeAt(i);
|
||||
if (code > 0x7f && code <= 0x7ff) s++;
|
||||
else if (code > 0x7ff && code <= 0xffff) s += 2;
|
||||
if (code >= 0xDC00 && code <= 0xDFFF) i--;
|
||||
}
|
||||
return s
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,13 +98,13 @@ export function byteLength(str) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
export function cleanArray(actual) {
|
||||
const newArray = []
|
||||
const newArray = [];
|
||||
for (let i = 0; i < actual.length; i++) {
|
||||
if (actual[i]) {
|
||||
newArray.push(actual[i])
|
||||
newArray.push(actual[i]);
|
||||
}
|
||||
}
|
||||
return newArray
|
||||
return newArray;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,13 +112,13 @@ export function cleanArray(actual) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
export function param(json) {
|
||||
if (!json) return ''
|
||||
if (!json) return "";
|
||||
return cleanArray(
|
||||
Object.keys(json).map(key => {
|
||||
if (json[key] === undefined) return ''
|
||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
||||
if (json[key] === undefined) return "";
|
||||
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
|
||||
})
|
||||
).join('&')
|
||||
).join("&");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,21 +126,21 @@ export function param(json) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function param2Obj(url) {
|
||||
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
|
||||
const search = decodeURIComponent(url.split("?")[1]).replace(/\+/g, " ");
|
||||
if (!search) {
|
||||
return {}
|
||||
return {};
|
||||
}
|
||||
const obj = {}
|
||||
const searchArr = search.split('&')
|
||||
const obj = {};
|
||||
const searchArr = search.split("&");
|
||||
searchArr.forEach(v => {
|
||||
const index = v.indexOf('=')
|
||||
const index = v.indexOf("=");
|
||||
if (index !== -1) {
|
||||
const name = v.substring(0, index)
|
||||
const val = v.substring(index + 1, v.length)
|
||||
obj[name] = val
|
||||
const name = v.substring(0, index);
|
||||
const val = v.substring(index + 1, v.length);
|
||||
obj[name] = val;
|
||||
}
|
||||
})
|
||||
return obj
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,9 +148,9 @@ export function param2Obj(url) {
|
|||
* @returns {string}
|
||||
*/
|
||||
export function html2Text(val) {
|
||||
const div = document.createElement('div')
|
||||
div.innerHTML = val
|
||||
return div.textContent || div.innerText
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = val;
|
||||
return div.textContent || div.innerText;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,21 +160,21 @@ export function html2Text(val) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function objectMerge(target, source) {
|
||||
if (typeof target !== 'object') {
|
||||
target = {}
|
||||
if (typeof target !== "object") {
|
||||
target = {};
|
||||
}
|
||||
if (Array.isArray(source)) {
|
||||
return source.slice()
|
||||
return source.slice();
|
||||
}
|
||||
Object.keys(source).forEach(property => {
|
||||
const sourceProperty = source[property]
|
||||
if (typeof sourceProperty === 'object') {
|
||||
target[property] = objectMerge(target[property], sourceProperty)
|
||||
const sourceProperty = source[property];
|
||||
if (typeof sourceProperty === "object") {
|
||||
target[property] = objectMerge(target[property], sourceProperty);
|
||||
} else {
|
||||
target[property] = sourceProperty
|
||||
target[property] = sourceProperty;
|
||||
}
|
||||
})
|
||||
return target
|
||||
});
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,18 +183,18 @@ export function objectMerge(target, source) {
|
|||
*/
|
||||
export function toggleClass(element, className) {
|
||||
if (!element || !className) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
let classString = element.className
|
||||
const nameIndex = classString.indexOf(className)
|
||||
let classString = element.className;
|
||||
const nameIndex = classString.indexOf(className);
|
||||
if (nameIndex === -1) {
|
||||
classString += '' + className
|
||||
classString += "" + className;
|
||||
} else {
|
||||
classString =
|
||||
classString.substr(0, nameIndex) +
|
||||
classString.substr(nameIndex + className.length)
|
||||
classString.substr(nameIndex + className.length);
|
||||
}
|
||||
element.className = classString
|
||||
element.className = classString;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,10 +202,10 @@ export function toggleClass(element, className) {
|
|||
* @returns {Date}
|
||||
*/
|
||||
export function getTime(type) {
|
||||
if (type === 'start') {
|
||||
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
||||
if (type === "start") {
|
||||
return new Date().getTime() - 3600 * 1000 * 24 * 90;
|
||||
} else {
|
||||
return new Date(new Date().toDateString())
|
||||
return new Date(new Date().toDateString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,38 +216,38 @@ export function getTime(type) {
|
|||
* @return {*}
|
||||
*/
|
||||
export function debounce(func, wait, immediate) {
|
||||
let timeout, args, context, timestamp, result
|
||||
let timeout, args, context, timestamp, result;
|
||||
|
||||
const later = function() {
|
||||
// 据上一次触发时间间隔
|
||||
const last = +new Date() - timestamp
|
||||
const last = +new Date() - timestamp;
|
||||
|
||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
||||
if (last < wait && last > 0) {
|
||||
timeout = setTimeout(later, wait - last)
|
||||
timeout = setTimeout(later, wait - last);
|
||||
} else {
|
||||
timeout = null
|
||||
timeout = null;
|
||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args)
|
||||
if (!timeout) context = args = null
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return function(...args) {
|
||||
context = this
|
||||
timestamp = +new Date()
|
||||
const callNow = immediate && !timeout
|
||||
context = this;
|
||||
timestamp = +new Date();
|
||||
const callNow = immediate && !timeout;
|
||||
// 如果延时不存在,重新设定延时
|
||||
if (!timeout) timeout = setTimeout(later, wait)
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args)
|
||||
context = args = null
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,18 +258,18 @@ export function debounce(func, wait, immediate) {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export function deepClone(source) {
|
||||
if (!source && typeof source !== 'object') {
|
||||
throw new Error('error arguments', 'deepClone')
|
||||
if (!source && typeof source !== "object") {
|
||||
throw new Error("error arguments", "deepClone");
|
||||
}
|
||||
const targetObj = source.constructor === Array ? [] : {}
|
||||
const targetObj = source.constructor === Array ? [] : {};
|
||||
Object.keys(source).forEach(keys => {
|
||||
if (source[keys] && typeof source[keys] === 'object') {
|
||||
targetObj[keys] = deepClone(source[keys])
|
||||
if (source[keys] && typeof source[keys] === "object") {
|
||||
targetObj[keys] = deepClone(source[keys]);
|
||||
} else {
|
||||
targetObj[keys] = source[keys]
|
||||
targetObj[keys] = source[keys];
|
||||
}
|
||||
})
|
||||
return targetObj
|
||||
});
|
||||
return targetObj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,16 +277,16 @@ export function deepClone(source) {
|
|||
* @returns {Array}
|
||||
*/
|
||||
export function uniqueArr(arr) {
|
||||
return Array.from(new Set(arr))
|
||||
return Array.from(new Set(arr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
export function createUniqueString() {
|
||||
const timestamp = +new Date() + ''
|
||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
||||
return (+(randomNum + timestamp)).toString(32)
|
||||
const timestamp = +new Date() + "";
|
||||
const randomNum = parseInt((1 + Math.random()) * 65536) + "";
|
||||
return (+(randomNum + timestamp)).toString(32);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ export function createUniqueString() {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
export function hasClass(ele, cls) {
|
||||
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
|
||||
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,7 +305,7 @@ export function hasClass(ele, cls) {
|
|||
* @param {string} cls
|
||||
*/
|
||||
export function addClass(ele, cls) {
|
||||
if (!hasClass(ele, cls)) ele.className += ' ' + cls
|
||||
if (!hasClass(ele, cls)) ele.className += " " + cls;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,90 +315,90 @@ export function addClass(ele, cls) {
|
|||
*/
|
||||
export function removeClass(ele, cls) {
|
||||
if (hasClass(ele, cls)) {
|
||||
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
||||
ele.className = ele.className.replace(reg, ' ')
|
||||
const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
||||
ele.className = ele.className.replace(reg, " ");
|
||||
}
|
||||
}
|
||||
|
||||
export function makeMap(str, expectsLowerCase) {
|
||||
const map = Object.create(null)
|
||||
const list = str.split(',')
|
||||
const map = Object.create(null);
|
||||
const list = str.split(",");
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
map[list[i]] = true
|
||||
map[list[i]] = true;
|
||||
}
|
||||
return expectsLowerCase
|
||||
? val => map[val.toLowerCase()]
|
||||
: val => map[val]
|
||||
: val => map[val];
|
||||
}
|
||||
|
||||
export const exportDefault = 'export default '
|
||||
export const exportDefault = "export default ";
|
||||
|
||||
export const beautifierConf = {
|
||||
html: {
|
||||
indent_size: '2',
|
||||
indent_char: ' ',
|
||||
max_preserve_newlines: '-1',
|
||||
indent_size: "2",
|
||||
indent_char: " ",
|
||||
max_preserve_newlines: "-1",
|
||||
preserve_newlines: false,
|
||||
keep_array_indentation: false,
|
||||
break_chained_methods: false,
|
||||
indent_scripts: 'separate',
|
||||
brace_style: 'end-expand',
|
||||
indent_scripts: "separate",
|
||||
brace_style: "end-expand",
|
||||
space_before_conditional: true,
|
||||
unescape_strings: false,
|
||||
jslint_happy: false,
|
||||
end_with_newline: true,
|
||||
wrap_line_length: '110',
|
||||
wrap_line_length: "110",
|
||||
indent_inner_html: true,
|
||||
comma_first: false,
|
||||
e4x: true,
|
||||
indent_empty_lines: true
|
||||
},
|
||||
js: {
|
||||
indent_size: '2',
|
||||
indent_char: ' ',
|
||||
max_preserve_newlines: '-1',
|
||||
indent_size: "2",
|
||||
indent_char: " ",
|
||||
max_preserve_newlines: "-1",
|
||||
preserve_newlines: false,
|
||||
keep_array_indentation: false,
|
||||
break_chained_methods: false,
|
||||
indent_scripts: 'normal',
|
||||
brace_style: 'end-expand',
|
||||
indent_scripts: "normal",
|
||||
brace_style: "end-expand",
|
||||
space_before_conditional: true,
|
||||
unescape_strings: false,
|
||||
jslint_happy: true,
|
||||
end_with_newline: true,
|
||||
wrap_line_length: '110',
|
||||
wrap_line_length: "110",
|
||||
indent_inner_html: true,
|
||||
comma_first: false,
|
||||
e4x: true,
|
||||
indent_empty_lines: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 首字母大小
|
||||
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) {
|
||||
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) {
|
||||
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
||||
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str);
|
||||
}
|
||||
|
||||
// 是否函数
|
||||
export const isFunction = (o) => {
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === 'Function';
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === "Function";
|
||||
};
|
||||
|
||||
// 是否数组
|
||||
export const isArray = (o) => {
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === 'Array';
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === "Array";
|
||||
};
|
||||
|
||||
// 是否对象
|
||||
export const isObj = (o) => {
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
||||
return Object.prototype.toString.call(o).slice(8, -1) === "Object";
|
||||
};
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
|
||||
import JSEncrypt from "jsencrypt/bin/jsencrypt.min";
|
||||
|
||||
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||
|
||||
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
|
||||
'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
|
||||
const publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n" +
|
||||
"nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ==";
|
||||
|
||||
const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
|
||||
'7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
|
||||
'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
|
||||
'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
|
||||
'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
|
||||
'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
|
||||
'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
|
||||
'UP8iWi1Qw0Y='
|
||||
const privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n" +
|
||||
"7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n" +
|
||||
"PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n" +
|
||||
"kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n" +
|
||||
"cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n" +
|
||||
"DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n" +
|
||||
"YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n" +
|
||||
"UP8iWi1Qw0Y=";
|
||||
|
||||
// 加密
|
||||
export function encrypt(txt) {
|
||||
const encryptor = new JSEncrypt()
|
||||
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||
return encryptor.encrypt(txt) // 对数据进行加密
|
||||
const encryptor = new JSEncrypt();
|
||||
encryptor.setPublicKey(publicKey); // 设置公钥
|
||||
return encryptor.encrypt(txt); // 对数据进行加密
|
||||
}
|
||||
|
||||
// 解密
|
||||
export function decrypt(txt) {
|
||||
const encryptor = new JSEncrypt()
|
||||
encryptor.setPrivateKey(privateKey) // 设置私钥
|
||||
return encryptor.decrypt(txt) // 对数据进行解密
|
||||
const encryptor = new JSEncrypt();
|
||||
encryptor.setPrivateKey(privateKey); // 设置私钥
|
||||
return encryptor.decrypt(txt); // 对数据进行解密
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import store from '@/store'
|
||||
import store from "@/store";
|
||||
// 获取字典方法 使用示例 this.getModelSelect(this.prop, this.label_name, this.listApi).then(res)
|
||||
// 或者 async函数下 const res = await this.getModelSelect(this.prop, this.label_name, this.listApi)
|
||||
export const getModelSelect = async (modelName, labelName, listApi, params, reset) => {
|
||||
await store.dispatch("modelSelect/getModelSelect", {modelName, labelName, listApi, params, reset})
|
||||
return store.getters["modelSelect/getModelSelect"][modelName]
|
||||
}
|
||||
export const getModelSelect = async(modelName, labelName, listApi, params, reset) => {
|
||||
await store.dispatch("modelSelect/getModelSelect", { modelName, labelName, listApi, params, reset });
|
||||
return store.getters["modelSelect/getModelSelect"][modelName];
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import store from '@/store'
|
||||
import store from "@/store";
|
||||
|
||||
/**
|
||||
* 字符权限校验
|
||||
|
@ -7,21 +7,21 @@ import store from '@/store'
|
|||
*/
|
||||
export function checkPermi(value) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const permissions = store.getters && store.getters.permissions
|
||||
const permissionDatas = value
|
||||
const permissions = store.getters && store.getters.permissions;
|
||||
const permissionDatas = value;
|
||||
const all_permission = "*:*:*";
|
||||
|
||||
const hasPermission = permissions.some(permission => {
|
||||
return all_permission === permission || permissionDatas.includes(permission)
|
||||
})
|
||||
return all_permission === permission || permissionDatas.includes(permission);
|
||||
});
|
||||
|
||||
if (!hasPermission) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
|
||||
return false
|
||||
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,20 +32,20 @@ export function checkPermi(value) {
|
|||
*/
|
||||
export function checkRole(value) {
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const roles = store.getters && store.getters.roles
|
||||
const permissionRoles = value
|
||||
const roles = store.getters && store.getters.roles;
|
||||
const permissionRoles = value;
|
||||
const super_admin = "admin";
|
||||
|
||||
const hasRole = roles.some(role => {
|
||||
return super_admin === role || permissionRoles.includes(role)
|
||||
})
|
||||
return super_admin === role || permissionRoles.includes(role);
|
||||
});
|
||||
|
||||
if (!hasRole) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
} else {
|
||||
console.error(`need roles! Like checkRole="['admin','editor']"`)
|
||||
return false
|
||||
console.error(`need roles! Like checkRole="['admin','editor']"`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,33 @@
|
|||
import axios from 'axios'
|
||||
import { Notification, MessageBox, Message } from 'element-ui'
|
||||
import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import errorCode from '@/utils/errorCode'
|
||||
import axios from "axios";
|
||||
import { Notification, MessageBox, Message } from "element-ui";
|
||||
import { getToken } from "@/utils/auth";
|
||||
import errorCode from "@/utils/errorCode";
|
||||
|
||||
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
||||
axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: process.env.VUE_APP_BASE_API,
|
||||
// 超时
|
||||
timeout: 10000
|
||||
})
|
||||
});
|
||||
// request拦截器
|
||||
service.interceptors.request.use(config => {
|
||||
// 是否需要设置 token
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
const isToken = (config.headers || {}).isToken === false;
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
// get请求映射params参数
|
||||
if (config.method === 'get' && config.params) {
|
||||
let url = config.url + '?';
|
||||
if (config.method === "get" && config.params) {
|
||||
let url = config.url + "?";
|
||||
for (const propName of Object.keys(config.params)) {
|
||||
const value = config.params[propName];
|
||||
var part = encodeURIComponent(propName) + "=";
|
||||
if (value !== null && typeof(value) !== "undefined") {
|
||||
if (typeof value === 'object') {
|
||||
if (value !== null && typeof (value) !== "undefined") {
|
||||
if (typeof value === "object") {
|
||||
for (const key of Object.keys(value)) {
|
||||
let params = propName + '[' + key + ']';
|
||||
const params = propName + "[" + key + "]";
|
||||
var subPart = encodeURIComponent(params) + "=";
|
||||
url += subPart + encodeURIComponent(value[key]) + "&";
|
||||
}
|
||||
|
@ -41,61 +40,59 @@ service.interceptors.request.use(config => {
|
|||
config.params = {};
|
||||
config.url = url;
|
||||
}
|
||||
return config
|
||||
return config;
|
||||
}, error => {
|
||||
console.log(error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
console.log(error);
|
||||
Promise.reject(error);
|
||||
});
|
||||
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(res => {
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.data.code || 200;
|
||||
// 获取错误信息
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
if (code === 401) {
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(() => {
|
||||
location.href = '/index';
|
||||
})
|
||||
} else if (code === 500) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'error'
|
||||
})
|
||||
return Promise.reject(new Error(msg))
|
||||
} else if (code !== 200) {
|
||||
Notification.error({
|
||||
title: msg
|
||||
})
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
return res.data
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.log('err' + error)
|
||||
let { message } = error;
|
||||
if (message == "Network Error") {
|
||||
message = "后端接口连接异常";
|
||||
}
|
||||
else if (message.includes("timeout")) {
|
||||
message = "系统接口请求超时";
|
||||
}
|
||||
else if (message.includes("Request failed with status code")) {
|
||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.data.code || 200;
|
||||
// 获取错误信息
|
||||
const msg = errorCode[code] || res.data.msg || errorCode["default"];
|
||||
if (code === 401) {
|
||||
MessageBox.confirm("登录状态已过期,您可以继续留在该页面,或者重新登录", "系统提示", {
|
||||
confirmButtonText: "重新登录",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}
|
||||
).then(() => {
|
||||
location.href = "/index";
|
||||
});
|
||||
} else if (code === 500) {
|
||||
Message({
|
||||
message: message,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
return Promise.reject(error)
|
||||
message: msg,
|
||||
type: "error"
|
||||
});
|
||||
return Promise.reject(new Error(msg));
|
||||
} else if (code !== 200) {
|
||||
Notification.error({
|
||||
title: msg
|
||||
});
|
||||
return Promise.reject("error");
|
||||
} else {
|
||||
return res.data;
|
||||
}
|
||||
)
|
||||
},
|
||||
error => {
|
||||
console.log("err" + error);
|
||||
let { message } = error;
|
||||
if (message == "Network Error") {
|
||||
message = "后端接口连接异常";
|
||||
} else if (message.includes("timeout")) {
|
||||
message = "系统接口请求超时";
|
||||
} else if (message.includes("Request failed with status code")) {
|
||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||
}
|
||||
Message({
|
||||
message: message,
|
||||
type: "error",
|
||||
duration: 5 * 1000
|
||||
});
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default service
|
||||
export default service;
|
||||
|
|
|
@ -3,104 +3,102 @@
|
|||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
const baseURL = process.env.VUE_APP_BASE_API
|
||||
|
||||
// 日期格式化
|
||||
export function parseTime(time, pattern) {
|
||||
if (arguments.length === 0 || !time) {
|
||||
return null
|
||||
}
|
||||
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
let date
|
||||
if (typeof time === 'object') {
|
||||
date = time
|
||||
} else {
|
||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time)
|
||||
} else if (typeof time === 'string') {
|
||||
time = time.replace(new RegExp(/-/gm), '/');
|
||||
}
|
||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
||||
time = time * 1000
|
||||
}
|
||||
date = new Date(time)
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
}
|
||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||
let value = formatObj[key]
|
||||
// Note: getDay() returns 0 on Sunday
|
||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value
|
||||
}
|
||||
return value || 0
|
||||
})
|
||||
return time_str
|
||||
if (arguments.length === 0 || !time) {
|
||||
return null;
|
||||
}
|
||||
const format = pattern || "{y}-{m}-{d} {h}:{i}:{s}";
|
||||
let date;
|
||||
if (typeof time === "object") {
|
||||
date = time;
|
||||
} else {
|
||||
if ((typeof time === "string") && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time);
|
||||
} else if (typeof time === "string") {
|
||||
time = time.replace(new RegExp(/-/gm), "/");
|
||||
}
|
||||
if ((typeof time === "number") && (time.toString().length === 10)) {
|
||||
time = time * 1000;
|
||||
}
|
||||
date = new Date(time);
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
};
|
||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||
let value = formatObj[key];
|
||||
// Note: getDay() returns 0 on Sunday
|
||||
if (key === "a") { return ["日", "一", "二", "三", "四", "五", "六"][value]; }
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = "0" + value;
|
||||
}
|
||||
return value || 0;
|
||||
});
|
||||
return time_str;
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
export function resetForm(refName) {
|
||||
if (this.$refs[refName]) {
|
||||
this.$refs[refName].resetFields();
|
||||
}
|
||||
if (this.$refs[refName]) {
|
||||
this.$refs[refName].resetFields();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加日期范围
|
||||
export function addDateRange(params, dateRange, propName) {
|
||||
let search = JSON.parse(JSON.stringify(params));
|
||||
if (null != dateRange && '' !== dateRange && dateRange.length !== 0) {
|
||||
search.as = JSON.stringify({create_datetime__range : dateRange});
|
||||
}
|
||||
return search;
|
||||
const search = JSON.parse(JSON.stringify(params));
|
||||
if (dateRange != null && dateRange !== "" && dateRange.length !== 0) {
|
||||
search.as = JSON.stringify({ create_datetime__range: dateRange });
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
var actions = [];
|
||||
Object.keys(datas).some((key) => {
|
||||
if (String(datas[key].dictValue) === ('' + String(value))) {
|
||||
actions.push(datas[key].dictLabel);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
return actions.join('');
|
||||
var actions = [];
|
||||
Object.keys(datas).some((key) => {
|
||||
if (String(datas[key].dictValue) === ("" + String(value))) {
|
||||
actions.push(datas[key].dictLabel);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return actions.join("");
|
||||
}
|
||||
// 获取字典默认值
|
||||
export function selectDictDefault(datas) {
|
||||
var actions = [];
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].is_default === true) {
|
||||
actions.push(datas[key].dictValue);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
var actions = [];
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].is_default === true) {
|
||||
actions.push(datas[key].dictValue);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!actions[0] && datas[0]) {
|
||||
actions.push(datas[0].dictValue)
|
||||
actions.push(datas[0].dictValue);
|
||||
}
|
||||
return actions.join('');
|
||||
return actions.join("");
|
||||
}
|
||||
|
||||
// 回显数据字典(字符串数组)
|
||||
export function selectDictLabels(datas, value, separator) {
|
||||
var actions = [];
|
||||
var currentSeparator = undefined === separator ? "," : separator;
|
||||
var temp = value.split(currentSeparator);
|
||||
Object.keys(value.split(currentSeparator)).some((val) => {
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].dictValue == ('' + temp[val])) {
|
||||
actions.push(datas[key].dictLabel + currentSeparator);
|
||||
}
|
||||
})
|
||||
})
|
||||
return actions.join('').substring(0, actions.join('').length - 1);
|
||||
var actions = [];
|
||||
var currentSeparator = undefined === separator ? "," : separator;
|
||||
var temp = value.split(currentSeparator);
|
||||
Object.keys(value.split(currentSeparator)).some((val) => {
|
||||
Object.keys(datas).some((key) => {
|
||||
if (datas[key].dictValue == ("" + temp[val])) {
|
||||
actions.push(datas[key].dictLabel + currentSeparator);
|
||||
}
|
||||
});
|
||||
});
|
||||
return actions.join("").substring(0, actions.join("").length - 1);
|
||||
}
|
||||
/**
|
||||
* 保存
|
||||
|
@ -112,21 +110,21 @@ function saveAs(blob, filename) {
|
|||
if (window.navigator.msSaveOrOpenBlob) {
|
||||
navigator.msSaveBlob(blob, filename);
|
||||
} else {
|
||||
var link = document.createElement('a');
|
||||
var body = document.querySelector('body');
|
||||
var link = document.createElement("a");
|
||||
var body = document.querySelector("body");
|
||||
|
||||
link.href = window.URL.createObjectURL(blob);
|
||||
link.download = filename;
|
||||
|
||||
// fix Firefox
|
||||
link.style.display = 'none';
|
||||
link.style.display = "none";
|
||||
body.appendChild(link);
|
||||
|
||||
link.click();
|
||||
body.removeChild(link);
|
||||
|
||||
window.URL.revokeObjectURL(link.href);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,9 +134,9 @@ function saveAs(blob, filename) {
|
|||
*/
|
||||
function getBlob(url, cb) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.onload = function () {
|
||||
xhr.open("GET", url, true);
|
||||
xhr.responseType = "blob";
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
cb(xhr.response);
|
||||
}
|
||||
|
@ -146,32 +144,32 @@ function getBlob(url, cb) {
|
|||
xhr.send();
|
||||
}
|
||||
// 通用下载方法
|
||||
export function download(file_url,fileName) {
|
||||
getBlob(process.env.VUE_APP_BASE_API + file_url, function (blob) {
|
||||
export function download(file_url, fileName) {
|
||||
getBlob(process.env.VUE_APP_BASE_API + file_url, function(blob) {
|
||||
saveAs(blob, fileName);
|
||||
});
|
||||
}
|
||||
|
||||
// 字符串格式化(%s )
|
||||
export function sprintf(str) {
|
||||
var args = arguments, flag = true, i = 1;
|
||||
str = str.replace(/%s/g, function () {
|
||||
var arg = args[i++];
|
||||
if (typeof arg === 'undefined') {
|
||||
flag = false;
|
||||
return '';
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return flag ? str : '';
|
||||
var args = arguments; var flag = true; var i = 1;
|
||||
str = str.replace(/%s/g, function() {
|
||||
var arg = args[i++];
|
||||
if (typeof arg === "undefined") {
|
||||
flag = false;
|
||||
return "";
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return flag ? str : "";
|
||||
}
|
||||
|
||||
// 转换字符串,undefined,null等转化为""
|
||||
export function praseStrEmpty(str) {
|
||||
if (!str || str == "undefined" || str == "null") {
|
||||
return "";
|
||||
}
|
||||
return str;
|
||||
if (!str || str == "undefined" || str == "null") {
|
||||
return "";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,28 +181,28 @@ export function praseStrEmpty(str) {
|
|||
* @param {*} rootId 根Id 默认 0
|
||||
*/
|
||||
export function handleTree(data, id, parentId, children, rootId) {
|
||||
id = id || 'id'
|
||||
parentId = parentId || 'parentId'
|
||||
children = children || 'children'
|
||||
id = id || "id";
|
||||
parentId = parentId || "parentId";
|
||||
children = children || "children";
|
||||
// 排序
|
||||
function NumCompare(a,b){
|
||||
//数字比较函数
|
||||
function NumCompare(a, b) {
|
||||
// 数字比较函数
|
||||
return a.orderNum - b.orderNum;
|
||||
}
|
||||
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
|
||||
//对源数据深度克隆
|
||||
const cloneData = JSON.parse(JSON.stringify(data))
|
||||
//循环所有项
|
||||
const treeData = cloneData.filter(father => {
|
||||
let branchArr = cloneData.filter(child => {
|
||||
//返回每一项的子级数组
|
||||
return father[id] === child[parentId]
|
||||
});
|
||||
branchArr.sort(NumCompare)
|
||||
branchArr.length > 0 ? father.children = branchArr : '';
|
||||
//返回第一层
|
||||
return father[parentId] === rootId || !father[parentId];
|
||||
});
|
||||
treeData.sort(NumCompare)
|
||||
return treeData != '' ? treeData : data;
|
||||
rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId]; })) || 0;
|
||||
// 对源数据深度克隆
|
||||
const cloneData = JSON.parse(JSON.stringify(data));
|
||||
// 循环所有项
|
||||
const treeData = cloneData.filter(father => {
|
||||
const branchArr = cloneData.filter(child => {
|
||||
// 返回每一项的子级数组
|
||||
return father[id] === child[parentId];
|
||||
});
|
||||
branchArr.sort(NumCompare);
|
||||
branchArr.length > 0 ? father.children = branchArr : "";
|
||||
// 返回第一层
|
||||
return father[parentId] === rootId || !father[parentId];
|
||||
});
|
||||
treeData.sort(NumCompare);
|
||||
return treeData !== "" ? treeData : data;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
Math.easeInOutQuad = function(t, b, c, d) {
|
||||
t /= d / 2
|
||||
t /= d / 2;
|
||||
if (t < 1) {
|
||||
return c / 2 * t * t + b
|
||||
return c / 2 * t * t + b;
|
||||
}
|
||||
t--
|
||||
return -c / 2 * (t * (t - 2) - 1) + b
|
||||
}
|
||||
t--;
|
||||
return -c / 2 * (t * (t - 2) - 1) + b;
|
||||
};
|
||||
|
||||
// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
|
||||
var 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
|
||||
* @param {number} amount
|
||||
*/
|
||||
function move(amount) {
|
||||
document.documentElement.scrollTop = amount
|
||||
document.body.parentNode.scrollTop = amount
|
||||
document.body.scrollTop = amount
|
||||
document.documentElement.scrollTop = amount;
|
||||
document.body.parentNode.scrollTop = amount;
|
||||
document.body.scrollTop = amount;
|
||||
}
|
||||
|
||||
function position() {
|
||||
return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop
|
||||
return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,27 +32,27 @@ function position() {
|
|||
* @param {Function} callback
|
||||
*/
|
||||
export function scrollTo(to, duration, callback) {
|
||||
const start = position()
|
||||
const change = to - start
|
||||
const increment = 20
|
||||
let currentTime = 0
|
||||
duration = (typeof (duration) === 'undefined') ? 500 : duration
|
||||
const start = position();
|
||||
const change = to - start;
|
||||
const increment = 20;
|
||||
let currentTime = 0;
|
||||
duration = (typeof (duration) === "undefined") ? 500 : duration;
|
||||
var animateScroll = function() {
|
||||
// increment the time
|
||||
currentTime += increment
|
||||
currentTime += increment;
|
||||
// find the value with the quadratic in-out easing function
|
||||
var val = Math.easeInOutQuad(currentTime, start, change, duration)
|
||||
var val = Math.easeInOutQuad(currentTime, start, change, duration);
|
||||
// move the document.body
|
||||
move(val)
|
||||
move(val);
|
||||
// do the animation unless its over
|
||||
if (currentTime < duration) {
|
||||
requestAnimFrame(animateScroll)
|
||||
requestAnimFrame(animateScroll);
|
||||
} else {
|
||||
if (callback && typeof (callback) === 'function') {
|
||||
if (callback && typeof (callback) === "function") {
|
||||
// the animation is done so lets callback
|
||||
callback()
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
animateScroll()
|
||||
};
|
||||
animateScroll();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue