Commit 7a3690aa by cwq0219

create

0 parents
Showing 212 changed files with 12248 additions and 0 deletions
> 1%
last 2 versions
not ie <= 8
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# 所有环境默认
# 页面 title 前缀
VUE_APP_TITLE=tFIMS
# 网络请求公用地址 http://tfims.glsx.com.cn/router
VUE_APP_API=http://tfims.test.glsx.com.cn/router
# 仓库地址
VUE_APP_REPO=https://oss-config.test.glsx.com.cn/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
# 国际化配置
VUE_APP_I18N_LOCALE=zh-chs
VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_ELEMENT_COLOR=#409EFF
VUE_APP_MAIN_COLOR=#3D6FE4
VUE_APP_STORAGE_PREFIX=tfims
\ No newline at end of file \ No newline at end of file
# 开发环境
# 页面 title 前缀
VUE_APP_TITLE=TFims Dev
# 网络请求开发地址
VUE_APP_API=https://oss-config.test.glsx.com.cn/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
\ No newline at end of file \ No newline at end of file
# No Mock 构建
# 指定构建模式
NODE_ENV=production
# 标记当前是 No Mock 构建
VUE_APP_BUILD_MODE=nomock
# travis
# 指定构建模式
NODE_ENV=production
# 标记当前是 CI 自动构建
VUE_APP_BUILD_MODE=TRAVIS
# 忽略目录
build/
tests/
node_modules/
# node 覆盖率文件
coverage/
# 忽略文件
**/*-min.js
**/*.min.js
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/prettier'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevent
// ion consider switching to `plugin:vue/strongly-recommended` or
// `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: ['vue'],
globals: {
NODE_ENV: false,
_:false,
echarts:false
},
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
// 添加,分号必须
// semi: ['error', 'always'],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'no-unexpected-multiline': 'off',
'space-before-function-paren': ['error', 'never'],
quotes: [
'error',
'single',
{
avoidEscape: true
}
]
}
};
\ No newline at end of file \ No newline at end of file
.DS_Store
node_modules
/dist
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
\ No newline at end of file \ No newline at end of file
module.exports = {
plugins: {
autoprefixer: {}
}
}
{
"semi": false,
"singleQuote": true
}
\ No newline at end of file \ No newline at end of file
language: node_js
node_js: stable
cache:
directories:
- "node_modules"
branches:
only:
- master
script:
- npm run build:travis
before_install:
- ./qshell account $AK $SK
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
after_success:
- ./qshell qupload qiniu-config
- ./qshell cdnrefresh -dirs cdnrefresh-dirs.txt
\ No newline at end of file \ No newline at end of file
MIT License
Copyright (c) 2018 李杨
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[![Build Status](https://www.travis-ci.org/d2-projects/d2-admin-start-kit.svg?branch=master)](https://www.travis-ci.org/d2-projects/d2-admin-start-kit)
[D2Admin](https://github.com/d2-projects/d2-admin) simplified version of the start template, delete all the sample code in the full version, retain all core functions.
[Gitee](https://gitee.com/fairyever/d2-admin-start-kit)
\ No newline at end of file \ No newline at end of file
[![Build Status](https://www.travis-ci.org/d2-projects/d2-admin-start-kit.svg?branch=master)](https://www.travis-ci.org/d2-projects/d2-admin-start-kit)
[D2Admin](https://github.com/d2-projects/d2-admin) 简化版起始模板,删除所有完整版中的示例代码,保留所有核心功能。
[码云镜像](https://gitee.com/fairyever/d2-admin-start-kit)
\ No newline at end of file \ No newline at end of file
module.exports = {
presets: [
'@vue/app'
],
// 允许两种编码引入方式共存,也就是 common 规范与 es6 规范的共存处理
sourceType: 'unambiguous'
}
https://start-kit.d2admin.fairyever.com/
\ No newline at end of file \ No newline at end of file
module.exports = {
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue'
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.jsx?$': 'babel-jest'
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotSerializers: [
'jest-serializer-vue'
],
testMatch: [
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],
testURL: 'http://localhost/'
}
This diff could not be displayed because it is too large.
{
"name": "test1",
"version": "0.1.0",
"scripts": {
"serve": "vue-cli-service serve --open",
"start": "npm run serve",
"dev": "npm run serve",
"build": "vue-cli-service build --mode nomock",
"build:nomock": "vue-cli-service build --mode nomock",
"build:travis": "vue-cli-service build --mode travis",
"lint": "vue-cli-service lint --fix",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"axios": "^0.18.0",
"better-scroll": "^1.15.2",
"dayjs": "^1.8.12",
"element-ui": "^2.11.1",
"flex.css": "^1.1.7",
"fuse.js": "^3.4.4",
"hotkeys-js": "^3.6.2",
"js-cookie": "^2.2.0",
"js-md5": "^0.7.3",
"lodash": "^4.17.11",
"lowdb": "^1.0.0",
"nprogress": "^0.2.0",
"qs": "^6.8.0",
"screenfull": "^4.2.0",
"ua-parser-js": "^0.7.19",
"vue": "^2.6.10",
"vue-i18n": "^8.14.0",
"vue-router": "^3.0.3",
"vuex": "^3.0.1"
},
"devDependencies": {
"@kazupon/vue-i18n-loader": "^0.4.1",
"@vue/cli-plugin-babel": "^3.6.0",
"@vue/cli-plugin-eslint": "^3.6.0",
"@vue/cli-plugin-unit-jest": "^3.6.0",
"@vue/cli-service": "^3.6.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "1.0.0-beta.29",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"sass": "^1.18.0",
"sass-loader": "^7.1.0",
"svg-sprite-loader": "^4.1.3",
"vue-template-compiler": "^2.5.21",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-theme-color-replacer": "^1.2.15"
}
}
> 1%
last 2 versions
not ie <= 8
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
module.exports = {
plugins: {
autoprefixer: {}
}
}
# filters-dayjs
\ No newline at end of file \ No newline at end of file
module.exports = {
presets: [
'@vue/app'
]
}
This diff could not be displayed because it is too large.
{
"name": "@d2-admin/filters-dayjs",
"version": "1.0.3",
"main": "dist/@d2-admin/filters-dayjs.common.js",
"scripts": {
"build": "vue-cli-service build --target lib --name @d2-admin/filters-dayjs --entry src/main.js"
},
"dependencies": {
"core-js": "^2.6.5",
"dayjs": "^1.8.12",
"vue": "^2.6.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0",
"@vue/cli-service": "^3.0.0",
"vue-template-compiler": "^2.5.21"
}
}
// 日期时间相关 filter
// https://github.com/iamkun/dayjs/blob/master/docs/zh-cn/API-reference.md
import dayjs from 'dayjs'
// 对象代理
const P = Day => {
return new Proxy(Day, {
get (target, key) {
if (dayjs.isDayjs(target)) {
// 是 Dayjs 对象,正常返回
return target[key]
} else {
// 不是 Dayjs 对象
if (dayjs(target).isValid()) {
// 尝试帮用户解析成 Dayjs 对象
return dayjs(target)[key]
} else {
// 无法解析
return function () {
return '无效日期'
}
}
}
},
set (target, key, value) {
target[key] = value
}
})
}
export default {
// ---------- [ dayjs 解析 ] ----------
// 时间字符串 | Date 对象 | Unix 时间戳 (毫秒)
day: value => dayjs(value),
// Unix 时间戳 (秒)
date_unix: value => dayjs.unix(value),
// ---------- [ 获取 ] ----------
date_year: Day => P(Day).year(),
date_month: Day => P(Day).month(),
date_date: Day => P(Day).date(),
date_day: Day => P(Day).day(),
date_hour: Day => P(Day).hour(),
date_minute: Day => P(Day).minute(),
date_second: Day => P(Day).second(),
date_millisecond: Day => P(Day).millisecond(),
// ---------- [ 设置 ] ----------
// date | day | month | year | hour | minute | second | millisecond
// 对大小写不敏感
date_set: (Day, unit, value) => P(Day).set(unit, value),
// ---------- [ 操作 ] ----------
// 增加
date_add: (Day, value, unit) => P(Day).add(value, unit),
// 减少
date_subtract: (Day, value, unit) => P(Day).subtract(value, unit),
// 开头时间
date_startof: (Day, unit) => P(Day).startOf(unit),
// 末尾时间
date_endof: (Day, unit) => P(Day).endOf(unit),
// ---------- [ 显示 ] ----------
// 格式化
date_format: (Day, setting = 'YYYY-MM-DD HH:mm:ss') => P(Day).format(setting),
// 时间差
date_diff: (Day, Day2 = '', unit = 'millisecond', accurate = false) => P(Day).diff(dayjs(Day2), unit, accurate),
// Unix 时间戳 (毫秒)
date_value_millisecond: Day => P(Day).valueOf(),
// Unix 时间戳 (秒)
date_value_second: Day => P(Day).unix(),
// 月份的天数
date_days_in_month: Day => P(Day).daysInMonth(),
// Date 对象
date_to_date: Day => P(Day).toDate(),
// JSON
date_to_json: Day => P(Day).toJSON(),
// ISO8601 格式
date_to_iso: Day => P(Day).toISOString(),
// 字符
date_to_string: Day => P(Day).toString(),
// ---------- [ 查询 ] ----------
// 是否之前
date_is_before: (Day, Day2, unit = 'millisecond') => P(Day).isBefore(dayjs(Day2), unit),
// 是否之后
date_is_after: (Day, Day2, unit = 'millisecond') => P(Day).isAfter(dayjs(Day2), unit),
// 是否相同
date_is_same: (Day, Day2, unit = 'millisecond') => P(Day).isSame(dayjs(Day2), unit)
}
import filters from './filters'
const vueFiltersDate = {
install: function (Vue, options) {
Object.keys(filters).forEach(name => {
Vue.filter(name, filters[name])
})
}
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(vueFiltersDate)
}
export default vueFiltersDate
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="white">
<path opacity=".25" d="M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"/>
<path d="M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z">
<animateTransform attributeName="transform" type="rotate" from="0 16 16" to="360 16 16" dur="0.8s" repeatCount="indefinite" />
</path>
</svg>
\ No newline at end of file \ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>icon.ico">
<!-- 使用CDN的CSS文件 -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<% } %>
<!-- 使用CDN的JS文件 预加载 -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.js[i] %>" rel="preload" as="script" />
<% } %>
<title><%= VUE_APP_TITLE %></title>
<style>
html,
body,
#app {
height: 100%;
margin: 0px;
padding: 0px;
width: 100%;
}
.d2-home {
background-color: #2A343D;
height: 100%;
display: flex;
flex-direction: column;
}
.d2-home__main {
user-select: none;
width: 100%;
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.d2-home__footer {
width: 100%;
flex-grow: 0;
text-align: center;
padding: 1em 0;
}
.d2-home__footer>a {
font-size: 12px;
color: #fff;
text-decoration: none;
}
.d2-home__loading {
height: 32px;
width: 32px;
margin-bottom: 20px;
}
.d2-home__title {
color: #FFF;
font-size: 20px;
margin-bottom: 10px;
}
.d2-home__sub-title {
color: #fff;
font-size: 14px;
}
</style>
<!-- <script>
var _hmt = _hmt || [];
var hmid = "1dfa88d0c8571eef2d383070cb3e5ca1";
(function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?" + hmid; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})();
</script> -->
</head>
<body>
<noscript>
<strong>
很抱歉,如果没有 JavaScript 支持,系统 将不能正常工作。请启用浏览器的 JavaScript 然后继续。
</strong>
</noscript>
<div id="app">
<div class="d2-home">
<div class="d2-home__main">
<img class="d2-home__loading" src="./image/loading/loading-spin.svg" alt="loading">
<div class="d2-home__title">
正在加载资源
</div>
<div class="d2-home__sub-title">
初次加载资源可能需要较多时间 请耐心等待
</div>
</div>
<div class="d2-home__footer">
<a href="http://www.glsx.com.cn" target="_blank">
<!-- 版权所有&copy-2019 GLSX粤ICP备12020087号 -->
</a>
</div>
</div>
</div>
<!-- built files will be auto injected -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
</body>
</html>
\ No newline at end of file \ No newline at end of file
{
"src_dir" : "/home/travis/build/d2-projects/d2-admin-start-kit/dist",
"bucket" : "d2-admin-start-kit",
"ignore_dir" : false,
"overwrite" : true,
"check_exists" : true,
"check_hash" : true,
"check_size" : true,
"rescan_local" : true,
"skip_file_prefixes" : "test,demo,",
"skip_path_prefixes" : "hello/,temp/",
"skip_fixed_strings" : ".svn,.git",
"skip_suffixes" : ".DS_Store,.exe",
"log_file" : "upload.log",
"log_level" : "info",
"log_rotate" : 1,
"log_stdout" : false
}
\ No newline at end of file \ No newline at end of file
No preview for this file type
var express = require('express')
var app = express()
app.use(express.static('./dist'))
app.get('/', function(req, res) {
res.send('Hello Vue')
})
app.listen(8080)
console.log('服务已运行:\r\n localhost:8080')
<template>
<div id="app">
<router-view />
</div>
</template>
<script>
// import util from '@/libs/util'
// export default {
// name: 'app',
// watch: {
// '$i18n.locale': 'i18nHandle'
// },
// created () {
// this.i18nHandle(this.$i18n.locale)
// },
// methods: {
// i18nHandle (val, oldVal) {
// util.cookies.set('lang', val)
// document.querySelector('html').setAttribute('lang', val)
// }
// }
// }
</script>
<style lang="scss">
@import "~@/assets/style/public-class.scss";
</style>
import request from './request'
const path = 'fims.'
export function searchReportLog(data) {
data.method = `${path}reportlog.search`
return request(data)
}
export function searchDepot(data) {
data.method = 'fims.configuration.from.conftype'
return request(data)
}
/*
* @Author: limin
* @Date: 2019-08-26 18:02:41
* @Last Modified by: chenwq
* @Last Modified time: 2020-01-08 17:30:56
*/
import axios from '@/plugin/axios'
import sign from './sign'
import RequestMethods from './request.methods'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = []) => {
params.source = 'test1'
params.app_key = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime()
params.v = '1.0.0'
params.format = 'json'
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const url = params.method // ''
/**
* 调后端接口,请使用以下代码。
*/
// var reqData = (method === RequestMethods.POST) ? {
// baseURL: process.env.VUE_APP_API + '?method=' + params.method,
// data: sign(params, noSignAttr)
// } : {
// params: sign(params, noSignAttr)
// }
// return axios({
// url,
// method,
// ...reqData
// })
/**
* mock,请使用以下代码。
*/
return axios({
url,
method,
params: sign(params, noSignAttr)
})
}
export default request
/*
* @Author: limin
* @Date: 2019-08-26 18:01:59
* @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:02:32
*/
const RequestMethods = {
POST: 'post',
GET: 'get',
PUT: 'put',
DELETE: 'delete'
}
export default RequestMethods
/*
* @Author: limin
* @Date: 2019-08-26 18:02:49
* @Last Modified by: limin
* @Last Modified time: 2019-09-16 14:45:51
*/
import MD5 from 'js-md5'
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const sign = (params, noSignAttr = []) => {
delete params.sign
const keys = Object.keys(params).sort()
var str = []
var obj = null
for (const key in params) {
obj = params[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
params[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + params[e])
})
params.sign = MD5(secret + str.join('') + secret)
return params
}
export default sign
/*
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: chenwq
* @Last Modified time: 2020-01-07 16:26:04
*/
import request from './request'
import RequestMethods from './request.methods'
// 用户相关
const USER_PATH = 'fims.user.'
// 角色相关
const ROLE_PATH = 'fims.role.'
export const LOGIN_URL = `${USER_PATH}loginTem`
export const REG_URL = `${USER_PATH}register`
export const ROLE_LIST_URL = `${ROLE_PATH}list`
/**
* 用户登录
* @param {*} data 参数
*/
export function AccountLogin(data) {
data.method = LOGIN_URL
return request(data, RequestMethods.POST)
}
/**
* 注册
* @param {*} data 参数
*/
export function Reg(data = {}) {
data.method = REG_URL
// data.refreshTable = true
return request(data, RequestMethods.GET)
}
/**
* 修改密码
* @param {*} data
*/
export function ModifyPassword(data) {
data.method = `${USER_PATH}password.modify`
return request(data, RequestMethods.POST)
}
/**
* 获取用户列表
* @param {*} data 参数
*/
export function UserList(data = {}) {
data.method = `${USER_PATH}search`
return request(data, RequestMethods.GET)
}
/**
* 重置密码
* @param {*} data 参数
*/
export function PassWordReset(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${USER_PATH}password.reset`
return request(data, RequestMethods.GET)
}
/**
* 帐户编辑
* @param {*} data 参数
*/
export function AccountModify(data = {}) {
// data.refreshTable = true
data.method = `${USER_PATH}modify`
return request(data, RequestMethods.GET)
}
/**
* 帐户延期
* @param {*} data 参数
*/
export function AccountIncrease(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${USER_PATH}validity.increase`
return request(data, RequestMethods.GET)
}
/**
* 帐户禁用
* @param {*} data 参数
*/
export function AccountForbidden(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${USER_PATH}forbidden`
return request(data, RequestMethods.GET)
}
/**
* 帐户激活
* @param {*} data 参数
*/
export function AccountActived(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${USER_PATH}actived`
return request(data, RequestMethods.GET)
}
/**
* 帐户审核
* @param {*} data 参数
*/
export function AccountValidate(data = {}) {
// data.refreshTable = true
data.method = `${USER_PATH}check`
return request(data, RequestMethods.GET)
}
/**
* 获取登录日志
* @param {} data
*/
export function getLoginlogs(data) {
data.method = `${USER_PATH}search.loginlog`
return request(data)
}
/**
* 获取角色权限资源列表
* @param {*} data 参数
*/
export function RoleAuthData(data = {}) {
data.method = `${ROLE_PATH}authority.data`
return request(data, RequestMethods.GET)
}
/**
* 创建角色
* @param {*} data 参数
*/
export function RoleReg(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${ROLE_PATH}register`
return request(data, RequestMethods.GET)
}
/**
* 权限修改
* @param {*} data 参数
*/
export function RoleModify(data = {}) {
// ok--
// data.refreshTable = true
data.method = `${ROLE_PATH}modify`
return request(data, RequestMethods.GET)
}
/**
* 权限列表
* @param {*} data 参数
*/
export function RoleList(data = {}) {
data.method = ROLE_LIST_URL
return request(data, RequestMethods.GET)
}
/**
* 角色详情
* @param {*} data 参数
*/
export function RoleDetail(data = {}) {
data.method = `${ROLE_PATH}detail`
return request(data, RequestMethods.GET)
}
/*
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: chenwq
* @Last Modified time: 2019-09-30 10:57:13
*/
import request from './request'
import RequestMethods from './request.methods'
export const BASE_DATA_URL = 'fims.configuration.from.conftype'
/**
* 获取角色列表
* @param {*} data 参数
*/
export function FetchRoleList(data = {}) {
data.method = 'fims.role.list'
return request(data, RequestMethods.GET)
}
/**
* 获取基础数据
* @param {*} data 参数
*/
export function BaseDataApi(data = {}) {
data.method = BASE_DATA_URL
return request(data, RequestMethods.GET)
}
import request from './request'
const path = 'fims.system.'
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function reportApi(data) {
data.method = `${path}report`
return request(data)
}
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
export {
getListApi,
reportApi,
exportApi
}
import request from './request'
const path = 'fims.order.'
function getListApi(data) {
data.method = `${path}search`
return request(data)
}
function editApi(data) {
data.method = `${path}edit`
return request(data)
}
function removeApi(data) {
data.method = `${path}delete`
return request(data)
}
export {
getListApi,
editApi,
removeApi
}
import request from './request'
const path = 'fims.material.'
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
export {
getListApi
}
// 过渡动画 横向渐变
.fade-transverse-leave-active,
.fade-transverse-enter-active {
transition: all .2s;
}
.fade-transverse-enter {
opacity: 0;
transform: translateX(30px);
}
.fade-transverse-leave-to {
opacity: 0;
transform: translateX(-30px);
}
// 过渡动画 缩放渐变
.fade-scale-leave-active,
.fade-scale-enter-active {
transition: all .3s;
}
.fade-scale-enter {
opacity: 0;
transform: scale(1.2);
}
.fade-scale-leave-to {
opacity: 0;
transform: scale(0.8);
}
// 优化显示
html, body {
margin: 0px;
height: 100%;
font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
#app {
@extend %full;
a {
text-decoration: none;
}
}
}
\ No newline at end of file \ No newline at end of file
// element 样式补丁
.el-card {
&.is-always-shadow {
box-shadow: 0 0 8px 0 rgba(232,237,250,.6), 0 2px 4px 0 rgba(232,237,250,.5);
}
&.is-hover-shadow {
&:hover {
box-shadow: 0 0 8px 0 rgba(232,237,250,.6), 0 2px 4px 0 rgba(232,237,250,.5);
}
}
}
.el-menu--horizontal {
border-bottom: none !important;
}
.el-tabs__item:focus.is-active.is-focus:not(:active) {
box-shadow: none !important;
}
.el-color-picker__trigger{
border-color:rgba(255,255,255,.1)
}
.el-table{
&--medium td{
padding: 10px 0 !important;
.el-button--text{
padding: 0px 0px;
}
.cell{
.el-tag{
width: 80px;
font-size: 13px;
}
}
}
margin:4px 0 !important;
}
.el-dialog{
margin-top: 6vh !important;
&__body{
padding:20px;
.el-form-item{
margin-bottom: 16px;
}
}
&__footer {
.el-button {
width: 150px;
}
}
}
.table-header{
height: 40px;
line-height: 40px;
color: #909399;
.el-col:nth-child(2){
position: relative; display: flex; justify-content: flex-end;
}
}
\ No newline at end of file \ No newline at end of file
#nprogress {
.bar {
background: $color-primary !important;
}
.peg {
box-shadow: 0 0 10px $color-primary, 0 0 5px $color-primary !important;
}
}
\ No newline at end of file \ No newline at end of file
@import 'public';
// 补丁 base
@import '~@/assets/style/fixed/base.scss';
// 补丁 element
@import '~@/assets/style/fixed/element.scss';
// 动画
@import '~@/assets/style/animate/vue-transition.scss';
// 在这里写公用的class
// 注意 这个文件里只写class
// mixin等内容请在 public.scss 里书写
// 文字相关
.#{$prefix}-text-center {
text-align: center;
}
// 浮动相关
.#{$prefix}-fl {
float: left;
}
.#{$prefix}-fr {
float: right;
}
// 边距相关
$sizes: (0, 5, 10, 15, 20);
@for $index from 1 to 6 {
.#{$prefix}-m-#{nth($sizes, $index)} { margin: #{nth($sizes, $index)}px !important; }
.#{$prefix}-mt-#{nth($sizes, $index)} { margin-top: #{nth($sizes, $index)}px !important; }
.#{$prefix}-mr-#{nth($sizes, $index)} { margin-right: #{nth($sizes, $index)}px !important; }
.#{$prefix}-mb-#{nth($sizes, $index)} { margin-bottom: #{nth($sizes, $index)}px !important; }
.#{$prefix}-ml-#{nth($sizes, $index)} { margin-left: #{nth($sizes, $index)}px !important; }
.#{$prefix}-p-#{nth($sizes, $index)} { padding: #{nth($sizes, $index)}px !important; }
.#{$prefix}-pt-#{nth($sizes, $index)} { padding-top: #{nth($sizes, $index)}px !important; }
.#{$prefix}-pr-#{nth($sizes, $index)} { padding-right: #{nth($sizes, $index)}px !important; }
.#{$prefix}-pb-#{nth($sizes, $index)} { padding-bottom: #{nth($sizes, $index)}px !important; }
.#{$prefix}-pl-#{nth($sizes, $index)} { padding-left: #{nth($sizes, $index)}px !important; }
}
// 快速使用
.#{$prefix}-m { margin: 20px !important; }
.#{$prefix}-mt { margin-top: 20px !important; }
.#{$prefix}-mr { margin-right: 20px !important; }
.#{$prefix}-mb { margin-bottom: 20px !important; }
.#{$prefix}-ml { margin-left: 20px !important; }
.#{$prefix}-p { padding: 20px !important; }
.#{$prefix}-pt { padding-top: 20px !important; }
.#{$prefix}-pr { padding-right: 20px !important; }
.#{$prefix}-pb { padding-bottom: 20px !important; }
.#{$prefix}-pl { padding-left: 20px !important; }
@import '~@/assets/style/unit/color.scss';
// 工具类名统一前缀
$prefix: d2;
// 禁止用户选中 鼠标变为手形
%unable-select {
user-select: none;
cursor: pointer;
}
// 填满父元素
// 组要父元素 position: relative | absolute;
%full {
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
// flex 垂直水平居中
%flex-center-row {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
}
%flex-center-col {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
// 将元素模拟成卡片外观
%card {
border: 1px solid #dddee1;
border-color: #e9eaec;
background: #fff;
border-radius: 4px;
font-size: 14px;
position: relative;
}
\ No newline at end of file \ No newline at end of file
@import './setting.scss';
@import '../theme.scss';
// 主题名称
$theme-name: 'blue';
// diff
$private-left-side-color:#652DED;
// diff
$private-menu-active-background-color:#521ADA;
$private-item-hover:rgba(#000,.05);
$private-menu-text-color:#C4D0DF;
$active-i-color:rgb(9, 234, 9);
// 主题背景颜色
$theme-bg-color: $private-left-side-color;
// 主题背景图片遮罩
$theme-bg-mask: rgba(#000, 0);
// 主区域背景色 --- limin diff
$theme-container-main-background-color:#F5F5F5;
// container组件
$theme-container-background-color: rgba(#FFF, 1);
$theme-container-header-footer-background-color: rgb(255, 255, 255);
$theme-container-border-inner: 1px solid $color-border-1;
$theme-container-border-outer: 1px solid #E7EAEC;
$theme-multiple-page-control-color: #888;
$theme-multiple-page-control-color-active: $color-text-normal;
$theme-multiple-page-control-nav-prev-color: $private-menu-text-color;
$theme-multiple-page-control-nav-next-color: $private-menu-text-color;
$theme-multiple-page-control-border-color: #E7EAEC;
$theme-multiple-page-control-border-color-active: #FFF;
$theme-multiple-page-control-background-color: rgba(#FFF, .2);
$theme-multiple-page-control-background-color-active: #FFF;
// hamberg --limin diff
$theme-header-hamberg-color:#FFF;
$theme-header-hamberg-color-hover:$private-menu-active-background-color;
// 顶栏和侧边栏中展开的菜单 hover 状态下
$theme-menu-item-color-hover: #293849;
$theme-menu-item-background-color-hover: #ecf5ff;
// 头部背景色 --- limin
$theme-header-background-color:$private-left-side-color;
//logo 背景色 --- limin
$theme-header-logo-background-color:$private-left-side-color;
// 顶栏上的文字颜色 diff
$theme-header-item-color: $private-menu-text-color;
$theme-header-item-background-color: transparent;
// 顶栏上的项目在 hover 时
$theme-header-item-color-hover: #FFF;
$theme-header-item-border-color-hover:rgba($theme-header-item-color-hover,.1);
$theme-header-item-background-color-hover: $private-item-hover;
// 顶栏上的项目在 focus 时
$theme-header-item-color-focus: #FFF;
$theme-header-item-background-color-focus: rgba($private-menu-active-background-color, 1);
// 顶栏上的项目在 active 时
$theme-header-item-color-active: #FFF;
$theme-header-item-background-color-active: rgba($private-menu-active-background-color, 1);
$theme-container-aside-background-color:linear-gradient(180deg, #6729ED 0%, #3E76E2 100%);
// 侧边栏上的文字颜色
$theme-aside-item-color: $private-menu-text-color;
$theme-aside-item-background-color: transparent;
// 侧边栏上的项目在 hover 时
$theme-aside-item-color-hover: #FFF;
$theme-aside-item-background-color-hover: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 focus 时
$theme-aside-item-color-focus: #FFF;
$theme-aside-item-background-color-focus: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 active 时
$theme-aside-item-color-active: #FFF;
$theme-aside-item-background-color-active: rgba($private-menu-active-background-color, .15);
// 侧边栏菜单为空的时候显示的元素
$theme-aside-menu-empty-icon-color: #1F3147;
$theme-aside-menu-empty-text-color: #1F3147;
$theme-aside-menu-empty-background-color: rgba(#FFF, .1);
$theme-aside-menu-empty-icon-color-hover: #FFEBA4;
$theme-aside-menu-empty-text-color-hover: #FFEBA4;
$theme-aside-menu-empty-background-color-hover: rgba(#FFF, .2);
\ No newline at end of file \ No newline at end of file
@import './setting.scss';
@import '../theme.scss';
// 主题名称
$theme-name: 'classic';
$private-left-side-color:#2A58AD;
$private-menu-active-background-color:#154190;
$private-item-hover:rgba(#000,.05);
$private-menu-text-color:#C4D0DF;
$active-i-color:rgb(9, 234, 9);
// 主题背景颜色
$theme-bg-color: $private-left-side-color;
// 主题背景图片遮罩
$theme-bg-mask: rgba(#000, 0);
// 主区域背景色 --- limin
$theme-container-main-background-color:#FFF;
// container组件
$theme-container-background-color: rgba(#FFF, 1);
$theme-container-header-footer-background-color: rgb(255, 255, 255);
$theme-container-border-inner: 1px solid $color-border-1;
$theme-container-border-outer: 1px solid #E7EAEC;
$theme-multiple-page-control-color: #888;
$theme-multiple-page-control-color-active: $color-text-normal;
// tab 页签 滚动条 左 箭头 按钮 颜色
$theme-multiple-page-control-nav-prev-color: $private-menu-text-color;
// tab 页签 滚动条 右 箭头 按钮 颜色
$theme-multiple-page-control-nav-next-color: $private-menu-text-color;
$theme-multiple-page-control-border-color: #E7EAEC;
$theme-multiple-page-control-border-color-active: #FFF;
$theme-multiple-page-control-background-color: rgba(#FFF, .2);
$theme-multiple-page-control-background-color-active: #FFF;
// hamberg --limin
$theme-header-hamberg-color:$private-left-side-color;
$theme-header-hamberg-color-hover:$private-menu-active-background-color;
// 顶栏和侧边栏中展开的菜单 hover 状态下
$theme-menu-item-color-hover: #293849;
$theme-menu-item-background-color-hover: #ecf5ff;
// 头部背景色 --- limin
$theme-header-background-color:#F3F3F4;
//logo 背景色 --- limin
$theme-header-logo-background-color:$private-left-side-color;
// 顶栏上的文字颜色
$theme-header-item-color: #666;
$theme-header-item-background-color: transparent;
// 顶栏上的项目在 hover 时
$theme-header-item-color-hover: #FFF;
$theme-header-item-border-color-hover:rgba($theme-header-item-color-hover,1);
$theme-header-item-background-color-hover: $private-item-hover;
// 顶栏上的项目在 focus 时
$theme-header-item-color-focus: #FFF;
$theme-header-item-background-color-focus: rgba($private-menu-active-background-color, 1);
// 顶栏上的项目在 active 时
$theme-header-item-color-active: #FFF;
$theme-header-item-background-color-active: rgba($private-menu-active-background-color, 1);
$theme-container-aside-background-color:'transparent';
// 侧边栏上的文字颜色
$theme-aside-item-color: $private-menu-text-color;
$theme-aside-item-background-color: transparent;
// 侧边栏上的项目在 hover 时
$theme-aside-item-color-hover: #FFF;
$theme-aside-item-background-color-hover: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 focus 时
$theme-aside-item-color-focus: #FFF;
$theme-aside-item-background-color-focus: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 active 时
$theme-aside-item-color-active: #FFF;
$theme-aside-item-background-color-active: rgba($private-menu-active-background-color, .15);
// 侧边栏菜单为空的时候显示的元素
$theme-aside-menu-empty-icon-color: #1F3147;
$theme-aside-menu-empty-text-color: #1F3147;
$theme-aside-menu-empty-background-color: rgba(#FFF, .1);
$theme-aside-menu-empty-icon-color-hover: #FFEBA4;
$theme-aside-menu-empty-text-color-hover: #FFEBA4;
$theme-aside-menu-empty-background-color-hover: rgba(#FFF, .2);
\ No newline at end of file \ No newline at end of file
@import './setting.scss';
@import '../theme.scss';
// 主题名称
$theme-name: 'dark';
$private-left-side-color:#314256;
$private-menu-active-background-color:#1F3147;
$private-item-hover:rgba(#000,.05);
$private-menu-text-color:#C4D0DF;
$active-i-color:rgb(9, 234, 9);
// 主题背景颜色
$theme-bg-color: $private-left-side-color;
// 主题背景图片遮罩
$theme-bg-mask: rgba(#000, 0);
// 主区域背景色 --- limin
$theme-container-main-background-color:#F5F5F5;
// container组件
$theme-container-background-color: rgba(#FFF, 1);
$theme-container-header-footer-background-color: #FFF;
$theme-container-border-inner: 1px solid $color-border-1;
$theme-container-border-outer: 1px solid #E7EAEC;
$theme-multiple-page-control-color: #888;
$theme-multiple-page-control-color-active: $color-text-normal;
$theme-multiple-page-control-nav-prev-color: $private-menu-text-color;
$theme-multiple-page-control-nav-next-color: $private-menu-text-color;
$theme-multiple-page-control-border-color: #E7EAEC;
$theme-multiple-page-control-border-color-active: #FFF;
$theme-multiple-page-control-background-color: rgba(#FFF, .2);
$theme-multiple-page-control-background-color-active: #FFF;
// hamberg --limin
$theme-header-hamberg-color:#FFF;
$theme-header-hamberg-color-hover:$private-menu-active-background-color;
// 顶栏和侧边栏中展开的菜单 hover 状态下
$theme-menu-item-color-hover: #293849;
$theme-menu-item-background-color-hover: #ecf5ff;
// 头部背景色 --- limin
$theme-header-background-color:#3B4F67;
//logo 背景色 --- limin
$theme-header-logo-background-color:$private-left-side-color;
// 顶栏上的文字颜色
$theme-header-item-color: $private-menu-text-color;
$theme-header-item-background-color: transparent;
// 顶栏上的项目在 hover 时
$theme-header-item-color-hover: #FFF;
$theme-header-item-border-color-hover:rgba($theme-header-item-color-hover,.1);
$theme-header-item-background-color-hover: $private-item-hover;
// 顶栏上的项目在 focus 时
$theme-header-item-color-focus: #FFF;
$theme-header-item-background-color-focus: rgba($private-menu-active-background-color, 1);
// 顶栏上的项目在 active 时
$theme-header-item-color-active: #FFF;
$theme-header-item-background-color-active: rgba($private-menu-active-background-color, 1);
$theme-container-aside-background-color:'transparent';
// 侧边栏上的文字颜色
$theme-aside-item-color: $private-menu-text-color;
$theme-aside-item-background-color: transparent;
// 侧边栏上的项目在 hover 时
$theme-aside-item-color-hover: #FFF;
$theme-aside-item-background-color-hover: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 focus 时
$theme-aside-item-color-focus: #FFF;
$theme-aside-item-background-color-focus: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 active 时
$theme-aside-item-color-active: #FFF;
$theme-aside-item-background-color-active: rgba($private-menu-active-background-color, .15);
// 侧边栏菜单为空的时候显示的元素
$theme-aside-menu-empty-icon-color: #1F3147;
$theme-aside-menu-empty-text-color: #1F3147;
$theme-aside-menu-empty-background-color: rgba(#FFF, .1);
$theme-aside-menu-empty-icon-color-hover: #FFEBA4;
$theme-aside-menu-empty-text-color-hover: #FFEBA4;
$theme-aside-menu-empty-background-color-hover: rgba(#FFF, .2);
\ No newline at end of file \ No newline at end of file
@import './setting.scss';
@import '../theme.scss';
// 主题名称
$theme-name: 'plane';
// diff
$private-left-side-color:transparent;
// diff
$private-menu-active-background-color:#002253;
$private-item-hover:rgba(#000,.05);
$private-menu-text-color:#C4D0DF;
$active-i-color:rgb(9, 234, 9);
// 主题背景颜色
$theme-bg-color: $private-left-side-color;
// 主题背景图片遮罩
$theme-bg-mask: rgba(#000, 0);
// 主区域背景色 --- limin diff
$theme-container-main-background-color:transparent;
// container组件
$theme-container-background-color: rgba(#FFF, 1);
$theme-container-header-footer-background-color: rgb(255, 255, 255);
$theme-container-border-inner: 1px solid $color-border-1;
$theme-container-border-outer: 1px solid #E7EAEC;
$theme-multiple-page-control-color: #888;
$theme-multiple-page-control-color-active: $color-text-normal;
$theme-multiple-page-control-nav-prev-color: $private-menu-text-color;
$theme-multiple-page-control-nav-next-color: $private-menu-text-color;
$theme-multiple-page-control-border-color: #E7EAEC;
$theme-multiple-page-control-border-color-active: #FFF;
$theme-multiple-page-control-background-color: rgba(#FFF, .8);
$theme-multiple-page-control-background-color-active: #FFF;
// hamberg --limin diff
$theme-header-hamberg-color:#FFF;
$theme-header-hamberg-color-hover:$private-menu-active-background-color;
// 顶栏和侧边栏中展开的菜单 hover 状态下
$theme-menu-item-color-hover: #293849;
$theme-menu-item-background-color-hover: #ecf5ff;
// 头部背景色 --- limin
$theme-header-background-color:$private-left-side-color;
//logo 背景色 --- limin
$theme-header-logo-background-color:$private-left-side-color;
// 顶栏上的文字颜色 diff
$theme-header-item-color: $private-menu-text-color;
$theme-header-item-background-color: transparent;
// 顶栏上的项目在 hover 时
$theme-header-item-color-hover: #FFF;
$theme-header-item-border-color-hover:rgba($theme-header-item-color-hover,.1);
$theme-header-item-background-color-hover: $private-item-hover;
// 顶栏上的项目在 focus 时
$theme-header-item-color-focus: #FFF;
$theme-header-item-background-color-focus: rgba($private-menu-active-background-color, .2);
// 顶栏上的项目在 active 时
$theme-header-item-color-active: #FFF;
$theme-header-item-background-color-active: rgba($private-menu-active-background-color, 1);
$theme-container-aside-background-color:'transparent';
// 侧边栏上的文字颜色
$theme-aside-item-color: $private-menu-text-color;
$theme-aside-item-background-color: transparent;
// 侧边栏上的项目在 hover 时
$theme-aside-item-color-hover: #FFF;
$theme-aside-item-background-color-hover: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 focus 时
$theme-aside-item-color-focus: #FFF;
$theme-aside-item-background-color-focus: rgba($private-menu-active-background-color, .15);
// 侧边栏上的项目在 active 时
$theme-aside-item-color-active: #FFF;
$theme-aside-item-background-color-active: rgba($private-menu-active-background-color, .15);
// 侧边栏菜单为空的时候显示的元素
$theme-aside-menu-empty-icon-color: #1F3147;
$theme-aside-menu-empty-text-color: #1F3147;
$theme-aside-menu-empty-background-color: rgba(#FFF, .1);
$theme-aside-menu-empty-icon-color-hover: #FFEBA4;
$theme-aside-menu-empty-text-color-hover: #FFEBA4;
$theme-aside-menu-empty-background-color-hover: rgba(#FFF, .2);
\ No newline at end of file \ No newline at end of file
@import '~@/assets/style/theme/theme-base.scss';
// @import '~@/assets/style/theme/d2/index.scss';
// @import '~@/assets/style/theme/line/index.scss';
// @import '~@/assets/style/theme/star/index.scss';
// @import '~@/assets/style/theme/tomorrow-night-blue/index.scss';
// @import '~@/assets/style/theme/violet/index.scss';
@import '~@/assets/style/theme/classic/index.scss';
@import '~@/assets/style/theme/dark/index.scss';
@import '~@/assets/style/theme/blue/index.scss';
@import '~@/assets/style/theme/plane/index.scss';
\ No newline at end of file \ No newline at end of file
// 减小弹出菜单的项目高度
.el-menu--popup {
.el-menu-item {
height: 36px;
line-height: 36px;
}
.el-submenu__title {
height: 36px;
line-height: 36px;
}
}
// 整体框架结构
.d2-layout-header-aside-group {
height: 100%;
width: 100%;
min-width: 900px;
background-size: cover;
background-position: center;
overflow: hidden;
position: relative;
// 背景上面的半透明遮罩
.d2-layout-header-aside-mask {
@extend %full;
}
// 内容层
.d2-layout-header-aside-content {
@extend %full;
.d2-theme-header {
height: 58px;
.d2-theme-header-menu {
overflow: hidden;
&.is-scrollable {
position: relative;
padding: 0 20px;
.d2-theme-header-menu__prev, .d2-theme-header-menu__next {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
}
.d2-theme-header-menu__content {
overflow: hidden;
.d2-theme-header-menu__scroll {
white-space: nowrap;
position: relative;
-webkit-transition: -webkit-transform .3s;
transition: -webkit-transform .3s;
transition: transform .3s;
transition: transform .3s, -webkit-transform .3s;
transition: transform .3s,-webkit-transform .3s;
float: left;
}
}
.d2-theme-header-menu__prev, .d2-theme-header-menu__next {
height: 60px;
position: absolute;
top: 0;
font-size: 20px;
cursor: pointer;
display: none;
}
.d2-theme-header-menu__prev {
left: 0;
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}
.d2-theme-header-menu__next {
right: 0;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
}
}
}
.d2-theme-container {
.d2-theme-container-aside {
transition: width .3s;
position: relative;
.d2-layout-header-aside-menu-side {
@extend %full;
overflow: hidden;
}
}
.d2-theme-container-main {
padding: 0px;
position: relative;
overflow: hidden;
transition: .1s ease;
.d2-theme-container-main-layer {
position: absolute;
top: 2px;
bottom: 0px;
left: 0px;
right: 0px;
}
.d2-theme-container-main-body {
position: relative;
}
}
}
}
}
// 主题公用
.d2-layout-header-aside-group {
&.grayMode {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
transition: 3s ease;
}
// 主体
.d2-layout-header-aside-content {
// [布局] 顶栏
.d2-theme-header {
transition: .1s ease;
// logo区域
.logo-group {
transition: width .3s;
float: left;
text-align: center;
img {
height: 65px;
transform: translateX(-16px);
}
}
// 折叠侧边栏切换按钮
.toggle-aside-btn {
margin-left: 21px;
}
// [菜单] 顶栏
.el-menu {
float: left;
border-bottom: none;
background-color: transparent;
%header-menu-item {
@extend %unable-select;
i.fa {
font-size: 16px;
margin-right: 4px;
}
}
.el-menu-item {
transition: .1s ease;
@extend %header-menu-item;
border-bottom: none;
}
.el-submenu {
@extend %header-menu-item;
.el-submenu__title {
border-bottom: none;
}
}
}
// 顶栏右侧的按钮
.d2-header-right {
float: right;
height: 60px;
display: flex;
align-items: center;
.btn-text {
padding: 14px 12px;
border-radius: 4px;
margin: 0px !important;
// limin
font-size:13px;
cursor:pointer;
}
.el-dropdown {
@extend %unable-select;
}
}
}
// [布局] 顶栏下面
.d2-theme-container {
// 侧边栏
.d2-theme-container-aside {
%d2-theme-container-aside-menu-icon {
width: 20px;
text-align: center;
font-size: 16px;
}
// [菜单] 正常状态
.el-menu {
@extend %unable-select;
background-color: transparent;
border-right: none;
.el-menu-item {
i {
@extend %d2-theme-container-aside-menu-icon;
}
}
}
.el-submenu {
@extend %unable-select;
.el-submenu__title {
i {
@extend %d2-theme-container-aside-menu-icon;
}
.el-submenu__icon-arrow {
margin-top: -10px;
}
}
ul.el-menu--inline{
background: rgba(#000, .03);
border-top: 1px solid rgba(#FFF, .03);
border-bottom: 1px solid rgba(#FFF, .03);
}
}
// 菜单为空的时候显示的信息
.d2-layout-header-aside-menu-empty {
height: 160px;
margin: 10px;
margin-top: 0px;
border-radius: 4px;
@extend %unable-select;
i {
font-size: 30px;
margin-bottom: 10px;
}
span {
font-size: 14px;
}
}
// [菜单] 折叠状态
.el-menu--collapse {
background-color: transparent;
.el-submenu__title {
text-align: center;
}
}
}
// 右下 主体
.d2-theme-container-main {
// 主体部分分为多页面控制器 和主体
.d2-theme-container-main-header {
height: 34px;
// 多页面控制器
.d2-multiple-page-control-group {
padding-right: 20px;
.d2-multiple-page-control-content {
overflow: auto;
position: relative;
.d2-multiple-page-control-content-inner {
.d2-multiple-page-control {
.el-tabs__header.is-top {
margin: 0px;
}
.el-tabs__nav-wrap{
.el-tabs__nav-scroll{
padding-left: 20px;
}
}
.el-tabs__nav-wrap.is-scrollable{
.el-tabs__nav-scroll{
padding-left: 0;
}
}
.el-tabs__nav {
overflow: hidden;
.el-tabs__item{
height: 33px;
line-height: 33px;
}
}
}
}
}
.d2-multiple-page-control-btn {
position: relative;
// .el-dropdown {
.el-button-group {
.el-button{
border-bottom: none ;
padding: 10px 20px;
&:first-child {
border-bottom-left-radius: 0px;
}
&:last-child {
border-bottom-right-radius: 0px;
}
}
// }
}
}
}
}
// 主体
.d2-theme-container-main-body {
// 布局组件
.container-component {
@extend %full;
overflow: hidden;
// 填充式布局组件
.d2-container-full {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-full__header {
padding: 10px 20px;
}
.d2-container-full__body {
flex-grow: 1;
height: 100%;
padding: 20px 20px;
overflow: auto;
position: relative;
}
.d2-container-full__footer {
padding: 20px;
}
}
// 填充式布局组件 - 滚动优化
.d2-container-full-bs {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-full-bs__header {
padding: 20px;
}
.d2-container-full-bs__body {
flex-grow: 1;
overflow: hidden;
position: relative;
.d2-container-full-bs__body-wrapper-inner {
padding: 20px;
position: relative;
}
}
.d2-container-full-bs__footer {
padding: 20px;
}
}
// 隐形布局组件
.d2-container-ghost {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-ghost__header {
padding: 20px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.d2-container-ghost__body {
flex-grow: 1;
overflow: auto;
position: relative;
}
.d2-container-ghost__footer {
padding: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
}
// 隐形布局组件 - 滚动优化
.d2-container-ghost-bs {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-ghost-bs__header {
padding: 20px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
.d2-container-ghost-bs__body {
flex-grow: 1;
overflow: hidden;
position: relative;
}
.d2-container-ghost-bs__footer {
padding: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
}
// 卡片式布局组件
.d2-container-card {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-card__header {
padding: 20px;
}
.d2-container-card__body {
flex-grow: 1;
overflow: auto;
.d2-container-card__body-card {
position: relative;
margin-bottom: 20px;
padding: 20px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
}
.d2-container-card__footer {
padding: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
}
// 卡片式布局组件 - 滚动优化
.d2-container-card-bs {
position: absolute;
top: 0px;
right: 20px;
bottom: 0px;
left: 0px;
display: flex;
flex-direction: column;
overflow: hidden;
.d2-container-card-bs__header {
padding: 20px;
}
.d2-container-card-bs__body {
position: relative;
flex-grow: 1;
overflow: hidden;
.d2-container-card-bs__body-wrapper-inner {
padding-bottom: 20px;
}
.d2-container-card-bs__body-card {
position: relative;
padding: 20px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
}
.d2-container-card-bs__footer {
padding: 20px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
}
}
}
}
}
}
}
// 每个主题特有的设置
.theme-#{$theme-name} {
.el-card {
&.d2-card {
border: $theme-container-border-outer;
.el-card__header {
border-bottom: $theme-container-border-outer;
}
}
}
// 背景图片和遮罩
.d2-layout-header-aside-group {
background-color: $theme-bg-color;
.d2-layout-header-aside-mask {
background: $theme-bg-mask;
}
}
// 菜单项目
@mixin theme-menu-hover-style {
color: $theme-menu-item-color-hover;
i.fa {
color: $theme-menu-item-color-hover;
}
background: $theme-menu-item-background-color-hover;
}
%el-menu-icon {
i {
display: inline-block;
width: 14px;
text-align: center;
margin-right: 5px;
}
svg {
margin: 0px;
height: 14px;
width: 14px;
margin-right: 5px;
}
}
.el-submenu__title {
@extend %unable-select;
@extend %el-menu-icon;
}
.el-menu-item {
@extend %unable-select;
@extend %el-menu-icon;
}
.el-submenu__title:hover {
@include theme-menu-hover-style;
}
.el-menu-item:hover {
@include theme-menu-hover-style;
}
.el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
@include theme-menu-hover-style;
}
.el-menu--horizontal .el-menu .el-submenu__title:hover {
@include theme-menu-hover-style;
}
// 顶栏
.d2-theme-header {
background-color: $theme-header-background-color;
.d2-theme-header-logo{
background-color: $theme-header-logo-background-color
}
.header-datetime{
color:$theme-header-item-color
}
// 顶栏菜单空间不足时显示的滚动控件
.d2-theme-header-menu {
.d2-theme-header-menu__prev, .d2-theme-header-menu__next {
color: $theme-header-item-color;
background: $theme-header-item-background-color;
&:hover {
color: $theme-header-item-color-hover;
background: $theme-header-item-background-color-hover;
}
}
}
// 切换按钮
.toggle-aside-btn {
// i {
color: $theme-header-hamberg-color;
background: $theme-header-item-background-color;
&:hover {
color: $theme-header-hamberg-color-hover;
}
// }
}
// 顶栏菜单
.el-menu {
.el-menu-item {
transition: border-top-color 0s;
color: $theme-header-item-color;
background: $theme-header-item-background-color;
i.fa { color: inherit; }
&:hover {
color: $theme-header-item-color-hover;
background: $theme-header-item-background-color-hover;
i.fa { color: inherit; }
}
&:focus {
color: $theme-header-item-color-focus;
background: $theme-header-item-background-color-focus;
i.fa { color: inherit; }
}
&.is-active {
color: $theme-header-item-color-active;
background: $theme-header-item-background-color-active;
i.fa { color: inherit; }
}
}
.el-submenu {
&.is-active {
.el-submenu__title {
color: $theme-header-item-color-active;
background: $theme-header-item-background-color-active;
i.fa { color: inherit; }
}
}
.el-submenu__title {
transition: border-top-color 0s;
color: $theme-header-item-color;
background: $theme-header-item-background-color;
i.fa { color: inherit; }
.el-submenu__icon-arrow {
color: $theme-header-item-color;
}
&:hover {
color: $theme-header-item-color-hover;
background: $theme-header-item-background-color-hover;
i.fa { color: inherit; }
.el-submenu__icon-arrow {
color: $theme-header-item-color-hover;
}
}
&:focus {
color: $theme-header-item-color-focus;
background: $theme-header-item-background-color-focus;
i.fa { color: inherit; }
.el-submenu__icon-arrow {
color: $theme-header-item-color-focus;
}
}
}
}
}
// 顶栏右侧
.d2-header-right {
.btn-text {
color: $theme-header-item-color;
&.can-hover {
&:hover {
color: $theme-header-item-color-hover;
background-color: $theme-header-item-background-color-hover;
border-color:$theme-header-item-border-color-hover;
}
}
}
}
}
// [布局] 顶栏下面
.d2-theme-container {
// 侧边栏
.d2-theme-container-aside {
background: $theme-container-aside-background-color;
// 菜单为空的时候显示的信息
.d2-layout-header-aside-menu-empty {
background: $theme-aside-menu-empty-background-color;
i {
color: $theme-aside-menu-empty-icon-color;
}
span {
color: $theme-aside-menu-empty-text-color;
}
&:hover {
background: $theme-aside-menu-empty-background-color-hover;
i {
color: $theme-aside-menu-empty-icon-color-hover;
}
span {
color: $theme-aside-menu-empty-text-color-hover;
}
}
}
// [菜单] 正常状态
.el-menu {
.el-menu-item {
color: $theme-aside-item-color;
background: $theme-aside-item-background-color;
i {
color: $theme-aside-item-color;
}
&:hover {
color: $theme-aside-item-color-hover;
fill: $theme-aside-item-color-hover;
background: $theme-aside-item-background-color-hover;
i {
color: $active-i-color;
}
}
&:focus {
color: $theme-aside-item-color-focus;
fill: $theme-aside-item-color-focus;
background: $theme-aside-item-background-color-focus;
i {
color: $theme-aside-item-color-focus;
}
}
&.is-active {
color: $theme-aside-item-color-active;
fill: $theme-aside-item-color-active;
background: $theme-aside-item-background-color-active;
i {
color: $active-i-color;
}
}
// &:nth-child(1).is-active {
// color: $theme-aside-item-color-active;
// background: $theme-aside-item-background-color;
// i {
// color: $active-i-color;
// }
// }
}
}
.el-submenu {
.el-submenu__title {
color: $theme-aside-item-color;
background: $theme-aside-item-background-color;
i {
color: $theme-aside-item-color;
}
.el-submenu__icon-arrow {
color: $theme-aside-item-color;
}
&:hover {
color: $theme-aside-item-color-hover;
background: $theme-aside-item-background-color-hover;
i {
color: $active-i-color;
}
.el-submenu__icon-arrow {
color: $theme-aside-item-color-hover;
}
}
}
}
}
.d2-theme-container-main {
background-color: $theme-container-main-background-color;
&.is-search{
background-color: rgba($theme-header-background-color,.5)
}
// 主体部分分为多页面控制器 和主体
.d2-theme-container-main-header {
// 多页面控制器
.d2-multiple-page-control {
.el-tabs__header.is-top {
border-bottom-color: $theme-multiple-page-control-border-color;
}
.el-tabs__nav {
border-color: $theme-multiple-page-control-border-color;
.el-tabs__item {
@extend %unable-select;
color: $theme-multiple-page-control-color;
background-color: $theme-multiple-page-control-background-color;
border-left-color: $theme-multiple-page-control-border-color;
&:first-child {
border-left: none;
&:hover {
padding: 0px 20px;
}
.el-icon-close {
display: none;
}
}
&.is-active {
color: $theme-multiple-page-control-color-active;
background-color: $theme-multiple-page-control-background-color-active;
border-bottom-color: $theme-multiple-page-control-border-color-active;
i{
color:$active-i-color
}
}
&:hover{
color: $theme-multiple-page-control-color-active;
i{
color:$active-i-color
}
}
}
}
%el-tabs__nav {
font-size: 20px;
line-height: 33px;
}
.el-tabs__nav-prev {
@extend %el-tabs__nav;
color: $theme-multiple-page-control-nav-prev-color;
}
.el-tabs__nav-next {
@extend %el-tabs__nav;
color: $theme-multiple-page-control-nav-next-color;
}
}
// 多页控制器的关闭控制
.d2-multiple-page-control-btn {
.el-dropdown {
.el-button-group {
.el-button {
border-color: $theme-multiple-page-control-border-color;
}
}
}
}
}
// 主体
.d2-theme-container-main-body {
// 布局组件
.container-component {
// [组件]
// d2-container-full 填充型
.d2-container-full {
border: $theme-container-border-outer;
border-top: none;
border-bottom: none;
.d2-container-full__header {
border-bottom: $theme-container-border-inner;
background: $theme-container-header-footer-background-color;
}
.d2-container-full__body {
background: $theme-container-background-color;
}
.d2-container-full__footer {
border-top: $theme-container-border-inner;
background: $theme-container-header-footer-background-color;
}
}
// [组件]
// d2-container-full-bs 填充型 滚动优化
.d2-container-full-bs {
border: $theme-container-border-outer;
border-top: none;
border-bottom: none;
.d2-container-full-bs__header {
border-bottom: $theme-container-border-inner;
background: $theme-container-header-footer-background-color;
}
.d2-container-full-bs__body {
background: $theme-container-background-color;
}
.d2-container-full-bs__footer {
border-top: $theme-container-border-inner;
background: $theme-container-header-footer-background-color;
}
}
// [组件]
// d2-container-ghost 隐形布局组件
.d2-container-ghost {
.d2-container-ghost__header {
border-bottom: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
.d2-container-ghost__footer {
border-top: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
}
// [组件]
// d2-container-ghost-bs 隐形布局组件 滚动优化
.d2-container-ghost-bs {
.d2-container-ghost-bs__header {
border-bottom: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
.d2-container-ghost-bs__footer {
border-top: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
}
// [组件]
// d2-container-card 卡片型
.d2-container-card {
.d2-container-card__header {
border-bottom: $theme-container-border-inner;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
.d2-container-card__body {
.d2-container-card__body-card {
background: $theme-container-background-color;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
border-bottom: $theme-container-border-outer;
}
}
.d2-container-card__footer {
border-top: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
}
// [组件]
// d2-container-card-bs 卡片型 滚动优化
.d2-container-card-bs {
.d2-container-card-bs__header {
border-bottom: $theme-container-border-inner;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
.d2-container-card-bs__body {
.d2-container-card-bs__body-card {
background: $theme-container-background-color;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
border-bottom: $theme-container-border-outer;
}
}
.d2-container-card-bs__footer {
border-top: $theme-container-border-outer;
border-left: $theme-container-border-outer;
border-right: $theme-container-border-outer;
background: $theme-container-header-footer-background-color;
}
}
}
}
}
}
}
// 主色
$color-primary: #409EFF;
// 辅助色
$color-info: #909399;
$color-success: #67C23A;
$color-warning: #E6A23C;
$color-danger: #F56C6C;
// 文字
$color-text-main: #303133;
$color-text-normal: #606266;
$color-text-sub: #909399;
$color-text-placehoder: #C0C4CC;
// 边框
$color-border-1: #DCDFE6;
$color-border-2: #E4E7ED;
$color-border-3: #EBEEF5;
$color-border-4: #F2F6FC;
// 背景
$color-bg: #f8f8f9;
\ No newline at end of file \ No newline at end of file
<svg viewBox="0 0 88 84" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 49.3 (51167) - http://www.bohemiancoding.com/sketch -->
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="page" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Tablet" transform="translate(-1077.000000, -135.000000)">
<g id="Group" transform="translate(1077.000000, 132.000000)">
<path d="M0.74,85.8 L0.74,71.44 L3.72,71.44 C5.7600102,71.44 7.2566619,71.5899985 8.21,71.89 C9.1633381,72.1900015 9.9866632,72.6633301 10.68,73.31 C11.3733368,73.9566699 11.9066648,74.746662 12.28,75.68 C12.6533352,76.613338 12.84,77.7033271 12.84,78.95 C12.84,80.1966729 12.5500029,81.3699945 11.97,82.47 C11.3899971,83.5700055 10.6033383,84.3999972 9.61,84.96 C8.6166617,85.5200028 7.186676,85.8 5.32,85.8 L0.74,85.8 Z M2.12,84.44 L3.78,84.44 C5.513342,84.44 6.7699961,84.3533342 7.55,84.18 C8.3300039,84.0066658 9.0133304,83.6633359 9.6,83.15 C10.1866696,82.6366641 10.6333318,82.013337 10.94,81.28 C11.2466682,80.546663 11.4,79.7066714 11.4,78.76 C11.4,77.8133286 11.2233351,76.940004 10.87,76.14 C10.5166649,75.339996 10.0133366,74.6800026 9.36,74.16 C8.7066634,73.6399974 7.9366711,73.2900009 7.05,73.11 C6.1633289,72.9299991 4.8600086,72.84 3.14,72.84 L2.12,72.84 L2.12,84.44 Z M16.2,75.94 L14.82,75.94 C14.886667,74.473326 15.3733288,73.2966711 16.28,72.41 C17.1866712,71.5233289 18.2833269,71.08 19.57,71.08 C20.8566731,71.08 21.9233291,71.4966625 22.77,72.33 C23.6166709,73.1633375 24.04,74.179994 24.04,75.38 C24.04,76.2733378 23.8033357,77.0999962 23.33,77.86 C22.8566643,78.6200038 22.1400048,79.5199948 21.18,80.56 L17.6,84.42 L24.24,84.42 L24.24,85.8 L14.48,85.8 L19.96,79.88 C20.9200048,78.8399948 21.6066646,78.020003 22.02,77.42 C22.4333354,76.819997 22.64,76.1333372 22.64,75.36 C22.64,74.5866628 22.3366697,73.9066696 21.73,73.32 C21.1233303,72.7333304 20.3700045,72.44 19.47,72.44 C18.5699955,72.44 17.8233363,72.7433303 17.23,73.35 C16.6366637,73.9566697 16.2933338,74.8199944 16.2,75.94 Z M32.58,70.86 L39.28,85.8 L37.74,85.8 L35.48,80.9 L29.28,80.9 L27.04,85.8 L25.44,85.8 L32.22,70.86 L32.58,70.86 Z M32.4,74.04 L29.94,79.44 L34.84,79.44 L32.4,74.04 Z M51.88,71.08 L51.88,85.8 L50.54,85.8 L50.54,83.98 C49.3266606,85.4333406 47.9366745,86.16 46.37,86.16 C44.8033255,86.16 43.486672,85.6066722 42.42,84.5 C41.353328,83.3933278 40.82,82.0666744 40.82,80.52 C40.82,78.9733256 41.3599946,77.6500055 42.44,76.55 C43.5200054,75.4499945 44.8133258,74.9 46.32,74.9 C48.053342,74.9 49.4599946,75.6399926 50.54,77.12 L50.54,71.08 L51.88,71.08 Z M50.62,80.56 C50.62,79.3466606 50.220004,78.3200042 49.42,77.48 C48.619996,76.6399958 47.620006,76.22 46.42,76.22 C45.219994,76.22 44.2166707,76.6499957 43.41,77.51 C42.6033293,78.3700043 42.2,79.3833275 42.2,80.55 C42.2,81.7166725 42.6133292,82.733329 43.44,83.6 C44.2666708,84.466671 45.2433277,84.9 46.37,84.9 C47.4966723,84.9 48.4866624,84.4900041 49.34,83.67 C50.1933376,82.8499959 50.62,81.8133396 50.62,80.56 Z M54.98,75.18 L56.34,75.18 L56.34,77.02 C57.2866714,75.6066596 58.4999926,74.9 59.98,74.9 C60.7666706,74.9 61.4699969,75.1233311 62.09,75.57 C62.7100031,76.0166689 63.1266656,76.6466626 63.34,77.46 C63.7800022,76.6333292 64.3399966,76.0000022 65.02,75.56 C65.7000034,75.1199978 66.4833289,74.9 67.37,74.9 C68.2566711,74.9 69.0599964,75.2433299 69.78,75.93 C70.5000036,76.6166701 70.86,77.9733232 70.86,80 L70.86,85.8 L69.46,85.8 L69.46,80 C69.46,79.0266618 69.4000006,78.3100023 69.28,77.85 C69.1599994,77.3899977 68.900002,77.0033349 68.5,76.69 C68.099998,76.3766651 67.5700033,76.22 66.91,76.22 C66.2499967,76.22 65.6333362,76.4399978 65.06,76.88 C64.4866638,77.3200022 64.0933344,77.8799966 63.88,78.56 C63.6666656,79.2400034 63.56,80.2666598 63.56,81.64 L63.56,85.8 L62.22,85.8 L62.22,80.36 C62.22,79.226661 62.1600006,78.4166691 62.04,77.93 C61.9199994,77.4433309 61.6533354,77.0366683 61.24,76.71 C60.8266646,76.3833317 60.320003,76.22 59.72,76.22 C59.119997,76.22 58.5566693,76.3966649 58.03,76.75 C57.5033307,77.1033351 57.0900015,77.5866636 56.79,78.2 C56.4899985,78.8133364 56.34,79.8466594 56.34,81.3 L56.34,85.8 L54.98,85.8 L54.98,75.18 Z M73.1,72.22 C73.1,71.9133318 73.2099989,71.6466678 73.43,71.42 C73.6500011,71.1933322 73.9166651,71.08 74.23,71.08 C74.5433349,71.08 74.8099989,71.1899989 75.03,71.41 C75.2500011,71.6300011 75.36,71.8966651 75.36,72.21 C75.36,72.5233349 75.2500011,72.7899989 75.03,73.01 C74.8099989,73.2300011 74.5433349,73.34 74.23,73.34 C73.9166651,73.34 73.6500011,73.2266678 73.43,73 C73.2099989,72.7733322 73.1,72.5133348 73.1,72.22 Z M73.54,75.18 L74.92,75.18 L74.92,85.8 L73.54,85.8 L73.54,75.18 Z M77.74,75.18 L79.12,75.18 L79.12,77.08 C80.2133388,75.6266594 81.5399922,74.9 83.1,74.9 C83.900004,74.9 84.6199968,75.1166645 85.26,75.55 C85.9000032,75.9833355 86.353332,76.5499965 86.62,77.25 C86.886668,77.9500035 87.02,78.9799932 87.02,80.34 L87.02,85.8 L85.66,85.8 L85.66,80.74 C85.66,79.4999938 85.6033339,78.6600022 85.49,78.22 C85.3766661,77.7799978 85.2033345,77.4066682 84.97,77.1 C84.7366655,76.7933318 84.4400018,76.5600008 84.08,76.4 C83.7199982,76.2399992 83.2833359,76.16 82.77,76.16 C82.2566641,76.16 81.7533358,76.2866654 81.26,76.54 C80.7666642,76.7933346 80.3466684,77.1466644 80,77.6 C79.6533316,78.0533356 79.4200006,78.5199976 79.3,79 C79.1799994,79.4800024 79.12,80.4466594 79.12,81.9 L79.12,85.8 L77.74,85.8 L77.74,75.18 Z" id="D2Admin" fill="#409EFF"></path>
<g id="logo-no-shadow" transform="translate(11.000000, 0.000000)">
<path d="M44.2833805,33.4299717 L6.05798302,56.3652102 C4.16366196,57.5018028 1.70662094,56.8875426 0.570028297,54.9932215 C0.197031333,54.3715599 8.87839274e-17,53.6602143 0,52.9352385 L-4.4408921e-16,7.06476152 C-7.1463071e-16,4.85562252 1.790861,3.06476152 4,3.06476152 C4.72497578,3.06476152 5.43632142,3.26179285 6.05798302,3.63478981 L44.2833805,26.5700283 C46.1777016,27.7066209 46.7919618,30.163662 45.6553692,32.057983 C45.3175701,32.6209814 44.8463789,33.0921727 44.2833805,33.4299717 Z" id="Triangle-Copy" fill="#35495E" transform="translate(25.000000, 30.000000) rotate(-180.000000) translate(-25.000000, -30.000000) "></path>
<path d="M60.2833805,33.4299717 L22.057983,56.3652102 C20.163662,57.5018028 17.7066209,56.8875426 16.5700283,54.9932215 C16.1970313,54.3715599 16,53.6602143 16,52.9352385 L16,7.06476152 C16,4.85562252 17.790861,3.06476152 20,3.06476152 C20.7249758,3.06476152 21.4363214,3.26179285 22.057983,3.63478981 L60.2833805,26.5700283 C62.1777016,27.7066209 62.7919618,30.163662 61.6553692,32.057983 C61.3175701,32.6209814 60.8463789,33.0921727 60.2833805,33.4299717 Z" id="Triangle" fill="#409EFF"></path>
<path d="M42.4688663,31.7973091 L24.0289915,42.8612339 C23.081831,43.4295303 21.8533105,43.1224001 21.2850141,42.1752396 C21.0985157,41.8644088 21,41.508736 21,41.1462481 L21,19.0183984 C21,17.9138289 21.8954305,17.0183984 23,17.0183984 C23.3624879,17.0183984 23.7181607,17.116914 24.0289915,17.3034125 L42.4688663,28.3673374 C43.4160268,28.9356337 43.7231569,30.1641542 43.1548606,31.1113147 C42.9859611,31.3928139 42.7503655,31.6284096 42.4688663,31.7973091 Z" id="Triangle-Copy" fill="#FFFFFF" transform="translate(31.000000, 30.082670) rotate(-180.000000) translate(-31.000000, -30.082670) "></path>
<path d="M37.5708451,30.8574929 L30.5144958,35.0913025 C30.0409155,35.3754507 29.4266552,35.2218856 29.1425071,34.7483054 C29.0492578,34.59289 29,34.4150536 29,34.2338096 L29,25.7661904 C29,25.2139056 29.4477153,24.7661904 30,24.7661904 C30.1812439,24.7661904 30.3590804,24.8154482 30.5144958,24.9086975 L37.5708451,29.1425071 C38.0444254,29.4266552 38.1979905,30.0409155 37.9138423,30.5144958 C37.8293925,30.6552454 37.7115947,30.7730432 37.5708451,30.8574929 Z" id="Triangle" fill="#409EFF"></path>
</g>
</g>
</g>
</g>
</svg>
\ No newline at end of file \ No newline at end of file
<svg viewBox="0 0 60 54" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<desc>D2Admin</desc>
<defs></defs>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="logo-no-shadow" transform="translate(-3.000000, -3.000000)">
<path d="M44.2833805,33.4299717 L6.05798302,56.3652102 C4.16366196,57.5018028 1.70662094,56.8875426 0.570028297,54.9932215 C0.197031333,54.3715599 8.87839274e-17,53.6602143 0,52.9352385 L-4.4408921e-16,7.06476152 C-7.1463071e-16,4.85562252 1.790861,3.06476152 4,3.06476152 C4.72497578,3.06476152 5.43632142,3.26179285 6.05798302,3.63478981 L44.2833805,26.5700283 C46.1777016,27.7066209 46.7919618,30.163662 45.6553692,32.057983 C45.3175701,32.6209814 44.8463789,33.0921727 44.2833805,33.4299717 Z" id="Triangle-Copy" fill="#35495E" transform="translate(25.000000, 30.000000) rotate(-180.000000) translate(-25.000000, -30.000000) "></path>
<path d="M60.2833805,33.4299717 L22.057983,56.3652102 C20.163662,57.5018028 17.7066209,56.8875426 16.5700283,54.9932215 C16.1970313,54.3715599 16,53.6602143 16,52.9352385 L16,7.06476152 C16,4.85562252 17.790861,3.06476152 20,3.06476152 C20.7249758,3.06476152 21.4363214,3.26179285 22.057983,3.63478981 L60.2833805,26.5700283 C62.1777016,27.7066209 62.7919618,30.163662 61.6553692,32.057983 C61.3175701,32.6209814 60.8463789,33.0921727 60.2833805,33.4299717 Z" id="Triangle" fill="#409EFF"></path>
<path d="M42.4688663,31.7973091 L24.0289915,42.8612339 C23.081831,43.4295303 21.8533105,43.1224001 21.2850141,42.1752396 C21.0985157,41.8644088 21,41.508736 21,41.1462481 L21,19.0183984 C21,17.9138289 21.8954305,17.0183984 23,17.0183984 C23.3624879,17.0183984 23.7181607,17.116914 24.0289915,17.3034125 L42.4688663,28.3673374 C43.4160268,28.9356337 43.7231569,30.1641542 43.1548606,31.1113147 C42.9859611,31.3928139 42.7503655,31.6284096 42.4688663,31.7973091 Z" id="Triangle-Copy" fill="#FFFFFF" transform="translate(31.000000, 30.082670) rotate(-180.000000) translate(-31.000000, -30.082670) "></path>
<path d="M37.5708451,30.8574929 L30.5144958,35.0913025 C30.0409155,35.3754507 29.4266552,35.2218856 29.1425071,34.7483054 C29.0492578,34.59289 29,34.4150536 29,34.2338096 L29,25.7661904 C29,25.2139056 29.4477153,24.7661904 30,24.7661904 C30.1812439,24.7661904 30.3590804,24.8154482 30.5144958,24.9086975 L37.5708451,29.1425071 C38.0444254,29.4266552 38.1979905,30.0409155 37.9138423,30.5144958 C37.8293925,30.6552454 37.7115947,30.7730432 37.5708451,30.8574929 Z" id="Triangle" fill="#409EFF"></path>
</g>
</g>
</svg>
\ No newline at end of file \ No newline at end of file
import Vue from 'vue'
const requireAll = requireContext => requireContext.keys().map(requireContext)
const req = require.context('./icons', false, /\.svg$/)
const iconMap = requireAll(req)
Vue.prototype.$IconSvg = iconMap.map(e => e.default.id.slice(3))
/*
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-18 20:07:42
*/
// import { LOGIN_URL, REG_URL, ROLE_LIST_URL } from '@/api/sys.account'
// import { BASE_DATA_URL } from '@/api/sys.base'
export const TYPE_NAME = 'confType'
/**
* 后台提供一个接 通过类型获取对应数据
* 此处定义类型
*/
export const ConfigType = {
STATION: 'STATION_TYPE',
POST: 'POST_TYPE',
SUBSYS: 'SUBSYSTEM_TYPE'
}
/**
* 前端基础数据管理对应的接口名称的key
*/
export const BaseData = {
ROLE: { KEY: 'role', TYPE: '' },
STATION: { KEY: 'station', TYPE: ConfigType.STATION },
POST: { KEY: 'post', TYPE: ConfigType.POST },
SUBSYS: { KEY: 'subsys', TYPE: ConfigType.SUBSYS }
}
/**
* 注册类型
*/
export const RegistType = {
BY_SELF: '1', // 自注册
BY_ADMIN: '2' // 管理员创建
}
/**
* 前端免登录验证接口名
*/
export const LogExternals = [
'fims.user.login', // 登录
'fims.user.register', // 注册
'fims.configuration.from.conftype', // 基础数据
'fims.role.list' // 角色列表
]
/**
* 登录来源
*/
export const LOGIN_TYPE = 1 // 1pc,2小程序
/**
* 超级管理员类型
*/
export const SUPPER_ADMIN = 1 //
/**
* 职务置灰选项
*/
export const POST_DISABLED = ['2001', '2002', '2003'] // 总经理 仓库 部门经理
import Vue from 'vue'
export default new Vue({
methods: {
warningTips(message) {
this.$notify({
type: 'warning',
title: message
})
},
okTips(message) {
this.$notify({
type: 'success',
title: message || '操作成功'
})
},
errorTips(message) {
this.$notify({
type: 'error',
title: message || '操作失败'
})
}
}
})
export default {
name: 'AuthButton',
props: {
label: {
type: String,
default: ''
},
size: {
type: String,
default: 'mini'
},
// type: {
// type: String,
// default: 'text'
// },
category: {
type: String,
default: 'operation'
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
id: {
type: String,
default: null
},
accept: {
type: String,
default: null
},
mapping: {
type: Object,
default: null
},
data: Object
},
functional: true, // 开启函数化组件
render: (h, ctx) => {
const _this = ctx.parent // 获取 vue this 实例
// console.log(ctx);
/**
* 获取传入参数
* category 非必填 button 类别 暂时两种 1 表格操作:operation ,2 Button 按钮: action 默认 operation ----- route 中不标明 视为默认值 operation
* data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row
* mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
*/
const { category, data, mapping, label } = ctx.props
let curBtns = []
/**
* 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中
* @param {*} btn
*/
const filter = btn => mapping ? mapping[data[mapping['field']]].includes(btn.label) : true
const $store = _this.$store.getters['d2admin/auth/curBtns']
if (!$store) return h('div')
if (label) { // 指定label
const __item = $store.find(btn => (btn.label === label) && filter(btn))
__item && curBtns.push(__item)
} else {
/**
* 拿到当前模块(页面) 所拥有按钮列表 过滤type属性 与 映射关系 返回需要显示的按钮列表
*/
curBtns = $store.filter(btn => {
if (category === 'operation') {
return (btn.category === 'operation' || !btn.category) && filter(btn)
} else if (!category) { // 未指定类别
return !btn.category && filter(btn)
}
return (btn.category === category) && filter(btn)
})
}
if (curBtns.length === 0) return h('div')
const __aBtns = []
/**
* 循环最终显示的按钮列表
* 并渲染到页面
*/
curBtns.forEach(btn =>
__aBtns.push(h('el-button', {
props: {
type: btn.type || 'text',
icon: btn.icon ? `el-icon-${btn.icon}` : ''
},
style: {
color: btn.color
},
on: {
click: (e) => btn.handle && _this[btn.handle](data, e)
}
}, [btn.label])))
return h('div', {}, [...__aBtns, ctx.children])
}
}
<template>
<div class="d2-container-card-bs">
<div v-if="$slots.header" class="d2-container-card-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-card-bs__body" ref="wrapper">
<div class="d2-container-card-bs__body-wrapper-inner">
<div class="d2-container-card-bs__body-card">
<slot/>
</div>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-card-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-card">
<div v-if="$slots.header" class="d2-container-card__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-card__body" ref="body">
<div class="d2-container-card__body-card">
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-card__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-card',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div class="d2-container-full-bs">
<div v-if="$slots.header" class="d2-container-full-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-full-bs__body" ref="wrapper">
<div class="d2-container-full-bs__body-wrapper-inner">
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-full-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-full">
<div v-if="$slots.header" class="d2-container-full__header" ref="header" :class="this.active?'active':'close'">
<slot name="header" />
<d2-header-switch />
</div>
<div class="d2-container-full__body" ref="body">
<slot />
</div>
<div v-if="$slots.footer" class="d2-container-full__footer" ref="footer">
<slot name="footer" />
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-full',
mixins: [scroll],
components: {
d2HeaderSwitch: () => import('./d2-header-switch.vue')
},
data() {
return {
oHeaderStyle: {
padding: '20px 20px 0 20px'
}
}
},
computed: {
active() {
return this.$store.state.d2admin.tsearch.active
}
},
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<style lang="scss">
.d2-container-full {
.d2-container-full__header {
position: relative;
transition: all .2s ease;
&.close{
height: 0;
padding: 0 20px !important;
form{
opacity: 0;
}
border-bottom-color:rgba(0,0,0,0) !important;
}
.el-form-item{
margin-bottom: 4px;
}
}
}
</style>
<template>
<div class="d2-container-ghost-bs">
<div v-if="$slots.header" class="d2-container-ghost-bs__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-ghost-bs__body" ref="wrapper">
<div>
<slot/>
</div>
</div>
<div v-if="$slots.footer" class="d2-container-ghost-bs__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import bs from './mixins/bs'
export default {
name: 'd2-container-card-bs',
mixins: [
bs
]
}
</script>
<template>
<div class="d2-container-ghost">
<div v-if="$slots.header" class="d2-container-ghost__header" ref="header">
<slot name="header"/>
</div>
<div class="d2-container-ghost__body" ref="body">
<slot/>
</div>
<div v-if="$slots.footer" class="d2-container-ghost__footer" ref="footer">
<slot name="footer"/>
</div>
</div>
</template>
<script>
import scroll from './mixins/normal'
export default {
name: 'd2-container-ghost',
mixins: [
scroll
],
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
}
</script>
<template>
<div
v-if="show"
class="d2-header-switch"
:class="{ 'd2-header-switch--active': isActive }"
@click="handleClick">
<d2-el-icon :name="name"/>
<!-- <li :class="$store.state.d2admin.tsearch.active?'fa fa-compress':'fa fa-expand'"></li> -->
</div>
</template>
<script>
import { mapMutations } from 'vuex'
export default {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show() {
return true
},
name() {
return this.$store.state.d2admin.tsearch.active ? 'top-right' : 'bottom-left'
}
},
mounted() {
setTimeout(() => (this.isActive = true), 0)
},
methods: {
...mapMutations('d2admin/tsearch', ['toggle']),
// 点击按钮的时候跳转到源代码
handleClick() {
this.toggle()
}
}
}
</script>
<style lang="scss" scoped>
.d2-header-switch {
$borderRadius: 30px;
$paddingLR: 30px;
$paddingTB: 2px;
$fontSize: 12px;
$rightOuter: $paddingLR / 2;
opacity: 0;
position: absolute;
z-index: 2019;
right: 20%;
bottom: -17px;
font-size: $fontSize;
line-height: $fontSize;
font-weight: bold;
border-radius: 0 0 $borderRadius $borderRadius;
padding: $paddingTB $paddingLR;
background-color: rgba(#fff, 1);
border: 1px solid #DCDFE6;
border-top: none;
color: #606266;
transition: all .3s;
@extend %unable-select;
&.d2-header-switch--active {
opacity: 1;
}
}
</style>
<template>
<div
v-if="show"
class="d2-source"
:class="{ 'd2-source--active': isActive }"
@click="handleClick">
<d2-icon name="code"/> 本页源码
</div>
</template>
<script>
export default {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show() {
return process.env.VUE_APP_BUILD_MODE === 'TRAVIS' || process.env.NODE_ENV === 'development'
}
},
watch: {
$route: {
handler(to) {
this.path = _.get(_.last(to.matched), 'components.default.__source')
},
immediate: true
}
},
mounted() {
// 一秒后显示按钮
setTimeout(() => {
this.isActive = true
}, 500)
},
methods: {
// 点击按钮的时候跳转到源代码
handleClick() {
this.$open(`${process.env.VUE_APP_REPO}/blob/master/${this.path}`)
}
}
}
</script>
<style lang="scss" scoped>
.d2-source {
$borderRadius: 4px;
$paddingLR: 15px;
$paddingTB: 7px;
$fontSize: 12px;
$rightOuter: $paddingLR / 2;
opacity: 0;
position: fixed;
z-index: 9999;
right: - $borderRadius - $rightOuter;
bottom: 20px;
font-size: $fontSize;
line-height: $fontSize;
font-weight: bold;
border-radius: $borderRadius;
padding: $paddingTB $paddingLR;
padding-right: $borderRadius + $paddingLR;
background-color: rgba(#000, .7);
border: 1px solid #000;
color: #FFF;
transition: all .3s;
@extend %unable-select;
&.d2-source--active {
opacity: 1;
}
&:hover {
right: - $borderRadius;
background-color: rgba(#000, .9);
}
}
</style>
import BScroll from 'better-scroll'
export default {
props: {
// 滚动优化的选项
betterScrollOptions: {
type: Object,
required: false,
default: () => ({})
}
},
data() {
return {
BS: null
}
},
mounted() {
this.scrollInit()
},
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit() {
// 初始化 bs
this.BS = new BScroll(this.$refs.wrapper, Object.assign({
mouseWheel: true,
click: true,
scrollbar: {
fade: true,
interactive: false
}
}, this.betterScrollOptions))
// 滚动时发出事件 并且统一返回的数据格式
this.BS.on('scroll', ({ x, y }) => this.$emit('scroll', {
x: -x,
y: -y
}))
},
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
} catch (e) {
delete this.BS
this.BS = null
}
},
// 外部调用的方法 返回顶部
scrollToTop() {
if (this.BS) this.BS.scrollTo(0, 0, 300)
},
// 手动发出滚动事件
scroll() {
if (this.BS) {
this.$emit('scroll', {
x: -this.BS.x,
y: -this.BS.y
})
}
}
}
}
// 提供滚动方面的功能
// 非滚动优化模式通用
// 生成滚动事件的 handler
function handleMaker(wait) {
return _.throttle(e => {
this.$emit('scroll', {
x: e.target.scrollLeft,
y: e.target.scrollTop
})
}, wait)
}
export default {
props: {
// 滚动事件节流间隔
scrollDelay: {
type: Number,
required: false,
default: 10
}
},
data() {
return {
handleScroll: null
}
},
watch: {
scrollDelay(val) {
// 移除旧的监听
this.removeScrollListener()
// 生成新的 handle 方法
this.handleScroll = handleMaker.call(this, val)
// 添加新的监听
this.addScrollListener()
}
},
methods: {
// 增加滚动事件监听
addScrollListener() {
if (typeof this.handleScroll !== 'function') {
// mounted 生命周期内调用这个方法的时候会进入这里的判断
this.handleScroll = handleMaker.call(this, this.scrollDelay)
}
// 添加监听
this.$refs.body.addEventListener('scroll', this.handleScroll)
},
// 移除滚动事件监听
removeScrollListener() {
this.$refs.body.removeEventListener('scroll', this.handleScroll)
},
// 外部调用的方法 返回顶部
scrollToTop() {
const smoothscroll = () => {
const body = this.$refs.body
const currentScroll = body.scrollTop
if (currentScroll > 0) {
window.requestAnimationFrame(smoothscroll)
body.scrollTo(0, currentScroll - (currentScroll / 5))
}
}
smoothscroll()
}
}
}
// 组件
import d2ContainerFull from './components/d2-container-full.vue'
import d2ContainerFullBs from './components/d2-container-full-bs.vue'
import d2ContainerGhost from './components/d2-container-ghost.vue'
import d2ContainerGhostBs from './components/d2-container-ghost-bs.vue'
import d2ContainerCard from './components/d2-container-card.vue'
import d2ContainerCardBs from './components/d2-container-card-bs.vue'
// import d2Source from './components/d2-source.vue'
export default {
name: 'd2-container',
props: {
// 容器样式
type: {
type: String,
required: false,
default: 'full'
},
// 滚动优化
betterScroll: {
type: Boolean,
required: false,
default: false
}
},
computed: {
// 始终返回渲染组件
component() {
if (this.type === 'card' && !this.betterScroll) return d2ContainerCard
if (this.type === 'card' && this.betterScroll) return d2ContainerCardBs
if (this.type === 'ghost' && !this.betterScroll) return d2ContainerGhost
if (this.type === 'ghost' && this.betterScroll) return d2ContainerGhostBs
if (this.type === 'full' && !this.betterScroll) return d2ContainerFull
if (this.type === 'full' && this.betterScroll) return d2ContainerFullBs
else {
return 'div'
}
}
},
render(h) {
const slots = [ this.$slots.default ]
if (this.$slots.header) slots.push(h('template', { slot: 'header' }, [ this.$slots.header ]))
if (this.$slots.footer) slots.push(h('template', { slot: 'footer' }, [ this.$slots.footer ]))
return h('div', {
ref: 'container',
class: 'container-component'
}, [
h(this.component, {
ref: 'component',
props: this.$attrs,
on: {
scroll: e => this.$emit('scroll', e)
}
}, slots)
// h(d2Source)
])
},
methods: {
// 返回顶部
scrollToTop() {
this.$refs.component.scrollToTop()
// 如果开启了 better scroll 还需要手动触发一遍 scroll 事件
const bs = this.$refs.component.BS
if (bs) this.$refs.component.scroll()
},
// 用法同原生方法 scrollBy
scrollBy(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollBy(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollBy(x, y)
}
},
// 用法同原生方法 scrollTo
scrollTo(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(-x, -y, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTo(x, y)
}
},
// 用法同原生方法 scrollTop
scrollTop(top = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
bs.scrollTo(bs.x, -top, time)
// 手动触发一遍 scroll 事件
this.$refs.component.scroll()
}
} else {
this.$refs.component.$refs.body.scrollTop = top
}
}
}
}
<template>
<i :class="`el-icon-${name}`" aria-hidden="true"></i>
</template>
<script>
export default {
name: 'd2-el-icon',
props: {
name: {
type: String,
required: false,
default: ''
}
}
}
</script>
<template>
<svg aria-hidden="true">
<use :xlink:href="icon"></use>
</svg>
</template>
<script>
export default {
name: 'd2-icon-svg',
props: {
name: {
type: String,
required: true
}
},
computed: {
icon() {
return `#d2-${this.name}`
}
}
}
</script>
/*!
* Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
*/@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.fa-handshake-o:before{content:"\f2b5"}.fa-envelope-open:before{content:"\f2b6"}.fa-envelope-open-o:before{content:"\f2b7"}.fa-linode:before{content:"\f2b8"}.fa-address-book:before{content:"\f2b9"}.fa-address-book-o:before{content:"\f2ba"}.fa-vcard:before,.fa-address-card:before{content:"\f2bb"}.fa-vcard-o:before,.fa-address-card-o:before{content:"\f2bc"}.fa-user-circle:before{content:"\f2bd"}.fa-user-circle-o:before{content:"\f2be"}.fa-user-o:before{content:"\f2c0"}.fa-id-badge:before{content:"\f2c1"}.fa-drivers-license:before,.fa-id-card:before{content:"\f2c2"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:"\f2c3"}.fa-quora:before{content:"\f2c4"}.fa-free-code-camp:before{content:"\f2c5"}.fa-telegram:before{content:"\f2c6"}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:"\f2c7"}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:"\f2c8"}.fa-thermometer-2:before,.fa-thermometer-half:before{content:"\f2c9"}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:"\f2ca"}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"\f2cb"}.fa-shower:before{content:"\f2cc"}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:"\f2cd"}.fa-podcast:before{content:"\f2ce"}.fa-window-maximize:before{content:"\f2d0"}.fa-window-minimize:before{content:"\f2d1"}.fa-window-restore:before{content:"\f2d2"}.fa-times-rectangle:before,.fa-window-close:before{content:"\f2d3"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"\f2d4"}.fa-bandcamp:before{content:"\f2d5"}.fa-grav:before{content:"\f2d6"}.fa-etsy:before{content:"\f2d7"}.fa-imdb:before{content:"\f2d8"}.fa-ravelry:before{content:"\f2d9"}.fa-eercast:before{content:"\f2da"}.fa-microchip:before{content:"\f2db"}.fa-snowflake-o:before{content:"\f2dc"}.fa-superpowers:before{content:"\f2dd"}.fa-wpexplorer:before{content:"\f2de"}.fa-meetup:before{content:"\f2e0"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}
This diff could not be displayed because it is too large.
<template>
<i class="fa" :class="`fa-${name}`" aria-hidden="true"></i>
</template>
<script>
import './font-awesome-4.7.0/css/font-awesome.min.css'
export default {
name: 'd2-icon',
props: {
name: {
type: String,
required: false,
default: 'font-awesome'
}
}
}
</script>
<template>
<el-row class="table-header">
<el-col :span="12">
<d2-el-icon name="s-grid" />
<span v-text="title"></span>
</el-col>
<el-col :span="12">
<slot></slot>
</el-col>
</el-row>
</template>
<script>
export default {
name: 'd2-teble-header',
props: {
title: {
type: String,
required: false,
default: ''
}
}
}
</script>
<!-- 表格+分页 -->
<template>
<div>
<el-table
:data="getListApi ? data : tableData"
v-loading="loading"
border
:highlight-current-row="true"
:stripe="true"
@sort-change="sortChange"
>
<el-table-column
align="center"
width="60px"
label="序号"
type='index'
:index="index=>index+(pagination.pageSize - 1) * pagination.pageCount + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableParams.tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
:align="item.align||'center'"
:sortable="item.sortable"
>
<template slot-scope="scope">
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="scope.row"
:prop="item.prop"
:momFlag="item.momFlag"
></slot>
<template v-else-if="item.momFlag">
<div>
<span v-text="scope.row[item.prop]"></span>
<span
v-if="scope.row[item.momFlag] > 0"
class="el-icon-top"
></span>
<span
v-else-if="scope.row[item.momFlag] < 0"
class="el-icon-bottom"
></span>
<span v-else-if="scope.row[item.momFlag] == 0">--</span>
</div>
</template>
<template v-else-if="item.tagLabel">
<el-tag
v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]"
v-text="tableParams.tag.label[scope.row[item.prop]]"
>
</el-tag>
<el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
></el-tag>
</template>
<template v-else-if="item.formatter">
<span v-text="item.formatter(scope.row)"></span>
</template>
<template v-else-if="getListApi">
<p v-text="data[scope.$index][item.prop]"></p>
</template>
<template v-else>
<p v-text="tableData[scope.$index][item.prop]"></p>
</template>
</template>
</el-table-column>
<el-table-column
v-if="tableParams.tableOption"
label="操作"
:align="tableParams.tableOption.align||'center'"
:width="tableParams.tableOption.width||'200'"
fixed="right"
>
<template slot-scope="scope">
<slot
name="auth-button"
:scope="scope.row"
></slot>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="hasPage"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageSize"
:page-sizes="[10,20,30,40]"
:page-size="page.pageCount"
:total="getListApi ? total : tableTotal"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination>
</div>
</template>
<script>
export default {
name: 'd2-table',
data() {
return {
loading: false,
oldValue: {},
data: [],
// 页码
page: {
pageCount: 10,
pageSize: 1
},
total: 10,
// 排序
sortColum: '',
sort: '',
pagination: {}
}
},
props: {
// 搜索条件
searchForm: {
type: Object,
default: () => []
},
// 表格数据-外部传入
tableData: {
type: Array,
default: () => []
},
tableTotal: {
type: Number,
default: 10
},
// 获取列表接口
getListApi: {
type: Function,
default: null
},
// 分页,默认有
hasPage: {
type: Boolean,
default: true
},
tableParams: {
type: Object,
default: () => {
return {
// 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000)
// btnId: {
// type: String,
// default: ''
// },
// 后端返回列表参数名
listName: {
type: String,
default: ''
},
// 标签-默认标签名为tag;若有多个,那么需要在表格栏的列中加“tagName”
// tag: {
// type: Array,
// default: () => []
// },
// 表格操作,默认没有
// tableOption: {
// type: Object,
// default: null
// },
// 表格栏
tableColumns: {
type: Array,
default: () => []
}
}
}
}
},
watch: {
searchForm: {
handler(val) {
const attr = Object.keys(val).find(item => val[item] !== this.oldValue[item])
if (!val[attr] && this.oldValue[attr]) {
this.getListApi ? this.refreshEmit() : this.$emit('refreshTable', this.page)
}
this.oldValue = _.cloneDeep(val)
},
deep: true
}
// 调用其他接口,导致表格刷新-标识
// '$store.state.d2admin.refreshtable.value'(val) {
// (val === 'fresh') && this.refreshEmit()
// }
},
mounted() {
const btn = document.getElementById(this.tableParams.btnId)
btn && btn.addEventListener('click', this.refreshEmit)
this.getListApi && this.refreshTable()
},
methods: {
// 排序
sortChange({ column, prop, order }) {
this.sortColum = order ? prop : ''
this.sort = order
this.refreshTable()
},
// 发布事件,以期查询条件改变后,页面图表需要刷新
refreshEmit() {
this.$emit('searchChange')
this.refreshTable()
},
refreshTable() {
this.loading = true
var params = {
...this.page,
...this.searchForm
}
if (this.sort) {
params.sortColum = this.sortColum
params.sort = this.sort === 'descending' ? 1 : 0
}
this.getListApi(params).then(res => {
this.pagination = res.pagination ? res.pagination : this.page
this.data = res[this.tableParams.listName]
res.pagination && (this.total = res.pagination.totalCount)
this.loading = false
}).catch(() => {
this.loading = false
})
},
// 页码
handleSizeChange(value) {
this.page.pageCount = value
this.getListApi ? this.refreshTable() : this.$emit('refreshTable', this.page)
},
handleCurrentChange(value) {
this.page.pageSize = value
this.getListApi ? this.refreshTable() : this.$emit('refreshTable', this.page)
}
}
}
</script>
<style>
.a-click {
cursor: pointer;
}
</style>
<!-- 表格+分页 -->
<template>
<div class="d2-table">
<el-table
:ref="tableParams.mutiSelectName + 'MutiTable' || 'mutiTable'"
:data="getListApi ? data : tableData"
:row-key="tableParams.mutiSelectUniqueKey || ''"
v-loading="loading"
border
:highlight-current-row="true"
:stripe="true"
@sort-change="sortChange"
@selection-change="handleSelect"
>
<el-table-column
v-if="tableParams.mutiSelectUniqueKey"
type="selection"
width="55"
:reserve-selection="true"
>
</el-table-column>
<el-table-column
v-if="hasNum"
align="center"
width="60px"
label="序号"
type='index'
:index="index=>index+(pagination.pageSize - 1) * pagination.pageCount + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableParams.tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
:min-width="item.minWidth"
:align="item.align||'center'"
:sortable="item.sortable"
>
<template slot-scope="scope">
<slot
v-if="item.addHtml"
:name="item.addHtml"
:scope="scope.row"
:prop="item.prop"
:width="item.width"
></slot>
<template v-else-if="item.tagLabel">
<el-tag
v-if="!item.tagName"
:type="tableParams.tag.type[scope.row[item.prop]]"
v-text="tableParams.tag.label[scope.row[item.prop]]"
>
</el-tag>
<el-tag
v-else
:type="tableParams[item.tagName].type[scope.row[item.prop]]"
v-text="tableParams[item.tagName].label[scope.row[item.prop]]"
></el-tag>
</template>
<template v-else-if="item.formatter">
<span v-text="item.formatter(scope.row)"></span>
</template>
<template v-else-if="getListApi">
<span v-text="data[scope.$index][item.prop]"></span>
</template>
<template v-else>
<span v-text="tableData[scope.$index][item.prop]"></span>
</template>
<template v-if="item.addSymbol">
<span v-text="item.addSymbol"></span>
</template>
</template>
</el-table-column>
<el-table-column
v-if="tableParams.tableOption"
label="操作"
:align="tableParams.tableOption.align||'center'"
:width="tableParams.tableOption.width||'200'"
fixed="right"
>
<template slot-scope="scope">
<slot
name="auth-button"
:scope="scope.row"
></slot>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="hasPage"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="page.pageSize"
:page-sizes="[10,20,30,40]"
:page-size="page.pageCount"
:total="getListApi ? total : tableTotal"
:layout="layout"
>
</el-pagination>
</div>
</template>
<script>
export default {
name: 'd2-table',
data() {
return {
loading: false,
oldValue: {},
data: [],
// 页码
page: {
pageCount: 10,
pageSize: 1
},
total: 10,
// 排序
sortColum: '',
sort: '',
pagination: {},
// 多选数组
mutiSelectArr: {}
}
},
props: {
// 搜索条件
searchForm: {
type: Object,
default: () => []
},
// 表格数据-外部传入
tableData: {
type: Array,
default: () => []
},
tableTotal: {
type: Number,
default: 10
},
// 获取列表接口
getListApi: {
type: Function,
default: null
},
// 搜索前操作
beforeSearchFn: {
type: Function,
default: () => {
return new Promise((resolve, reject) => {
resolve()
})
}
},
// 分页,默认有
hasPage: {
type: Boolean,
default: true
},
// 分页组件配置
layout: {
type: String,
default: 'sizes,total,->,prev,pager,next,jumper'
},
// 序号,默认有
hasNum: {
type: Boolean,
default: true
},
tableParams: {
type: Object,
default: () => {
return {
// 多选-判断来自哪个页面
// mutiSelectName: {
// type: String,
// default: ''
// },
// 多选-唯一标识
// mutiSelectUniqueKey: {
// type: String,
// default: ''
// },
// 搜索按钮id;new Date().getTime() + parseInt(Math.random() * 1000)
// btnId: {
// type: String,
// default: ''
// },
// 后端返回列表参数名
listName: {
type: String,
default: ''
},
// 标签-默认标签名为tag;若有多个,那么需要在表格栏的列中加“tagName”
// tag: {
// type: Array,
// default: () => []
// },
// 表格操作,默认没有
// tableOption: {
// type: Object,
// default: null
// },
// 表格栏
tableColumns: {
type: Array,
default: () => []
}
}
}
}
},
watch: {
// searchForm: {
// handler(val) {
// const attr = Object.keys(val).find(item => val[item] !== this.oldValue[item])
// if (!val[attr] && this.oldValue[attr]) {
// this.getListApi ? this.refreshEmit() : this.$emit('refreshTable', this.page)
// }
// this.oldValue = _.cloneDeep(val)
// },
// deep: true
// },
// 调用其他接口,导致表格刷新-标识
// '$store.state.d2admin.refreshtable.value'(val) {
// (val === 'fresh') && this.refreshEmit()
// }
},
mounted() {
const btn = document.getElementById(this.tableParams.btnId)
btn && btn.addEventListener('click', this.refreshEmit)
this.getListApi && this.refreshTable()
},
methods: {
// 排序
sortChange({ column, prop, order }) {
this.sortColum = order ? prop : ''
this.sort = order
this.refreshTable()
},
// 多选
handleSelect(val) {
this.mutiSelectArr[this.tableParams.mutiSelectName] = val
},
// 清空多选
clearMutiSelect() {
this.mutiSelectArr[this.tableParams.mutiSelectName] = []
this.$refs[this.tableParams.mutiSelectName + 'MutiTable'].clearSelection()
},
// 发布事件,以期查询条件改变后,页面图表需要刷新
refreshEmit() {
this.$emit('searchChange')
this.refreshTable()
},
refreshTable(clearMuti = true) {
this.beforeSearchFn().then(res => {
console.log(res)
// 清空多选
clearMuti && this.clearMutiSelect()
this.loading = true
var params = {
...this.page,
...this.searchForm
}
if (this.sort) {
params.sortColum = this.sortColum
params.sort = this.sort === 'descending' ? 1 : 0
}
this.getListApi(params).then(res => {
this.pagination = res.pagination ? res.pagination : this.page
this.data = res[this.tableParams.listName]
res.pagination && (this.total = res.pagination.totalCount)
this.loading = false
}).catch(() => {
this.loading = false
})
})
},
// 页码
handleSizeChange(value) {
this.page.pageCount = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
},
handleCurrentChange(value) {
this.page.pageSize = value
this.getListApi ? this.refreshTable(false) : this.$emit('refreshTable', this.page)
}
}
}
</script>
<style>
.a-click {
cursor: pointer;
}
.el-table .cell {
line-height: 14px;
}
.d2-table p {
margin: 10px 0;
}
</style>
import Vue from 'vue'
import d2Container from './d2-container'
import authButton from './d2-auth/d2-auth-btn.js'
// 注意 有些组件使用异步加载会有影响
Vue.component('d2-container', d2Container)
Vue.component('d2-icon', () => import('./d2-icon'))
Vue.component('d2-el-icon', () => import('./d2-el-icon'))
Vue.component('d2-icon-svg', () => import('./d2-icon-svg/index.vue'))
Vue.component('d2-table-header', () => import('./d2-table-header/index.vue'))
Vue.component('d2-table', () => import('./d2-table/index.vue'))
Vue.component([authButton.name], authButton)
/*
* @Author: limin
* @Date: 2019-08-31 12:44:16
* @Last Modified by: limin
* @Last Modified time: 2019-08-31 12:44:16
*/
import Vue from 'vue'
import focus from './src/focus'
Vue.directive(focus.name, focus)
/*
* @Author: limin
* @Date: 2019-08-31 12:44:08
* @Last Modified by: limin
* @Last Modified time: 2019-08-31 12:44:08
*/
export default {
name: 'focus',
inserted: function(el) {
el.querySelector('input').focus()
}
}
/*
* @Author: limin
* @Date: 2019-09-06 10:12:23
* @Last Modified by: limin
* @Last Modified time: 2019-09-06 13:23:25
*/
import Vue from 'vue'
import * as filters from './src'
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
/*
* @Author: limin
* @Date: 2019-09-06 10:11:24
* @Last Modified by: limin
* @Last Modified time: 2019-09-08 19:26:56
*/
const dateFormat = (dateStr, time) => {
// 得到特定的时间
var date = new Date(dateStr)
var year = date.getFullYear()
// ES6语法填充:var month = (date.getMonth()+1).toString().padStart(2, '0');
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hh = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
// return `${year}-${month}-${day}`;
if (time && time.toLowerCase() === 'yyyy-mm-dd') {
return `${year}-${month}-${day}`
} else if (time && time.toLowerCase() === 'hh:mm:ss') {
return `${hh}:${mm}:${ss}`
} else {
return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
}
}
export { dateFormat }
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import util from '@/libs/util'
Vue.use(VueI18n)
function loadLocaleMessages() {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
const messages = {}
locales.keys().forEach(key => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
if (matched && matched.length > 1) {
const locale = matched[1]
messages[locale] = locales(key)
}
})
return messages
}
const messages = loadLocaleMessages()
Vue.prototype.$languages = Object.keys(messages).map(langlage => ({
label: messages[langlage]._name,
value: langlage
}))
export default new VueI18n({
locale: util.cookies.get('lang') || process.env.VUE_APP_I18N_LOCALE,
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE,
messages
})
<template>
<div
class="d2-contentmenu-list"
@click="rowClick">
<div
v-for="item in menulist"
:key="item.value"
:data-value="item.value"
class="d2-contentmenu-item"
flex="cross:center main:center">
<d2-el-icon
v-if="item.icon"
:name="item.icon"/>
<div
class="d2-contentmenu-item-title"
flex-box="1"
v-text="item.title">
</div>
</div>
</div>
</template>
<script>
export default {
name: 'd2-contextmenu-list',
props: {
menulist: {
type: Array,
default: () => []
}
},
methods: {
rowClick(event) {
let target = event.target
while (!target.dataset.value) {
target = target.parentNode
}
this.$emit('rowClick', target.dataset.value)
}
}
}
</script>
<style lang="scss">
.d2-contentmenu-list {
.d2-contentmenu-item {
padding: 8px 20px 8px 15px;
margin: 0;
font-size: 14px;
color: #606266;
cursor: pointer;
&:hover {
background: #ecf5ff;
color: #66b1ff;
}
.d2-contentmenu-item-title {
margin-left: 10px;
}
}
}
</style>
<template>
<div
class="d2-contextmenu"
v-show="flag"
:style="style">
<slot/>
</div>
</template>
<script>
export default {
name: 'd2-contextmenu',
props: {
visible: {
type: Boolean,
default: false
},
x: {
type: Number,
default: 0
},
y: {
type: Number,
default: 0
}
},
computed: {
flag: {
get() {
if (this.visible) {
// 注册全局监听事件 [ 目前只考虑鼠标解除触发 ]
window.addEventListener('mousedown', this.watchContextmenu)
}
return this.visible
},
set(newVal) {
this.$emit('update:visible', newVal)
}
},
style() {
return {
left: this.x + 'px',
top: this.y + 'px',
display: this.visible ? 'block' : 'none '
}
}
},
methods: {
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) this.flag = false
window.removeEventListener('mousedown', this.watchContextmenu)
}
},
mounted() {
// 将菜单放置到body下
document.querySelector('body').appendChild(this.$el)
}
}
</script>
<style>
.d2-contextmenu {
position: absolute;
padding: 5px 0;
z-index: 2019;
background: #FFF;
border: 1px solid #cfd7e5;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
</style>
<template>
<!-- <svg t="1492500959545" @click="click" class="hamburger" :class="{'is-active':isActive}" viewBox="0 0 1024 1024"
version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64">
<path d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z"
p-id="1692"></path>
<path d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z"
p-id="1693"></path>
<path d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z"
p-id="1694"></path>
</svg> -->
<div @click="click" class="hamburger" :class="{'is-active':isActive}">
<d2-el-icon name="s-fold" />
</div>
</template>
<script>
export default {
name: 'hamburger',
props: {
isActive: {
type: Boolean,
default: false
},
onClick: {
type: Function,
default: null
}
},
methods: {
click() {
this.onClick && this.onClick()
}
}
}
</script>
<style scoped lang="scss">
.hamburger {
height: 58px;
cursor: pointer;
transition: .38s;
transform-origin: 50% 50%;
i{
line-height: 58px;
font-size: 28px;
}
}
.hamburger.is-active {
transform: rotate(180deg);
}
</style>
<template>
<el-color-picker
class="btn-text can-hover"
:value="value"
:predefine="predefine"
size="mini"
@change="set"/>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-header-color',
data() {
return {
predefine: [
'#FF0000', '#008000', '#0000FF'
]
}
},
computed: {
...mapState('d2admin', {
value: state => state.color.value,
listTheme: state => state.theme.list
})
},
watch: {
value(value) {
this.set(value)
}
},
mounted() {
this.predefine = [...this.predefine, ...this.listTheme.map(theme => theme.color)]
},
methods: {
...mapActions('d2admin/color', [
'set'
])
}
}
</script>
<template>
<div class="header-datetime"></div>
</template>
<script>
import dayjs from 'dayjs'
const sFormat = 'YYYY年MM月DD日'
const WEEK = ['天', '一', '二', '三', '四', '五', '六']
export default {
name: 'd2-header-datetime',
data() {
return {
timeInterval: null,
time: `${dayjs().format(sFormat)} 星期${WEEK[dayjs().day()]} `
}
}
}
</script>
<style lang="scss">
.header-datetime{
font-size: 12px;
transform: translateX(-10px);
}
</style>
<template>
<el-tooltip
effect="dark"
:content="active ? '退出全屏' : '全屏'"
placement="bottom">
<el-button class="d2-mr btn-text can-hover" type="text" @click="toggle">
<d2-el-icon v-if="active" name="aim"/>
<d2-el-icon v-else name="full-screen" style="font-size: 16px"/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
computed: {
...mapState('d2admin/fullscreen', [
'active'
])
},
methods: {
...mapActions('d2admin/fullscreen', [
'toggle'
])
}
}
</script>
<template>
<el-dropdown
placement="bottom"
size="small"
@command="onChangeLocale">
<el-button class="d2-mr btn-text can-hover" type="text">
<d2-icon name="language" style="font-size: 16px;"/>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(language, index) in $languages"
:key="index"
:command="language.value">
<d2-icon :name="$i18n.locale === language.value ? 'dot-circle-o' : 'circle-o'" class="d2-mr-5"/>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
methods: {
onChangeLocale(command) {
this.$i18n.locale = command
let message = `当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`
if (!['TRAVIS', 'NETLIFY'].includes(process.env.VUE_APP_BUILD_MODE)) {
message = [
`当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`,
'仅提供切换功能,没有配置具体的语言数据 ',
'文档参考:<a class="el-link el-link--primary is-underline" target="_blank" href="https://doc.d2admin.fairyever.com/zh/sys-locales/">《国际化 | D2Admin》</a>'
].join('<br/>')
}
this.$notify({
title: '语言变更',
dangerouslyUseHTMLString: true,
message
})
}
}
}
</script>
<template>
<el-tooltip
effect="dark"
:content="tooltipContent"
placement="bottom">
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="handleClick">
<el-badge
v-if="logLength > 0"
:max="99"
:value="logLengthError"
:is-dot="logLengthError === 0">
<d2-icon
:name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
style="font-size: 20px"/>
</el-badge>
<d2-icon
v-else
name="dot-circle-o"
style="font-size: 20px"/>
</el-button>
</el-tooltip>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
computed: {
...mapGetters('d2admin', {
logLength: 'log/length',
logLengthError: 'log/lengthError'
}),
tooltipContent() {
return this.logLength === 0
? '没有日志或异常'
: `${this.logLength} 条日志${this.logLengthError > 0
? ` | 包含 ${this.logLengthError} 个异常`
: ''}`
}
},
methods: {
...mapMutations('d2admin/log', [
'clean'
]),
handleClick() {
this.$router.push({
name: 'log'
})
}
}
}
</script>
<template>
<el-button class="d2-mr btn-text can-hover" type="text" @click="handleClick">
<d2-el-icon name="search" style="font-size: 18px;"/>
</el-button>
</template>
<script>
export default {
methods: {
handleClick() {
this.$emit('click')
}
}
}
</script>
<template>
<el-dropdown placement="bottom" size="small" @command="handleChange">
<el-button class="d2-mr btn-text can-hover" type="text">
<d2-icon name="font" style="font-size: 16px;"/>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item in options" :key="item.value" :command="item.value">
<d2-icon :name="iconName(item.value)" class="d2-mr-5"/>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
name: 'd2-header-size',
data() {
return {
options: [
{ label: '大', value: 'default' },
{ label: '中', value: 'medium' },
{ label: '小', value: 'small' },
{ label: '最小', value: 'mini' }
]
}
},
computed: {
...mapState('d2admin/size', [
'value'
])
},
methods: {
...mapMutations({
pageKeepAliveClean: 'd2admin/page/keepAliveClean'
}),
...mapActions({
sizeSet: 'd2admin/size/set'
}),
handleChange(value) {
this.sizeSet(value)
// this.$notify({
// title: '提示',
// dangerouslyUseHTMLString: true,
// message: '已更新页面内 <b>组件</b> 的 <b>默认尺寸</b><br/>例如按钮大小,<b>非字号</b>',
// type: 'success'
// })
},
iconName(name) {
return name === this.value ? 'dot-circle-o' : 'circle-o'
}
}
}
</script>
<template>
<el-table
:data="list"
v-bind="table">
<el-table-column
prop="title"
align="center"
width="160"/>
<el-table-column
label="预览"
width="120">
<div
slot-scope="scope"
class="theme-preview"
:style="{
backgroundImage: `url(${$baseUrl}${scope.row.preview})`
}">
</div>
</el-table-column>
<el-table-column
prop="address"
align="center">
<template slot-scope="scope">
<el-button
v-if="activeName === scope.row.name"
type="primary"
icon="el-icon-check"
class="btn-active-success"
round>
已激活
</el-button>
<el-button
v-else
round
@click="handleSelectTheme(scope.row)">
使用
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-theme-list',
data() {
return {
table: {
showHeader: false,
border: true
}
}
},
computed: {
...mapState('d2admin/theme', [
'list',
'activeName'
])
},
methods: {
...mapActions('d2admin/theme', [
'set'
]),
...mapActions('d2admin/color', { setColor: 'set' }),
handleSelectTheme(row) {
const { name, color } = row
this.set(name)
this.setColor(color)
}
}
}
</script>
<style lang="scss" scoped>
.theme-preview {
height: 50px;
width: 100px;
border-radius: 4px;
background-size: cover;
border: 1px solid $color-border-1;
}
</style>
<style lang="scss">
.btn-active-success{
&:hover{
background-color: "#67C23A" !important;
}
}
</style>
<template>
<div>
<el-tooltip
effect="dark"
content="主题"
placement="bottom">
<el-button
class="d2-ml-0 d2-mr btn-text can-hover"
type="text"
@click="dialogVisible = true">
<d2-el-icon
name="magic-stick"
style="font-size: 18px"/>
</el-button>
</el-tooltip>
<el-dialog
title="主题"
width="600px"
:visible.sync="dialogVisible"
:append-to-body="true">
<d2-theme-list style="margin-top: -25px;"/>
</el-dialog>
</div>
</template>
<script>
import themeList from './components/d2-theme-list'
export default {
components: {
'd2-theme-list': themeList
},
data() {
return {
dialogVisible: false
}
}
}
</script>
<template>
<div>
<!-- <el-dropdown size="small" class="d2-mr">
<span class="btn-text">{{info.name ? `你好 ${info.name}` : '未登录'}}</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="logOff">
<d2-icon name="power-off" class="d2-mr-5"/>
注销
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>-->
<div v-popover:popover-personal class="d2-mr personal-wrap">
<span class="btn-text">{{info && info.userName ? `${info.userName}` : '未登录'}} <d2-el-icon name="caret-bottom"/></span>
<el-popover ref="popover-personal" placement="bottom-end" trigger="hover">
<personal-panel :user="info"></personal-panel>
</el-popover>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
import PersonalPanel from '../personal-panel'
export default {
components: {
PersonalPanel
},
mounted() {
this.$event.$on('e-password-dialog', res => (this.passVisible = res))
},
computed: {
...mapState('d2admin/user', ['info'])
}
}
</script>
<style lang="scss" scoped>
.personal-wrap{
transform: translateY(-3px);
}
</style>
// 创建 el-menu-item
export function elMenuItem(createElement, menu) {
return createElement('el-menu-item', { props: { index: menu.path } }, [
...menu.icon ? [
createElement('i', { attrs: { class: `el-icon-${menu.icon}` } })
] : [],
...menu.icon === undefined & !menu.iconSvg ? [
createElement('i', { attrs: { class: 'fa fa-file-o' } })
] : [],
...menu.iconSvg ? [
createElement('d2-icon-svg', { props: { name: menu.iconSvg } })
] : [],
createElement('span', { slot: 'title' }, menu.title || '未命名菜单')
])
}
// 创建 el-submenu
export function elSubmenu(createElement, menu) {
return createElement('el-submenu', { props: { index: menu.path } }, [
...menu.icon ? [
createElement('i', { slot: 'title', attrs: { class: `el-icon-${menu.icon}` } })
] : [],
...menu.icon === undefined & !menu.iconSvg ? [
createElement('i', { slot: 'title', attrs: { class: 'fa fa-file-o' } })
] : [],
...menu.iconSvg ? [
createElement('d2-icon-svg', { slot: 'title', props: { name: menu.iconSvg } })
] : [],
createElement('span', { slot: 'title' }, menu.title || '未命名菜单'),
...menu.children.map((child, childIndex) => (child.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, child))
])
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
export default {
name: 'd2-layout-header-aside-menu-header',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', {
attrs: { flex: 'cross:center' },
class: { 'd2-theme-header-menu': true, 'is-scrollable': this.isScroll },
ref: 'page'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__content', flex: '', 'flex-box': '1' },
ref: 'content'
}, [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__scroll', 'flex-box': '0' },
style: { transform: `translateX(${this.currentTranslateX}px)` },
ref: 'scroll'
}, [
createElement('el-menu', {
props: { mode: 'horizontal', defaultActive: this.active },
on: { select: this.handleMenuSelect }
}, this.header.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu)))
])
]),
...this.isScroll ? [
createElement('div', {
attrs: { class: 'd2-theme-header-menu__prev', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('left') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-left' } })
]),
createElement('div', {
attrs: { class: 'd2-theme-header-menu__next', flex: 'main:center cross:center', 'flex-box': '0' },
on: { click: () => this.scroll('right') }
}, [
createElement('i', { attrs: { class: 'el-icon-arrow-right' } })
])
] : []
])
},
computed: {
...mapState('d2admin/menu', [
'header'
])
},
data() {
return {
active: '',
isScroll: false,
scrollWidth: 0,
contentWidth: 0,
currentTranslateX: 0,
throttledCheckScroll: null
}
},
watch: {
'$route.matched': {
handler(val) {
this.active = val[val.length - 1].path
},
immediate: true
}
},
methods: {
scroll(direction) {
if (direction === 'left') {
// 向右滚动
this.currentTranslateX = 0
} else {
// 向左滚动
if (this.contentWidth * 2 - this.currentTranslateX <= this.scrollWidth) {
this.currentTranslateX -= this.contentWidth
} else {
this.currentTranslateX = this.contentWidth - this.scrollWidth
}
}
},
checkScroll() {
let contentWidth = this.$refs.content.clientWidth
let scrollWidth = this.$refs.scroll.clientWidth
if (this.isScroll) {
// 页面依旧允许滚动的情况,需要更新width
if (this.contentWidth - this.scrollWidth === this.currentTranslateX) {
// currentTranslateX 也需要相应变化【在右端到头的情况时】
this.currentTranslateX = contentWidth - scrollWidth
// 快速的滑动依旧存在判断和计算时对应的contentWidth变成正数,所以需要限制一下
if (this.currentTranslateX > 0) {
this.currentTranslateX = 0
}
}
// 更新元素数据
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
// 判断何时滚动消失: 当scroll > content
if (contentWidth > scrollWidth) {
this.isScroll = false
}
}
// 判断何时滚动出现: 当scroll < content
if (!this.isScroll && contentWidth < scrollWidth) {
this.isScroll = true
// 注意,当isScroll变为true,对应的元素盒子大小会发生变化
this.$nextTick(() => {
contentWidth = this.$refs.content.clientWidth
scrollWidth = this.$refs.scroll.clientWidth
this.contentWidth = contentWidth
this.scrollWidth = scrollWidth
this.currentTranslateX = 0
})
}
}
},
mounted() {
// 初始化判断
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
window.addEventListener('load', this.checkScroll)
// 全局窗口变化监听,判断父元素和子元素的大小,从而控制isScroll的开关
this.throttledCheckScroll = _.throttle(this.checkScroll, 300)
window.addEventListener('resize', this.throttledCheckScroll)
},
beforeDestroy() {
// 取消监听
window.removeEventListener('resize', this.throttledCheckScroll)
window.removeEventListener('load', this.checkScroll)
}
}
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
import BScroll from 'better-scroll'
export default {
name: 'd2-layout-header-aside-menu-side',
mixins: [
menuMixin
],
render(createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' } }, [
createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu',
on: { select: this.handleMenuSelect }
}, this.aside.map(menu => (menu.children === undefined ? elMenuItem : elSubmenu).call(this, createElement, menu))),
...this.aside.length === 0 && !this.asideCollapse ? [
createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [
createElement('d2-icon', { props: { name: 'inbox' } }),
createElement('span', {}, '没有侧栏菜单')
])
] : []
])
},
data() {
return {
active: '',
asideHeight: 300,
BS: null
}
},
computed: {
...mapState('d2admin/menu', [
'aside',
'asideCollapse'
])
},
watch: {
// 折叠和展开菜单的时候销毁 better scroll
asideCollapse(val) {
this.scrollDestroy()
setTimeout(() => {
this.scrollInit()
}, 500)
},
// 监听路由 控制侧边栏激活状态
'$route.fullPath': {
handler(value) {
this.active = value
},
immediate: true
}
},
mounted() {
this.scrollInit()
},
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit() {
this.BS = new BScroll(this.$el, {
mouseWheel: true,
click: true
// 如果你愿意可以打开显示滚动条
// scrollbar: {
// fade: true,
// interactive: false
// }
})
},
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
} catch (e) {
delete this.BS
this.BS = null
}
}
}
}
import util from '@/libs/util.js'
export default {
methods: {
handleMenuSelect(index, indexPath) {
if (/^d2-menu-empty-\d+$/.test(index) || index === undefined) {
this.$message.warning('临时菜单')
} else if (/^https:\/\/|http:\/\//.test(index)) {
util.open(index)
} else {
this.$router.push({
path: index
})
}
}
}
}
<template>
<div class="d2-panel-search-item" :class="hoverMode ? 'can-hover' : ''" flex>
<div class="d2-panel-search-item__icon" flex-box="0">
<div class="d2-panel-search-item__icon-box" flex="main:center cross:center">
<d2-el-icon v-if="item.icon" :name="item.icon"/>
<!-- <d2-icon-svg v-else-if="item.iconSvg" :name="item.iconSvg"/>
<d2-icon v-else name="file-o"/> -->
</div>
</div>
<div class="d2-panel-search-item__info" flex-box="1" flex="dir:top">
<div class="d2-panel-search-item__info-title" flex-box="1" flex="cross:center">
<span></span>
</div>
<div class="d2-panel-search-item__info-fullTitle" flex-box="0">
<span></span>
</div>
<div class="d2-panel-search-item__info-path" flex-box="0">
<span></span>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
item: {
default: () => ({})
},
hoverMode: {
default: false
}
}
}
</script>
<style lang="scss" scoped>
.d2-panel-search-item {
height: 64px;
margin: 0px -20px;
&.can-hover {
@extend %unable-select;
margin: 0px;
&:hover {
background-color: #F5F7FA;
.d2-panel-search-item__icon {
.d2-panel-search-item__icon-box {
i {
font-size: 24px;
color: $color-primary;
}
}
}
.d2-panel-search-item__info {
.d2-panel-search-item__info-title {
color: $color-text-main;
}
.d2-panel-search-item__info-fullTitle {
color: $color-text-normal;
}
.d2-panel-search-item__info-path {
color: $color-text-normal;
}
}
}
}
.d2-panel-search-item__icon {
width: 64px;
.d2-panel-search-item__icon-box {
height: 64px;
width: 64px;
border-right: 1px solid $color-border-3;
i {
font-size: 20px;
color: $color-text-sub;
}
svg {
height: 20px;
width: 20px;
}
}
}
.d2-panel-search-item__info {
margin-left: 10px;
.d2-panel-search-item__info-title {
font-size: 16px;
line-height: 16px;
font-weight: bold;
color: $color-text-normal;
}
.d2-panel-search-item__info-fullTitle {
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
.d2-panel-search-item__info-path {
margin-bottom: 4px;
font-size: 10px;
line-height: 14px;
color: $color-text-placehoder;
}
}
}
</style>
<template>
<div
class="panel-search"
flex="dir:top">
<div
class="panel-search__input-group"
flex-box="0"
flex="dir:top main:center cross:center"
@click.self="handlePanelClick">
<!-- <d2-icon-svg
class="panel-search__logo"
name="d2-admin-text"/> -->
<img src="./image/logo.png" alt="">
<el-autocomplete
class="panel-search__input"
ref="input"
v-model="searchText"
suffix-icon="el-icon-search"
placeholder="搜索页面"
:fetch-suggestions="querySearch"
:trigger-on-focus="false"
:clearable="true"
@keydown.esc.native="handleEsc"
@select="handleSelect">
<d2-panel-search-item
slot-scope="{ item }"
:item="item"/>
</el-autocomplete>
<div class="panel-search__tip">
您可以使用快捷键
<span class="panel-search__key"></span>
唤醒搜索面板,按
<span class="panel-search__key"></span>
关闭
</div>
</div>
<div
v-if="resultsList.length > 0"
class="panel-search__results-group"
flex-box="1">
<el-card>
<div class="panel-search__results-group-inner">
<d2-panel-search-item
v-for="(item, index) in resultsList"
:key="index"
:item="item"
:hover-mode="true"
@click.native="handleResultsGroupItemClick(item.path)"/>
</div>
</el-card>
</div>
</div>
</template>
<script>
import Fuse from 'fuse.js'
import { mapState } from 'vuex'
import mixin from '../mixin/menu'
export default {
mixins: [
mixin
],
components: {
'd2-panel-search-item': () => import('./components/panel-search-item/index.vue')
},
data() {
return {
searchText: '',
results: []
}
},
computed: {
...mapState('d2admin/search', [
'hotkey',
'pool'
]),
// 这份数据是展示在搜索面板下面的
resultsList() {
return (this.results.length === 0 && this.searchText === '') ? this.pool.map(e => ({
value: e.fullTitle,
...e
})) : this.results
}
},
methods: {
/**
* @description 过滤选项 这个方法在每次输入框的值发生变化时会触发
*/
querySearch(queryString, callback) {
var pool = this.pool
const results = this.query(queryString ? pool : [], queryString)
this.results = results
callback(results)
},
/**
* @description 指定的数据源中根据指定的查询字符串过滤数据
* @param {Object} pool 需要过滤的数据
* @param {String} queryString 查询字符串
*/
query(pool, queryString) {
return new Fuse(pool, {
shouldSort: true,
tokenize: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [
'fullTitle',
'path'
]
})
.search(queryString)
.map(e => ({
value: e.fullTitle,
...e
}))
},
/**
* @description 聚焦输入框
*/
focus() {
this.input = ''
setTimeout(() => {
if (this.$refs.input) {
this.$refs.input.focus()
}
// 还原
this.searchText = ''
this.results = []
}, 500)
},
/**
* @description 接收用户在列表中选择项目的事件
*/
handleResultsGroupItemClick(path) {
// 如果用户选择的就是当前页面 就直接关闭搜索面板
if (path === this.$route.path) {
this.handleEsc()
return
}
// 用户选择的是其它页面
this.handleMenuSelect(path)
},
/**
* @description 接收用户在下拉菜单中选中事件
*/
handleSelect({ path }) {
// 如果用户选择的就是当前页面 就直接关闭搜索面板
if (path === this.$route.path) {
this.handleEsc()
return
}
// 用户选择的是其它页面
this.$nextTick(() => {
this.handleMenuSelect(path)
})
},
/**
* @augments 关闭输入框的下拉菜单
*/
closeSuggestion() {
if (this.$refs.input.activated) {
this.$refs.input.suggestions = []
this.$refs.input.activated = false
}
},
/**
* @augments 接收用户点击空白区域的关闭
*/
handlePanelClick() {
this.handleEsc()
},
/**
* @augments 接收用户触发的关闭
*/
handleEsc() {
this.closeSuggestion()
this.$nextTick(() => {
this.$emit('close')
})
}
}
}
</script>
<style lang="scss" scoped>
.panel-search {
margin: 20px;
width: 100%;
.panel-search__input-group {
height: 240px;
.panel-search__logo {
width: 80px;
height: 80px;
margin-bottom: 20px;
}
.panel-search__input {
width: 500px;
}
.panel-search__tip {
@extend %unable-select;
margin-top: 20px;
margin-bottom: 40px;
font-size: 12px;
color: $color-text-sub;
.panel-search__key {
padding: 1px 5px;
margin: 0px 2px;
border-radius: 2px;
background-color: $color-text-normal;
color: $color-bg;
}
}
}
.panel-search__results-group {
overflow: auto;
margin-bottom: -20px;
.panel-search__results-group-inner {
margin: -20px;
}
}
}
</style>
<template>
<div class="personal">
<div class="personal-panel">
<div
class="personal-desc"
v-if="user"
>
<div class="avatar-container">
<el-avatar
:size="'large'"
:src="'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'"
></el-avatar>
</div>
<div class="name-role">
<span class="sender"> - </span>
</div>
<div class="registe-info">
<span class="registe-info">
<d2-el-icon name="time" />
有效期:<span v-text="user.validTime || '未知' "></span>
</span>
</div>
</div>
<!-- <div class="personal-relation">
<span class="relation-item">followers</span>
<span class="relation-item">watches</span>
<span class="relation-item">friends</span>
</div>-->
<div class="main-operation">
<span class="main-operation-item">
<el-button
size="small"
icon="el-icon-user"
@click="personalVisible = true"
> 个人信息</el-button>
</span>
<span class="main-operation-item">
<el-button
size="small"
icon="el-icon-key"
@click="passwordVisible = true"
> 修改密码</el-button>
</span>
</div>
<div
class="other-operation"
@click="clear"
>
<div class="other-operation-item">
<d2-el-icon name="delete" />
清空本地缓存
</div>
</div>
<div
class="personal-footer"
@click="logOut"
>
<el-button type="text">
<d2-el-icon name="switch-button" /> 退出
</el-button>
</div>
</div>
<personal-dialog
:visible="personalVisible"
:user="info"
/>
<password-dialog
:visible="passwordVisible"
:user="info"
/>
</div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
import { Message, MessageBox } from 'element-ui'
export default {
name: 'PersonalPanel',
props: {
user: Object
},
computed: {
...mapState('d2admin/user', ['info'])
},
data() {
return {
personalVisible: false,
passwordVisible: false
}
},
mounted() {
this.$event.$on('e-ps-close', is2Login => {
this.passwordVisible = false
if (!is2Login) return
this.$message('修改密码成功,2秒后退回登录页')
setTimeout(async() => {
await this.logout()
this.$router.push('/login')
}, 2000)
})
this.$event.$on('e-pd-close', () => (this.personalVisible = false))
},
components: {
personalDialog: () => import('./personalDialog'),
passwordDialog: () => import('./passwordDialog')
},
methods: {
...mapActions('d2admin/account', ['logout']),
/**
* @description 登出
*/
async logOut() {
await this.logout()
await this.$StoreReset.call(this.$store) // 重置 store
this.$router.push('/login')
},
clear() {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(
'清空本地缓存将重置所有个性化设置并退出到登录界面',
'清空本地缓存',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
.then(() => {
const reload = async() => {
localStorage.clear()
await this.logout()
this.$store.commit('d2admin/gray/set', false)
window.location.reload()
}
if (this.$router.currentRoute.name === 'index') {
reload()
} else {
this.$router.push({ name: 'index' })
var _t = setInterval(() => {
if (this.$router.currentRoute.name === 'index') {
clearInterval(_t)
reload()
}
}, 0)
}
})
.catch(() => {
this.$store.commit('d2admin/gray/set', false)
// Message({
// message: '取消清除缓存操作'
// })
})
},
comfirm(text, title, cancleText) {
// eslint-disable-next-line promise/param-names
return new Promise((resolve, reject) => {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(text, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async() => {
await this.$store.commit('d2admin/gray/set', false)
resolve(true)
})
.catch(() => {
this.$store.commit('d2admin/gray/set', false)
Message({
message: cancleText
})
reject(new Error('错误'))
})
})
}
}
}
</script>
<style lang="scss" scoped>
.personal-panel {
font-size: 13px;
width: 220px;
text-align: center;
border-color: rgba(180, 190, 190, 0.2);
border-width: 1px;
border-style: solid;
background: rgba(182, 172, 172, 0.1);
margin: -14px;
}
.personal-desc {
/* padding: 15px;
color: #fff; */
padding: 24px 0;
}
.avatar {
width: 80px;
height: 80px;
border-radius: 90px;
}
.avatar-container {
display: inline-block;
text-align: center;
}
.name-role {
font-size: 12px;
padding: 5px;
}
.personal-relation {
font-size: 16px;
padding: 12px;
margin-right: 1px;
background: rgba(200, 209, 204, 0.3);
}
.relation-item {
padding: 12px;
}
.relation-item:hover {
cursor: pointer;
color: rgb(19, 138, 156);
}
.main-operation {
padding: 2px 0;
/* background: rgba(175, 182, 179, 0.3); */
border-color: rgba(201, 206, 206, 0.2);
border-top-width: 1px;
border-top-style: solid;
display: flex;
justify-content: space-between;
}
.main-operation-item {
margin: 4px;
}
.other-operation {
padding: 0;
margin-right: 1px;
text-align: left;
border-color: rgba(180, 190, 190, 0.2);
border-top-width: 1px;
border-top-style: solid;
&-item {
padding: 8px 16px;
}
&:hover {
cursor: pointer;
color: rgb(19, 138, 156);
background: #b1a6a61e;
}
}
.personal-footer {
margin-right: 1px;
font-size: 14px;
text-align: center;
padding: 2px 0;
border-color: rgba(180, 190, 190, 0.2);
border-top-width: 1px;
border-top-style: solid;
&:hover {
cursor: pointer;
color: rgb(19, 138, 156);
background: #b1a6a61e;
}
}
</style>
<!-- 详情弹框 -->
<template>
<div class="password-detail">
<el-dialog
title="修改密码"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form label-width="120px" v-if="info" :model="info" :rules="rules" ref="passwordForm">
<el-form-item label="用户名:" prop="userName">
<el-input disabled="disabled" v-model="info.userName"></el-input>
</el-form-item>
<el-form-item label="原密码:" prop="oldPassword">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.oldPassword" />
</el-form-item>
<el-form-item label="新密码:" prop="newPassword">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.newPassword" />
</el-form-item>
<el-form-item label="确认密码:" prop="confirm">
<el-input type="password" maxlength="12" :show-password="true" v-model="info.confirm" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit">保 存</el-button>
<el-button @click="handleClose">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { ModifyPassword } from '@api/sys.account'
export default {
name: 'PasswordDialog',
components: {},
data() {
return {
rules: Object.freeze({
oldPassword: [
{ required: true, message: '请输入旧密码', trigger: ['blur'] }
],
newPassword: [
{ required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请输入新密码'))
} else {
if (this.info.confirm) {
this.$refs.passwordForm.validateField('confirm')
}
callback()
}
},
trigger: 'blur'
}
],
confirm: [
{ required: true,
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请再次输入新密码'))
} else if (value !== this.info.newPassword) {
callback(new Error('两次新密码不一致!'))
} else {
callback()
}
},
trigger: 'blur'
}
]
})
}
},
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
computed: {
info() {
return this.user
}
},
methods: {
// 修改密码
submit() {
this.$refs.passwordForm.validate(async valid => {
if (valid) {
const { userId, oldPassword, newPassword } = this.info
const result = await ModifyPassword({ userId, oldPassword, newPassword })
const { operateStatus } = result
if (operateStatus) {
this.emit(true)
return
}
this.$message.error('修改密码失败')
}
})
},
handleClose() {
this.emit(false)
},
emit(is2Login) {
this.$event.$emit('e-ps-close', is2Login)
this.$refs.passwordForm.validateField()
}
}
}
</script>
<!-- 详情弹框 -->
<template>
<div class="personal-detail">
<el-dialog
title="个人信息"
:visible.sync="visible"
:before-close="handleClose"
:append-to-body="true"
:close-on-click-modal="false"
width="600px"
>
<el-form v-if="user" label-width="120px" :model="user">
<el-form-item label="用户名:" prop="loginName">
<el-input disabled v-model="user.loginName"></el-input>
</el-form-item>
<el-form-item label="姓名:" prop="userName">
<el-input disabled v-model="user.userName"></el-input>
</el-form-item>
<el-form-item label="联系方式:" prop="mobile">
<el-input disabled v-model="user.mobile"></el-input>
</el-form-item>
<el-form-item label="所属公司:" prop="companyName">
<el-input disabled v-model="user.companyName"></el-input>
</el-form-item>
<el-form-item label="部门:" prop="departName">
<el-input disabled v-model="user.departName"></el-input>
</el-form-item>
<el-form-item label="职务:" prop="postName">
<el-input disabled v-model="user.postName"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="personDialogVisible = false">确 定</el-button> -->
<el-button @click="handleClose">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import { ctMethods, request } from '@/api'
export default {
name: 'personalDialog',
props: {
visible: {
type: Boolean,
default: false
},
user: Object
},
methods: {
handleClose() {
this.$event.$emit('e-pd-close')
}
}
}
</script>
<template>
<div class="d2-multiple-page-control-group" flex>
<div class="d2-multiple-page-control-content" flex-box="1">
<div class="d2-multiple-page-control-content-inner">
<d2-contextmenu
:visible.sync="contextmenuFlag"
:x="contentmenuX"
:y="contentmenuY">
<d2-contextmenu-list
:menulist="tagName === '/index' ? contextmenuListIndex : contextmenuList"
@rowClick="contextmenuClick"/>
</d2-contextmenu>
<el-tabs
class="d2-multiple-page-control"
:value="current"
type="card"
:closable="true"
@tab-click="handleClick"
@edit="handleTabsEdit"
@contextmenu.native="handleContextmenu">
<el-tab-pane
v-for="page in opened"
:key="page.fullPath"
:name="page.fullPath">
<span slot="label"><d2-el-icon :name="page.meta.icon"/> <span v-text="(page.meta && page.meta.title) || '未命名'"></span></span>
</el-tab-pane>
</el-tabs>
</div>
</div>
<div
class="d2-multiple-page-control-btn"
flex-box="0">
<el-button-group>
<el-button icon="el-icon-error" @click="closeAll"></el-button>
<el-tooltip class="item" effect="dark" :content="cacheTip" placement="bottom">
<el-button :icon="kaIcon" @click="handleCache"></el-button>
</el-tooltip>
<el-button icon="el-icon-refresh" @click="reload" :disabled="current==='/index'"></el-button>
</el-button-group>
</div>
</div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
const CMD_MAP = {
'left': 'closeLeft',
'right': 'closeRight',
'other': 'closeOther',
'all': 'closeAll',
'reload': 'reload'
}
export default {
components: {
D2Contextmenu: () => import('../contextmenu'),
D2ContextmenuList: () => import('../contextmenu/components/contentmenuList')
},
data() {
return {
contextmenuFlag: false,
contentmenuX: 0,
contentmenuY: 0,
contextmenuListIndex: [
{ icon: 'error', title: '关闭全部', value: 'all' }
],
contextmenuList: [
{ icon: 'back', title: '关闭左侧', value: 'left' },
{ icon: 'right', title: '关闭右侧', value: 'right' },
{ icon: 'circle-close', title: '关闭其它', value: 'other' },
{ icon: 'error', title: '关闭全部', value: 'all' }
],
tagName: '/index'
}
},
computed: {
...mapState('d2admin/page', [
'opened',
'current',
'keepAlive'
]),
isCached() {
const _curPage = this.opened.find(page => page.fullPath === this.current)
const _cache = _curPage && _curPage.meta.cache
return _cache
},
cacheTip() {
return this.isCached ? '已缓存当前页面数据' : '不缓存当前页面数据'
},
kaIcon() {
return this.isCached ? 'el-icon-star-on' : 'el-icon-star-off'
}
},
mounted() {
this.$event.$on('e-reload', this.reload)
},
methods: {
...mapActions('d2admin/page', [
'close',
'closeLeft',
'closeRight',
'closeOther',
'closeAll',
'keepAliveRemove',
'keepAlivePush'
]),
/**
* @description 右键菜单功能点击
*/
handleContextmenu(event) {
let target = event.target
let flag = false
if (target.className.indexOf('el-tabs__item') > -1) flag = true
else if (target.parentNode.className.indexOf('el-tabs__item') > -1) {
target = target.parentNode
flag = true
}
if (flag) {
event.preventDefault()
event.stopPropagation()
this.contentmenuX = event.clientX
this.contentmenuY = event.clientY
this.tagName = target.getAttribute('aria-controls').slice(5)
this.contextmenuFlag = true
}
},
/**
* @description 右键菜单的row-click事件
*/
contextmenuClick(command) {
this.handleControlItemClick(command, this.tagName)
},
/**
* @description 接收点击关闭控制上选项的事件
*/
handleControlItemClick(command, tagName = null) {
if (tagName) {
this.contextmenuFlag = false
}
const params = {
pageSelect: tagName
}
this[CMD_MAP[command]](params)
},
/**
* @description 接收点击 tab 标签的事件
*/
handleClick(tab, event) {
// 找到点击的页面在 tag 列表里是哪个
const page = this.opened.find(page => page.fullPath === tab.name)
const { name, params, query } = page
if (page) {
this.$router.push({ name, params, query })
}
},
handleCache() {
this[this.isCached ? 'keepAliveRemove' : 'keepAlivePush'](this.$router.currentRoute.name)
},
async reload() {
if (this.isCached) {
const name = this.$router.currentRoute.name
await this.keepAliveRemove(name)
var __timer = setInterval(() => {
if (this.$router.currentRoute.name === name) {
clearInterval(__timer)
this.keepAlivePush(name)
}
}, 10)
}
this.$router.replace('/refresh')
},
/**
* @description 点击 tab 上的删除按钮触发这里 首页的删除按钮已经隐藏 因此这里不用判断是 index
*/
handleTabsEdit(tagName, action) {
if (action === 'remove') {
this.close({
tagName
})
}
}
}
}
</script>
import layout from './layout'
export default layout
<template>
<div
class="d2-layout-header-aside-group"
:style="styleLayoutMainGroup"
:class="{grayMode: grayActive}">
<!-- 半透明遮罩 -->
<div class="d2-layout-header-aside-mask"></div>
<!-- 主体内容 -->
<div class="d2-layout-header-aside-content" flex="dir:top">
<!-- 顶栏 -->
<div
class="d2-theme-header"
:style="{
opacity: this.searchActive ? 0.5 : 1
}"
flex-box="0"
flex>
<div class="logo-group d2-theme-header-logo" :class="asideCollapse ? 'logo-only' : 'logo-all'" flex-box="0">
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/logo/icon-only.png`">
<img v-else :src="`${$baseUrl}image/theme/logo/all.png`">
</div>
<hamburger :onClick="handleToggleAside" :isActive="asideCollapse" flex-box="0" class="toggle-aside-btn"></hamburger>
<d2-menu-header flex-box="1"/>
<!-- 顶栏右侧 -->
<div class="d2-header-right" flex-box="0">
<d2-header-datetime />
<!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$env === 'development'" -->
<d2-header-search @click="handleSearchClick"/>
<!-- <d2-header-log v-if="$env === 'development'"/> -->
<!-- <d2-header-size/> -->
<d2-header-fullscreen/>
<!-- <d2-header-locales v-if="$env === 'development'"/> -->
<d2-header-theme/>
<d2-header-color/>
<d2-header-user/>
</div>
</div>
<!-- 下面 主体 -->
<div class="d2-theme-container" flex-box="1" flex>
<!-- 主体 侧边栏 -->
<div
flex-box="0"
ref="aside"
class="d2-theme-container-aside"
:style="{
width: asideCollapse ? asideWidthCollapse : asideWidth,
opacity: this.searchActive ? 0.5 : 1
}">
<d2-menu-side/>
</div>
<!-- 主体 -->
<div class="d2-theme-container-main" :class="this.searchActive ? 'is-search' : ''" flex-box="1" flex>
<!-- 搜索 -->
<transition name="fade-scale">
<div v-if="searchActive" class="d2-theme-container-main-layer" flex>
<d2-panel-search
ref="panelSearch"
@close="searchPanelClose"/>
</div>
</transition>
<!-- 内容 -->
<transition name="fade-scale">
<div v-if="!searchActive" class="d2-theme-container-main-layer" flex="dir:top">
<!-- tab -->
<div class="d2-theme-container-main-header" flex-box="0">
<d2-tabs/>
</div>
<!-- 页面 -->
<div class="d2-theme-container-main-body" flex-box="1">
<transition :name="transitionActive ? 'el-fade-in' : ''" mode="linear">
<keep-alive :include="keepAlive">
<router-view/>
</keep-alive>
</transition>
</div>
</div>
</transition>
</div>
</div>
</div>
</div>
</template>
<script>
import d2MenuSide from './components/menu-side'
import d2MenuHeader from './components/menu-header'
import d2Tabs from './components/tabs'
import d2HeaderFullscreen from './components/header-fullscreen'
// import d2HeaderLocales from './components/header-locales'
import d2HeaderSearch from './components/header-search'
// import d2HeaderSize from './components/header-size'
import d2HeaderTheme from './components/header-theme'
import d2HeaderUser from './components/header-user'
// import d2HeaderLog from './components/header-log'
import d2HeaderColor from './components/header-color'
import hamburger from './components/hamburger'
import d2HeaderDatetime from './components/header-datetime'
import { mapState, mapGetters, mapActions } from 'vuex'
import mixinSearch from './mixins/search'
export default {
name: 'd2-layout-header-aside',
mixins: [
mixinSearch
],
components: {
d2MenuSide,
d2MenuHeader,
d2Tabs,
d2HeaderFullscreen,
// d2HeaderLocales,
d2HeaderSearch,
// d2HeaderSize,
d2HeaderTheme,
d2HeaderUser,
// d2HeaderLog,
d2HeaderColor,
hamburger,
d2HeaderDatetime
},
data() {
return {
// [侧边栏宽度] 正常状态
asideWidth: '200px',
// [侧边栏宽度] 折叠状态
asideWidthCollapse: '65px'
}
},
mounted() {
},
computed: {
...mapState('d2admin', {
keepAlive: state => state.page.keepAlive,
grayActive: state => state.gray.active,
transitionActive: state => state.transition.active,
asideCollapse: state => state.menu.asideCollapse
}),
...mapGetters('d2admin', {
themeActiveSetting: 'theme/activeSetting'
}),
/**
* @description 最外层容器的背景图片样式
*/
styleLayoutMainGroup() {
return {
...this.themeActiveSetting.backgroundImage ? {
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`
} : {}
}
}
},
methods: {
...mapActions('d2admin/menu', [
'asideCollapseToggle'
]),
/**
* 接收点击切换侧边栏的按钮
*/
handleToggleAside() {
this.asideCollapseToggle()
}
}
}
</script>
<style lang="scss">
// 注册主题
@import '~@/assets/style/theme/register.scss';
@keyframes lightflow {
90% {
left: -300px; /*起始位置*/
}
100% {
left: 300px; /*结束位置*/
}
}
.logo-all{
width: 200px;
img{
height: 75px !important;
transform: translate3d(-8px, -6px, 0) !important;
}
}
.logo-only{
width:65px;
img{
height: 35px !important;
transform: translate3d(0px,12px,0) !important;
}
}
</style>
import { mapState, mapMutations } from 'vuex'
import hotkeys from 'hotkeys-js'
export default {
components: {
'd2-panel-search': () => import('../components/panel-search')
},
mounted() {
// 绑定搜索功能快捷键 [ 打开 ]
hotkeys(this.searchHotkey.open, event => {
event.preventDefault()
this.searchPanelOpen()
})
// 绑定搜索功能快捷键 [ 关闭 ]
hotkeys(this.searchHotkey.close, event => {
event.preventDefault()
this.searchPanelClose()
})
},
beforeDestroy() {
hotkeys.unbind(this.searchHotkey.open)
hotkeys.unbind(this.searchHotkey.close)
},
computed: {
...mapState('d2admin', {
searchActive: state => state.search.active,
searchHotkey: state => state.search.hotkey
})
},
methods: {
...mapMutations({
searchToggle: 'd2admin/search/toggle',
searchSet: 'd2admin/search/set'
}),
/**
* 接收点击搜索按钮
*/
handleSearchClick() {
this.searchToggle()
if (this.searchActive) {
setTimeout(() => {
if (this.$refs.panelSearch) {
this.$refs.panelSearch.focus()
}
}, 500)
}
},
searchPanelOpen() {
if (!this.searchActive) {
this.searchSet(true)
setTimeout(() => {
if (this.$refs.panelSearch) {
this.$refs.panelSearch.focus()
}
}, 500)
}
},
// 关闭搜索面板
searchPanelClose() {
if (this.searchActive) {
this.searchSet(false)
}
}
}
}
import Cookies from 'js-cookie'
const cookies = {}
const COOKIE_NAME_PREFIX = `${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}-`
/**
* @description 存储 cookie 值
* @param {String} name cookie name
* @param {String} value cookie value
* @param {Object} setting cookie setting
*/
cookies.set = function(name = 'default', value = '', cookieSetting = {}) {
let currentCookieSetting = {
expires: 1
}
Object.assign(currentCookieSetting, cookieSetting)
Cookies.set(`${COOKIE_NAME_PREFIX}${name}`, value, currentCookieSetting)
}
/**
* @description 拿到 cookie 值
* @param {String} name cookie name
*/
cookies.get = function(name = 'default') {
return Cookies.get(`${COOKIE_NAME_PREFIX}${name}`)
}
/**
* @description 拿到 cookie 全部的值
*/
cookies.getAll = function() {
return Cookies.get()
}
/**
* @description 删除 cookie
* @param {String} name cookie name
*/
cookies.remove = function(name = 'default') {
return Cookies.remove(`${COOKIE_NAME_PREFIX}${name}`)
}
export default cookies
import low from 'lowdb'
import LocalStorage from 'lowdb/adapters/LocalStorage'
import util from '@/libs/util'
const isDev = process.env.NODE_ENV === 'development'
const adapter = new LocalStorage(`${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}`, {
serialize: (data) => isDev ? JSON.stringify(data) : escape(JSON.stringify(data)),
deserialize: (data) => isDev ? JSON.parse(data) : JSON.parse(unescape(data))
})
const db = low(adapter)
db
.defaults({
sys: {},
database: {}
})
.write()
export default db
/**
* @description 检查路径是否存在 不存在的话初始化
* @param {Object} payload dbName {String} 数据库名称
* @param {Object} payload path {String} 路径
* @param {Object} payload user {Boolean} 区分用户
* @param {Object} payload validator {Function} 数据校验钩子 返回 true 表示验证通过
* @param {Object} payload defaultValue {*} 初始化默认值
* @returns {String} 可以直接使用的路径
*/
export function pathInit({
dbName = 'database',
path = '',
user = true,
validator = () => true,
defaultValue = ''
}) {
const uuid = util.cookies.get('uuid') || 'ghost-uuid'
const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`
const value = db.get(currentPath).value()
if (!(value !== undefined && validator(value))) {
db
.set(currentPath, defaultValue)
.write()
}
return currentPath
}
/**
* @description 将数据存储到指定位置 | 路径不存在会自动初始化
* @description 效果类似于取值 dbName.path = value
* @param {Object} payload dbName {String} 数据库名称
* @param {Object} payload path {String} 存储路径
* @param {Object} payload value {*} 需要存储的值
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function dbSet({
dbName = 'database',
path = '',
value = '',
user = false
}) {
db.set(pathInit({
dbName,
path,
user
}), value).write()
}
/**
* @description 获取数据
* @description 效果类似于取值 dbName.path || defaultValue
* @param {Object} payload dbName {String} 数据库名称
* @param {Object} payload path {String} 存储路径
* @param {Object} payload defaultValue {*} 取值失败的默认值
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function dbGet({
dbName = 'database',
path = '',
defaultValue = '',
user = false
}) {
return new Promise(resolve => {
resolve(_.cloneDeep(db.get(pathInit({
dbName,
path,
user,
defaultValue
})).value()))
})
}
/**
* @description 获取存储数据库对象
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function database({
dbName = 'database',
path = '',
user = false,
validator = () => true,
defaultValue = ''
} = {}) {
return new Promise(resolve => {
resolve(db.get(pathInit({
dbName, path, user, validator, defaultValue
})))
})
}
module.exports = file => require('@/views/' + file).default
module.exports = file => () => import('@/views/' + file)
import cookies from './util.cookies'
import db from './util.db'
import log from './util.log'
import permision from './util.permision'
const util = {
cookies,
db,
log,
permision
}
/**
* @description 更新标题
* @param {String} title 标题
*/
util.title = function(titleText) {
const processTitle = process.env.VUE_APP_TITLE
window.document.title = `${processTitle}${titleText ? ` | ${titleText}` : ''}`
}
/**
* @description 打开新页面
* @param {String} url 地址
*/
util.open = function(url, target) {
var a = document.createElement('a')
a.setAttribute('href', url)
a.setAttribute('target', target || '_blank')
a.setAttribute('id', 'd2admin-link-temp')
document.body.appendChild(a)
a.click()
document.body.removeChild(document.getElementById('d2admin-link-temp'))
}
/**
* 深克隆 所有原型链上的对象和属性
* 例: const bar=deepClone(foo)
* console.log(bar===foo) false
* @param {*} obj
*/
util.deepClone = (obj) => {
// Handle the 3 simple types, and null or undefined or function
if (obj == null || typeof obj !== 'object') return obj
// Handle Date
if (obj instanceof Date) {
const copy = new Date()
copy.setTime(obj.getTime())
return copy
}
// Handle Array or Object
if (obj instanceof Array | obj instanceof Object) {
const copy = (obj instanceof Array) ? [] : {}
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) { copy[attr] = util.deepClone(obj[attr]) }
}
return copy
}
throw new Error("Unable to clone obj! Its type isn't supported.")
}
/**
* 深度递归搜索
* @param {Array} arr 你要搜索的数组
* @param {Function} condition 回调函数,必须返回谓词,判断是否找到了。会传入(item, index, level)三个参数
* @param {String} children 子数组的key
*/
util.deepFind = function(menus, id) {
const cloneMenus = util.deepClone(menus)
for (let menu of cloneMenus) {
if (menu.id === id) {
delete menu.children
return menu
}
if (menu.children) {
return util.deepFind(menu.children, id)
}
}
return null
}
/**
* 16进制颜色值 转换为 rgb
* @param {*} sColor 16进制颜色值
* @param {*} alpha 透明度
*/
util.colorToRgb = (sColor, alpha) => {
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
sColor = sColor.toLowerCase()
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = '#'
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
}
sColor = sColorNew
}
// 处理六位的颜色值
var sColorChange = []
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
}
if (alpha || alpha === 0 || alpha === '0') {
return `rgba(${sColorChange.join(',')} ,${alpha})`
}
return `rgb(${sColorChange.join(',')})`
} else {
return sColor
}
}
/**
* 重置form
* 用法: util.resetForm.call(this,'formName')
*/
util.resetForm = function(formName) {
this.$nextTick(() => {
for (var key in this[formName]) {
if (this[formName].hasOwnProperty(key)) {
this[formName][key] = ''
}
}
this.$refs[formName] && this.$refs[formName].resetFields()
})
}
/**
* 格式化时间
* @param {Array} time
*/
util.formatTime = function(time) {
return {
startTime: time ? time[0] + ' ' + '00:00:00' : '',
endTime: time ? time[1] + ' ' + '23:59:59' : ''
}
}
export default util
const log = {}
/**
* @description 返回这个样式的颜色值
* @param {String} type 样式名称 [ primary | success | warning | danger | text ]
*/
function typeColor(type = 'default') {
let color = ''
switch (type) {
case 'default': color = '#35495E'; break
case 'primary': color = '#3488ff'; break
case 'success': color = '#43B883'; break
case 'warning': color = '#e6a23c'; break
case 'danger': color = '#f56c6c'; break
default:; break
}
return color
}
/**
* @description 打印一个 [ title | text ] 样式的信息
* @param {String} title title text
* @param {String} info info text
* @param {String} type style
*/
log.capsule = function(title, info, type = 'primary') {
console.log(
`%c ${title} %c ${info} %c`,
'background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;',
`background:${typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`,
'background:transparent'
)
}
/**
* @description 打印彩色文字
*/
log.colorful = function(textArr) {
console.log(
`%c${textArr.map(t => t.text || '').join('%c')}`,
...textArr.map(t => `color: ${typeColor(t.type)};`)
)
}
/**
* @description 打印 default 样式的文字
*/
log.default = function(text) {
log.colorful([{ text }])
}
/**
* @description 打印 primary 样式的文字
*/
log.primary = function(text) {
log.colorful([{ text, type: 'primary' }])
}
/**
* @description 打印 success 样式的文字
*/
log.success = function(text) {
log.colorful([{ text, type: 'success' }])
}
/**
* @description 打印 warning 样式的文字
*/
log.warning = function(text) {
log.colorful([{ text, type: 'warning' }])
}
/**
* @description 打印 danger 样式的文字
*/
log.danger = function(text) {
log.colorful([{ text, type: 'danger' }])
}
export default log
/*
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-09-17 17:20:53
*/
const permision = {}
/**
* 打包如有与按钮
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packRoutesBtns = function(resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
const __aRouteInPermision = []
const __oBtnInPermision = {}
let __objResource = null
let __obj = null
idsInPermision.forEach(obj => {
__objResource = resources[obj.authId]
if (__objResource) { // 直接能取到的为路由 (也可以在routes 中定标识变量)
__aRouteInPermision.push(resources[obj.authId]) // push 进 路由数组
} else { // 如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量)
__objResource = resources[obj.parentId]
if (__objResource && __objResource.auth) {
__obj = __objResource.auth.find(o => +o.authId === +obj.authId)
if (__oBtnInPermision[obj.parentId] && __oBtnInPermision[obj.parentId].length) {
__oBtnInPermision[obj.parentId].push(__obj)
} else {
__oBtnInPermision[obj.parentId] = [__obj]
}
// __oBtnInPermision[obj.parentId] = __objResource.auth
// __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.authId),...__objResource.auth.operation.map(o=>o.authId)])
}
}
})
return {
'route': __aRouteInPermision,
'btn': __oBtnInPermision
}
}
/**
* 打包菜单
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packAsideMenus = function(resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
return _loop(idsInPermision, obj => permision.format2Menu(resources[obj.authId]))
}
/**
* 打包菜单
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packMenusBtns = function(resources) {
if (!resources) {
throw new Error('参数错误')
}
const menus = _loop(resources, obj => permision.format2ResourceMenu(obj))
return { menus, all: [] }
}
const _loop = function(res, fnGetMenu) {
const __aParent = []
const __aSub = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
res.forEach(obj => {
const __oMenu = fnGetMenu(obj)
if (!__oMenu) { // 不存在 可能是 按钮 直接继续循环
return true
}
if (+(__oMenu.parentId) === 0) { // 取出1级菜单
__aParent.push(__oMenu)
} else { // 取出子菜单
__aSub.push(__oMenu)
}
})
/**
* 第二次循环所有子菜单 ,然后挂载到对应的一级菜单
*/
let __parent = null
__aSub.forEach(obj => {
__parent = __aParent.find(menu => +(menu.authId) === +(obj.parentId))
if (__parent) {
if (__parent.children) {
__parent.children.push(obj)
} else {
__parent.children = [obj]
}
}
})
return __aParent
}
/**
* 格式化菜单 封装成系统所需格式
*/
permision.format2Menu = function(oMenu) {
if (!oMenu) return null
const { icon, path, meta } = oMenu
const { title, authId, parentId } = meta
return {
title,
icon,
path,
authId,
parentId }
}
/**
* 格式化菜单 封装成系统所需格式
*/
permision.format2ResourceMenu = function(oMenu) {
if (!oMenu) return null
const { icon, meta, auth } = oMenu
const { title, authId, parentId } = meta
return {
label: title,
icon,
authId,
parentId,
auth }
}
/**
* 扁平化 routes (@/router/routes)
*/
permision.flatten = function(arr) {
return arr.reduce((result, item) => {
item.authId = item.authId || item.meta.authId
item.parentId = item.parentId || item.meta.parentId
const cloneItem = _.cloneDeep(item)
delete cloneItem.auth
return result.concat(item.auth ? permision.flatten([...item.auth, cloneItem]) : item)
}, [])
}
export default permision
{
"_name": "English"
}
{
"_name": "日本語"
}
{
"_name": "简体中文"
}
{
"_name": "繁體中文"
}
// Vue
import Vue from 'vue'
// import i18n from './i18n'
import App from './App'
// 核心插件
import d2Admin from '@/plugin/d2admin'
// store
import store from '@/store/index'
// import D2Crud from '@d2-projects/d2-crud'
// 菜单和路由设置
import router from './router'
// import menuHeader from '@/menu/header'
// import menuAside from '@/menu/aside'
// import { frameInRoutes } from '@/router/routes'
// import VRM from 'vue-role-manager'
// Vue.use(VRM, {
// router,
// redirect: '403',
// enabled: false
// })
// 核心插件
Vue.use(d2Admin)
// Vue.use(D2Crud)
new Vue({
router,
store,
// i18n,
render: h => h(App),
// created () {
// 处理路由 得到每一级的路由设置
// this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 (暂时不需要)
// this.$store.commit('d2admin/menu/headerSet', menuHeader)
// 设置侧边栏菜单 (TODO 进行过滤)
// this.$store.commit('d2admin/menu/asideSet', menuAside)
// 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader)
// },
mounted() {
Vue.config.devtools = true
// 展示系统信息
this.$store.commit('d2admin/releases/versionShow')
// 用户登录后从数据库加载一系列的设置
this.$store.dispatch('d2admin/account/load')
// 获取并记录用户 UA
this.$store.commit('d2admin/ua/get')
// 初始化全屏监听
this.$store.dispatch('d2admin/fullscreen/listen')
}
}).$mount('#app')
const userDB = [
{ username: 'admin', password: 'admin', uuid: 'admin-uuid', name: '管理员' },
{ username: 'editor', password: 'editor', uuid: 'editor-uuid', name: '编辑' },
{ username: 'user1', password: 'user1', uuid: 'user1-uuid', name: '用户1' }
]
export default [
{
path: '/api/login',
method: 'post',
handle({ body }) {
const user = userDB.find(e => e.username === body.username && e.password === body.password)
if (user) {
return {
code: 0,
msg: '登录成功',
data: {
...user,
token: '8dfhassad0asdjwoeiruty'
}
}
} else {
return {
code: 401,
msg: '用户名或密码错误',
data: {}
}
}
}
}
]
import Mock from 'mockjs'
import qs from 'qs'
import withCredentials from './patch/withCredentials'
/* 补丁 */
withCredentials(Mock)
/* Mock 默认配置 */
Mock.setup({ timeout: '200-300' })
/* 扩展 [生成器] */
const Generator = (prop, template) => {
const obj = {}
obj[prop] = [template]
return Mock.mock(obj)
}
/* 扩展 [循环] */
const Repeat = (num, itemTemplate) => Generator(`data|${num}`, itemTemplate).data
const CustomExtends = {
Generator,
Repeat,
Mock,
Random: Mock.Random
}
const extend = (prop, value) => {
CustomExtends[prop] = value
}
/* 装配配置组 */
const wired = ({ url, type, body }) => ({
method: type,
params: qs.parse(url.split('?').length > 1 ? url.split('?')[1] : ''),
body: JSON.parse(body),
url: qs.parse(url.split('?')[0]),
...CustomExtends
})
const setup = (path, method, handle) => {
Mock.mock(
RegExp(path),
method,
typeof handle === 'function' ? o => handle(wired(o)) : handle
)
}
const load = (collection) => {
collection.map(({ path, method, handle }) => {
if (method === '*') {
method = [
'get',
'head',
'post',
'put',
'delete',
'connect',
'options',
'trace',
'patch'
]
}
if (typeof method === 'string' && method.indexOf('|') > -1) method = method.split('|')
if (method instanceof Array) {
method.map(item => setup(path, item, handle))
} else {
setup(path, method, handle)
}
})
}
export default { setup, load, extend }
export default function(Mock) {
// http://cnine.me/note/FrontEnd/mock-lose-cookies-dbg.html
Mock.XHR.prototype.__send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() {
if (this.custom.xhr) this.custom.xhr.withCredentials = this.withCredentials || false
this.__send.apply(this, arguments)
}
}
import d2Mock from './d2-mock'
const req = context => context.keys().map(context)
const options = req(require.context('./api/', true, /\.js$/))
.filter(e => e.default)
.map(e => e.default)
options.forEach(option => {
d2Mock.load(option)
})
import store from '@/store'
import axios from 'axios'
import {
Message
} from 'element-ui'
import util from '@/libs/util'
import router from '@/router'
import {
LogExternals
} from '@/common/constants'
import Qs from 'qs'
axios.defaults.withCredentials = true
const expiresMinute = 60 // 过期时间(分钟)
// var refreshTable = false // 标记是否刷新表格
// 创建一个错误
export function errorCreate(msg) {
const error = new Error(msg)
errorLog(error)
throw error
}
// 记录和显示错误
function errorLog(error) {
// 添加到日志
store.dispatch('d2admin/log/push', {
message: '数据请求异常',
type: 'danger',
meta: {
error
}
})
// 打印到控制台
if (process.env.NODE_ENV === 'development') {
util.log.danger('>>>>>> Error >>>>>>')
console.log(error)
}
// 显示提示
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
})
}
// 网络请求公用地址 http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
// VUE_APP_API=http://192.168.3.191:8944/router
// 创建一个 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_API,
timeout: 5000, // 请求超时时间
transformRequest: [function(data) {
return Qs.stringify(data)
}]
})
// 请求拦截器
service.interceptors.request.use(
config => {
return new Promise(async resolve => {
const { url, params } = config
// params.refreshTable && (refreshTable = true)
await store.commit('d2admin/loading/set', true)
const uuid = util.cookies.get('uuid')
// 如果请求链接不在排除列表 (排除列表: 登录 基础数据) 并且cookie 过期(判断是否长时间未操作)
if (!LogExternals.some(u => u === url || (params && u === params.method)) && !uuid) {
await store.dispatch('d2admin/account/logout')
router.replace('/login')
}
if (uuid) { // 判断 cookie 是否存在 存在则更新时间 避免登出时 记录空值
const inExpiresMinutes = new Date(new Date().getTime() + expiresMinute * 60 * 1000)
util.cookies.set('uuid', uuid, {
expires: inExpiresMinutes
})
}
resolve(config)
})
},
error => {
store.commit('d2admin/loading/set', false)
// 发送失败
console.log(error)
Promise.reject(error)
}
)
// 响应拦截器
service.interceptors.response.use(
response => {
store.commit('d2admin/loading/set', false)
// dataAxios 是 axios 返回数据中的 data
const dataAxios = response.data
// 这个状态码是和后端约定的
const { code, data } = dataAxios
// 有 code 代表这是一个后端接口 可以进行进一步的判断
switch (+code) {
case 0:
// [ 示例 ] code === 0 代表没有错误
// if (refreshTable) {
// store.commit('d2admin/refreshtable/set', !store.state.d2admin.refreshtable.value)
// refreshTable = false
// }
return data
default:
// 不是正确的 code
errorCreate(`${dataAxios.message}`)
break
}
// refreshTable = false
},
error => {
if (error && error.response) {
switch (error.response.status) {
case 400:
error.message = '请求错误'
break
case 401:
error.message = '未授权,请登录'
break
case 403:
error.message = '拒绝访问'
break
case 404:
error.message = `请求地址出错: ${error.response.config.url}`
break
case 408:
error.message = '请求超时'
break
case 500:
error.message = '服务器内部错误'
break
case 501:
error.message = '服务未实现'
break
case 502:
error.message = '网关错误'
break
case 503:
error.message = '服务不可用'
break
case 504:
error.message = '网关超时'
break
case 505:
error.message = 'HTTP版本不受支持'
break
default:
break
}
}
store.commit('d2admin/loading/set', false)
errorLog(error)
return Promise.reject(error)
}
)
export default service
// Element
import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
// flex 布局库
import 'flex.css'
// 组件
import '@/components'
// svg 图标
import '@/assets/svg-icons'
// 指令
import '@/directives'
// 过滤器
import '@/filters'
// 功能插件
import pluginError from '@/plugin/error'
import pluginLog from '@/plugin/log'
import pluginOpen from '@/plugin/open'
export default {
async install(Vue, options) {
// 设置为 false 以阻止 vue 在启动时生成生产提示
// https://cn.vuejs.org/v2/api/#productionTip
Vue.config.productionTip = false
// 当前环境
Vue.prototype.$env = process.env.NODE_ENV
// 当前的 baseUrl
Vue.prototype.$baseUrl = process.env.BASE_URL
// 当前版本
Vue.prototype.$version = process.env.VUE_APP_VERSION
// 构建时间
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
// 事件传递
Vue.prototype.$event = new Vue()
// Element
Vue.use(ElementUI, { size: 'medium', zIndex: 3000 })
// 插件
Vue.use(pluginError)
Vue.use(pluginLog)
Vue.use(pluginOpen)
}
}
import store from '@/store'
import util from '@/libs/util'
export default {
install(Vue, options) {
Vue.config.errorHandler = function(error, instance, info) {
Vue.nextTick(() => {
// store 追加 log
store.dispatch('d2admin/log/push', {
message: `${info}: ${error.message}`,
type: 'danger',
meta: {
error,
instance
}
})
// 只在开发模式下打印 log
if (process.env.NODE_ENV === 'development') {
util.log.capsule('D2Admin', 'ErrorHandler', 'danger')
util.log.danger('>>>>>> 错误信息 >>>>>>')
console.log(info)
util.log.danger('>>>>>> Vue 实例 >>>>>>')
console.log(instance)
util.log.danger('>>>>>> Error >>>>>>')
console.log(error)
}
})
}
}
}
import store from '@/store'
import util from '@/libs/util'
export default {
install(Vue, options) {
// 快速打印 log
Vue.prototype.$log = {
...util.log,
push(data) {
if (typeof data === 'string') {
// 如果传递来的数据是字符串
// 赋值给 message 字段
// 为了方便使用
// eg: this.$log.push('foo text')
store.dispatch('d2admin/log/push', {
message: data
})
} else if (typeof data === 'object') {
// 如果传递来的数据是对象
store.dispatch('d2admin/log/push', data)
}
}
}
}
}
import util from '@/libs/util'
export default {
install(Vue, options) {
Vue.prototype.$open = util.open
}
}
import Vue from 'vue'
import VueRouter from 'vue-router'
// 进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import store from '@/store/index'
import util from '@/libs/util.js'
// 路由数据
import routes from './routes'
const originalPush = VueRouter.prototype.push // 解决连续点击路由异常问题 limin
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location) && originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
// 导出路由 在 main.js 里使用
const router = new VueRouter({
routes
})
const setCurrent = path => {
return new Promise(async resolve => {
path !== '/login' && await store.dispatch('d2admin/page/currentSet', path)
resolve()
})
}
/**
* 路由拦截
* 权限验证
*/
router.beforeEach(async(to, from, next) => {
const source = store.state.d2admin.auth.source
// 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
// await store.dispatch('d2admin/page/isLoaded')
// 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
// await store.dispatch('d2admin/size/isLoaded')
// 设置当前页 下次登录 默认打开此页面
await setCurrent(to.fullPath)
// 进度条
NProgress.start()
// 关闭搜索面板
store.commit('d2admin/search/set', false)
if (from.name === null && to.path !== '/login' && !source) { // 页面刷新 动态路由会失效 初始化路由与左侧菜单栏
await store.dispatch('d2admin/auth/init')
await store.dispatch('d2admin/account/load')
next(to.path)
} else {
if (store.state.d2admin.user.info) { // sessionstorage 用户存在继续当前路由 不存在 跳转登录 防止页面关闭还可以打开页面
next()
} else {
if (to.path === '/login') { // 如果是登录页面路径,就直接next()
next()
} else { // 不然就跳转到登录;
await store.dispatch('d2admin/account/logout')
next('/login')
}
}
}
})
router.afterEach(to => {
// 进度条
NProgress.done()
// 多页控制 打开新的页面
store.dispatch('d2admin/page/open', to)
// 更改标题
util.title(to.meta.title)
// 保存当前页面meta信息
store.dispatch('d2admin/auth/setCurrentPageMeta', to.meta)
})
export const ResetRouter = () => new VueRouter({
routes
})
export default router
import layoutHeaderAside from '@/layout/header-aside'
// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
/**
* 在主框架内显示(children 由后台返回资源点集合 从 resources 中动态过滤加载)
*/
const frameIn = [{
path: '/',
redirect: {
name: 'index'
},
component: layoutHeaderAside,
children: []
}]
/**
* 首页
* icon:element-ui
*/
export const home = {
path: '/index',
name: 'index',
icon: 's-home',
meta: {
title: 'echats',
authId: '101',
parentId: '0',
cache: true
},
component: _import('index')
}
export const sys = [
// 系统 前端日志
// {
// path: '/log',
// name: 'log',
// meta: {
// title: '前端日志',
// },
// component: _import('system/log')
// },
// 刷新页面 必须保留
{
path: '/refresh',
name: 'refresh',
hidden: true,
component: _import('system/function/refresh')
},
// 页面重定向 必须保留
{
path: 'redirect/:route*',
name: 'redirect',
hidden: true,
component: _import('system/function/redirect')
}
]
/**
* 所有需动态过滤的资源点
*/
export const resources = {
'102': {
path: '/bb',
icon: 'document',
name: '表格组件',
meta: {
title: '表格组件',
authId: '102',
parentId: '0'
}
},
'10201': {
path: '/table1',
icon: 'document-copy',
name: 'fimsTable1',
meta: {
title: '默认使用',
authId: '10201',
parentId: '102',
cache: true
},
component: _import('table1'),
auth: [{
authId: '1020101',
parentId: '10201',
label: '编辑',
handle: 'handleEdit'
}, {
authId: '1020102',
parentId: '10201',
label: '删除',
color: '#FF0000',
handle: 'handleDelete'
}, {
authId: '1020103',
parentId: '10201',
label: '添加',
category: 'Button',
type: 'button',
handle: 'handleEdit',
icon: 'plus'
}, {
authId: '1020104',
parentId: '10201',
label: '批量操作',
category: 'Button',
type: 'button',
handle: 'handleOperate'
}]
},
'10202': {
path: '/table2',
icon: 'finished',
name: 'fimsTable2',
meta: {
title: '外部数据传入',
authId: '10202',
parentId: '102',
cache: true
},
component: _import('table2')
},
'107': {
path: '/users',
icon: 'user',
name: '帐号管理',
meta: {
title: '用户管理',
authId: '107',
parentId: '0'
}
},
'10701': {
path: '/user',
name: 'FimsUsers',
icon: 'user-solid',
meta: {
title: '用户管理',
authId: '10701',
parentId: '107',
cache: true
},
auth: [{ // 列表操作
authId: '1070101',
parentId: '10701',
label: '审核',
handle: 'handleVerify'
}, { //
authId: '1070102',
parentId: '10701',
label: '重置密码',
handle: 'handleOperation'
}, { //
authId: '1070103',
parentId: '10701',
label: '编辑',
handle: 'handleEdit'
}, { //
authId: '1070104',
parentId: '10701',
label: '延期',
handle: 'handleOperation'
}, { //
authId: '1070105',
parentId: '10701',
label: '禁用',
color: '#FF0000',
handle: 'handleOperation'
}, { //
authId: '1070106',
parentId: '10701',
label: '激活',
handle: 'handleOperation'
}, { // 列表操作
authId: '1070107',
parentId: '10701',
label: '创建用户',
category: 'action',
type: 'button',
handle: 'handleRegister',
icon: 'plus'
}],
component: _import('userManage/user')
},
'10702': {
path: '/role',
name: 'FimsRoles',
icon: 'open',
meta: {
title: '权限管理',
authId: '10702',
parentId: '107'
},
auth: [{
authId: '1070201',
parentId: '10702',
label: '创建角色',
category: 'action',
handle: 'handleEdit',
type: 'button',
icon: 'plus'
}, {
authId: '1070202',
parentId: '10702',
label: '权限编辑',
handle: 'handleEdit',
type: 'text'
}],
component: _import('userManage/role')
},
'10703': {
path: '/loginLogs',
name: 'FimsLoginLogs',
icon: 'tickets',
meta: {
title: '登录日志',
authId: '10703',
parentId: '107',
cache: true
},
component: _import('userManage/loginLogs')
}
}
/**
* 在主框架之外显示
*/
const frameOut = [
// 登录
{
path: '/login',
name: 'login',
component: _import('system/login')
}
]
/**
* 错误页面
*/
export const errorPage = {
path: '*',
name: '404',
component: _import('system/error/404')
}
// 导出需要显示菜单的
export const frameInRoutes = frameIn
export const localRoutes = {
...resources, [home.meta.authId]: home
}
// 重新组织后导出
export default [
...frameOut,
errorPage
]
export default {
// 快捷键
// 支持快捷键 例如 ctrl+shift+s
hotkey: {
search: {
open: 's',
close: 'esc'
}
},
// 侧边栏默认折叠状态
menu: {
asideCollapse: false
},
// 在读取持久化数据失败时默认页面
page: {
opened: [
{
name: 'index',
fullPath: '/index',
meta: {
title: '首页',
auth: false
}
}
]
},
// 菜单搜索
search: {
enable: true
},
// 注册的主题
theme: {
list: [
{
title: 'classic',
name: 'classic',
color: '#2A58AD',
preview: 'image/theme/classic/preview@2x.png'
},
{
title: 'dark',
name: 'dark',
color: '#314256',
preview: 'image/theme/dark/preview@2x.png'
},
{
title: 'blue',
name: 'blue',
color: '#652DED',
preview: 'image/theme/blue/preview@2x.png'
},
{
title: 'plane',
name: 'plane',
color: '#377DE7',
backgroundImage: 'image/theme/plane/bg.jpg',
preview: 'image/theme/plane/preview@2x.png'
}
// {
// title: 'd2admin 经典',
// name: 'd2',
// preview: 'image/theme/d2/preview@2x.png'
// },
// {
// title: '紫罗兰',
// name: 'violet',
// preview: 'image/theme/violet/preview@2x.png'
// },
// {
// title: '简约线条',
// name: 'line',
// backgroundImage: 'image/theme/line/bg.jpg',
// preview: 'image/theme/line/preview@2x.png'
// },
// {
// title: '流星',
// name: 'star',
// backgroundImage: 'image/theme/star/bg.jpg',
// preview: 'image/theme/star/preview@2x.png'
// },
// {
// title: 'Tomorrow Night Blue (vsCode)',
// name: 'tomorrow-night-blue',
// preview: 'image/theme/tomorrow-night-blue/preview@2x.png'
// }
]
},
// 是否默认开启页面切换动画
transition: {
active: true
}
}
import Vue from 'vue'
import Vuex from 'vuex'
import d2admin, { storeResets } from './modules/d2admin'
Vue.prototype.$StoreReset = function() {
return new Promise(resolve => {
storeResets.forEach(reset => this.dispatch(reset))
resolve()
})
}
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
d2admin
}
})
/**
* The file enables `@/store/index.js` to import all vuex modules
* in a one-shot manner. There should not be any reason to edit this file.
*/
const files = require.context('./modules', false, /\.js$/)
const modules = {}
const resets = []
let _default = null
files.keys().forEach(key => {
_default = files(key).default
key = key.replace(/(\.\/|\.js)/g, '')
modules[key] = _default
_default.actions && _default.actions.reset && resets.push(`d2admin/${key}/reset`)
})
export const storeResets = resets
export default {
namespaced: true,
modules
}
import util from '@/libs/util.js'
import { AccountLogin } from '@api/sys.account'
import { SUPPER_ADMIN } from '@/common/constants'
import { localRoutes } from '@/router/routes'
export default {
namespaced: true,
actions: {
/**
* @description 登录
* @param {Object} context
* @param {Object} payload username {String} 用户账号
* @param {Object} payload password {String} 密码
* @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
*/
login({ dispatch, commit }, p) {
// console.log(router.addRoutes);
return new Promise((resolve, reject) => {
// 开始请求登录接口
AccountLogin(p).then(async(data = {}) => {
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
// token 代表用户当前登录状态 建议在网络请求中携带 token
// 如有必要 token 需要定时更新,默认保存一天
util.cookies.set('uuid', data.loginName)
// data.roleType = SUPPER_ADMIN
const authes = (+data.roleType === SUPPER_ADMIN)
? util.permision.flatten(Object.values(localRoutes))
.map(obj => ({ authId: obj.authId, parentId: obj.parentId }))
: _.cloneDeep(data.authes)
await dispatch('d2admin/auth/set', authes, { root: true })
// // 设置 vuex 用户信息
delete data.authes
await dispatch('d2admin/user/set', data, { root: true })
// 初始化权限
await dispatch('d2admin/auth/init', null, { root: true })
// // 用户登录后从持久化数据加载一系列的设置
await dispatch('load')
// 结束
resolve()
})
.catch(err => {
console.log('err: ', err)
reject(err)
})
})
},
/**
* @description 注销用户并返回登录页面
* @param {Object} context
* @param {Object} payload confirm {Boolean} 是否需要确认
*/
logout({ commit, dispatch }, { confirm = false } = {}) {
/**
* @description 注销
*/
return new Promise(async resolve => {
// 删除cookie
util.cookies.remove('uuid')
// await dispatch('d2admin/user/clear', null, { root: true })
// await dispatch('d2admin/base/clear', null, { root: true })
// await commit('d2admin/page/setCurrent', null, { root: true })
// await commit('d2admin/auth/set', null, { root: true })
resolve()
})
},
/**
* @description 用户登录后从持久化数据加载一系列的设置
* @param {Object} context
*/
load({ dispatch }) {
return new Promise(async resolve => {
// DB -> store 加载用户名
await dispatch('d2admin/user/load', null, { root: true })
// DB -> store 加载主题
await dispatch('d2admin/theme/load', null, { root: true })
// DB -> store 加载页面过渡效果设置
await dispatch('d2admin/transition/load', null, { root: true })
// DB -> store 持久化数据加载上次退出时的多页列表
await dispatch('d2admin/page/openedLoad', null, { root: true })
// DB -> store 持久化数据加载侧边栏折叠状态
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true })
// DB - > 初始化 基础数据
// await dispatch('d2admin/base/init', null, { root: true })
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end
resolve()
})
}
}
}
/*
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-09-19 10:45:51
*/
import util from '@/libs/util.js'
import router, { ResetRouter } from '@/router'
import { localRoutes, frameInRoutes, sys } from '@/router/routes'
export default {
namespaced: true,
state: {
source: null,
meta: {},
btns: {},
btnIdAll: []
},
getters: {
/**
* @description 返回当前登录用户权限资源
* @param {Object} state state
*/
source(state) {
return state.source
},
/**
* @description 返回当前页面meta
* @param {Object} state state
*/
meta(state) {
return state.meta
},
/**
* @description 当前角色拥有的所有按钮
* @param {Object} state state
*/
btns(state) {
return state.btns
},
/**
* 返回当前页面的btn
* @param {*} state
*/
curBtns(state) {
return state.btns[state.meta.authId]
},
/**
* 返回当前页面的btn
* @param {*} state
*/
btnIdAll(state) {
return state.btnIdAll
}
},
actions: {
save2db({ state, dispatch }) {
return new Promise(async resolve => {
// 设置数据
dispatch('d2admin/db/set', {
dbName: 'database',
path: 'source',
value: state.source,
user: true
}, { root: true })
// end
resolve()
})
},
/**
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
set({ state, dispatch }, source) {
return new Promise(async resolve => {
// 检查这个主题在主题列表里是否存在
state.source = source
// 持久化数据 防止刷新 数据 丢失
await dispatch('save2db')
// end
resolve()
})
},
/**
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
setCurrentPageMeta({ state }, meta) {
return new Promise(async resolve => {
state.meta = meta
// end
resolve()
})
},
/**
* @description 从持久化数据加载资源数据
* @param {Object} context
*/
load({ state, dispatch }) {
return new Promise(async resolve => {
if (!state.source) {
state.source = await dispatch('d2admin/db/get', {
dbName: 'database',
path: 'source',
user: true
}, { root: true })
}
// end
resolve(state.source)
})
},
/**
* 过滤并初始化路由与左侧菜单栏
* @param {*} param0
*/
init({ state, dispatch }) {
return new Promise(async resolve => {
// 获取权限资源点
const __source = await dispatch('load')
await dispatch('_initRoutes', __source)
await dispatch('_initByRole', __source)
// end
resolve(state.source)
})
},
_initRoutes({ state }, source) {
return new Promise(async resolve => {
try {
const { route, btn } = util.permision.packRoutesBtns(localRoutes, source)
router.matcher = ResetRouter().matcher // 重置基础路由 解决切换用户 保留上一个用户路由问题
frameInRoutes[0].children = [...route, ...sys]
router.addRoutes(frameInRoutes)
state.btns = btn
} catch (error) {
if (error.message === '参数错误' && !source) {
router.replace('/login')
return false
}
}
// end
resolve()
})
},
_initByRole({ commit }, source) {
return new Promise(async resolve => {
const __aMenus = util.permision.packAsideMenus(localRoutes, source)
await commit('d2admin/page/init', frameInRoutes, { root: true })
await commit('d2admin/menu/asideSet', __aMenus, { root: true })
await commit('d2admin/search/init', __aMenus, { root: true })
// end
resolve()
})
},
async reset({ state, dispatch }) {
state.source = null
state.meta = {}
state.btns = {}
state.btnIdAll = []
await dispatch('save2db')
}
}
}
/*
* @Author: limin
* @Date: 2019-09-01 17:56:57
* @Last Modified by: chenwq
* @Last Modified time: 2019-09-29 14:50:07
*/
import { FetchRoleList, BaseDataApi } from '@/api/sys.base'
import { BaseData, TYPE_NAME, ConfigType } from '@/common/constants'
const map = {
[BaseData.ROLE.KEY]: FetchRoleList,
// [BaseData.COMPANY]: CompanyList,
// [BaseData.DEPART.KEY]: DepartList,
[BaseData.STATION.KEY]: BaseDataApi,
[BaseData.POST.KEY]: BaseDataApi,
[BaseData.SUBSYS.KEY]: BaseDataApi
}
export default {
namespaced: true,
state: {
// 角色
role: [],
// 站点
station: [],
// 职务
post: [],
// 子系统
subsys: []
},
actions: {
/**
* 初始化获取 基础数据 并 前端持久化
* 每次登录会强制 初始化
* @param {*} param0
*/
init({ state, dispatch, commit }) {
return new Promise(async resolve => {
Promise.all([
FetchRoleList(),
BaseDataApi({ [TYPE_NAME]: ConfigType.STATION }),
BaseDataApi({ [TYPE_NAME]: ConfigType.POST }),
BaseDataApi({ [TYPE_NAME]: ConfigType.SUBSYS })
]).then(async([role, station, post, subsys]) => {
state.role = role
state.station = station
state.subsys = subsys
state.post = post
await dispatch('save2db', { name: '', value: state })
resolve(state)
})
})
},
// 重置
clear({ state, dispatch }) {
return new Promise(async resolve => {
state.role = []
state.station = []
state.subsys = []
state.post = []
await dispatch('save2db', { name: '', value: state })
resolve(state)
})
},
/**
* 根据名字获取基础数据
* 获取步骤:
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
* @param {*} name 名称 state 中的任意一个 强烈建议 使用 @/common/constants/BaseData 中的常量 便于灵活修改
*/
get({ state, dispatch }, name) {
return new Promise(async resolve => {
let __data = state[name]
if (__data) {
__data = await dispatch('getFromdb', `base.${name}`) || await dispatch('getFromAjax', name)
state[name] = __data
await dispatch('save2db', { name, value: __data })
}
resolve(__data)
})
},
set({ state, dispatch }, { name, value }) {
return new Promise(async resolve => {
state[name] = value
await dispatch('save2db', { name, value })
resolve(value)
})
},
/**
* 获取所有基础数据
* 获取步骤:
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
*/
load({ state, dispatch }) {
return new Promise(async resolve => {
if (state.role.length === 0) {
state = await dispatch('getFromdb', 'base') || await dispatch('init')
}
const { role, station, post, subsys } = state
resolve({ role, station, post, subsys })
})
},
/**
* 内部方法 从前端持久化数据库 获取指定数据
* @param {*} param0
* @param {*} path 数据 路径
*/
getFromdb({ dispatch }, path) {
return new Promise(async resolve => {
const value = await dispatch('d2admin/db/get', {
dbName: 'database',
path,
user: false
}, { root: true })
resolve(value)
})
},
/**
* 内部方法 前端持久化 一个 数据
* @param {*} param0
* @param {*} param1 value 需要持久化的数据 path 需要持久化的数据路径
*/
save2db({ dispatch }, { value, name }) {
return new Promise(async resolve => {
await dispatch('d2admin/db/set', {
dbName: 'database',
path: name ? `base.${name}` : 'base',
value,
user: false
}, { root: true })
resolve(value)
})
},
/**
* 从后端获取一个数据
* @param {*} param0
* @param {*} name @/common/constants/BaseData 中的常量
*/
getFromAjax({ state, dispatch, commit }, name) {
return new Promise(async resolve => {
const value = await map[name]({ [TYPE_NAME]: Object.values(BaseData).find(data => data.KEY === name).TYPE })
resolve(value)
})
},
async reset({ dispatch }) {
await dispatch('clear')
}
}
}
import client from 'webpack-theme-color-replacer/client'
import forElementUI from 'webpack-theme-color-replacer/forElementUI'
export default {
namespaced: true,
state: {
// 颜色
value: process.env.VUE_APP_ELEMENT_COLOR
},
getters: {
/**
* @description 返回当前颜色值
* @param {Object} state state
*/
color(state, dispatch) {
return state.value
}
},
actions: {
/**
* @description 设置颜色
* @param {Object} context
* @param {String} color 尺寸
*/
set({ state, dispatch, commit }, color) {
return new Promise(async resolve => {
// 记录上个值
const old = state.value
// store 赋值
state.value = color || process.env.VUE_APP_ELEMENT_COLOR
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'color.value',
value: state.value,
user: true
}, { root: true })
// 应用
commit('apply', {
oldColor: old,
newColor: state.value
})
// end
resolve()
})
},
/**
* @description 从持久化数据读取颜色设置
* @param {Object} context
*/
load({ state, dispatch, commit }) {
return new Promise(async resolve => {
// 记录上个值
const old = state.value
// store 赋值
state.value = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'color.value',
defaultValue: process.env.VUE_APP_ELEMENT_COLOR,
user: true
}, { root: true })
// 应用
commit('apply', {
oldColor: old,
newColor: state.value
})
// end
resolve()
})
},
loadFromDB({ state, dispatch, commit }) {
return new Promise(async resolve => {
const color = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'color.value',
defaultValue: '',
user: true
}, { root: true })
resolve(color)
})
}
// reset({ state, dispatch, commit }) {
// return new Promise(async resolve => {
// await dispatch('set', '')
// resolve()
// })
// }
},
mutations: {
/**
* @description 将 vuex 中的主题颜色设置应用到系统中
* @param {Object} context
* @param {Object} payload oldColor {String} 旧的颜色
* @param {Object} payload newColor {String} 新颜色
*/
apply(state, { oldColor, newColor }) {
var options = {
oldColors: [...forElementUI.getElementUISeries(oldColor)],
newColors: [...forElementUI.getElementUISeries(newColor)]
}
client.changer.changeColor(options)
}
}
}
import router from '@/router'
import { database as getDatabase, dbGet, dbSet } from '@/libs/util.db'
export default {
namespaced: true,
actions: {
/**
* @description 将数据存储到指定位置 | 路径不存在会自动初始化
* @description 效果类似于取值 dbName.path = value
* @param {Object} context
* @param {Object} payload dbName {String} 数据库名称
* @param {Object} payload path {String} 存储路径
* @param {Object} payload value {*} 需要存储的值
* @param {Object} payload user {Boolean} 是否区分用户
*/
set(context, {
dbName = 'database',
path = '',
value = '',
user = false
}) {
dbSet({ dbName, path, value, user })
},
/**
* @description 获取数据
* @description 效果类似于取值 dbName.path || defaultValue
* @param {Object} context
* @param {Object} payload dbName {String} 数据库名称
* @param {Object} payload path {String} 存储路径
* @param {Object} payload defaultValue {*} 取值失败的默认值
* @param {Object} payload user {Boolean} 是否区分用户
*/
get(context, {
dbName = 'database',
path = '',
defaultValue = '',
user = false
}) {
return dbGet({ dbName, path, defaultValue, user })
},
/**
* @description 获取存储数据库对象
* @param {Object} context
* @param {Object} payload user {Boolean} 是否区分用户
*/
database(context, {
user = false
} = {}) {
return getDatabase({
user,
defaultValue: {}
})
},
/**
* @description 清空存储数据库对象
* @param {Object} context
* @param {Object} payload user {Boolean} 是否区分用户
*/
databaseClear(context, {
user = false
} = {}) {
return getDatabase({
user,
validator: () => false,
defaultValue: {}
})
},
/**
* @description 获取存储数据库对象 [ 区分页面 ]
* @param {Object} context
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
databasePage(context, {
basis = 'fullPath',
user = false
} = {}) {
return getDatabase({
path: `$page.${router.app.$route[basis]}`,
user,
defaultValue: {}
})
},
/**
* @description 清空存储数据库对象 [ 区分页面 ]
* @param {Object} context
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
databasePageClear(context, {
basis = 'fullPath',
user = false
} = {}) {
return getDatabase({
path: `$page.${router.app.$route[basis]}`,
user,
validator: () => false,
defaultValue: {}
})
},
/**
* @description 快速将页面当前的数据 ( $data ) 持久化
* @param {Object} context
* @param {Object} payload instance {Object} vue 实例
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageSet(context, {
instance,
basis = 'fullPath',
user = false
}) {
return getDatabase({
path: `$page.${router.app.$route[basis]}.$data`,
user,
validator: () => false,
defaultValue: _.cloneDeep(instance.$data)
})
},
/**
* @description 快速获取页面快速持久化的数据
* @param {Object} context
* @param {Object} payload instance {Object} vue 实例
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageGet(context, {
instance,
basis = 'fullPath',
user = false
}) {
return dbGet({
path: `$page.${router.app.$route[basis]}.$data`,
user,
defaultValue: _.cloneDeep(instance.$data)
})
},
/**
* @description 清空页面快照
* @param {Object} context
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageClear(context, {
basis = 'fullPath',
user = false
}) {
return getDatabase({
path: `$page.${router.app.$route[basis]}.$data`,
user,
validator: () => false,
defaultValue: {}
})
}
}
}
import screenfull from 'screenfull'
export default {
namespaced: true,
state: {
// 全屏激活
active: false
},
actions: {
/**
* @description 初始化监听
* @param {Object} context
*/
listen({ commit }) {
return new Promise(resolve => {
screenfull.enabled && screenfull.on('change', () => !screenfull.isFullscreen && commit('set', false))
// end
resolve()
})
},
/**
* @description 切换全屏
* @param {Object} context
*/
toggle({ commit }) {
return new Promise(resolve => {
if (screenfull.isFullscreen) {
screenfull.exit()
commit('set', false)
} else {
screenfull.request()
commit('set', true)
}
// end
resolve()
})
},
reset({ state }) {
state.active = false
}
},
mutations: {
/**
* @description 设置 store 里的全屏状态
* @param {Object} state state
* @param {Boolean} active active
*/
set(state, active) {
state.active = active
}
}
}
export default {
namespaced: true,
state: {
// 灰度
active: false
},
mutations: {
/**
* @description 切换灰度状态
* @param {Object} state state
*/
toggle(state) {
state.active = !state.active
},
/**
* @description 设置灰度模式
* @param {Object} state state
* @param {Boolean} active active
*/
set(state, active) {
state.active = active
}
},
actions: {
reset({ state }) {
state.active = false
}
}
}
/*
* @Author: limin
* @Date: 2019-09-15 17:34:41
* @Last Modified by: limin
* @Last Modified time: 2019-09-19 10:21:06
*/
export default {
namespaced: true,
state: {
// 加载中...
value: false
},
getters: {
/**
* 返回当前加载状态
* @param {*} state
*/
loading(state) {
return state.value
}
},
mutations: {
/**
* @description 设置加载中
* @param {Object} state state
* @param {Boolean} loading loading
*/
set(state, loading) {
return new Promise(resolve => {
state.value = loading
resolve()
})
}
},
actions: {
reset({ state }) {
state.value = false
}
}
}
import dayjs from 'dayjs'
import util from '@/libs/util.js'
export default {
namespaced: true,
state: {
// 错误日志
// + 日志条目的属性
// - message 必须 日志信息
// - type 非必须 类型 success | warning | info(默认) | danger
// - time 必须 日志记录时间
// - meta 非必须 其它携带信息
log: []
},
getters: {
/**
* @description 返回现存 log (all) 的条数
* @param {*} state vuex state
*/
length(state) {
return state.log.length
},
/**
* @description 返回现存 log (error) 的条数
* @param {*} state vuex state
*/
lengthError(state) {
return state.log.filter(log => log.type === 'danger').length
}
},
actions: {
/**
* @description 添加一个日志
* @param {Object} context
* @param {String} param message {String} 信息
* @param {String} param type {String} 类型
* @param {Object} payload meta {Object} 附带的信息
*/
push({ rootState, commit }, { message, type = 'info', meta }) {
commit('push', {
message,
type,
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
meta: {
// 当前用户信息
user: rootState.d2admin.user.info,
// 当前用户的 uuid
uuid: util.cookies.get('uuid'),
// 当前的 token
// token: util.cookies.get('token'),
// 当前地址
url: _.get(window, 'location.href', ''),
// 用户设置
...meta
}
})
}
},
mutations: {
/**
* @description 添加日志
* @param {Object} state state
* @param {Object} log data
*/
push(state, log) {
state.log.push(log)
},
/**
* @description 清空日志
* @param {Object} state state
*/
clean(state) {
// store 赋值
state.log = []
}
}
}
// 设置文件
import setting from '@/setting.js'
/**
* 给菜单数据补充上 path 字段
* https://github.com/d2-projects/d2-admin/issues/209
* @param {Array} menu 原始的菜单数据
*/
function supplementMenuPath(menu) {
return menu.map(e => ({
...e,
path: e.path || _.uniqueId('d2-menu-empty-'),
...e.children ? {
children: supplementMenuPath(e.children)
} : {}
}))
}
export default {
namespaced: true,
state: {
// 顶栏菜单
header: [],
// 侧栏菜单
aside: [],
// 侧边栏收缩
asideCollapse: setting.menu.asideCollapse
},
actions: {
/**
* 设置侧边栏展开或者收缩
* @param {Object} context
* @param {Boolean} collapse is collapse
*/
asideCollapseSet({ state, dispatch }, collapse) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = collapse
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'menu.asideCollapse',
value: state.asideCollapse,
user: true
}, { root: true })
// end
resolve()
})
},
/**
* 切换侧边栏展开和收缩
* @param {Object} context
*/
asideCollapseToggle({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = !state.asideCollapse
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'menu.asideCollapse',
value: state.asideCollapse,
user: true
}, { root: true })
// end
resolve(state.asideCollapse)
})
},
/**
* 从持久化数据读取侧边栏展开或者收缩
* @param {Object} context
*/
asideCollapseLoad({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'menu.asideCollapse',
defaultValue: setting.menu.asideCollapse,
user: true
}, { root: true })
// end
resolve()
})
},
has({ state, dispatch }, path) {
return new Promise(async resolve => {
const _in = state.aside.some(obj => {
if (obj.children) {
return obj.path === path || obj.children.some(child => child.path === path)
}
return obj.path === path
})
resolve(_in)
})
},
reset({ state }) {
state.header = []
state.aside = []
state.asideCollapse = setting.menu.asideCollapse
}
},
mutations: {
/**
* @description 设置顶栏菜单
* @param {Object} state state
* @param {Array} menu menu setting
*/
headerSet(state, menu) {
// store 赋值
state.header = supplementMenuPath(menu)
},
/**
* @description 设置侧边栏菜单
* @param {Object} state state
* @param {Array} menu menu setting
*/
asideSet(state, menu) {
// store 赋值
state.aside = supplementMenuPath(menu)
}
}
}
import router from '@/router'
// import setting from '@/setting.js'
import { home, localRoutes } from '@/router/routes'
const INDEX_PATH = '/index'
home.fullPath = INDEX_PATH
// 判定是否需要缓存
const isKeepAlive = data => _.get(data, 'meta.cache', false)
const setIcon = meta => (meta.icon = localRoutes[meta.authId].icon)
export default {
namespaced: true,
state: {
// 可以在多页 tab 模式下显示的页面
pool: [],
// 当前显示的多页面列表
opened: [home],
// 已经加载多标签页数据
openedLoaded: false,
// 当前页面
current: '',
// 需要缓存的页面 name
keepAlive: []
},
actions: {
/**
* @description 确认已经加载多标签页数据
* @param {Object} context
*/
isLoaded({ state }) {
if (state.openedLoaded) return Promise.resolve()
return new Promise(resolve => {
const timer = setInterval(() => {
if (state.openedLoaded) {
resolve(clearInterval(timer))
}
}, 10)
})
},
/**
* @class opened
* @description 从持久化数据载入标签页列表
* @param {Object} context
*/
openedLoad({ state, commit, dispatch }) {
return new Promise(async resolve => {
// store 赋值
let value = await dispatch(
'd2admin/db/get',
{
dbName: 'sys',
path: 'page.opened',
defaultValue: [home],
user: true
},
{ root: true }
)
if (value[0].fullPath !== INDEX_PATH) {
const index = value.some(page => page.fullPath === INDEX_PATH)
if (index) {
value = value.filter(page => page.fullPath !== INDEX_PATH)
}
value.unshift(home)
}
// 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签
// 以 fullPath 字段为准
// 如果页面过多的话可能需要优化算法
// valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效
const valid = []
const __oSource = await dispatch('d2admin/auth/load', null, {
root: true
})
// 处理数据
state.opened = value
.map(opened => {
// 忽略首页
if (opened.fullPath === INDEX_PATH) {
valid.push(1)
setIcon(opened.meta)
return opened
}
// 尝试在所有的支持多标签页的页面里找到 name 匹配的页面
const find = state.pool.find(item => {
return (
item.path === opened.path &&
__oSource.some(obj => +obj.authId === +item.meta.authId)
)
})
// 记录有效或无效信息
valid.push(find ? 1 : 0)
// 返回合并后的数据 新的覆盖旧的
// 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存
return Object.assign({}, opened, find)
})
.filter((opened, index) => valid[index] === 1)
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
state.openedLoaded = true
// 根据 opened 数据生成缓存设置
commit('keepAliveRefresh')
// end
resolve()
})
},
/**
* 将 opened 属性赋值并持久化 在这之前请先确保已经更新了 state.opened
* @param {Object} context
*/
opend2db({ state, dispatch }) {
return new Promise(async resolve => {
// 设置数据
dispatch(
'd2admin/db/set',
{
dbName: 'sys',
path: 'page.opened',
value: state.opened,
user: true
},
{ root: true }
)
// end
resolve()
})
},
/**
* @class opened
* @description 更新页面列表上的某一项
* @param {Object} context
* @param {Object} payload { index, params, query, fullPath } 路由信息
*/
openedUpdate(
{ state, commit, dispatch },
{ page, params, query, fullPath }
) {
return new Promise(async resolve => {
// 更新页面列表某一项
// const page = state.opened[index]
page.params = params || page.params
page.query = query || page.query
page.fullPath = fullPath || page.fullPath
// state.opened.splice(index, 1, page)
// 持久化
await dispatch('opend2db')
// end
resolve()
})
},
/**
* @class opened
* @description 新增一个 tag (打开一个页面)
* @param {Object} context
* @param {Object} payload new tag info
*/
add({ state, commit, dispatch }, { tag, params, query, fullPath }) {
return new Promise(async resolve => {
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
const newTag = tag
newTag.params = params || newTag.params
newTag.query = query || newTag.query
newTag.fullPath = fullPath || newTag.fullPath
setIcon(newTag.meta)
// 添加进当前显示的页面数组
state.opened.push(newTag)
// 如果这个页面需要缓存 将其添加到缓存设置
if (isKeepAlive(newTag)) {
dispatch('keepAlivePush', tag.name)
}
// 持久化
await dispatch('opend2db')
// end
resolve()
})
},
/**
* @class current
* @description 打开一个新的页面
* @param {Object} context
* @param {Object} payload 从路由钩子的 to 对象上获取 { name, params, query, fullPath } 路由信息
*/
open({ state, commit, dispatch }, { name, params, query, fullPath }) {
return new Promise(async resolve => {
// 已经打开的页面
const opened = state.opened
// 判断此页面是否已经打开 并且记录位置
// let pageOpendIndex = 0
const page = opened.find((page, index) => {
const same = page.fullPath === fullPath
// pageOpendIndex = same ? index : pageOpendIndex
return same
})
if (page) {
// 页面以前打开过
await dispatch('openedUpdate', {
page,
params,
query,
fullPath
})
} else {
// 页面以前没有打开过
const page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) {
await dispatch('add', {
tag: Object.assign({}, page),
params,
query,
fullPath
})
}
}
// dispatch('currentSet', fullPath)
// end
resolve()
})
},
/**
* @class opened
* @description 关闭一个 tag (关闭一个页面)
* @param {Object} context
* @param {Object} payload { tagName: 要关闭的标签名字 }
*/
close({ state, commit, dispatch }, { tagName }) {
return new Promise(async resolve => {
// 下个新的页面
let newPage = state.opened[0]
const isCurrent = state.current === tagName
// 如果关闭的页面就是当前显示的页面
if (isCurrent) {
// 去找一个新的页面
const len = state.opened.length
for (let i = 1; i < len; i++) {
if (state.opened[i].fullPath === tagName) {
if (i < len - 1) {
newPage = state.opened[i + 1]
} else {
newPage = state.opened[i - 1]
}
break
}
}
}
// 找到这个页面在已经打开的数据里是第几个
const index = state.opened.findIndex(page => page.fullPath === tagName)
if (index >= 0) {
// 如果这个页面是缓存的页面 将其在缓存设置中删除
dispatch('keepAliveRemove', state.opened[index].name)
// 更新数据 删除关闭的页面
state.opened.splice(index, 1)
}
// 持久化
await dispatch('opend2db')
// 最后需要判断是否需要跳到首页
if (isCurrent) {
const { name = '', params = {}, query = {} } = newPage
const routerObj = {
name,
params,
query
}
router.push(routerObj)
}
// end
resolve()
})
},
/**
* @class opened
* @description 关闭当前标签左边的标签
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeLeft({ dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
await dispatch('_do', {
pageSelect,
call: currentIndex => {
return new Promise(async resolve => {
if (currentIndex > 0) {
// 删除打开的页面 并在缓存设置中删除
await dispatch('_splice', { index: 1, howmany: currentIndex - 1 })
}
resolve()
})
}
})
// end
resolve()
})
},
/**
* @class opened
* @description 关闭当前标签右边的标签
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeRight({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
await dispatch('_do', {
pageSelect,
call: currentIndex => {
return new Promise(async resolve => {
// 删除打开的页面 并在缓存设置中删除
await dispatch('_splice', { index: currentIndex + 1 })
resolve()
})
}
})
resolve()
})
},
/**
* @class opened
* @description 关闭当前激活之外的 tag
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeOther({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
await dispatch('_do', {
pageSelect,
call: currentIndex => {
return new Promise(async resolve => {
// 删除打开的页面数据 并更新缓存设置
if (currentIndex === 0) {
await dispatch('_splice', { index: 1 })
} else {
await dispatch('_splice', { index: currentIndex + 1 })
await dispatch('_splice', { index: 1, howmany: currentIndex - 1 })
}
resolve()
})
}
})
// end
resolve()
})
},
/**
* @class opened
* @description 关闭所有 tag
* @param {Object} context
*/
closeAll({ state, dispatch, commit }) {
return new Promise(async resolve => {
// 删除打开的页面 并在缓存设置中删除
await dispatch('closeOpened')
// dispatch('currentSet', _index)
// 持久化
// await dispatch('opend2db')
router.replace(INDEX_PATH)
// end
resolve()
})
},
/**
* @class opened
* @description 私有公共方法
* @param {Object} context
*/
async _do({ state, dispatch, commit }, { pageSelect, call }) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
state.opened.forEach((page, index) => {
if (page.fullPath === pageAim) {
currentIndex = index
}
})
await call(currentIndex)
// 设置当前的页面
// dispatch('currentSet', pageAim)
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
}
// 持久化
await dispatch('opend2db')
// end
resolve()
})
},
/**
* @class opened
* @description 私有公共方法
* @param {Object} context
*/
_splice({ state, dispatch }, { index, howmany }) {
return new Promise(resolve => {
let _clone = _.cloneDeep(state.opened)
if (howmany !== undefined) {
_clone.splice(index, howmany)
} else {
_clone.splice(index)
}
_clone.forEach(({ name }) => dispatch('keepAliveRemove', name))
state.opened = _clone
resolve()
})
},
/**
* @class current
* @description 设置当前激活的页面 fullPath
* @param {Object} state state
* @param {String} fullPath new fullPath
*/
currentSet({ state, dispatch, commit }, fullPath) {
return new Promise(async resolve => {
await commit('setCurrent', fullPath)
// 设置数据
dispatch(
'd2admin/db/set',
{
dbName: 'sys',
path: 'page.current',
value: state.current,
user: true
},
{ root: true }
)
resolve()
})
},
/**
* @class current
* @description 设置当前激活的页面 fullPath
* @param {Object} state state
* @param {String} fullPath new fullPath
*/
async currentGet({ state, dispatch }, fullPath) {
return new Promise(async resolve => {
const _current = state.current || await dispatch(
'd2admin/db/get',
{
dbName: 'sys',
path: 'page.current',
defaultValue: INDEX_PATH,
user: true
},
{ root: true }
)
const _in = await dispatch('d2admin/menu/has', _current, {
root: true
})
resolve(_in ? _current : INDEX_PATH)
})
},
/**
* @class closeOpened
* @description 关闭所有 打开的页面
* @param {Object} context
*/
closeOpened({ state, dispatch, commit }) {
return new Promise(async resolve => {
// 删除打开的页面 并在缓存设置中删除
await dispatch('_splice', { index: 1 })
// 持久化
await dispatch('opend2db')
// end
resolve()
})
},
/**
* @description 删除一个页面的缓存设置
* @param {Object} state state
* @param {String} name name
*/
keepAliveRemove({ state, dispatch }, name) {
state.keepAlive = state.keepAlive.filter(item => item !== name)
state.opened.find(page => page.name === name).meta.cache = false
dispatch('opend2db')
},
/**
* @description 增加一个页面的缓存设置
* @param {Object} state state
* @param {String} name name
*/
keepAlivePush({ state, dispatch }, name) {
// const keep = [...state.keepAlive]
state.keepAlive.push(name)
state.opened.find(page => page.name === name).meta.cache = true
dispatch('opend2db')
},
reset({ state }) {
state.pool = []
state.opened = [home]
state.openedLoaded = false
state.current = ''
state.keepAlive = []
}
},
mutations: {
/**
* @class keepAlive
* @description 从已经打开���页面记录中更新需要缓存的页面记录
* @param {Object} state state
*/
keepAliveRefresh(state) {
state.keepAlive = state.opened
.filter(item => isKeepAlive(item))
.map(e => e.name)
},
/**
* @description 删除一个页面的缓存设置
* @param {Object} state state
* @param {String} name name
*/
keepAliveRemove(state, name) {
const list = [...state.keepAlive]
const index = list.findIndex(item => item === name)
if (index !== -1) {
list.splice(index, 1)
state.keepAlive = list
}
},
/**
* @description 增加一个页面的缓存设置
* @param {Object} state state
* @param {String} name name
*/
keepAlivePush(state, name) {
const keep = [...state.keepAlive]
keep.push(name)
state.keepAlive = keep
},
/**
* @description 清空页面缓存设置
* @param {Object} state state
*/
keepAliveClean(state) {
state.keepAlive = []
},
/**
* @class pool
* @description 保存 pool (候选池)
* @param {Object} state state
* @param {Array} routes routes
*/
init(state, routes) {
const pool = []
const push = function(routes) {
routes.forEach(route => {
if (route.children) {
push(route.children)
} else {
if (!route.hidden) {
const { meta, name, path } = route
setIcon(meta)
pool.push({ meta, name, path })
}
}
})
}
push(routes)
state.pool = pool
},
setCurrent(state, path) {
return new Promise(resolve => {
state.current = path
resolve()
})
}
}
}
/*
* @Author: chenwq
* @Date: 2019-09-27 11:39:49
* @Last Modified by: chenwq
* @Last Modified time: 2020-01-07 11:15:33
*/
export default {
namespaced: true,
state: {
// 刷新表格
// noFresh - 不需要刷新;fresh - 需要刷新; needFresh - 刷新前标记
value: 'noFresh'
},
getters: {
/**
* 返回刷新表格状态
* @param {*} state
*/
refresh(state) {
return state.value
}
},
mutations: {
/**
* @description 设置表格刷新
* @param {Object} state state
* @param {Boolean} refresh refresh
*/
set(state, refresh) {
return new Promise(resolve => {
state.value = refresh
resolve(true)
})
}
},
actions: {
reset({
state
}) {
state.value = false
}
}
}
import util from '@/libs/util.js'
export default {
namespaced: true,
mutations: {
/**
* @description 显示版本信息
* @param {Object} state state
*/
versionShow() {
util.log.capsule(process.env.VUE_APP_TITLE, `v${process.env.VUE_APP_VERSION}`)
console.log('广联赛讯 http://www.glsx.com.cn')
}
}
}
import setting from '@/setting.js'
export default {
namespaced: true,
state: {
// 搜索面板激活状态
active: false,
// 快捷键
hotkey: {
open: setting.hotkey.search.open,
close: setting.hotkey.search.close
},
// 所有可以搜索的页面
pool: []
},
mutations: {
/**
* @description 切换激活状态
* @param {Object} state state
*/
toggle(state) {
state.active = !state.active
},
/**
* @description 设置激活模式
* @param {Object} state state
* @param {Boolean} active active
*/
set(state, active) {
state.active = active
},
/**
* @description 初始化
* @param {Object} state state
* @param {Array} menu menu
*/
init(state, menu) {
const pool = []
const push = function(menu, titlePrefix = []) {
menu.forEach(m => {
if (m.children) {
push(m.children, [ ...titlePrefix, m.title ])
} else {
pool.push({
...m,
fullTitle: [ ...titlePrefix, m.title ].join(' / ')
})
}
})
}
push(menu)
state.pool = pool
}
},
actions: {
reset({ state }) {
state.active = false
state.hotkey = {
open: setting.hotkey.search.open,
close: setting.hotkey.search.close
}
state.pool = []
}
}
}
import Vue from 'vue'
import router from '@/router'
const size = 'medium' // medium small mini
export default {
namespaced: true,
state: {
// 尺寸
value: ''// medium small mini
},
actions: {
/**
* @description 将当前的设置应用到 element
* @param {Object} context
* @param {Boolean} refresh 是否在设置之后刷新页面
*/
apply({ state, commit }, refresh) {
Vue.prototype.$ELEMENT.size = state.value
if (refresh) {
commit('d2admin/page/keepAliveClean', null, { root: true })
router.replace('/refresh')
}
},
/**
* @description 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
* @param {Object} context
*/
isLoaded({ state }) {
if (state.value) return Promise.resolve()
return new Promise(resolve => {
const timer = setInterval(() => {
if (state.value) {
resolve(clearInterval(timer))
}
}, 10)
})
},
/**
* @description 设置尺寸
* @param {Object} context
* @param {String} size 尺寸
*/
set({ state, dispatch }, size) {
return new Promise(async resolve => {
// store 赋值
state.value = size
// 应用
dispatch('apply', true)
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'size.value',
value: state.value,
user: true
}, { root: true })
// end
resolve()
})
},
/**
* @description 从持久化数据读取尺寸设置
* @param {Object} context
*/
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.value = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'size.value',
defaultValue: size,
user: true
}, { root: true })
// 应用
dispatch('apply')
// end
resolve()
})
},
reset({ state }) {
state.value = ''
}
}
}
// 设置文件
import setting from '@/setting.js'
export default {
namespaced: true,
state: {
// 主题
list: setting.theme.list,
// 现在激活的主题 这应该是一个名字 不是对象
activeName: setting.theme.list[0].name
},
getters: {
/**
* @description 返回当前的主题信息 不是一个名字 而是当前激活主题的所有数据
* @param {Object} state state
*/
activeSetting(state) {
return state.list.find(theme => theme.name === state.activeName)
}
},
actions: {
/**
* @description 激活一个主题
* @param {String} themeValue 需要激活的主题名称
*/
set({ state, commit, dispatch }, themeName) {
return new Promise(async resolve => {
// 检查这个主题在主题列表里是否存在
state.activeName = state.list.find(e => e.name === themeName) ? themeName : state.list[0].name
// 将 vuex 中的主题应用到 dom
commit('dom')
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'theme.activeName',
value: state.activeName,
user: true
}, { root: true })
// end
resolve()
})
},
/**
* @description 从持久化数据加载主题设置 * @param {Object} context
*/
load({ state, commit, dispatch }) {
return new Promise(async resolve => {
// store 赋值
let activeName = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'theme.activeName',
defaultValue: state.list[0].name,
user: true
}, { root: true })
// 检查这个主题在主题列表里是否存在
let __theme = state.list.find(e => e.name === activeName)
if (__theme) {
state.activeName = activeName
} else {
__theme = state.list[0]
state.activeName = __theme.name
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'theme.activeName',
value: state.activeName,
user: true
}, { root: true })
}
const color = await dispatch('d2admin/color/loadFromDB', null, { root: true })
// 设置ui 颜色
await dispatch('d2admin/color/set', color || __theme.color, { root: true })
// 将 vuex 中的主题应用到 dom
commit('dom')
// end
resolve()
})
}
// reset({ state, dispatch }) {
// state.list = setting.theme.list
// state.activeName = setting.theme.list[0].name
// }
},
mutations: {
/**
* @description 将 vuex 中的主题应用到 dom
* @param {Object} state state
*/
dom(state) {
document.body.className = `theme-${state.activeName}`
}
}
}
// 设置文件
import setting from '@/setting.js'
export default {
namespaced: true,
state: {
// 是否开启页面过度动画
active: setting.transition.active
},
actions: {
/**
* @description 设置开启状态
* @param {Object} context
* @param {Boolean} active 新的状态
*/
set({ state, dispatch }, active) {
return new Promise(async resolve => {
// store 赋值
state.active = active
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'transition.active',
value: state.active,
user: true
}, { root: true })
// end
resolve()
})
},
/**
* 从数据库读取页面过渡动画设置
* @param {Object} context
*/
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.active = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'transition.active',
defaultValue: setting.transition.active,
user: true
}, { root: true })
// end
resolve()
})
},
reset({ state }) {
state.active = setting.transition.active
}
}
}
export default {
namespaced: true,
state: {
// 列表搜索框状态
active: true
},
mutations: {
/**
* @description 切换状态
* @param {Object} state state
*/
toggle(state) {
state.active = !state.active
},
/**
* @description 设置搜索框状态
* @param {Object} state state
* @param {Boolean} active active
*/
set(state, active) {
state.active = active
}
},
actions: {
reset({ state }) {
state.active = true
}
}
}
import UAParser from 'ua-parser-js'
export default {
namespaced: true,
state: {
// 用户 UA
data: {}
},
mutations: {
/**
* @description 记录 UA
* @param {Object} state state
*/
get(state) {
state.data = new UAParser().getResult()
}
}
}
const SESSION_NAME = `${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}-user`
export default {
namespaced: true,
state: {
// 用户信息 采用sessionStorage管理 方便判断用户是否关闭浏览器
info: ''
},
actions: {
/**
* @description 设置用户数据
* @param {Object} context
* @param {*} info info
*/
set({ state, dispatch }, info) {
return new Promise(async resolve => {
// store 赋值
state.info = info
// 持久化
// await dispatch('d2admin/db/set', {
// dbName: 'sys',
// path: 'user.info',
// value: info,
// user: true
// }, { root: true })
sessionStorage.setItem(SESSION_NAME, escape(JSON.stringify(info)))
// end
resolve()
})
},
/**
* @description 从数据库取用户数据
* @param {Object} context
*/
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
// state.info = await dispatch('d2admin/db/get', {
// dbName: 'sys',
// path: 'user.info',
// defaultValue: {},
// user: true
// }, { root: true })
state.info = JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME)))
// end
resolve()
})
},
clear({ state }) {
return new Promise(async resolve => {
// await dispatch('d2admin/db/set', {
// dbName: 'database',
// path: 'user',
// value: {},
// user: true
// }, { root: true })
state.info = null
sessionStorage.removeItem(SESSION_NAME)
resolve()
})
},
reset({ dispatch }) {
dispatch('clear')
}
}
}
<!-- 首页 -->
<template>
<d2-container class="indexPage">
<div class="echarts">
<el-row>
<el-col :span="24">
<span style="margin-right: 20px;color:#909399"><d2-el-icon name="s-data"/> 类型</span>
<el-radio-group v-model="radio" @change="getPie">
<el-radio-button
v-for="(item, index) in baseData.subsys"
:key="index"
:value="item.confCode"
:label="item.confValue"
>
</el-radio-button>
</el-radio-group>
</el-col>
<el-col :span="24">
<div id="totalEcharts" style="width: 100%; height: 400px;"></div>
</el-col>
</el-row>
</div>
</d2-container>
</template>
<script>
import { reportApi } from '@api/systemMonitor'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
export default {
name: 'index',
data() {
return {
radio: '全部',
// 绘图
totalECharts: '',
totalOptions: {
title: [{
text: '标题',
x: '49.5%',
y: '8%',
textAlign: 'center'
}],
tooltip: {},
series: [{
name: '在网情况',
type: 'pie',
radius: ['35%', '55%'],
label: {
normal: {
fontSize: 16,
formatter: '{b}: {c}'
}
},
data: [{
name: '在网',
value: 0,
itemStyle: {
color: '#00b639'
}
}, {
name: '离网',
value: 0,
itemStyle: {
color: '#999999'
}
// selected: true
}]
}]
},
baseData: {
station: [],
subsys: []
}
}
},
mounted() {
this.$echarts = echarts
this.loadBaseData()
this.totalECharts = this.$echarts.init(document.getElementById('totalEcharts'))
this.getPie()
},
methods: {
...mapActions('d2admin/base', ['load']),
async loadBaseData() {
/**
* 全局方法-获取公共参数
*/
const { station, subsys } = await this.load()
this.baseData.station = _.cloneDeep(station)
this.baseData.subsys = _.cloneDeep(subsys)
this.baseData.subsys.unshift({ confCode: '', confValue: '全部' })
},
getPie(label = '') {
const params = {
subsystemTypeCode: label ? this.baseData.subsys.find(item => item.confValue === label).confCode : ''
}
reportApi(params).then(res => {
this.drawPie(res)
}).catch(() => {
notice.errorTips()
})
},
// handleEdit() {
// exportApi(this.searchForm).then(res => {
// this.$open(res.url)
// notice.okTips()
// }).catch(() => {
// notice.errorTips()
// })
// }
/* 接口请求-end */
// onlineNum 在网数量
// offlineNum 离网数量
// normalNum 正常数量
// breakdownNum 故障数量
drawPie(params) {
let item = this.totalOptions.series[0]
item.data[0].value = params.onlineNum ? params.onlineNum : 0
item.data[1].value = params.offlineNum ? params.offlineNum : 0
this.totalECharts.setOption(this.totalOptions)
}
}
}
</script>
<style>
</style>
<template>
<div class="page">
<p class="page_title">404 page not found</p>
<el-button class="d2-mt" @click="$router.replace({ path: '/' })">
返回首页
</el-button>
</div>
</template>
<script>
export default {
mounted() {
this.$store.commit('d2admin/page/setCurrent', '')
}
}
</script>
<style lang="scss" scoped>
.page {
background: #303133;
background-blend-mode: multiply,multiply;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.page_title {
font-size: 20px;
color: #FFF;
}
}
</style>
export default {
beforeRouteEnter(to, from, next) {
next(instance => instance.$router.replace(JSON.parse(from.params.route)))
},
render: h => h()
}
export default {
beforeRouteEnter(to, from, next) {
next(instance => instance.$router.replace(from.fullPath))
},
render: h => h()
}
<template>
<d2-container>
<el-table
:data="log"
size="mini"
style="width: 100%"
empty-text="暂无日志信息"
stripe>
<!-- 时间 -->
<el-table-column
prop="time"
label="Time"
width="140">
</el-table-column>
<!-- 信息 -->
<el-table-column
prop="message"
label="Message">
</el-table-column>
<!-- 触发页面 -->
<el-table-column
label="Url"
align="center"
min-width="200">
<template slot-scope="scope">
<p v-text="get(scope.row, 'meta.url')"></p>
</template>
</el-table-column>
<!-- 触发组件 -->
<el-table-column
label="Tag"
align="center"
min-width="120">
<template slot-scope="scope">
<el-tag
v-if="get(scope.row, 'meta.instance.$vnode.componentOptions.tag')"
type="info"
size="mini"
v-text="get(scope.row, 'meta.instance.$vnode.componentOptions.tag')">
</el-tag>
</template>
</el-table-column>
<!-- 查看详情 -->
<el-table-column
fixed="right"
align="center"
label="More"
width="100">
<template slot-scope="scope">
<el-button
type="primary"
size="mini"
@click="handleShowMore(scope.row)">
<d2-icon name="eye"/>
</el-button>
</template>
</el-table-column>
</el-table>
<template slot="footer">
<el-button
type="primary"
size="mini"
:loading="uploading"
@click="handleUpload">
<d2-icon name="cloud-upload"/>
Upload log data
</el-button>
</template>
</d2-container>
</template>
<script>
import { mapState } from 'vuex'
export default {
data() {
return {
uploading: false
}
},
computed: {
...mapState('d2admin/log', [
'log'
])
},
methods: {
get: _.get,
handleShowMore(log) {
// 打印一条日志的所有信息到控制台
this.$notify({
type: 'info',
title: '日志详情',
message: '完整的日志内容已经打印到控制台'
})
this.$log.capsule('D2Admin', 'handleShowMore', 'primary')
console.group(log.message)
console.log('time: ', log.time)
console.log('type: ', log.type)
console.log(log.meta)
console.groupEnd()
},
// 日志上传
handleUpload() {
this.uploading = true
this.$notify({
type: 'info',
title: '日志上传',
message: `开始上传${this.log.length}条日志`
})
setTimeout(() => {
this.uploading = false
this.$notify({
type: 'success',
title: '日志上传',
message: '上传成功'
})
}, 3000)
}
}
}
</script>
<template>
<el-dialog
center
title="用户注册"
:visible.sync="dialogVisible"
:before-close="handleClose"
width="680px"
:close-on-click-modal="false"
custom-class="reg-dialog"
>
<el-form
ref="regForm"
:model="regForm"
label-width="120px"
class="reg-dialog-form"
:rules="rules"
>
<el-form-item label="用户名:" prop="loginName">
<el-input v-model="regForm.loginName" requred maxlength="10" clearable placeholder="请输入用户名" :show-word-limit="true"></el-input>
</el-form-item>
<el-form-item label="密码:" prop="password">
<el-input type="password" v-model="regForm.password" placeholder="请输入密码" clearable maxlength="12" :show-word-limit="true" :show-password="true"></el-input>
</el-form-item>
<el-form-item label="确认密码:" prop="confirm">
<el-input type="password" v-model="regForm.confirm" placeholder="请再输入一次密码" clearable maxlength="12" :show-word-limit="true" :show-password="true"></el-input>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="姓名:" prop="userName">
<el-input v-model="regForm.userName" placeholder="请输入姓名" clearable maxlength="8" :show-word-limit="true"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系方式:" prop="mobile">
<el-input v-model="regForm.mobile" placeholder="请输入联系方式" oninput ="value=value.replace(/[^\d]/g,'')" clearable maxlength="11" :show-word-limit="true"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="所属公司:" prop="companyName">
<el-input v-model="regForm.companyName" placeholder="请输入公司名称" maxlength="32" :show-word-limit="true" clearable ></el-input>
</el-form-item>
<el-form-item label="部门:" prop="departName">
<el-input v-model="regForm.departName" placeholder="请输入部门名称" maxlength="32" :show-word-limit="true" clearable></el-input>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="职务:" prop="postCode">
<el-select v-model="regForm.postCode" placeholder="请选择">
<el-option
:label="post.confValue"
:value="post.confCode"
v-for="(post,index) in baseData.posts"
:key="index"
:disabled="POST_DISABLED.includes(post.confCode)"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属站点:" prop="stationCode">
<el-select v-model="regForm.stationCode" placeholder="请选择" class="sigle-select">
<el-option
:label="station.confValue"
:value="station.confCode"
v-for="(station,index) in baseData.stations"
:key="index"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item flex="main:left cross:center"></el-form-item>
</el-form>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">提交</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { Reg } from '@/api/sys.account'
import { mapActions } from 'vuex'
import notice from '@/common/notice'
import { RegistType, POST_DISABLED } from '@/common/constants'
export default {
name: 'DialogReg',
props: {
isVisible: {
type: Boolean,
default: false
}
},
computed: {
dialogVisible() {
return this.isVisible
}
},
data() {
return {
POST_DISABLED,
company: [],
regForm: {
createType: RegistType.BY_SELF, // 1 自注册 2 管理员创建
loginName: '',
password: '',
confirm: '',
userName: '',
mobile: '',
companyName: '',
departName: '',
postCode: '',
stationCode: ''
},
rules: Object.freeze({
loginName: [
{ required: true, message: '用户名不能为空', trigger: ['blur'] }
],
password: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'))
} else {
if (this.regForm.confirm !== '') {
this.$refs.regForm.validateField('confirm')
}
callback()
}
},
trigger: 'blur'
}
],
confirm: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'))
} else if (value !== this.regForm.password) {
callback(new Error('两次输入密码不一致!'))
} else {
callback()
}
},
trigger: 'blur'
}
],
userName: [
{ required: true, message: '姓名不能为空', trigger: ['blur'] }
],
mobile: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('联系方式不能为空'))
} else {
if (/^1\d{10}$/.test(value)) {
callback()
} else {
return callback(new Error('联系方式错误'))
}
}
},
trigger: ['blur'] }
],
companyName: [
{ required: true, message: '所属公司不能为空', trigger: ['blur'] }
],
departName: [
{ required: true, message: '部门不能为空', trigger: ['blur'] }
],
postCode: [
{ required: true, message: '职务不能为空', trigger: ['blur'] }
],
stationCode: [
{ required: true, message: '所属站点不能为空', trigger: ['blur'] }
]
}),
/* -----------------------基础数据---------------------- */
baseData: {
// 所属站点
stations: [],
// 职务
posts: []
}
}
},
methods: {
...mapActions('d2admin/base', ['init']),
handleClose() {
this.$refs.regForm.resetFields()
this.$event.$emit('e-reg-dialog', false)
},
// 提交注册数据
submit() {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm
Reg(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips('注册信息已提交,请等待管理员审核')
this.handleClose()
} else {
notice.errorTips('注册失败!')
}
})
}
})
},
// 加载业务所需所有数据
async fetchData() {
// // 强制初始化基础数据
const { station, post } = await this.init()
this.baseData.posts = post
this.baseData.stations = station
Object.freeze(this.baseData)
}
},
mounted() {
this.fetchData()
}
}
</script>
<style lang="scss">
$login-dialog-lable-width: 90px;
$login-dialog-font: 13px;
.reg-dialog {
background: #fff;
box-shadow: 0 8px 20px 0 rgba(0, 0, 0, 0.06);
border-radius: 9px;
.reg-dialog-form {
width: 600px;
.el-form-item {
margin-bottom: 20px;
.el-input__inner {
height: 35px;
line-height: 35px;
border-radius: 2px;
}
}
}
.el-dialog__title {
font-size: 20px;
color: #333;
}
.el-dialog__body {
display: flex;
justify-content: center;
padding: 25px 25px 0 30px;
.el-form-item__label {
// width: $login-dialog-lable-width !important;
// text-align: right;
font-size: $login-dialog-font;
}
// .el-form-item__content {
// margin-left: $login-dialog-lable-width;
// font-size: $login-dialog-font;
// }
}
.el-dialog__footer {
padding-top:0;
display: flex;
justify-content: flex-end;
// padding: 0 0 38px 0 !important;
}
.sigle-select {
width: 100%;
}
}
</style>
<template>
<div class="page-login">
<dialog-reg :isVisible="registerDialogVisible" />
<div class="page-login--layer page-login--layer-area">
<ul class="circles">
<li v-for="n in 10" :key="n"></li>
</ul>
</div>
<div class="page-login--layer page-login--layer-time" flex="main:center cross:center"></div>
<div class="page-login--layer">
<div class="page-login--content" flex="dir:top main:justify cross:stretch box:justify">
<div class="page-login--content-header">
<p class="page-login--content-header-motto"></p>
</div>
<div class="page-login--content-main" flex="dir:top main:center cross:center">
<!-- form -->
<div class="page-login--form">
<div class="form-left">
<el-form
ref="loginForm"
label-position="top"
:rules="rules"
:model="formLogin"
size="default"
>
<div class="title-wrap">
<span class="form-title">tFIMS管理系统</span>
<span class="form-sub">让服务更智慧、更直接</span>
</div>
<div class="input-wrap">
<el-form-item prop="loginName">
<el-input
type="text"
v-on:keyup.native.13="submit"
v-model="formLogin.loginName"
placeholder="请输入用户名"
clearable
maxlength="10"
v-focus
>
<d2-el-icon slot="prepend" name="user"></d2-el-icon>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
type="password"
v-model="formLogin.password"
v-on:keyup.native.13="submit"
clearable
maxlength="12"
placeholder="请输入密码"
>
<d2-el-icon slot="prepend" name="key"/>
</el-input>
</el-form-item>
<el-form-item class="form-action">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-login">登录</el-button>
<el-button
@click.prevent="registerDialogVisible = true"
plain
class="button-reg"
>注册</el-button>
</el-form-item>
</div>
</el-form>
</div>
<div class="form-right">
<div class="img-top"></div>
<div class="img-bg"></div>
</div>
</div>
</div>
<div class="page-login--content-footer">
<p class="page-login--content-footer-copyright">
<!-- 版权所有 -->
<!-- <d2-icon name="copyright"/> -->
<!-- -2019 GLSX粤ICP备12020087号 -->
</p>
</div>
</div>
</div>
</div>
</template>
<script>
import dayjs from 'dayjs'
import { mapActions } from 'vuex'
import { LOGIN_TYPE } from '@/common/constants'
export default {
components: {
DialogReg: () => import('./dialogReg')
},
data() {
return {
registerDialogVisible: false,
timeInterval: null,
time: dayjs().format('HH:mm:ss'),
// 表单
formLogin: {
loginName: '',
password: '',
loginType: LOGIN_TYPE
},
// 表单校验
rules: Object.freeze({
loginName: [{
required: true,
message: '请输入用户名',
trigger: 'submit'
}
],
password: [{
required: true,
message: '请输入密码',
trigger: 'submit'
}
]
})
}
},
mounted() {
this.timeInterval = setInterval(() => this.refreshTime(), 1000)
this.$event.$on('e-reg-dialog', res => (this.registerDialogVisible = res))
},
beforeDestroy() {
clearInterval(this.timeInterval)
},
methods: {
...mapActions({
login: 'd2admin/account/login',
current: 'd2admin/page/currentGet'
}),
// ...mapActions('d2admin/account', ['login']),
refreshTime() {
this.time = dayjs().format('HH:mm:ss')
},
// 提交登录信息
submit() {
// console.log(navigator.userAgent.toLocaleLowerCase())
this.$refs.loginForm.validate(valid => {
if (valid) {
const { browser, os } = this.$store.state.d2admin.ua.data
const _p = {
...this.formLogin,
deviceCode: `${os.name}${os.version}-${browser.name}${browser.version}`
}
// 登录
// 注意 这里的演示没有传验证码
// 具体需要传递的数据请自行修改代码
this.login(_p)
// .then(() => this.$store.dispatch('d2admin/auth/init'))
.then(async _ => {
const _current = await this.current()
this.$router.replace(this.$route.query.redirect || _current)
})
}
})
}
}
}
</script>
<style lang="scss">
.page-login {
@extend %unable-select;
$backgroundColor: #2a343d;
// ---
background-color: $backgroundColor;
height: 100%;
position: relative;
// 层
&--layer {
@extend %full;
overflow: auto;
&-area {
overflow: hidden;
}
// 时间
&-time {
font-size: 24em;
font-weight: bold;
color: rgba(0, 0, 0, 0.05);
overflow: hidden;
}
}
// 登陆页面控件的容器
&--content {
height: 100%;
min-height: 500px;
// header
&-header {
padding: 1em 0;
&-motto {
margin: 0px;
padding: 0px;
color: $color-text-normal;
text-align: center;
font-size: 12px;
}
}
// footer
&-footer {
padding: 1em 0;
&-locales {
padding: 0px;
margin: 0px;
margin-bottom: 15px;
font-size: 12px;
line-height: 12px;
text-align: center;
color: $color-text-normal;
a {
color: $color-text-normal;
margin: 0 0.5em;
&:hover {
color: $color-text-main;
}
}
}
&-copyright {
padding: 0px;
margin: 0px;
margin-bottom: 10px;
font-size: 16px;
line-height: 12px;
text-align: center;
color: $color-text-normal;
a {
color: $color-text-normal;
}
}
&-options {
padding: 0px;
margin: 0px;
font-size: 12px;
line-height: 12px;
text-align: center;
a {
color: $color-text-normal;
margin: 0 1em;
}
}
}
}
// 登录表单
&--form {
width: 720px;
height: 400px;
background: #ffffff;
box-shadow: 0 8px 20px 0 rgba(0, 0, 0, 0.06);
border-radius: 16px;
padding: 40px 0 0 37px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
.form-left {
width: 300px;
.title-wrap {
width: 180px;
height: 45px;
margin-bottom: 62px;
.form-title {
font-size: 20px;
color: #333;
line-height: 28px;
}
.form-sub {
font-size: 12px;
color: #999;
line-height: 17px;
float: left;
}
}
.input-warp {
.el-input {
width: 300px;
height: 35px;
margin-bottom: 24px;
background: #ffffff;
border: 1px solid #ddd;
border-radius: 2px;
}
}
.form-action {
.el-button {
width: 145px;
height: 35px;
border-radius: 2px;
letter-spacing: 2px;
font-size: 14px;
line-height: 35px;
display: flex;
justify-content: center;
box-sizing: border-box;
span {
transform: translateY(-12px);
}
}
.button-login {
// background-color: #3D6FE4 !important;
// color: #FFF;
letter-spacing: 2px;
float: left;
}
.button-reg {
border: 1px solid #ddd;
background-color: #fff;
opacity: 0.9;
color: #333;
float: right;
}
}
}
.form-right {
width: 354px;
.img-top {
width: 364px;
height: 24px;
background: url("./image/bz.png");
margin-bottom: 53px;
transform: translateX(-20px);
}
.img-bg {
// box-sizing: border-box;
background: url("./image/bg.png");
width: 322px;
height: 276px;
// border:6px solid #F4F9FF;
}
}
@keyframes login-form-animate {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
animation: login-form-animate 0.5s ease;
}
// 背景
.circles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
margin: 0px;
padding: 0px;
li {
position: absolute;
display: block;
list-style: none;
width: 20px;
height: 20px;
background: #fff;
animation: animate 25s linear infinite;
bottom: -200px;
@keyframes animate {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0.1;
border-radius: 0;
}
100% {
transform: translateY(-1000px) rotate(720deg);
opacity: 0;
border-radius: 50%;
}
}
&:nth-child(1) {
left: 15%;
width: 80px;
height: 80px;
animation-delay: 0s;
}
&:nth-child(2) {
left: 5%;
width: 20px;
height: 20px;
animation-delay: 2s;
animation-duration: 12s;
}
&:nth-child(3) {
left: 70%;
width: 20px;
height: 20px;
animation-delay: 4s;
}
&:nth-child(4) {
left: 40%;
width: 60px;
height: 60px;
animation-delay: 0s;
animation-duration: 18s;
}
&:nth-child(5) {
left: 65%;
width: 20px;
height: 20px;
animation-delay: 0s;
}
&:nth-child(6) {
left: 75%;
width: 150px;
height: 150px;
animation-delay: 3s;
}
&:nth-child(7) {
left: 35%;
width: 200px;
height: 200px;
animation-delay: 7s;
}
&:nth-child(8) {
left: 50%;
width: 25px;
height: 25px;
animation-delay: 15s;
animation-duration: 45s;
}
&:nth-child(9) {
left: 20%;
width: 15px;
height: 15px;
animation-delay: 2s;
animation-duration: 35s;
}
&:nth-child(10) {
left: 85%;
width: 150px;
height: 150px;
animation-delay: 0s;
animation-duration: 11s;
}
}
}
}
</style>
<!-- 查看详情 -->
<template>
<div class="detailDialog">
<el-dialog
:visible.sync="isVisible"
:title="title"
:before-close="handleClose"
:close-on-click-modal="false"
width="860px"
>
<iframe width="100%" height="700px" scrolling="yes" frameborder="0" :src="pdfUrl"></iframe>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'DetailDialog',
data() {
return {
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
title: String,
pdfUrl: String
},
mounted() {},
methods: {
handleClose() {
this.$emit('closeDialog')
}
}
}
</script>
<style lang="scss">
.detailDialog{
.el-dialog__header {
padding: 10px 16px 4px;
background-color: #141516;
.el-dialog__title{
color: #fff;
font-size: 16px;
}
}
.el-dialog__body {
padding: 0;
background-color: #202223
}
}
</style>
<!-- 新增/编辑车辆弹窗 -->
<template>
<div>
<el-dialog
:title="title"
:visible.sync="isVisible"
:before-close="handleClose"
:close-on-click-modal="false"
width="580px"
>
<el-form
:model="editForm"
:rules="rules"
ref="editRuleForm"
label-width="110px"
>
<el-form-item label="订单编号" prop="orderCode">
<el-input v-model="editForm.orderCode" maxlength="14"
:show-word-limit="true" placeholder="请输入订单编号" clearable></el-input>
</el-form-item>
<el-form-item label="申请人" prop="userName">
<el-input v-model="editForm.userName" maxlength="32"
:show-word-limit="true" placeholder="请输入申请人" clearable></el-input>
</el-form-item>
</el-form>
<div slot="footer">
<el-button
type="primary"
@click="handleConfirm"
:loading="$store.state.d2admin.loading.value"
>保存</el-button>
<el-button
@click="handleClose"
>取消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
// import { isExistApi } from '@api/subSysManagement'
// import { isTrafficExistApi } from '@api/trafficManagement'
export default {
name: 'EditDialog',
data() {
return {
disabled: false,
title: '添加子系统',
rules: {
orderCode: [
{ required: true, message: '请输入订单编号', trigger: 'change' }
],
userName: [
{ required: true, message: '请输入申请人', trigger: 'blur' }
]
}
}
},
props: {
isVisible: {
type: Boolean,
default: false
},
editForm: Object
},
watch: {
isVisible(val) {
// this.disabled = !!this.editForm.subsystemCode
this.title = !this.editForm.id ? '添加子系统' : '编辑子系统'
this.$refs.editRuleForm && this.$refs.editRuleForm.resetFields()
}
},
methods: {
// async isCodeExist(rule, value, callback) {
// if (this.editForm.trafficCode && !this.editForm.id) {
// const res = await isExistApi({ subsystemCode: value, trafficCode: this.editForm.trafficCode })
// res.subsystemCode ? callback(new Error(rule.message)) : callback()
// }
// },
// async isTrafficCodeExist(rule, value, callback) {
// if (!this.editForm.id) {
// const res = await isTrafficExistApi({ trafficCode: value })
// res.trafficCode ? callback() : callback(new Error(rule.message))
// }
// },
// isNum(rule, value, callback) {
// const regNum = /^[\d]{4,4}$/
// regNum.test(value) ? callback() : callback(new Error(rule.message))
// },
// isNumOrString(rule, value, callback) {
// const regNum = /^[A-Z\d]{14,14}$/
// regNum.test(value) ? callback() : callback(new Error(rule.message))
// },
// validateCode(value) {
// this.$refs.editRuleForm.validateField('subsystemCode')
// },
handleClose() {
this.$emit('closeDialog')
},
handleConfirm() {
this.$refs.editRuleForm.validate((vaild) => {
if (vaild) {
this.$emit('confirmDialog')
}
})
}
}
}
</script>
<style scoped>
</style>
<!-- 表格组件-使用 -->
<template>
<d2-container>
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="名称">
<el-input
v-model="searchForm.name"
placeholder="请输入名称"
clearable
></el-input>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="createTime"
type="daterange"
value-format="yyyy-MM-dd"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
:id="tableParams.btnId"
>查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="列表标题">
<auth-button
category="Button"
:data="editFormReset"
></auth-button>
</d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableParams="tableParams"
:layout="layout"
:getListApi="getListApi"
:beforeSearchFn="beforeSearchFn"
>
<el-button
type="text"
slot="userName"
slot-scope="scope"
@click="handleClick(scope.scope.userName)"
></el-button>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editForm="editForm"
@closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm"
></edit-dialog>
</d2-container>
</template>
<script>
import EditDialog from './editDialog'
import { getListApi, editApi, removeApi } from '@api/table1'
import notice from '@/common/notice'
import util from '@/libs/util'
export default {
name: 'fimsTable1',
components: {
EditDialog
},
data() {
return {
editVisible: false,
// 搜索
createTime: '',
searchForm: {
name: '',
startTime: '',
endTime: ''
},
editFormReset: {
orderCode: '',
userName: ''
},
editForm: {
id: '',
orderCode: '',
userName: ''
},
// 表格参数
tableParams: {
mutiSelectName: 'table1',
mutiSelectUniqueKey: 'id',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'orderList',
tag: Object.freeze({
type: ['', '', 'info', 'danger', 'warning', 'success'],
label: ['', '状态一', '状态二', '状态三', '状态四', '状态五']
}),
otherTag: Object.freeze({
type: ['', '', 'info', 'danger', 'warning', 'success'],
label: ['', '一', '二', '三', '四', '五']
}),
tableOption: true,
tableColumns: [{
label: '订单编号',
prop: 'orderCode',
minWidth: '200'
}, {
label: '销量',
prop: 'sales',
minWidth: '180',
sortable: 'custom',
// momFlag: 'salesMom',
addSymbol: '元'
}, {
label: '类型',
prop: 'orderType',
width: '120',
formatter: (cellValue) => {
if (cellValue.orderType) {
return {
1: '物料申请',
2: '物料报废'
}[cellValue.orderType]
}
}
}, {
label: '申请人',
prop: 'userName',
addHtml: 'userName',
width: '140'
}, {
label: '状态',
prop: 'status',
tagLabel: true
}, {
label: '状态2',
prop: 'status2',
tagLabel: true,
tagName: 'otherTag'
}]
},
layout: 'sizes, prev, pager, next, jumper, ->, total',
getListApi: getListApi
}
},
watch: {
'createTime'(value) {
Object.assign(this.searchForm, util.formatTime(this.createTime))
}
},
mounted() { },
methods: {
// 在搜索前,特殊操作函数
beforeSearchFn() {
return new Promise((resolve, reject) => {
this.searchForm.name = '改变值--'
resolve()
})
},
handleEditClose() {
this.editVisible = !this.editVisible
},
handleEditConfirm() {
var editParams = JSON.parse(JSON.stringify(this.editForm))
editApi(editParams).then(res => {
notice.okTips()
this.editVisible = false
// 删除操作后,删除表格。d2-admin设置一个ref
this.$refs.table.refreshTable()
}).catch(() => { })
},
// 表格-编辑
handleEdit(row) {
this.editForm = JSON.parse(JSON.stringify(row))
this.handleEditClose()
},
// 批量操作
handleOperate(row) {
this.$notify({
title: '表格中选中的数据如下:',
message: this.$refs.table.mutiSelectArr[this.tableParams.mutiSelectName],
duration: 0
})
},
handleClick(item) {
this.$notify({
title: '申请人:',
message: item,
duration: 0
})
},
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
removeApi({
orderCode: row.orderCode
}).then(() => {
// 删除操作后,删除表格。d2-admin设置一个ref
this.$refs.table.refreshTable()
notice.okTips()
}).catch(() => {
notice.errorTips()
})
}).catch(() => { })
}
}
}
</script>
<style scoped>
</style>
<!-- 物料列表 -->
<template>
<d2-container>
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="名称">
<el-input v-model="searchForm.keyWord" placeholder="请输入名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="物料列表"></d2-table-header>
<d2-table
ref="table"
:searchForm="searchForm"
:tableData="tableData"
:tableTotal="tableTotal"
:tableParams="tableParams"
@refreshTable="getList"
></d2-table>
</d2-container>
</template>
<script>
import { getListApi } from '@api/table2'
import notice from '@/common/notice'
export default {
name: 'fimsTable2',
data() {
return {
searchForm: {
keyWord: ''
},
getListApi: getListApi,
// 表格
tableData: [],
tableTotal: 10,
tableParams: {
listName: 'deviceList',
tableColumns: [{
label: '物料代码',
prop: 'deviceNum',
width: '170'
}, {
label: '物料编码',
prop: 'deviceCode',
width: '170'
}, {
label: 'CRC物料号',
prop: 'crcCode',
width: '170'
}, {
label: '图号',
prop: 'drawNum',
width: '170'
}, {
label: '物料名称',
prop: 'deviceName',
minWidth: '200'
}, {
label: '规格',
prop: 'specifications',
width: '140'
}, {
label: '责任人',
prop: 'responsible',
width: '120'
}]
}
}
},
mounted() {
this.getList()
},
methods: {
getList(page) {
const params = {
...(page || { pageCount: 10, pageSize: 1 }),
...this.searchForm
}
getListApi(params).then(res => {
// console.log(res)
this.tableData = res.data
this.tableTotal = res.pagination.totalCount
}).catch(() => {
notice.errorTips()
})
}
}
}
</script>
<style scoped>
</style>
<!-- 登陆日志 -->
<template>
<d2-container class="loginLogs">
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="用户">
<el-input v-model="searchForm.userName" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<el-form-item label="登录方式">
<el-select v-model="searchForm.loginType" placeholder="请选择" clearable filterable>
<el-option label="PC" value="1"></el-option>
<el-option label="小程序" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="登录时间">
<el-date-picker
v-model="loginTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="登录日志列表"></d2-table-header>
<d2-table
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
></d2-table>
</d2-container>
</template>
<script>
import { getLoginlogs } from '@api/sys.account'
import util from '@/libs/util'
export default {
name: 'FimsLoginLogs',
data() {
return {
getListApi: getLoginlogs,
loginTime: '',
searchForm: {
startTime: '',
endTime: '',
userName: '',
loginType: ''
},
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'loges',
tableColumns: [{
label: '登录时间',
prop: 'loginTime',
width: '200px'
}, {
label: '登录用户',
prop: 'loginName'
}, {
label: '姓名',
prop: 'userName'
}, {
label: '联系电话',
prop: 'mobile',
width: '180px'
}, {
label: '登录方式',
prop: 'loginTypeValue'
}, {
label: '登录设备',
prop: 'deviceCode',
width: '300px'
}]
}
}
},
watch: {
'loginTime'(value) {
Object.assign(this.searchForm, util.formatTime(this.loginTime))
}
},
mounted() {},
methods: {}
}
</script>
<style scoped>
</style>
<template>
<el-dialog
:title="title"
:before-close="handleClose"
:visible.sync="dialogVisible"
width="720px"
custom-class="edit-role-dialog"
:close-on-click-modal="false"
v-if="dialogVisible"
>
<el-form
ref="roleForm"
:model="roleForm"
label-width="120px"
class="edit-dialog-form"
:rules="rules"
>
<el-form-item label="角色名:" prop="roleName">
<el-input v-model="roleForm.roleName" requred maxlength="10" :show-word-limit="true" clearable placeholder="请输入角色名" :disabled="!!roleForm.roleId"></el-input>
</el-form-item>
<el-form-item label="描述:">
<el-input
type="textarea"
:rows="2"
placeholder="角色描述"
clearable
maxlength="50"
:show-word-limit="true"
v-model="roleForm.description">
</el-input>
</el-form-item>
</el-form>
<el-divider content-position="left">权限设置</el-divider>
<RoleTree :resources="resources" :authIds="authIds" ref="roleTree" :close="dialogVisible"></RoleTree>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">保存</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { RoleReg, RoleModify } from '@/api/sys.account'
import notice from '@/common/notice'
import RoleTree from './roleTree'
import { localRoutes } from '@/router/routes'
import util from '@/libs/util.js'
export default {
name: 'editDialog',
props: {
isVisible: {
type: Boolean,
default: false
},
editData: {
type: Object,
default: null
}
},
components: {
RoleTree
},
watch: {
editData: {
handler: function(value) {
this.title = value && value.roleId ? '编辑角色' : '创建角色'
Object.assign(this.roleForm, value)
this.authIds = this.roleForm.authes || []
delete this.roleForm.authes
},
immediate: true
}
},
computed: {
dialogVisible() {
if (!this.isVisible) {
util.resetForm.call(this, 'roleForm')
}
return this.isVisible
},
resources() {
const clone = util.deepClone(Object.values(localRoutes))
const { menus } = util.permision.packMenusBtns(clone)
const all = util.permision.flatten(clone)
menus.find(o => o.authId === '101').disabled = true
return { menus, all }
}
},
data() {
return {
authIds: [],
title: '',
roleForm: {
roleName: '',
description: ''
},
rules: Object.freeze({
roleName: [
{ required: true, message: '角色名不能为空', trigger: ['blur'] }
]
})
}
},
methods: {
handleClose(done) {
this.emitClose(false)
},
emitClose(reload) {
this.$event.$emit('e-role-dialog-close', reload)
reload && this.$refs.roleForm.resetFields()
},
submit() {
this.$refs.roleForm.validate(vaild => {
if (vaild) {
const authIds = this.$refs.roleTree.getCheckedNodes()
var __p = { ...this.roleForm, authIds }
const fMethod = __p.roleId ? RoleModify : RoleReg
fMethod(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${this.title}成功!`)
this.emitClose(true)
} else {
notice.errorTips(`${this.title}失败!`)
}
})
}
})
}
},
mounted() {
}
}
</script>
<style lang="scss">
.edit-role-dialog {
.el-divider--horizontal{
margin: 30px 0px 20px;
}
.role-tree{
height: 443px;overflow-y: auto;
}
}
</style>
<!-- 权限管理 -->
<template>
<d2-container class="role">
<d2-table-header title="角色列表"><auth-button category="action" label="创建角色"></auth-button></d2-table-header>
<d2-table
ref="roleTable"
:tableParams="tableParams"
:pagination="pagination"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
></auth-button>
</d2-table>
<edit-dialog
:isVisible="editVisible"
:editData="editData"
></edit-dialog>
</d2-container>
</template>
<script>
import { RoleList, RoleDetail } from '@/api/sys.account'
// import notice from '@/common/notice'
import { mapActions } from 'vuex'
import { BaseData } from '@/common/constants'
export default {
name: 'FimsRoles',
components: {
'EditDialog': () => import('./editDialog')
},
data() {
return {
getListApi: RoleList,
// 新增/编辑弹窗
editVisible: false,
// 表格
pagination: false,
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'roles',
tableOption: true,
tableColumns: Object.freeze([
{
label: '角色名称',
prop: 'roleName'
},
{
label: '描述',
prop: 'description'
},
{
label: '创建时间',
prop: 'createTime'
}
])
}
}
},
mounted() {
// this.fetchData()
this.$event.$on('e-role-dialog-close', async isReload => {
if (isReload) {
const { roles } = await RoleList()
this.set({ name: BaseData.ROLE.KEY, value: roles })
this.$refs.roleTable.refreshTable()
}
this.editVisible = false
})
},
methods: {
...mapActions('d2admin/base', ['set']),
async handleEdit(row) {
// this.editData = row && await RoleDetail({ roleId: row.roleId })
this.editData = row && Object.assign(row, await RoleDetail({ roleId: row.roleId }))
this.editVisible = true
}
}
}
</script>
<style scoped>
</style>
<template>
<div class="role-tree">
<el-tree
:data="resources.menus"
show-checkbox
ref="tree"
node-key="authId"
:default-expand-all="true"
:check-strictly="true"
@check-change="treeCheckChange"
:expand-on-click-node="true"
>
<span class="role-tree-node" slot-scope="{ node, data }">
<p v-text="node.label"></p>
<div class="role-tree-auth">
<template v-if="data.auth">
<el-checkbox-group size="mini" v-model="checked">
<el-checkbox
v-for="(btn,index) in data.auth"
:key="index"
:label="btn.authId"
@change="(sta)=>btnChange(node,btn,sta)"
><p v-text="btn.label"></p>
</el-checkbox>
</el-checkbox-group>
</template>
</div>
</span>
</el-tree>
</div>
</template>
<script>
export default {
data() {
return { checked: [] }
},
props: {
resources: {
type: Object,
default: null
},
authIds: [],
close: Boolean
},
watch: {
close(value) {
// !value && this.reset();
},
authIds: {
handler(value) {
if (!value) return
const chk = []
const treeChk = ['101']
this.$nextTick(() => {
value.forEach(v => {
v.authId += ''
const node = this.find(v.authId)
if (!node) return true
const check = node.hasOwnProperty('label') ? chk : treeChk
check.push(v.authId)
})
this.$refs.tree.setCheckedKeys(treeChk)
this.checked = chk
})
},
immediate: true
}
},
methods: {
treeCheckChange(node, checked, childChecked) {
// if(node.parentId ==='0') return
// this.checked=checked?[...this.resources.all.filter(res=> res.parentId === node.authId),...this.checked]:this.checked.filter(obj=>obj.parentId!==node.authId)
// !checked && (this.checked = this.checked.filter(obj=>this.resources.all.find( res => res.authId === obj).parentId!==node.authId))
// this.setCheckedNodes()
},
btnChange(node, data, sta) {
const checked = sta // || this.checked.some(child => child.parentId === node.key && child.authId !== data.authId);
checked && this.$refs.tree.setChecked(node.key, checked, true)
// this.setCheckedNodes()
},
getCheckedNodes() {
const { getCheckedKeys, getHalfCheckedKeys } = this.$refs.tree
let checkedIds = [
...getCheckedKeys(),
...getHalfCheckedKeys(),
...this.checked
]
checkedIds = checkedIds.map(node => {
const { authId, parentId } = this.resources.all.find(
res => res.authId === node
)
return { authId, parentId }
})
return checkedIds
// this.$emit('update:authIds', checkedIds)
},
reset() {
this.checked = []
this.$refs.tree.setCheckedKeys([])
// this.$emit('update:authIds', [])
},
find(authId) {
return this.resources.all.find(res => res.authId === authId)
}
}
}
</script>
<style lang="scss">
.role-tree {
padding-left: 30px;
.role-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding: 8px;
}
.el-tree-node__content {
height: 34px;
.el-checkbox {
margin-right: 5px;
.el-checkbox__label {
padding: 0;
}
}
}
&-auth {
word-break: break-all;
word-wrap: break-word;
white-space: normal;
position: absolute;
left: 200px;
padding: 5px 0;
}
}
</style>
<template>
<el-dialog
:title="title"
:visible.sync="dialogVisible"
:before-close="handleClose"
width="720px"
custom-class="reg-dialog-admin"
:close-on-click-modal="false"
v-if="dialogVisible"
:append-to-body="true"
:lock-scroll="false"
>
<el-form
ref="regForm"
:model="regForm"
label-width="120px"
class="reg-dialog-form"
:rules="rules"
>
<el-form-item label="用户名:" prop="loginName">
<el-input
v-model="regForm.loginName"
:disabled="!!regForm.userId"
requred
maxlength="10"
placeholder="请输入用户名"
clearable
:show-word-limit="true"
></el-input>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="姓名:" prop="userName">
<el-input
v-model="regForm.userName"
placeholder="请输入姓名"
maxlength="8"
:show-word-limit="true"
clearable
></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="角色:" prop="roleId">
<el-select v-model="regForm.roleId" placeholder="请选择">
<el-option
:label="role.roleName"
:value="role.roleId"
v-for="(role,index) in baseData.roles"
:key="index"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">提交</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { mapActions } from 'vuex'
import notice from '@/common/notice'
import { RegistType, POST_DISABLED } from '@/common/constants'
import util from '@/libs/util'
export default {
name: 'DialogReg',
props: {
isVisible: {
type: Boolean,
default: false
},
editData: {
type: Object,
default: null
},
verify: {
type: Function,
default: null
}
},
watch: {
editData: {
handler: function(value) {
if (!value || !value.data) return
const { data } = value
const { title, submit } = data
this.title = title
this.submitFunction = submit
delete value.data
Object.assign(this.regForm, value)
},
immediate: true
}
},
computed: {
dialogVisible() {
if (!this.isVisible) {
util.resetForm.call(this, 'regForm')
}
return this.isVisible
}
},
data() {
return {
POST_DISABLED,
regForm: {
createType: RegistType.BY_ADMIN, // 1 自注册 2 管理员创建
loginName: '',
userName: '',
roleId: ''
},
title: '',
submitFunction: null,
rules: Object.freeze({
loginName: [
{ required: true, message: '用户名不能为空', trigger: ['blur'] }
],
userName: [
{ required: true, message: '姓名不能为空', trigger: ['blur'] }
],
// mobile: [
// {
// required: true,
// validator: (rule, value, callback) => {
// if (value === '') {
// callback(new Error('联系方式不能为空'))
// } else {
// if (/^1\d{10}$/.test(value)) {
// callback()
// } else {
// return callback(new Error('联系方式错误'))
// }
// }
// },
// trigger: ['blur']
// }
// ],
// companyName: [
// { required: true, message: '所属公司不能为空', trigger: ['blur'] }
// ],
// departName: [
// { required: true, message: '部门不能为空', trigger: ['blur'] }
// ],
// postCode: [
// { required: true, message: '职务不能为空', trigger: ['blur'] }
// ],
// stationCode: [
// { required: true, message: '所属站点不能为空', trigger: ['blur'] }
// ],
roleId: [{ required: true, message: '角色不能为空', trigger: ['blur'] }]
}),
/* -----------------------基础数据---------------------- */
baseData: {
// 所属站点
stations: [],
// 职务
posts: [],
// roles
roles: []
}
}
},
methods: {
...mapActions('d2admin/base', ['load']),
handleClose(done) {
this.$event.$emit('e-reg-dialog-close', false)
},
// 提交注册或审核数据
submit() {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm
__p.createType = RegistType.BY_ADMIN
// __p.postName = this.baseData.posts.find(post => post.confCode === __p.postCode).confValue
this.submitFunction(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${this.title}成功!`)
this.$refs.regForm.resetFields()
this.$event.$emit('e-reg-dialog-close', true)
} else {
notice.errorTips(`${this.title}失败!`)
}
})
}
})
},
// 加载业务所需所有数据
async fetchData() {
const { role, station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.roles = role.roles
Object.freeze(this.baseData)
}
},
mounted() {
this.fetchData()
}
}
</script>
<!-- 用户管理 -->
<template>
<d2-container class="user">
<el-form :inline="true" :model="searchForm" label-width="85px" slot="header">
<el-form-item label="用户:">
<el-input v-model="searchForm.userName" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<el-form-item label="角色:">
<el-select v-model="searchForm.roleId" clearable placeholder="请选择">
<el-option
v-for="(role,index) in baseData.roles"
:label="role.roleName"
:value="role.roleId"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="注册时间:">
<el-date-picker
v-model="searchTimes"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :id="tableParams.btnId">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="用户列表"><auth-button category="action" label="创建用户"></auth-button></d2-table-header>
<d2-table
ref="userTable"
:searchForm="searchForm"
:tableParams="tableParams"
:getListApi="getListApi"
>
<auth-button
slot="auth-button"
slot-scope="scope"
:data="scope.scope"
:mapping="mapping"
></auth-button>
</d2-table>
<dialog-reg :isVisible="registerDialogVisible" :editData="editData" :key="key"/>
</d2-container>
</template>
<script>
import {
UserList,
PassWordReset,
AccountModify,
AccountIncrease,
AccountForbidden,
AccountValidate,
AccountActived,
Reg
} from '@/api/sys.account'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
import util from '@/libs/util'
export default {
name: 'FimsUsers',
components: {
DialogReg: () => import('./dialogReg')
},
data() {
return {
getListApi: UserList,
key: new Date(),
mapping: Object.freeze({
field: 'status',
'1': ['重置密码', '编辑', '延期', '禁用'],
'2': ['重置密码', '编辑', '激活'],
'3': ['重置密码', '编辑', '激活'],
'4': ['审核']
}),
apiMapping: Object.freeze({
'重置密码': PassWordReset,
'延期': AccountIncrease,
'禁用': AccountForbidden,
'激活': AccountActived
}),
// 新增/编辑弹窗
registerDialogVisible: false,
editData: {},
// 搜索
searchForm: {
userName: '',
status: '',
stationCode: '',
postCode: '',
startTime: '',
endTime: ''
},
searchTimes: [],
// 表格
// 表格参数
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'userList',
tag: Object.freeze({
type: ['', 'success', 'info', 'danger', 'warning'],
label: ['未知', '正常', '已过期', '禁用', '待审核']
}),
tableOption: true,
tableColumns: [{
label: '用户名',
prop: 'loginName',
width: '200'
}, {
label: '角色',
prop: 'roleName',
width: '140'
}, {
label: '注册时间',
prop: 'registerTime',
minWidth: '200'
}, {
label: '有效期',
prop: 'validTime',
minWidth: '200'
}, {
label: '状态',
prop: 'status',
width: '120',
tagLabel: true
}, {
label: '姓名',
prop: 'userName',
width: '120'
}]
},
/* -----------------------基础数据---------------------- */
baseData: {
// 所属站点
stations: [],
// 职务
posts: [],
// 角色
roles: []
}
}
},
watch: {
'searchTimes'(value) {
Object.assign(this.searchForm, util.formatTime(this.searchTimes))
},
'$store.state.d2admin.base.role'(value) {
this.baseData.roles = value
this.key = new Date()
}
},
mounted() {
this.fetchData()
this.$event.$on('e-reg-dialog-close', isReload => {
isReload && this.$refs.userTable.refreshTable()
this.registerDialogVisible = false
})
},
methods: {
...mapActions('d2admin/base', ['load']),
// 加载业务所需所有数据
fetchData() {
this.loadBaseData()
},
async loadBaseData() {
const { role, station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.roles = role.roles
Object.freeze(this.baseData)
},
/* 接口请求-start */
filterTag(value, row) {
return row.status === value
},
handleRegister() {
const row = {
data: {
title: '用户创建',
submit: Reg
}
}
this.openDialog(row)
},
handleEdit(row) {
row = util.deepClone(row)
row.data = {
title: '用户编辑',
submit: AccountModify
}
this.openDialog(row)
},
openDialog(row) {
this.registerDialogVisible = true
this.editData = row
},
handleVerify(row) {
row = util.deepClone(row)
row.data = {
title: '用户审核',
submit: AccountValidate
}
this.openDialog(row)
},
// ------------
// 列表各种操作
async handleOperation(row, e) {
const _actionText = e.target.innerText
const res = await this.apiMapping[_actionText]({ userId: row.userId })
const { operateStatus } = res
if (operateStatus) {
notice.okTips(`${_actionText}成功!`)
this.$refs.userTable.refreshTable()
} else {
notice.errorTips(`${_actionText}失败!`)
}
}
}
}
</script>
<style scoped>
</style>
File mode changed
module.exports = {
index: '主页',
'customer/glsx': '广联赛讯'
}
# Vue Filename Injector
Inject the file path of the `.vue` on `this.$options.__source`.
## Usage
`vue.config.js`:
``` js
const VueFilenameInjector = require('./path/to/vue-filename-injector')
module.exports = {
chainWebpack: config => {
// only with chainWebpack
VueFilenameInjector(config, {
propName: '__source' // default
})
}
}
```
## Relevant
https://github.com/neutrinojs/webpack-chain
https://vue-loader.vuejs.org/guide/custom-blocks.html
const all = require('./src/index.js')
module.exports = all
const { blockName } = require('./lib/config.js')
// for chainWebpack
module.exports = function(config, options) {
config.module
.rule('vue')
.use('vue-filename-injector')
.loader(require.resolve('./lib/injector.js'))
.options(options)
.after('vue-loader')
.end()
config.module
.rule('')
.resourceQuery(new RegExp(`blockType=${blockName}`))
.use('vue-filename-injector-loader')
.loader(require.resolve('./lib/loader.js'))
.end()
}
const defaultPropName = '__source'
const blockName = 'vue-filename-injector'
module.exports = {
defaultPropName,
blockName
}
const path = require('path')
const loaderUtils = require('loader-utils')
const { blockName, defaultPropName } = require('./config.js')
module.exports = function (content /*, map, meta */) {
const loaderContext = this
const {
rootContext,
resourcePath
} = loaderContext
const context = rootContext || process.cwd()
const options = loaderUtils.getOptions(loaderContext) || {}
const rawShortFilePath = path
.relative(context, resourcePath)
.replace(/^(\.\.[\/\\])+/, '')
const propName = options.propName || defaultPropName
content += `
<${blockName}>
export default function (Component) {
Component.options.${propName} = ${JSON.stringify(rawShortFilePath.replace(/\\/g, '/'))}
}
</${blockName}>
`
return content
}
module.exports = function (source, map) {
this.callback(null, source, map)
}
const VueFilenameInjector = require('./tools/vue-filename-injector')
const ThemeColorReplacer = require('webpack-theme-color-replacer')
const forElementUI = require('webpack-theme-color-replacer/forElementUI')
// 拼接路径
const resolve = dir => require('path').join(__dirname, dir)
// 增加环境变量
process.env.VUE_APP_VERSION = require('./package.json').version
process.env.VUE_APP_BUILD_TIME = require('dayjs')().format('YYYY-M-D HH:mm:ss')
// 基础路径 注意发布之前要先修改这里
let publicPath = '/'
const CDN_DOMAIN = 'https://cdn.bootcss.com'
const cdn = {
css: [
`${CDN_DOMAIN}/element-ui/2.11.1/theme-chalk/index.css`,
`${CDN_DOMAIN}/nprogress/0.2.0/nprogress.min.css`
],
js: [
`${CDN_DOMAIN}/vue/2.6.10/vue.min.js`,
`${CDN_DOMAIN}/vue-router/3.0.6/vue-router.min.js`,
`${CDN_DOMAIN}/element-ui/2.11.1/index.js`,
`${CDN_DOMAIN}/vuex/3.1.1/vuex.min.js`,
`${CDN_DOMAIN}/axios/0.19.0/axios.min.js`,
`${CDN_DOMAIN}/js-cookie/2.2.0/js.cookie.min.js`,
`${CDN_DOMAIN}/nprogress/0.2.0/nprogress.min.js`,
`${CDN_DOMAIN}/echarts/4.3.0-rc.1/echarts.min.js`,
`${CDN_DOMAIN}/lodash.js/4.17.15/lodash.min.js`,
`${CDN_DOMAIN}/qs/6.8.0/qs.min.js`,
// `${CDN_DOMAIN}/core-js/2.6.9/core.min.js`,
// `${CDN_DOMAIN}/vue-i18n/8.14.0/vue-i18n.esm.js`,
`${CDN_DOMAIN}/UAParser.js/0.7.20/ua-parser.min.js`,
'https://unpkg.com/better-scroll@1.15.2/dist/bscroll.min.js'
]
}
module.exports = {
publicPath, // 根据你的实际情况更改这里
lintOnSave: true,
devServer: {
publicPath // 和 publicPath 保持一致
},
css: {
loaderOptions: {
// 设置 scss 公用变量文件
sass: {
data: '@import \'~@/assets/style/public.scss\';'
}
}
},
configureWebpack: config => {
config.externals = {
'vue': 'Vue',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'axios': 'axios',
'js-cookie': 'Cookies',
'nprogress': 'NProgress',
'echarts': 'echarts',
'lodash': '_',
// 'vue-i18n':'vue-i18n',
'ua-parser-js': 'UAParser',
'better-scroll': 'BScroll',
'qs': 'Qs'
// 'core-js': 'core-js'
}
// 非开发环境
if (process.env.NODE_ENV !== 'development') {
config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
}
// const Plugins = [
// new MiniCssExtractPlugin({
// // Options similar to the same options in webpackOptions.output
// // both options are optional
// filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
// chunkFilename: devMode ? 'css/[id].css' : 'css/[id].[hash].css',
// })]
// config.plugins = [...config.plugins, ...Plugins]
},
// 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
chainWebpack: config => {
/**
* 删除懒加载模块的 prefetch preload,降低带宽压力
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
resolveCss(resultCss) { // optional. Resolve result css code as you wish.
return resultCss.replace(/process.env.VUE_APP_ELEMENT_COLOR/g, process.env.VUE_APP_ELEMENT_COLOR)
},
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
// sourcemap不包含列信息
config => config.devtool('cheap-source-map')
)
// TRAVIS 构建 vue-loader 添加 filename
.when(process.env.VUE_APP_BUILD_MODE === 'TRAVIS' || process.env.NODE_ENV === 'development',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// svg
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.include
.add(resolve('src/assets/svg-icons/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'd2-[name]'
})
.end()
// image exclude
const imagesRule = config.module.rule('images')
imagesRule
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/)
.exclude
.add(resolve('src/assets/svg-icons/icons'))
.end()
// 重新设置 alias
config.resolve.alias
.set('@', resolve('src'))
.set('@api', resolve('src/api'))
config.plugin('html')
.tap(args => {
// args[0].minify.removeComments = false;
args[0].cdn = cdn
return args
})
// if (process.env.NODE_ENV === 'development') {
// config
// .plugin('webpack-bundle-analyzer')
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
// }
// 判断环境加入模拟数据
// const entry = config.entry('app')
// if (process.env.VUE_APP_BUILD_MODE !== 'nomock') {
// entry
// .add('@/mock')
// .end()
// }
},
// i18n
pluginOptions: {
i18n: {
locale: 'zh-chs',
fallbackLocale: 'en',
localeDir: 'locales',
enableInSFC: true
}
}
}
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!