Commit 10753c5a by cwq0219

合并

2 parents 014bcf9e f61b334b
Showing 109 changed files with 555 additions and 538 deletions
......@@ -3,12 +3,8 @@
# 页面 title 前缀
VUE_APP_TITLE=tFIMS
# 网络请求开发地址
# VUE_APP_API=http://192.168.3.191:8944/router
# 网络请求mock测试地址
# VUE_APP_API=http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
# 网络请求公用地址
VUE_APP_API=http://tfims.test.glsx.com.cn/router
VUE_APP_API=http://tfims.test.glsx.com.cn/router
# 仓库地址
VUE_APP_REPO=http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
......@@ -18,4 +14,6 @@ VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_ELEMENT_COLOR=#409EFF
VUE_APP_MAIN_COLOR=#3D6FE4
\ No newline at end of file
VUE_APP_MAIN_COLOR=#3D6FE4
VUE_APP_STORAGE_PREFIX=tfims
\ No newline at end of file
......@@ -2,3 +2,5 @@
# 页面 title 前缀
VUE_APP_TITLE=TFims Dev
# 网络请求开发地址
VUE_APP_API=http://192.168.3.191:8944/router
\ No newline at end of file
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
node: true
browser: true
},
'extends': [
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',
'@vue/standard'
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
// required to lint *.vue files
plugins: ['vue'],
globals: {
NODE_ENV: false,
_:false,
echarts:false
},
parserOptions: {
parser: 'babel-eslint'
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
......@@ -3,7 +3,7 @@ var app = express()
app.use(express.static('./dist'))
app.get('/', function (req, res) {
app.get('/', function(req, res) {
res.send('Hello Vue')
})
......
import request from './request'
const path = 'fims.device.'
function getListApi (data) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function editApi (data) {
function editApi(data) {
data.method = `${path}edit`
return request(data)
}
function removeApi (data) {
function removeApi(data) {
data.method = `${path}remove`
return request(data)
}
......@@ -22,12 +22,12 @@ function removeApi (data) {
// return request(data, 'post', noSignAttr)
// }
function exportApi (data) {
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
function isExistApi (data) {
function isExistApi(data) {
data.method = `${path}detail`
return request(data)
}
......
......@@ -2,17 +2,17 @@ import request from './request'
const path = 'fims.maintains.'
function getListApi (data) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function removeApi (data) {
function removeApi(data) {
data.method = `${path}delete`
return request(data)
}
function exportApi (data) {
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
......
......@@ -2,27 +2,27 @@ import request from './request'
const path = 'fims.order.'
function getListApi (data) {
function getListApi(data) {
data.method = `${path}search`
return request(data)
}
function detailApi (data) {
function detailApi(data) {
data.method = `${path}detail`
return request(data)
}
function removeApi (data) {
function removeApi(data) {
data.method = `${path}delete`
return request(data)
}
function exportApi (data) {
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
function downloadApi (data) {
function downloadApi(data) {
data.method = `${path}download`
return request(data)
}
......
......@@ -2,7 +2,7 @@ import request from './request'
const path = 'fims.material.'
function getListApi (data) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
......
import request from './request'
import RequestMethods from './request.methods'
const path = 'fims.'
export function searchReportLog (data) {
export function searchReportLog(data) {
data.method = `${path}reportlog.search`
return request(data)
}
export function searchDepot (data) {
data.method = `fims.configuration.from.conftype`
export function searchDepot(data) {
data.method = 'fims.configuration.from.conftype'
return request(data)
}
......@@ -2,12 +2,12 @@ import request from './request'
const path = 'fims.reportlog.'
function getLogsApi (data) {
function getLogsApi(data) {
data.method = `${path}search`
return request(data)
}
function exportApi (data) {
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
......
......@@ -6,21 +6,21 @@ const methods = {
Edit: `${path}edit`
}
function getListApi (data) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function editApi (data) {
function editApi(data) {
return request(data)
}
function removeApi (data) {
function removeApi(data) {
data.method = `${path}remove`
return request(data)
}
function isExistApi (data) {
function isExistApi(data) {
data.method = `${path}detail`
return request(data)
}
......
......@@ -2,25 +2,25 @@
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-10 17:10:53
* @Last Modified time: 2019-09-11 19:09:21
*/
import request from './request'
import RequestMethods from './request.methods'
// 用户相关
const user_path = 'fims.user.'
const USER_PATH = 'fims.user.'
// 角色相关
const role_path = 'fims.role.'
const ROLE_PATH = 'fims.role.'
export const LOGIN_URL = `${user_path}login`
export const Reg_URL = `${user_path}register`
export const Role_LIST_URL = `${role_path}list`
export const LOGIN_URL = `${USER_PATH}login`
export const REG_URL = `${USER_PATH}register`
export const ROLE_LIST_URL = `${ROLE_PATH}list`
/**
* 用户登录
* @param {*} data 参数
*/
export function AccountLogin (data) {
export function AccountLogin(data) {
data.method = LOGIN_URL
return request(data, RequestMethods.POST)
}
......@@ -29,8 +29,8 @@ export function AccountLogin (data) {
* 注册
* @param {*} data 参数
*/
export function Reg (data = {}) {
data.method = Reg_URL
export function Reg(data = {}) {
data.method = REG_URL
return request(data, RequestMethods.GET)
}
......@@ -38,8 +38,8 @@ export function Reg (data = {}) {
* 修改密码
* @param {*} data
*/
export function ModifyPassword (data) {
data.method = `${user_path}password.modify`
export function ModifyPassword(data) {
data.method = `${USER_PATH}password.modify`
return request(data, RequestMethods.POST)
}
......@@ -47,8 +47,8 @@ export function ModifyPassword (data) {
* 获取用户列表
* @param {*} data 参数
*/
export function UserList (data = {}) {
data.method = `${user_path}search`
export function UserList(data = {}) {
data.method = `${USER_PATH}search`
return request(data, RequestMethods.GET)
}
......@@ -56,8 +56,8 @@ export function UserList (data = {}) {
* 重置密码
* @param {*} data 参数
*/
export function PassWordReset (data = {}) {
data.method = `${user_path}password.reset`
export function PassWordReset(data = {}) {
data.method = `${USER_PATH}password.reset`
return request(data, RequestMethods.GET)
}
......@@ -65,8 +65,8 @@ export function PassWordReset (data = {}) {
* 帐户编辑
* @param {*} data 参数
*/
export function AccountModify (data = {}) {
data.method = `${user_path}modify`
export function AccountModify(data = {}) {
data.method = `${USER_PATH}modify`
return request(data, RequestMethods.GET)
}
......@@ -74,8 +74,8 @@ export function AccountModify (data = {}) {
* 帐户延期
* @param {*} data 参数
*/
export function AccountIncrease (data = {}) {
data.method = `${user_path}validity.increase`
export function AccountIncrease(data = {}) {
data.method = `${USER_PATH}validity.increase`
return request(data, RequestMethods.GET)
}
......@@ -83,8 +83,8 @@ export function AccountIncrease (data = {}) {
* 帐户禁用
* @param {*} data 参数
*/
export function AccountForbidden (data = {}) {
data.method = `${user_path}forbidden`
export function AccountForbidden(data = {}) {
data.method = `${USER_PATH}forbidden`
return request(data, RequestMethods.GET)
}
......@@ -92,8 +92,8 @@ export function AccountForbidden (data = {}) {
* 帐户激活
* @param {*} data 参数
*/
export function AccountActived (data = {}) {
data.method = `${user_path}actived`
export function AccountActived(data = {}) {
data.method = `${USER_PATH}actived`
return request(data, RequestMethods.GET)
}
......@@ -101,8 +101,8 @@ export function AccountActived (data = {}) {
* 帐户审核
* @param {*} data 参数
*/
export function AccountValidate (data = {}) {
data.method = `${user_path}check`
export function AccountValidate(data = {}) {
data.method = `${USER_PATH}check`
return request(data, RequestMethods.GET)
}
......@@ -110,8 +110,8 @@ export function AccountValidate (data = {}) {
* 获取登录日志
* @param {} data
*/
export function getLoginlogs (data) {
data.method = `${user_path}search.loginlog`
export function getLoginlogs(data) {
data.method = `${USER_PATH}search.loginlog`
return request(data)
}
......@@ -119,8 +119,8 @@ export function getLoginlogs (data) {
* 获取角色权限资源列表
* @param {*} data 参数
*/
export function RoleAuthData (data = {}) {
data.method = `${role_path}authority.data`
export function RoleAuthData(data = {}) {
data.method = `${ROLE_PATH}authority.data`
return request(data, RequestMethods.GET)
}
......@@ -128,8 +128,8 @@ export function RoleAuthData (data = {}) {
* 创建角色
* @param {*} data 参数
*/
export function RoleReg (data = {}) {
data.method = `${role_path}register`
export function RoleReg(data = {}) {
data.method = `${ROLE_PATH}register`
return request(data, RequestMethods.GET)
}
......@@ -137,8 +137,8 @@ export function RoleReg (data = {}) {
* 权限修改
* @param {*} data 参数
*/
export function RoleModify (data = {}) {
data.method = `${role_path}modify`
export function RoleModify(data = {}) {
data.method = `${ROLE_PATH}modify`
return request(data, RequestMethods.GET)
}
......@@ -146,8 +146,8 @@ export function RoleModify (data = {}) {
* 权限列表
* @param {*} data 参数
*/
export function RoleList (data = {}) {
data.method = Role_LIST_URL
export function RoleList(data = {}) {
data.method = ROLE_LIST_URL
return request(data, RequestMethods.GET)
}
......@@ -155,7 +155,7 @@ export function RoleList (data = {}) {
* 角色详情
* @param {*} data 参数
*/
export function RoleDetail (data = {}) {
data.method = `${role_path}detail`
export function RoleDetail(data = {}) {
data.method = `${ROLE_PATH}detail`
return request(data, RequestMethods.GET)
}
......@@ -2,13 +2,13 @@
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-05 18:01:21
* @Last Modified time: 2019-09-11 19:09:15
*/
import request from './request'
import RequestMethods from './request.methods'
export const BaseDataURL = 'fims.configuration.from.conftype'
export const BASE_DATA_URL = 'fims.configuration.from.conftype'
// 基础数据
const path = 'fims.base.'
......@@ -16,7 +16,7 @@ const path = 'fims.base.'
* 获取站点列表
* @param {*} data 参数
*/
export function StationList (data = {}) {
export function StationList(data = {}) {
data.method = `${path}station`
return request(data, RequestMethods.GET)
}
......@@ -24,7 +24,7 @@ export function StationList (data = {}) {
* 获取公司列表
* @param {*} data 参数
*/
export function CompanyList (data = {}) {
export function CompanyList(data = {}) {
data.method = `${path}company`
return request(data, RequestMethods.GET)
}
......@@ -32,7 +32,7 @@ export function CompanyList (data = {}) {
* 获取部门列表
* @param {*} data 参数
*/
export function DepartList (data = {}) {
export function DepartList(data = {}) {
data.method = `${path}depart`
return request(data, RequestMethods.GET)
}
......@@ -41,8 +41,8 @@ export function DepartList (data = {}) {
* 获取角色列表
* @param {*} data 参数
*/
export function FetchRoleList (data = {}) {
data.method = `fims.role.list`
export function FetchRoleList(data = {}) {
data.method = 'fims.role.list'
return request(data, RequestMethods.GET)
}
......@@ -50,7 +50,7 @@ export function FetchRoleList (data = {}) {
* 获取职务列表
* @param {*} data 参数
*/
export function PostList (data = {}) {
export function PostList(data = {}) {
data.method = `${path}post`
return request(data, RequestMethods.GET)
}
......@@ -59,7 +59,7 @@ export function PostList (data = {}) {
* 获取基础数据
* @param {*} data 参数
*/
export function BaseDataApi (data = {}) {
data.method = BaseDataURL
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) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function reportApi (data) {
function reportApi(data) {
data.method = `${path}report`
return request(data)
}
function exportApi (data) {
function exportApi(data) {
data.method = `${path}export`
return request(data)
}
......
......@@ -6,22 +6,22 @@ const methods = {
Edit: `${path}edit`
}
function getListApi (data) {
function getListApi(data) {
data.method = `${path}list`
return request(data)
}
function editApi (data) {
function editApi(data) {
// data.method = `${path}edit`
return request(data)
}
function removeApi (data) {
function removeApi(data) {
data.method = `${path}remove`
return request(data)
}
function isExistApi (data) {
function isExistApi(data) {
data.method = `${path}detail`
return request(data)
}
......
......@@ -2,11 +2,11 @@
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-10 10:32:06
* @Last Modified time: 2019-09-11 19:09:01
*/
import { LOGIN_URL, REG_URL, Role_LIST_URL } from '@/api/sys.account'
import { BaseDataURL } from '@/api/sys.base'
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'
/**
......@@ -40,8 +40,8 @@ export const RegistType = {
export const LogExternals = [
LOGIN_URL, // 登录
REG_URL, // 注册
BaseDataURL, // 基础数据
Role_LIST_URL // 角色列表
BASE_DATA_URL, // 基础数据
ROLE_LIST_URL // 角色列表
]
/**
* 登录来源
......
......@@ -2,19 +2,19 @@ import Vue from 'vue'
export default new Vue({
methods: {
warningTips (message) {
warningTips(message) {
this.$notify({
type: 'warning',
title: message
})
},
okTips (message) {
okTips(message) {
this.$notify({
type: 'success',
title: message || '操作成功'
})
},
errorTips (message) {
errorTips(message) {
this.$notify({
type: 'error',
title: message || '操作失败'
......
......@@ -21,11 +21,11 @@ export default {
mixins: [
scroll
],
mounted () {
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy () {
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
......
......@@ -15,14 +15,13 @@
<script>
import scroll from './mixins/normal'
import { mapState } from 'vuex'
export default {
name: 'd2-container-full',
mixins: [scroll],
components: {
d2HeaderSwitch: () => import('./d2-header-switch.vue')
},
data () {
data() {
return {
oHeaderStyle: {
padding: '20px 20px 0 20px'
......@@ -30,15 +29,15 @@ export default {
}
},
computed: {
active () {
active() {
return this.$store.state.d2admin.tsearch.active
}
},
mounted () {
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy () {
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
......
......@@ -19,11 +19,11 @@ export default {
mixins: [
scroll
],
mounted () {
mounted() {
// 增加滚动事件监听
this.addScrollListener()
},
beforeDestroy () {
beforeDestroy() {
// 移除滚动事件监听
this.removeScrollListener()
}
......
......@@ -11,24 +11,24 @@
<script>
import { mapMutations } from 'vuex'
export default {
data () {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show () {
show() {
return true
}
},
mounted () {
setTimeout(() => this.isActive = true, 0)
mounted() {
setTimeout(() => (this.isActive = true), 0)
},
methods: {
...mapMutations('d2admin/tsearch', ['toggle']),
// 点击按钮的时候跳转到源代码
handleClick () {
handleClick() {
this.toggle()
}
}
......
......@@ -9,28 +9,27 @@
</template>
<script>
import { last, get } from 'lodash'
export default {
data () {
data() {
return {
isActive: false,
path: ''
}
},
computed: {
show () {
show() {
return process.env.VUE_APP_BUILD_MODE === 'TRAVIS' || process.env.NODE_ENV === 'development'
}
},
watch: {
$route: {
handler (to) {
handler(to) {
this.path = _.get(_.last(to.matched), 'components.default.__source')
},
immediate: true
}
},
mounted () {
mounted() {
// 一秒后显示按钮
setTimeout(() => {
this.isActive = true
......@@ -38,7 +37,7 @@ export default {
},
methods: {
// 点击按钮的时候跳转到源代码
handleClick () {
handleClick() {
this.$open(`${process.env.VUE_APP_REPO}/blob/master/${this.path}`)
}
}
......
......@@ -8,19 +8,19 @@ export default {
default: () => ({})
}
},
data () {
data() {
return {
BS: null
}
},
mounted () {
mounted() {
this.scrollInit()
},
beforeDestroy () {
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit () {
scrollInit() {
// 初始化 bs
this.BS = new BScroll(this.$refs.wrapper, Object.assign({
mouseWheel: true,
......@@ -36,7 +36,7 @@ export default {
y: -y
}))
},
scrollDestroy () {
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
......@@ -46,11 +46,11 @@ export default {
}
},
// 外部调用的方法 返回顶部
scrollToTop () {
scrollToTop() {
if (this.BS) this.BS.scrollTo(0, 0, 300)
},
// 手动发出滚动事件
scroll () {
scroll() {
if (this.BS) {
this.$emit('scroll', {
x: -this.BS.x,
......
// 提供滚动方面的功能
// 非滚动优化模式通用
import { throttle } from 'lodash'
// 生成滚动事件的 handler
function handleMaker (wait) {
function handleMaker(wait) {
return _.throttle(e => {
this.$emit('scroll', {
x: e.target.scrollLeft,
......@@ -22,13 +20,13 @@ export default {
default: 10
}
},
data () {
data() {
return {
handleScroll: null
}
},
watch: {
scrollDelay (val) {
scrollDelay(val) {
// 移除旧的监听
this.removeScrollListener()
// 生成新的 handle 方法
......@@ -39,7 +37,7 @@ export default {
},
methods: {
// 增加滚动事件监听
addScrollListener () {
addScrollListener() {
if (typeof this.handleScroll !== 'function') {
// mounted 生命周期内调用这个方法的时候会进入这里的判断
this.handleScroll = handleMaker.call(this, this.scrollDelay)
......@@ -48,11 +46,11 @@ export default {
this.$refs.body.addEventListener('scroll', this.handleScroll)
},
// 移除滚动事件监听
removeScrollListener () {
removeScrollListener() {
this.$refs.body.removeEventListener('scroll', this.handleScroll)
},
// 外部调用的方法 返回顶部
scrollToTop () {
scrollToTop() {
const smoothscroll = () => {
const body = this.$refs.body
const currentScroll = body.scrollTop
......
......@@ -25,7 +25,7 @@ export default {
},
computed: {
// 始终返回渲染组件
component () {
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
......@@ -37,7 +37,7 @@ export default {
}
}
},
render (h) {
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 ]))
......@@ -57,14 +57,14 @@ export default {
},
methods: {
// 返回顶部
scrollToTop () {
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) {
scrollBy(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
......@@ -77,7 +77,7 @@ export default {
}
},
// 用法同原生方法 scrollTo
scrollTo (x = 0, y = 0, time = 300) {
scrollTo(x = 0, y = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
......@@ -90,7 +90,7 @@ export default {
}
},
// 用法同原生方法 scrollTop
scrollTop (top = 0, time = 300) {
scrollTop(top = 0, time = 300) {
if (this.betterScroll) {
const bs = this.$refs.component.BS
if (bs) {
......
......@@ -14,7 +14,7 @@ export default {
}
},
computed: {
icon () {
icon() {
return `#d2-${this.name}`
}
}
......
......@@ -7,7 +7,7 @@
export default {
name: 'focus',
inserted: function (el) {
inserted: function(el) {
el.querySelector('input').focus()
}
}
......@@ -4,7 +4,7 @@ import util from '@/libs/util'
Vue.use(VueI18n)
function loadLocaleMessages () {
function loadLocaleMessages() {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
const messages = {}
locales.keys().forEach(key => {
......
......@@ -30,7 +30,7 @@ export default {
}
},
methods: {
rowClick (event) {
rowClick(event) {
let target = event.target
while (!target.dataset.value) {
target = target.parentNode
......
......@@ -26,18 +26,18 @@ export default {
},
computed: {
flag: {
get () {
get() {
if (this.visible) {
// 注册全局监听事件 [ 目前只考虑鼠标解除触发 ]
window.addEventListener('mousedown', this.watchContextmenu)
}
return this.visible
},
set (newVal) {
set(newVal) {
this.$emit('update:visible', newVal)
}
},
style () {
style() {
return {
left: this.x + 'px',
top: this.y + 'px',
......@@ -46,12 +46,12 @@ export default {
}
},
methods: {
watchContextmenu (event) {
watchContextmenu(event) {
if (!this.$el.contains(event.target) || event.button !== 0) this.flag = false
window.removeEventListener('mousedown', this.watchContextmenu)
}
},
mounted () {
mounted() {
// 将菜单放置到body下
document.querySelector('body').appendChild(this.$el)
}
......
......@@ -24,7 +24,7 @@ export default {
}
},
methods: {
click () {
click() {
this.onClick && this.onClick()
}
}
......
......@@ -12,7 +12,7 @@ import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-header-color',
data () {
data() {
return {
predefine: [
'#FF0000', '#008000', '#0000FF'
......@@ -26,11 +26,11 @@ export default {
})
},
watch: {
value (value) {
value(value) {
this.set(value)
}
},
mounted () {
mounted() {
this.predefine = [...this.predefine, ...this.listTheme.map(theme => theme.color)]
},
methods: {
......
......@@ -7,20 +7,20 @@ import dayjs from 'dayjs'
const sFormat = 'YYYY年MM月DD日'
export default {
name: 'd2-header-datetime',
data () {
data() {
return {
timeInterval: null,
time: dayjs().format(sFormat)
}
},
mounted () {
mounted() {
// this.timeInterval = setInterval(() => this.refreshTime(), 1000);
},
beforeDestroy () {
beforeDestroy() {
clearInterval(this.timeInterval)
},
methods: {
refreshTime () {
refreshTime() {
this.time = dayjs().format(sFormat)
}
}
......
......@@ -21,14 +21,14 @@
<script>
export default {
methods: {
onChangeLocale (command) {
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>`
'仅提供切换功能,没有配置具体的语言数据 ',
'文档参考:<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({
......
......@@ -32,7 +32,7 @@ export default {
logLength: 'log/length',
logLengthError: 'log/lengthError'
}),
tooltipContent () {
tooltipContent() {
return this.logLength === 0
? '没有日志或异常'
: `${this.logLength} 条日志${this.logLengthError > 0
......@@ -44,7 +44,7 @@ export default {
...mapMutations('d2admin/log', [
'clean'
]),
handleClick () {
handleClick() {
this.$router.push({
name: 'log'
})
......
......@@ -7,7 +7,7 @@
<script>
export default {
methods: {
handleClick () {
handleClick() {
this.$emit('click')
}
}
......
......@@ -15,7 +15,7 @@
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
name: 'd2-header-size',
data () {
data() {
return {
options: [
{ label: '大', value: 'default' },
......@@ -37,7 +37,7 @@ export default {
...mapActions({
sizeSet: 'd2admin/size/set'
}),
handleChange (value) {
handleChange(value) {
this.sizeSet(value)
// this.$notify({
// title: '提示',
......@@ -46,7 +46,7 @@ export default {
// type: 'success'
// })
},
iconName (name) {
iconName(name) {
return name === this.value ? 'dot-circle-o' : 'circle-o'
}
}
......
......@@ -44,7 +44,7 @@
import { mapState, mapActions } from 'vuex'
export default {
name: 'd2-theme-list',
data () {
data() {
return {
table: {
showHeader: false,
......@@ -63,7 +63,7 @@ export default {
'set'
]),
...mapActions('d2admin/color', { setColor: 'set' }),
handleSelectTheme (row) {
handleSelectTheme(row) {
const { name, color } = row
this.set(name)
this.setColor(color)
......
......@@ -29,7 +29,7 @@ export default {
components: {
'd2-theme-list': themeList
},
data () {
data() {
return {
dialogVisible: false
}
......
......@@ -26,7 +26,7 @@ export default {
components: {
PersonalPanel
},
mounted () {
mounted() {
this.$event.$on('e-password-dialog', res => (this.passVisible = res))
},
computed: {
......
// 创建 el-menu-item
export function elMenuItem (createElement, menu) {
export function elMenuItem(createElement, menu) {
return createElement('el-menu-item', { props: { index: menu.path } }, [
...menu.icon ? [
createElement('i', { attrs: { class: `el-icon-${menu.icon}` } })
......@@ -15,7 +15,7 @@ export function elMenuItem (createElement, menu) {
}
// 创建 el-submenu
export function elSubmenu (createElement, menu) {
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}` } })
......
import { throttle } from 'lodash'
import { mapState } from 'vuex'
import menuMixin from '../mixin/menu'
import { elMenuItem, elSubmenu } from '../libs/util.menu'
......@@ -8,7 +7,7 @@ export default {
mixins: [
menuMixin
],
render (createElement) {
render(createElement) {
return createElement('div', {
attrs: { flex: 'cross:center' },
class: { 'd2-theme-header-menu': true, 'is-scrollable': this.isScroll },
......@@ -50,7 +49,7 @@ export default {
'header'
])
},
data () {
data() {
return {
active: '',
isScroll: false,
......@@ -62,14 +61,14 @@ export default {
},
watch: {
'$route.matched': {
handler (val) {
handler(val) {
this.active = val[val.length - 1].path
},
immediate: true
}
},
methods: {
scroll (direction) {
scroll(direction) {
if (direction === 'left') {
// 向右滚动
this.currentTranslateX = 0
......@@ -82,7 +81,7 @@ export default {
}
}
},
checkScroll () {
checkScroll() {
let contentWidth = this.$refs.content.clientWidth
let scrollWidth = this.$refs.scroll.clientWidth
if (this.isScroll) {
......@@ -117,7 +116,7 @@ export default {
}
}
},
mounted () {
mounted() {
// 初始化判断
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
window.addEventListener('load', this.checkScroll)
......@@ -125,7 +124,7 @@ export default {
this.throttledCheckScroll = _.throttle(this.checkScroll, 300)
window.addEventListener('resize', this.throttledCheckScroll)
},
beforeDestroy () {
beforeDestroy() {
// 取消监听
window.removeEventListener('resize', this.throttledCheckScroll)
window.removeEventListener('load', this.checkScroll)
......
......@@ -8,7 +8,7 @@ export default {
mixins: [
menuMixin
],
render (createElement) {
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 },
......@@ -23,7 +23,7 @@ export default {
] : []
])
},
data () {
data() {
return {
active: '',
asideHeight: 300,
......@@ -38,7 +38,7 @@ export default {
},
watch: {
// 折叠和展开菜单的时候销毁 better scroll
asideCollapse (val) {
asideCollapse(val) {
this.scrollDestroy()
setTimeout(() => {
this.scrollInit()
......@@ -46,20 +46,20 @@ export default {
},
// 监听路由 控制侧边栏激活状态
'$route.fullPath': {
handler (value) {
handler(value) {
this.active = value
},
immediate: true
}
},
mounted () {
mounted() {
this.scrollInit()
},
beforeDestroy () {
beforeDestroy() {
this.scrollDestroy()
},
methods: {
scrollInit () {
scrollInit() {
this.BS = new BScroll(this.$el, {
mouseWheel: true,
click: true
......@@ -70,7 +70,7 @@ export default {
// }
})
},
scrollDestroy () {
scrollDestroy() {
// https://github.com/d2-projects/d2-admin/issues/75
try {
this.BS.destroy()
......
......@@ -2,7 +2,7 @@ import util from '@/libs/util.js'
export default {
methods: {
handleMenuSelect (index, indexPath) {
handleMenuSelect(index, indexPath) {
if (/^d2-menu-empty-\d+$/.test(index) || index === undefined) {
this.$message.warning('临时菜单')
} else if (/^https:\/\/|http:\/\//.test(index)) {
......
......@@ -63,7 +63,7 @@ export default {
components: {
'd2-panel-search-item': () => import('./components/panel-search-item/index.vue')
},
data () {
data() {
return {
searchText: '',
results: []
......@@ -75,7 +75,7 @@ export default {
'pool'
]),
// 这份数据是展示在搜索面板下面的
resultsList () {
resultsList() {
return (this.results.length === 0 && this.searchText === '') ? this.pool.map(e => ({
value: e.fullTitle,
...e
......@@ -86,7 +86,7 @@ export default {
/**
* @description 过滤选项 这个方法在每次输入框的值发生变化时会触发
*/
querySearch (queryString, callback) {
querySearch(queryString, callback) {
var pool = this.pool
const results = this.query(queryString ? pool : [], queryString)
this.results = results
......@@ -97,7 +97,7 @@ export default {
* @param {Object} pool 需要过滤的数据
* @param {String} queryString 查询字符串
*/
query (pool, queryString) {
query(pool, queryString) {
return new Fuse(pool, {
shouldSort: true,
tokenize: true,
......@@ -120,7 +120,7 @@ export default {
/**
* @description 聚焦输入框
*/
focus () {
focus() {
this.input = ''
setTimeout(() => {
if (this.$refs.input) {
......@@ -134,7 +134,7 @@ export default {
/**
* @description 接收用户在列表中选择项目的事件
*/
handleResultsGroupItemClick (path) {
handleResultsGroupItemClick(path) {
// 如果用户选择的就是当前页面 就直接关闭搜索面板
if (path === this.$route.path) {
this.handleEsc()
......@@ -146,7 +146,7 @@ export default {
/**
* @description 接收用户在下拉菜单中选中事件
*/
handleSelect ({ path }) {
handleSelect({ path }) {
// 如果用户选择的就是当前页面 就直接关闭搜索面板
if (path === this.$route.path) {
this.handleEsc()
......@@ -160,7 +160,7 @@ export default {
/**
* @augments 关闭输入框的下拉菜单
*/
closeSuggestion () {
closeSuggestion() {
if (this.$refs.input.activated) {
this.$refs.input.suggestions = []
this.$refs.input.activated = false
......@@ -169,13 +169,13 @@ export default {
/**
* @augments 接收用户点击空白区域的关闭
*/
handlePanelClick () {
handlePanelClick() {
this.handleEsc()
},
/**
* @augments 接收用户触发的关闭
*/
handleEsc () {
handleEsc() {
this.closeSuggestion()
this.$nextTick(() => {
this.$emit('close')
......
......@@ -59,23 +59,23 @@ export default {
computed: {
...mapState('d2admin/user', ['info'])
},
data () {
data() {
return {
personalVisible: false,
passwordVisible: false
}
},
mounted () {
mounted() {
this.$event.$on('e-ps-close', is2Login => {
this.passwordVisible = false
if (!is2Login) return
this.$message(`修改密码成功,2秒后退回登录页`)
setTimeout(async () => {
this.$message('修改密码成功,2秒后退回登录页')
setTimeout(async() => {
await this.logout()
this.$router.push('/login')
}, 2000)
})
this.$event.$on('e-pd-close', () => this.personalVisible = false)
this.$event.$on('e-pd-close', () => (this.personalVisible = false))
},
components: {
personalDialog: () => import('./personalDialog'),
......@@ -86,14 +86,14 @@ export default {
/**
* @description 登出
*/
logOut () {
logOut() {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm('确定要注销当前用户吗', '注销用户', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
.then(async() => {
await this.$store.commit('d2admin/gray/set', false)
// await this.$store.dispatch('d2admin/user/set', {})
await this.logout()
......@@ -106,7 +106,7 @@ export default {
// })
})
},
clear () {
clear() {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(
'清空本地缓存将重置所有个性化设置并退出到登录界面',
......@@ -117,7 +117,7 @@ export default {
type: 'warning'
}
)
.then(async () => {
.then(async() => {
await this.$store.commit('d2admin/gray/set', false)
localStorage.clear()
window.location.reload()
......@@ -129,15 +129,16 @@ export default {
// })
})
},
comfirm (text, title, cancleText) {
return new Promise((reject, resolve) => {
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 () => {
.then(async() => {
await this.$store.commit('d2admin/gray/set', false)
resolve(true)
})
......@@ -146,15 +147,15 @@ export default {
Message({
message: cancleText
})
reject()
reject(new Error('错误'))
})
})
},
// 打开个人信息弹出框
openPersonalDialog: function () {
openPersonalDialog: function() {
this.personalVisible = true
},
openPasswordDialog: function () {
openPasswordDialog: function() {
this.passwordVisible = true
}
}
......
......@@ -35,7 +35,7 @@ import { ModifyPassword } from '@api/sys.account'
export default {
name: 'PasswordDialog',
components: {},
data () {
data() {
return {
rules: Object.freeze({
oldPassword: [
......@@ -81,13 +81,13 @@ export default {
user: Object
},
computed: {
info () {
info() {
return this.user
}
},
methods: {
// 修改密码
submit () {
submit() {
this.$refs.passwordForm.validate(async valid => {
if (valid) {
const { userId, oldPassword, newPassword } = this.info
......@@ -101,10 +101,10 @@ export default {
}
})
},
handleClose () {
handleClose() {
this.emit(false)
},
emit (is2Login) {
emit(is2Login) {
this.$event.$emit('e-ps-close', is2Login)
this.$refs.passwordForm.validateField()
}
......
......@@ -48,7 +48,7 @@ export default {
user: Object
},
methods: {
handleClose () {
handleClose() {
this.$event.$emit('e-pd-close')
}
}
......
......@@ -65,7 +65,7 @@ export default {
D2Contextmenu: () => import('../contextmenu'),
D2ContextmenuList: () => import('../contextmenu/components/contentmenuList')
},
data () {
data() {
return {
contextmenuFlag: false,
contentmenuX: 0,
......@@ -99,7 +99,7 @@ export default {
/**
* @description 右键菜单功能点击
*/
handleContextmenu (event) {
handleContextmenu(event) {
let target = event.target
// 解决 https://github.com/d2-projects/d2-admin/issues/54
let flag = false
......@@ -120,13 +120,13 @@ export default {
/**
* @description 右键菜单的row-click事件
*/
contextmenuClick (command) {
contextmenuClick(command) {
this.handleControlItemClick(command, this.tagName)
},
/**
* @description 接收点击关闭控制上选项的事件
*/
handleControlItemClick (command, tagName = null) {
handleControlItemClick(command, tagName = null) {
if (tagName) {
this.contextmenuFlag = false
}
......@@ -154,7 +154,7 @@ export default {
/**
* @description 接收点击 tab 标签的事件
*/
handleClick (tab, event) {
handleClick(tab, event) {
// 找到点击的页面在 tag 列表里是哪个
const page = this.opened.find(page => page.fullPath === tab.name)
const { name, params, query } = page
......@@ -165,7 +165,7 @@ export default {
/**
* @description 点击 tab 上的删除按钮触发这里 首页的删除按钮已经隐藏 因此这里不用判断是 index
*/
handleTabsEdit (tagName, action) {
handleTabsEdit(tagName, action) {
if (action === 'remove') {
this.close({
tagName
......
......@@ -86,12 +86,12 @@ 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 d2HeaderLocales from './components/header-locales'
import d2HeaderSearch from './components/header-search'
import d2HeaderSize from './components/header-size'
// 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 d2HeaderLog from './components/header-log'
import d2HeaderColor from './components/header-color'
import hamburger from './components/hamburger'
import d2HeaderDatetime from './components/header-datetime'
......@@ -107,17 +107,17 @@ export default {
d2MenuHeader,
d2Tabs,
d2HeaderFullscreen,
d2HeaderLocales,
// d2HeaderLocales,
d2HeaderSearch,
d2HeaderSize,
// d2HeaderSize,
d2HeaderTheme,
d2HeaderUser,
d2HeaderLog,
// d2HeaderLog,
d2HeaderColor,
hamburger,
d2HeaderDatetime
},
data () {
data() {
return {
// [侧边栏宽度] 正常状态
asideWidth: '200px',
......@@ -125,7 +125,7 @@ export default {
asideWidthCollapse: '65px'
}
},
mounted () {
mounted() {
},
computed: {
...mapState('d2admin', {
......@@ -140,7 +140,7 @@ export default {
/**
* @description 最外层容器的背景图片样式
*/
styleLayoutMainGroup () {
styleLayoutMainGroup() {
return {
...this.themeActiveSetting.backgroundImage ? {
backgroundImage: `url('${this.$baseUrl}${this.themeActiveSetting.backgroundImage}')`
......@@ -155,7 +155,7 @@ export default {
/**
* 接收点击切换侧边栏的按钮
*/
handleToggleAside () {
handleToggleAside() {
this.asideCollapseToggle()
}
}
......
......@@ -6,7 +6,7 @@ export default {
components: {
'd2-panel-search': () => import('../components/panel-search')
},
mounted () {
mounted() {
// 绑定搜索功能快捷键 [ 打开 ]
hotkeys(this.searchHotkey.open, event => {
event.preventDefault()
......@@ -18,7 +18,7 @@ export default {
this.searchPanelClose()
})
},
beforeDestroy () {
beforeDestroy() {
hotkeys.unbind(this.searchHotkey.open)
hotkeys.unbind(this.searchHotkey.close)
},
......@@ -36,7 +36,7 @@ export default {
/**
* 接收点击搜索按钮
*/
handleSearchClick () {
handleSearchClick() {
this.searchToggle()
if (this.searchActive) {
setTimeout(() => {
......@@ -46,7 +46,7 @@ export default {
}, 500)
}
},
searchPanelOpen () {
searchPanelOpen() {
if (!this.searchActive) {
this.searchSet(true)
setTimeout(() => {
......@@ -57,7 +57,7 @@ export default {
}
},
// 关闭搜索面板
searchPanelClose () {
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 = {}) {
cookies.set = function(name = 'default', value = '', cookieSetting = {}) {
let currentCookieSetting = {
expires: 1
}
Object.assign(currentCookieSetting, cookieSetting)
Cookies.set(`tfims-${process.env.VUE_APP_VERSION}-${name}`, value, currentCookieSetting)
Cookies.set(`${COOKIE_NAME_PREFIX}${name}`, value, currentCookieSetting)
}
/**
* @description 拿到 cookie 值
* @param {String} name cookie name
*/
cookies.get = function (name = 'default') {
return Cookies.get(`tfims-${process.env.VUE_APP_VERSION}-${name}`)
cookies.get = function(name = 'default') {
return Cookies.get(`${COOKIE_NAME_PREFIX}${name}`)
}
/**
* @description 拿到 cookie 全部的值
*/
cookies.getAll = function () {
cookies.getAll = function() {
return Cookies.get()
}
......@@ -35,8 +35,8 @@ cookies.getAll = function () {
* @description 删除 cookie
* @param {String} name cookie name
*/
cookies.remove = function (name = 'default') {
return Cookies.remove(`tfims-${process.env.VUE_APP_VERSION}-${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'
import { cloneDeep } from 'lodash'
const adapter = new LocalStorage(`tfims-${process.env.VUE_APP_VERSION}`, {
const adapter = new LocalStorage(`${process.env.VUE_APP_STORAGE_PREFIX}-${process.env.VUE_APP_VERSION}`, {
serialize: (data) => escape(JSON.stringify(data)),
deserialize: (data) => JSON.parse(unescape(data))
})
......@@ -27,7 +26,7 @@ export default db
* @param {Object} payload defaultValue {*} 初始化默认值
* @returns {String} 可以直接使用的路径
*/
export function pathInit ({
export function pathInit({
dbName = 'database',
path = '',
user = true,
......@@ -53,7 +52,7 @@ export function pathInit ({
* @param {Object} payload value {*} 需要存储的值
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function dbSet ({
export function dbSet({
dbName = 'database',
path = '',
value = '',
......@@ -74,7 +73,7 @@ export function dbSet ({
* @param {Object} payload defaultValue {*} 取值失败的默认值
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function dbGet ({
export function dbGet({
dbName = 'database',
path = '',
defaultValue = '',
......@@ -94,7 +93,7 @@ export function dbGet ({
* @description 获取存储数据库对象
* @param {Object} payload user {Boolean} 是否区分用户
*/
export function database ({
export function database({
dbName = 'database',
path = '',
user = false,
......
......@@ -13,7 +13,7 @@ const util = {
* @description 更新标题
* @param {String} title 标题
*/
util.title = function (titleText) {
util.title = function(titleText) {
const processTitle = process.env.VUE_APP_TITLE
window.document.title = `${processTitle}${titleText ? ` | ${titleText}` : ''}`
}
......@@ -22,7 +22,7 @@ util.title = function (titleText) {
* @description 打开新页面
* @param {String} url 地址
*/
util.open = function (url, target) {
util.open = function(url, target) {
var a = document.createElement('a')
a.setAttribute('href', url)
a.setAttribute('target', target || '_blank')
......@@ -62,7 +62,7 @@ util.deepClone = (obj) => {
* @param {Function} condition 回调函数,必须返回谓词,判断是否找到了。会传入(item, index, level)三个参数
* @param {String} children 子数组的key
*/
util.deepFind = function (menus, id) {
util.deepFind = function(menus, id) {
const cloneMenus = util.deepClone(menus)
for (let menu of cloneMenus) {
if (menu.id === id) {
......@@ -110,7 +110,7 @@ util.colorToRgb = (sColor, alpha) => {
* 重置form
* 用法: util.resetForm.call(this,'formName')
*/
util.resetForm = function (formName) {
util.resetForm = function(formName) {
this.$nextTick(() => {
for (var key in this[formName]) {
if (this[formName].hasOwnProperty(key)) {
......
......@@ -4,7 +4,7 @@ const log = {}
* @description 返回这个样式的颜色值
* @param {String} type 样式名称 [ primary | success | warning | danger | text ]
*/
function typeColor (type = 'default') {
function typeColor(type = 'default') {
let color = ''
switch (type) {
case 'default': color = '#35495E'; break
......@@ -23,7 +23,7 @@ function typeColor (type = 'default') {
* @param {String} info info text
* @param {String} type style
*/
log.capsule = function (title, info, type = 'primary') {
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;',
......@@ -35,7 +35,7 @@ log.capsule = function (title, info, type = 'primary') {
/**
* @description 打印彩色文字
*/
log.colorful = function (textArr) {
log.colorful = function(textArr) {
console.log(
`%c${textArr.map(t => t.text || '').join('%c')}`,
...textArr.map(t => `color: ${typeColor(t.type)};`)
......@@ -45,35 +45,35 @@ log.colorful = function (textArr) {
/**
* @description 打印 default 样式的文字
*/
log.default = function (text) {
log.default = function(text) {
log.colorful([{ text }])
}
/**
* @description 打印 primary 样式的文字
*/
log.primary = function (text) {
log.primary = function(text) {
log.colorful([{ text, type: 'primary' }])
}
/**
* @description 打印 success 样式的文字
*/
log.success = function (text) {
log.success = function(text) {
log.colorful([{ text, type: 'success' }])
}
/**
* @description 打印 warning 样式的文字
*/
log.warning = function (text) {
log.warning = function(text) {
log.colorful([{ text, type: 'warning' }])
}
/**
* @description 打印 danger 样式的文字
*/
log.danger = function (text) {
log.danger = function(text) {
log.colorful([{ text, type: 'danger' }])
}
......
......@@ -2,21 +2,20 @@
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-09-10 09:20:37
* @Last Modified time: 2019-09-11 19:08:21
*/
import { cloneDeep } from 'lodash'
const permision = {}
/**
* 打包如有与按钮
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packRoutesBtns = function (resources, idsInPermision) {
permision.packRoutesBtns = function(resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
let __oBtnInPermision = {}
const __aRouteInPermision = []
const __oBtnInPermision = {}
let __objResource = null
let __obj = null
idsInPermision.forEach(obj => {
......@@ -48,12 +47,12 @@ permision.packRoutesBtns = function (resources, idsInPermision) {
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packAsideMenus = function (resources, idsInPermision) {
permision.packAsideMenus = function(resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
const __aMenusInPermision = []
const __aSub = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
......@@ -88,13 +87,13 @@ permision.packAsideMenus = function (resources, idsInPermision) {
* resources 所有资源集合
* idsInPermision 返回的权限id集合
*/
permision.packMenusBtns = function (resources) {
permision.packMenusBtns = function(resources) {
if (!resources) {
throw new Error('参数错误')
}
let __aParent = []
let __aSub = []
let __aAll = []
const __aParent = []
const __aSub = []
const __aAll = []
/**
* 第一次循环 分出一级菜单与所有子菜单
*/
......@@ -135,7 +134,7 @@ permision.packMenusBtns = function (resources) {
/**
* 格式化菜单 封装成系统所需格式
*/
permision.format2Menu = function (oMenu) {
permision.format2Menu = function(oMenu) {
if (!oMenu) return null
const { icon, path, meta } = oMenu
const { title, authId, parentId } = meta
......@@ -150,7 +149,7 @@ permision.format2Menu = function (oMenu) {
/**
* 格式化菜单 封装成系统所需格式
*/
permision.format2ResourceMenu = function (oMenu) {
permision.format2ResourceMenu = function(oMenu) {
if (!oMenu) return null
const { icon, meta, auth } = oMenu
const { title, authId, parentId } = meta
......@@ -165,7 +164,7 @@ permision.format2ResourceMenu = function (oMenu) {
/**
* 扁平化 routes (@/router/routes)
*/
permision.flatten = function (arr) {
permision.flatten = function(arr) {
return arr.reduce((result, item) => {
item.authId = item.authId || item.meta.authId
item.parentId = item.parentId || item.meta.parentId
......
......@@ -38,7 +38,7 @@ new Vue({
// 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader)
// },
mounted () {
mounted() {
// Vue.config.devtools = true
// 展示系统信息
this.$store.commit('d2admin/releases/versionShow')
......
......@@ -8,7 +8,7 @@ export default [
{
path: '/api/login',
method: 'post',
handle ({ body }) {
handle({ body }) {
const user = userDB.find(e => e.username === body.username && e.password === body.password)
if (user) {
return {
......
export default function (Mock) {
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 () {
Mock.XHR.prototype.send = function() {
if (this.custom.xhr) this.custom.xhr.withCredentials = this.withCredentials || false
this.__send.apply(this, arguments)
}
......
......@@ -12,14 +12,14 @@ import qs from 'qs'
axios.defaults.withCredentials = true
const expiresMinute = 60 // 过期时间(分钟)
// 创建一个错误
function errorCreate (msg) {
function errorCreate(msg) {
const error = new Error(msg)
errorLog(error)
throw error
}
// 记录和显示错误
function errorLog (error) {
function errorLog(error) {
// 添加到日志
store.dispatch('d2admin/log/push', {
message: '数据请求异常',
......@@ -51,7 +51,7 @@ const service = axios.create({
// 请求拦截器
service.interceptors.request.use(
config => {
config.transformRequest = [function (data) {
config.transformRequest = [function(data) {
return qs.stringify(data)
}]
return new Promise(async resolve => {
......
......@@ -19,7 +19,7 @@ import pluginLog from '@/plugin/log'
import pluginOpen from '@/plugin/open'
export default {
async install (Vue, options) {
async install(Vue, options) {
// 设置为 false 以阻止 vue 在启动时生成生产提示
// https://cn.vuejs.org/v2/api/#productionTip
Vue.config.productionTip = false
......
......@@ -2,8 +2,8 @@ import store from '@/store'
import util from '@/libs/util'
export default {
install (Vue, options) {
Vue.config.errorHandler = function (error, instance, info) {
install(Vue, options) {
Vue.config.errorHandler = function(error, instance, info) {
Vue.nextTick(() => {
// store 追加 log
store.dispatch('d2admin/log/push', {
......
......@@ -2,11 +2,11 @@ import store from '@/store'
import util from '@/libs/util'
export default {
install (Vue, options) {
install(Vue, options) {
// 快速打印 log
Vue.prototype.$log = {
...util.log,
push (data) {
push(data) {
if (typeof data === 'string') {
// 如果传递来的数据是字符串
// 赋值给 message 字段
......
import util from '@/libs/util'
export default {
install (Vue, options) {
install(Vue, options) {
Vue.prototype.$open = util.open
}
}
......@@ -13,7 +13,7 @@ import util from '@/libs/util.js'
import routes from './routes'
const originalPush = VueRouter.prototype.push // 解决连续点击路由异常问题 limin
VueRouter.prototype.push = function push (location) {
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location) && originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
......@@ -27,7 +27,7 @@ const router = new VueRouter({
* 路由拦截
* 权限验证
*/
router.beforeEach(async (to, from, next) => {
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')
......
import util from '@/libs/util.js'
import { cloneDeep } from 'lodash'
import { AccountLogin } from '@api/sys.account'
import { SUPPER_ADMIN } from '@/common/constants'
import { localRoutes } from '@/router/routes'
......@@ -13,11 +12,11 @@ export default {
* @param {Object} payload password {String} 密码
* @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
*/
login ({ dispatch, commit }, p) {
login({ dispatch, commit }, p) {
// console.log(router.addRoutes);
return new Promise((resolve, reject) => {
// 开始请求登录接口
AccountLogin(p).then(async (data = {}) => {
AccountLogin(p).then(async(data = {}) => {
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
......@@ -49,7 +48,7 @@ export default {
* @param {Object} context
* @param {Object} payload confirm {Boolean} 是否需要确认
*/
logout ({ commit, dispatch }, { confirm = false } = {}) {
logout({ commit, dispatch }, { confirm = false } = {}) {
/**
* @description 注销
*/
......@@ -68,7 +67,7 @@ export default {
* @description 用户登录后从持久化数据加载一系列的设置
* @param {Object} context
*/
load ({ dispatch }) {
load({ dispatch }) {
return new Promise(async resolve => {
// DB -> store 加载用户名
await dispatch('d2admin/user/load', null, { root: true })
......
......@@ -20,40 +20,40 @@ export default {
* @description 返回当前登录用户权限资源
* @param {Object} state state
*/
source (state, dispatch) {
source(state, dispatch) {
return state.source
},
/**
* @description 返回当前页面meta
* @param {Object} state state
*/
meta (state, dispatch) {
meta(state, dispatch) {
return state.meta
},
/**
* @description 当前角色拥有的所有按钮
* @param {Object} state state
*/
btns (state, dispatch) {
btns(state, dispatch) {
return state.btns
},
/**
* 返回当前页面的btn
* @param {*} state
*/
curBtns (state) {
curBtns(state) {
return state.btns[state.meta.authId]
},
/**
* 返回当前页面的btn
* @param {*} state
*/
btnIdAll (state) {
btnIdAll(state) {
return state.btnIdAll
}
},
actions: {
save2db ({ state, dispatch }) {
save2db({ state, dispatch }) {
return new Promise(async resolve => {
// 设置数据
dispatch('d2admin/db/set', {
......@@ -70,7 +70,7 @@ export default {
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
set ({ state, commit, dispatch }, source) {
set({ state, commit, dispatch }, source) {
return new Promise(async resolve => {
// 检查这个主题在主题列表里是否存在
state.source = source
......@@ -84,7 +84,7 @@ export default {
* @description 保存当前角色权限资源
* @param {obj} source 需要保存的权限资源
*/
setCurrentPageMeta ({ state, commit, dispatch }, meta) {
setCurrentPageMeta({ state, commit, dispatch }, meta) {
return new Promise(async resolve => {
state.meta = meta
// end
......@@ -95,7 +95,7 @@ export default {
* @description 从持久化数据加载资源数据
* @param {Object} context
*/
load ({ state, commit, dispatch }) {
load({ state, commit, dispatch }) {
return new Promise(async resolve => {
if (!state.source) {
state.source = await dispatch('d2admin/db/get', {
......@@ -112,7 +112,7 @@ export default {
* 过滤并初始化路由与左侧菜单栏
* @param {*} param0
*/
init ({ state, commit, dispatch }) {
init({ state, commit, dispatch }) {
return new Promise(async resolve => {
try {
// 获取权限资源点
......
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-09-01 17:56:57
* @Last Modified by: limin
* @Last Modified time: 2019-09-09 20:34:18
* @Last Modified time: 2019-09-11 19:07:58
*/
import { FetchRoleList, BaseDataApi } from '@/api/sys.base'
......@@ -33,14 +33,14 @@ export default {
* 每次登录会强制 初始化
* @param {*} param0
*/
init ({ state, dispatch, commit }) {
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] = res) => {
]).then(async([role, station, post, subsys]) => {
state.role = role.roles
state.station = station.confes
state.subsys = subsys.confes
......@@ -57,7 +57,7 @@ export default {
* @param {*} param0
* @param {*} name 名称 state 中的任意一个 强烈建议 使用 @/common/constants/BaseData 中的常量 便于灵活修改
*/
get ({ state, dispatch }, name) {
get({ state, dispatch }, name) {
return new Promise(async resolve => {
let __data = state[name]
if (__data) {
......@@ -68,7 +68,7 @@ export default {
resolve(__data)
})
},
set ({ state, dispatch }, { name, value }) {
set({ state, dispatch }, { name, value }) {
return new Promise(async resolve => {
state[name] = value
await dispatch('save2db', { name, value })
......@@ -81,7 +81,7 @@ export default {
* 内存 -> 前端持久化数据库 -> 后台接口
* @param {*} param0
*/
load ({ state, dispatch }) {
load({ state, dispatch }) {
return new Promise(async resolve => {
if (state.role.length === 0) {
state = await dispatch('getFromdb', 'base') || await dispatch('init')
......@@ -95,7 +95,7 @@ export default {
* @param {*} param0
* @param {*} path 数据 路径
*/
getFromdb ({ dispatch }, path) {
getFromdb({ dispatch }, path) {
return new Promise(async resolve => {
const value = await dispatch('d2admin/db/get', {
dbName: 'database',
......@@ -111,7 +111,7 @@ export default {
* @param {*} param0
* @param {*} param1 value 需要持久化的数据 path 需要持久化的数据路径
*/
save2db ({ dispatch }, { value, name }) {
save2db({ dispatch }, { value, name }) {
return new Promise(async resolve => {
await dispatch('d2admin/db/set', {
dbName: 'database',
......@@ -127,7 +127,7 @@ export default {
* @param {*} param0
* @param {*} name @/common/constants/BaseData 中的常量
*/
getFromAjax ({ state, dispatch, commit }, name) {
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)
......
......@@ -12,7 +12,7 @@ export default {
* @description 返回当前颜色值
* @param {Object} state state
*/
color (state, dispatch) {
color(state, dispatch) {
return state.value
}
},
......@@ -22,7 +22,7 @@ export default {
* @param {Object} context
* @param {String} color 尺寸
*/
set ({ state, dispatch, commit }, color) {
set({ state, dispatch, commit }, color) {
return new Promise(async resolve => {
// 记录上个值
const old = state.value
......@@ -48,7 +48,7 @@ export default {
* @description 从持久化数据读取颜色设置
* @param {Object} context
*/
load ({ state, dispatch, commit }) {
load({ state, dispatch, commit }) {
return new Promise(async resolve => {
// 记录上个值
const old = state.value
......@@ -68,7 +68,7 @@ export default {
resolve()
})
},
loadFromDB ({ state, dispatch, commit }) {
loadFromDB({ state, dispatch, commit }) {
return new Promise(async resolve => {
const color = await dispatch('d2admin/db/get', {
dbName: 'sys',
......@@ -87,7 +87,7 @@ export default {
* @param {Object} payload oldColor {String} 旧的颜色
* @param {Object} payload newColor {String} 新颜色
*/
apply (state, { oldColor, newColor }) {
apply(state, { oldColor, newColor }) {
var options = {
oldColors: [...forElementUI.getElementUISeries(oldColor)],
newColors: [...forElementUI.getElementUISeries(newColor)]
......
import router from '@/router'
import { cloneDeep } from 'lodash'
import { database as getDatabase, dbGet, dbSet } from '@/libs/util.db'
export default {
......@@ -14,7 +13,7 @@ export default {
* @param {Object} payload value {*} 需要存储的值
* @param {Object} payload user {Boolean} 是否区分用户
*/
set (context, {
set(context, {
dbName = 'database',
path = '',
value = '',
......@@ -31,7 +30,7 @@ export default {
* @param {Object} payload defaultValue {*} 取值失败的默认值
* @param {Object} payload user {Boolean} 是否区分用户
*/
get (context, {
get(context, {
dbName = 'database',
path = '',
defaultValue = '',
......@@ -44,7 +43,7 @@ export default {
* @param {Object} context
* @param {Object} payload user {Boolean} 是否区分用户
*/
database (context, {
database(context, {
user = false
} = {}) {
return getDatabase({
......@@ -57,7 +56,7 @@ export default {
* @param {Object} context
* @param {Object} payload user {Boolean} 是否区分用户
*/
databaseClear (context, {
databaseClear(context, {
user = false
} = {}) {
return getDatabase({
......@@ -72,7 +71,7 @@ export default {
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
databasePage (context, {
databasePage(context, {
basis = 'fullPath',
user = false
} = {}) {
......@@ -88,7 +87,7 @@ export default {
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
databasePageClear (context, {
databasePageClear(context, {
basis = 'fullPath',
user = false
} = {}) {
......@@ -106,7 +105,7 @@ export default {
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageSet (context, {
pageSet(context, {
instance,
basis = 'fullPath',
user = false
......@@ -125,7 +124,7 @@ export default {
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageGet (context, {
pageGet(context, {
instance,
basis = 'fullPath',
user = false
......@@ -142,7 +141,7 @@ export default {
* @param {Object} payload basis {String} 页面区分依据 [ name | path | fullPath ]
* @param {Object} payload user {Boolean} 是否区分用户
*/
pageClear (context, {
pageClear(context, {
basis = 'fullPath',
user = false
}) {
......
......@@ -11,7 +11,7 @@ export default {
* @description 初始化监听
* @param {Object} context
*/
listen ({ commit }) {
listen({ commit }) {
return new Promise(resolve => {
if (screenfull.enabled) {
screenfull.on('change', () => {
......@@ -29,7 +29,7 @@ export default {
* @description 切换全屏
* @param {Object} context
*/
toggle ({ commit }) {
toggle({ commit }) {
return new Promise(resolve => {
if (screenfull.isFullscreen) {
screenfull.exit()
......@@ -49,7 +49,7 @@ export default {
* @param {Object} state state
* @param {Boolean} active active
*/
set (state, active) {
set(state, active) {
state.active = active
}
}
......
......@@ -9,7 +9,7 @@ export default {
* @description 切换灰度状态
* @param {Object} state state
*/
toggle (state) {
toggle(state) {
state.active = !state.active
},
/**
......@@ -17,7 +17,7 @@ export default {
* @param {Object} state state
* @param {Boolean} active active
*/
set (state, active) {
set(state, active) {
state.active = active
}
}
......
import dayjs from 'dayjs'
import { get } from 'lodash'
import util from '@/libs/util.js'
export default {
......@@ -18,14 +17,14 @@ export default {
* @description 返回现存 log (all) 的条数
* @param {*} state vuex state
*/
length (state) {
length(state) {
return state.log.length
},
/**
* @description 返回现存 log (error) 的条数
* @param {*} state vuex state
*/
lengthError (state) {
lengthError(state) {
return state.log.filter(log => log.type === 'danger').length
}
},
......@@ -37,7 +36,7 @@ export default {
* @param {String} param type {String} 类型
* @param {Object} payload meta {Object} 附带的信息
*/
push ({ rootState, commit }, { message, type = 'info', meta }) {
push({ rootState, commit }, { message, type = 'info', meta }) {
commit('push', {
message,
type,
......@@ -63,14 +62,14 @@ export default {
* @param {Object} state state
* @param {Object} log data
*/
push (state, log) {
push(state, log) {
state.log.push(log)
},
/**
* @description 清空日志
* @param {Object} state state
*/
clean (state) {
clean(state) {
// store 赋值
state.log = []
}
......
import { uniqueId } from 'lodash'
// 设置文件
import setting from '@/setting.js'
......@@ -7,7 +6,7 @@ import setting from '@/setting.js'
* https://github.com/d2-projects/d2-admin/issues/209
* @param {Array} menu 原始的菜单数据
*/
function supplementMenuPath (menu) {
function supplementMenuPath(menu) {
return menu.map(e => ({
...e,
path: e.path || _.uniqueId('d2-menu-empty-'),
......@@ -33,7 +32,7 @@ export default {
* @param {Object} context
* @param {Boolean} collapse is collapse
*/
asideCollapseSet ({ state, dispatch }, collapse) {
asideCollapseSet({ state, dispatch }, collapse) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = collapse
......@@ -52,7 +51,7 @@ export default {
* 切换侧边栏展开和收缩
* @param {Object} context
*/
asideCollapseToggle ({ state, dispatch }) {
asideCollapseToggle({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = !state.asideCollapse
......@@ -71,7 +70,7 @@ export default {
* 从持久化数据读取侧边栏展开或者收缩
* @param {Object} context
*/
asideCollapseLoad ({ state, dispatch }) {
asideCollapseLoad({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.asideCollapse = await dispatch('d2admin/db/get', {
......@@ -91,7 +90,7 @@ export default {
* @param {Object} state state
* @param {Array} menu menu setting
*/
headerSet (state, menu) {
headerSet(state, menu) {
// store 赋值
state.header = supplementMenuPath(menu)
},
......@@ -100,7 +99,7 @@ export default {
* @param {Object} state state
* @param {Array} menu menu setting
*/
asideSet (state, menu) {
asideSet(state, menu) {
// store 赋值
state.aside = supplementMenuPath(menu)
}
......
import { get } from 'lodash'
import router from '@/router'
// import setting from '@/setting.js'
import home from '@/router/routes'
......@@ -25,7 +24,7 @@ export default {
* @description 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
* @param {Object} context
*/
isLoaded ({ state }) {
isLoaded({ state }) {
if (state.value) return Promise.resolve()
return new Promise(resolve => {
const timer = setInterval(() => {
......@@ -40,7 +39,7 @@ export default {
* @description 从持久化数据载入标签页列表
* @param {Object} context
*/
openedLoad ({ state, commit, dispatch }) {
openedLoad({ state, commit, dispatch }) {
return new Promise(async resolve => {
// store 赋值
const value = await dispatch('d2admin/db/get', {
......@@ -84,7 +83,7 @@ export default {
* 将 opened 属性赋值并持久化 在这之前请先确保已经更新了 state.opened
* @param {Object} context
*/
opend2db ({ state, dispatch }) {
opend2db({ state, dispatch }) {
return new Promise(async resolve => {
// 设置数据
dispatch('d2admin/db/set', {
......@@ -103,10 +102,10 @@ export default {
* @param {Object} context
* @param {Object} payload { index, params, query, fullPath } 路由信息
*/
openedUpdate ({ state, commit, dispatch }, { index, params, query, fullPath }) {
openedUpdate({ state, commit, dispatch }, { index, params, query, fullPath }) {
return new Promise(async resolve => {
// 更新页面列表某一项
let page = state.opened[index]
const page = state.opened[index]
page.params = params || page.params
page.query = query || page.query
page.fullPath = fullPath || page.fullPath
......@@ -123,10 +122,10 @@ export default {
* @param {Object} context
* @param {Object} payload new tag info
*/
add ({ state, commit, dispatch }, { tag, params, query, fullPath }) {
add({ state, commit, dispatch }, { tag, params, query, fullPath }) {
return new Promise(async resolve => {
// 设置新的 tag 在新打开一个以前没打开过的页面时使用
let newTag = tag
const newTag = tag
newTag.params = params || newTag.params
newTag.query = query || newTag.query
newTag.fullPath = fullPath || newTag.fullPath
......@@ -148,10 +147,10 @@ export default {
* @param {Object} context
* @param {Object} payload 从路由钩子的 to 对象上获取 { name, params, query, fullPath } 路由信息
*/
open ({ state, commit, dispatch }, { name, params, query, fullPath }) {
open({ state, commit, dispatch }, { name, params, query, fullPath }) {
return new Promise(async resolve => {
// 已经打开的页面
let opened = state.opened
const opened = state.opened
// 判断此页面是否已经打开 并且记录位置
let pageOpendIndex = 0
const pageOpend = opened.find((page, index) => {
......@@ -169,7 +168,7 @@ export default {
})
} else {
// 页面以前没有打开过
let page = state.pool.find(t => t.name === name)
const page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) {
await dispatch('add', {
......@@ -191,7 +190,7 @@ export default {
* @param {Object} context
* @param {Object} payload { tagName: 要关闭的标签名字 }
*/
close ({ state, commit, dispatch }, { tagName }) {
close({ state, commit, dispatch }, { tagName }) {
return new Promise(async resolve => {
// 下个新的页面
let newPage = state.opened[0]
......@@ -199,7 +198,7 @@ export default {
// 如果关闭的页面就是当前显示的页面
if (isCurrent) {
// 去找一个新的页面
let len = state.opened.length
const len = state.opened.length
for (let i = 1; i < len; i++) {
if (state.opened[i].fullPath === tagName) {
if (i < len - 1) {
......@@ -224,7 +223,7 @@ export default {
// 最后需要判断是否需要跳到首页
if (isCurrent) {
const { name = '', params = {}, query = {} } = newPage
let routerObj = {
const routerObj = {
name,
params,
query
......@@ -241,7 +240,7 @@ export default {
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeLeft ({ state, commit, dispatch }, { pageSelect } = {}) {
closeLeft({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
......@@ -270,7 +269,7 @@ export default {
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeRight ({ state, commit, dispatch }, { pageSelect } = {}) {
closeRight({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
......@@ -298,7 +297,7 @@ export default {
* @param {Object} context
* @param {Object} payload { pageSelect: 当前选中的tagName }
*/
closeOther ({ state, commit, dispatch }, { pageSelect } = {}) {
closeOther({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
......@@ -330,7 +329,7 @@ export default {
* @description 关闭所有 tag
* @param {Object} context
*/
closeAll ({ state, commit, dispatch }) {
closeAll({ state, commit, dispatch }) {
return new Promise(async resolve => {
// 删除打开的页面 并在缓存设置中删除
state.opened.splice(1).forEach(({ name }) => commit('keepAliveRemove', name))
......@@ -353,7 +352,7 @@ export default {
* @description 从已经打开的页面记录中更新需要缓存的页面记录
* @param {Object} state state
*/
keepAliveRefresh (state) {
keepAliveRefresh(state) {
state.keepAlive = state.opened.filter(item => isKeepAlive(item)).map(e => e.name)
},
/**
......@@ -361,8 +360,8 @@ export default {
* @param {Object} state state
* @param {String} name name
*/
keepAliveRemove (state, name) {
const list = [ ...state.keepAlive ]
keepAliveRemove(state, name) {
const list = [...state.keepAlive]
const index = list.findIndex(item => item === name)
if (index !== -1) {
......@@ -375,8 +374,8 @@ export default {
* @param {Object} state state
* @param {String} name name
*/
keepAlivePush (state, name) {
const keep = [ ...state.keepAlive ]
keepAlivePush(state, name) {
const keep = [...state.keepAlive]
keep.push(name)
state.keepAlive = keep
},
......@@ -384,7 +383,7 @@ export default {
* @description 清空页面缓存设置
* @param {Object} state state
*/
keepAliveClean (state) {
keepAliveClean(state) {
state.keepAlive = []
},
/**
......@@ -393,7 +392,7 @@ export default {
* @param {Object} state state
* @param {String} fullPath new fullPath
*/
currentSet (state, fullPath) {
currentSet(state, fullPath) {
state.current = fullPath
},
/**
......@@ -402,9 +401,9 @@ export default {
* @param {Object} state state
* @param {Array} routes routes
*/
init (state, routes) {
init(state, routes) {
const pool = []
const push = function (routes) {
const push = function(routes) {
routes.forEach(route => {
if (route.children) {
push(route.children)
......
......@@ -7,7 +7,7 @@ export default {
* @description 显示版本信息
* @param {Object} state state
*/
versionShow () {
versionShow() {
util.log.capsule(process.env.VUE_APP_TITLE, `v${process.env.VUE_APP_VERSION}`)
console.log('广联赛讯 http://www.glsx.com.cn')
// console.log('D2 Crud https://github.com/d2-projects/d2-crud')
......
......@@ -18,7 +18,7 @@ export default {
* @description 切换激活状态
* @param {Object} state state
*/
toggle (state) {
toggle(state) {
state.active = !state.active
},
/**
......@@ -26,7 +26,7 @@ export default {
* @param {Object} state state
* @param {Boolean} active active
*/
set (state, active) {
set(state, active) {
state.active = active
},
/**
......@@ -34,9 +34,9 @@ export default {
* @param {Object} state state
* @param {Array} menu menu
*/
init (state, menu) {
init(state, menu) {
const pool = []
const push = function (menu, titlePrefix = []) {
const push = function(menu, titlePrefix = []) {
menu.forEach(m => {
if (m.children) {
push(m.children, [ ...titlePrefix, m.title ])
......
......@@ -13,7 +13,7 @@ export default {
* @param {Object} context
* @param {Boolean} refresh 是否在设置之后刷新页面
*/
apply ({ state, commit }, refresh) {
apply({ state, commit }, refresh) {
Vue.prototype.$ELEMENT.size = state.value
if (refresh) {
commit('d2admin/page/keepAliveClean', null, { root: true })
......@@ -24,7 +24,7 @@ export default {
* @description 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
* @param {Object} context
*/
isLoaded ({ state }) {
isLoaded({ state }) {
if (state.value) return Promise.resolve()
return new Promise(resolve => {
const timer = setInterval(() => {
......@@ -39,7 +39,7 @@ export default {
* @param {Object} context
* @param {String} size 尺寸
*/
set ({ state, dispatch }, size) {
set({ state, dispatch }, size) {
return new Promise(async resolve => {
// store 赋值
state.value = size
......@@ -60,7 +60,7 @@ export default {
* @description 从持久化数据读取尺寸设置
* @param {Object} context
*/
load ({ state, dispatch }) {
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.value = await dispatch('d2admin/db/get', {
......
......@@ -14,7 +14,7 @@ export default {
* @description 返回当前的主题信息 不是一个名字 而是当前激活主题的所有数据
* @param {Object} state state
*/
activeSetting (state) {
activeSetting(state) {
return state.list.find(theme => theme.name === state.activeName)
}
},
......@@ -23,7 +23,7 @@ export default {
* @description 激活一个主题
* @param {String} themeValue 需要激活的主题名称
*/
set ({ state, commit, dispatch }, themeName) {
set({ state, commit, dispatch }, themeName) {
return new Promise(async resolve => {
// 检查这个主题在主题列表里是否存在
state.activeName = state.list.find(e => e.name === themeName) ? themeName : state.list[0].name
......@@ -43,7 +43,7 @@ export default {
/**
* @description 从持久化数据加载主题设置 * @param {Object} context
*/
load ({ state, commit, dispatch }) {
load({ state, commit, dispatch }) {
return new Promise(async resolve => {
// store 赋值
let activeName = await dispatch('d2admin/db/get', {
......@@ -82,7 +82,7 @@ export default {
* @description 将 vuex 中的主题应用到 dom
* @param {Object} state state
*/
dom (state) {
dom(state) {
document.body.className = `theme-${state.activeName}`
}
}
......
......@@ -13,7 +13,7 @@ export default {
* @param {Object} context
* @param {Boolean} active 新的状态
*/
set ({ state, dispatch }, active) {
set({ state, dispatch }, active) {
return new Promise(async resolve => {
// store 赋值
state.active = active
......@@ -32,7 +32,7 @@ export default {
* 从数据库读取页面过渡动画设置
* @param {Object} context
*/
load ({ state, dispatch }) {
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.active = await dispatch('d2admin/db/get', {
......
......@@ -9,7 +9,7 @@ export default {
* @description 切换状态
* @param {Object} state state
*/
toggle (state) {
toggle(state) {
state.active = !state.active
},
/**
......@@ -17,7 +17,7 @@ export default {
* @param {Object} state state
* @param {Boolean} active active
*/
set (state, active) {
set(state, active) {
state.active = active
}
}
......
......@@ -11,7 +11,7 @@ export default {
* @description 记录 UA
* @param {Object} state state
*/
get (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: {
......@@ -10,7 +12,7 @@ export default {
* @param {Object} context
* @param {*} info info
*/
set ({ state, dispatch }, info) {
set({ state, dispatch }, info) {
return new Promise(async resolve => {
// store 赋值
state.info = info
......@@ -21,7 +23,7 @@ export default {
// value: info,
// user: true
// }, { root: true })
sessionStorage.setItem('tfims-user', escape(JSON.stringify(info)))
sessionStorage.setItem(SESSION_NAME, escape(JSON.stringify(info)))
// end
resolve()
})
......@@ -30,7 +32,7 @@ export default {
* @description 从数据库取用户数据
* @param {Object} context
*/
load ({ state, dispatch }) {
load({ state, dispatch }) {
return new Promise(async resolve => {
// store 赋值
// state.info = await dispatch('d2admin/db/get', {
......@@ -39,13 +41,13 @@ export default {
// defaultValue: {},
// user: true
// }, { root: true })
state.info = JSON.parse(unescape(sessionStorage.getItem('tfims-user')))
state.info = JSON.parse(unescape(sessionStorage.getItem(SESSION_NAME)))
// end
resolve()
})
},
clear ({ state, dispatch }) {
clear({ state, dispatch }) {
return new Promise(async resolve => {
// await dispatch('d2admin/db/set', {
// dbName: 'database',
......@@ -54,7 +56,7 @@ export default {
// user: true
// }, { root: true })
state.info = null
sessionStorage.removeItem('tfims-user')
sessionStorage.removeItem(SESSION_NAME)
resolve()
})
}
......
......@@ -12,7 +12,7 @@
<script>
export default {
name: 'page1',
render: function (createElement) {
render: function(createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' }
}, [
createElement('el-menu', {
......
......@@ -56,11 +56,11 @@
export default {
name: 'page2',
methods: {
handleClick (row) {
handleClick(row) {
alert(JSON.stringify(row))
}
},
data () {
data() {
return {
testCache: '',
btn: {
......
......@@ -96,7 +96,7 @@
import { isExistApi } from '@api/deviceManagement'
export default {
name: 'EditDialog',
data () {
data() {
return {
deviceNum: '',
deviceCode: '',
......@@ -142,31 +142,31 @@ export default {
},
watch: {
isVisible (val) {
isVisible(val) {
val && (this.deviceNum = this.editForm.deviceNum)
val && (this.deviceName = this.editForm.deviceName)
this.$refs.editRuleForm && this.$refs.editRuleForm.resetFields()
}
},
mounted () {},
mounted() {},
methods: {
async isCodeExist (rule, value, callback) {
async isCodeExist(rule, value, callback) {
if (this.deviceNum !== value || this.deviceName !== this.editForm.deviceName) {
const res = await isExistApi({ deviceNum: value, deviceName: this.editForm.deviceName, stationCode: this.editForm.stationCode })
res.deviceNum ? callback(new Error(rule.message)) : callback()
}
},
validateCode (value) {
validateCode(value) {
this.$refs.editRuleForm.validateField('deviceNum')
},
handleClose () {
handleClose() {
this.$emit('closeDialog')
},
handleConfirm () {
handleConfirm() {
this.$refs.editRuleForm.validate((vaild) => {
if (vaild) {
this.$emit('confirmDialog')
......
......@@ -109,7 +109,7 @@ export default {
components: {
EditDialog
},
data () {
data() {
return {
// 编辑弹窗
editVisible: false,
......@@ -173,23 +173,23 @@ export default {
}
},
mounted () {
mounted() {
this.loadingGetList()
this.loadBaseData()
},
methods: {
async loadBaseData () {
async loadBaseData() {
const data = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
this.baseData.station = data
},
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
getParams() {
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
......@@ -197,7 +197,7 @@ export default {
}
},
getList () {
getList() {
const params = this.getParams()
getListApi(params).then(res => {
this.tableData = res.deviceList
......@@ -209,12 +209,12 @@ export default {
})
},
delObjMutiAttr (obj, keys) {
delObjMutiAttr(obj, keys) {
keys.map(key => delete obj[key])
return obj
},
editDevice (params) {
editDevice(params) {
params = this.delObjMutiAttr(params, ['createTime', 'keyWord', 'pageCount', 'pageSize', 'updateTime', 'stationName', 'stationCode'])
// console.log(params)
editApi(params).then(res => {
......@@ -227,7 +227,7 @@ export default {
},
// 导入
importFile (e) {
importFile(e) {
const name = e.target.files[0].name
this.fileInfo.fileType = name.split('.')[1]
// // 转码base64
......@@ -272,7 +272,7 @@ export default {
}
},
exportFile () {
exportFile() {
const params = this.getParams()
exportApi(params).then(res => {
this.$open(res.url)
......@@ -283,40 +283,40 @@ export default {
},
/* 接口请求-end */
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
},
handleEditClose () {
handleEditClose() {
this.editVisible = !this.editVisible
},
handleEditConfirm () {
handleEditConfirm() {
var editParams = _.cloneDeep(this.editForm)
this.editDevice(editParams)
},
// 表格-编辑
handleEdit (row) {
handleEdit(row) {
// console.log(row)
this.editForm = _.cloneDeep(row)
this.editVisible = !this.editVisible
},
handleDelete (row) {
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
......
......@@ -115,7 +115,7 @@ import { mapActions } from 'vuex'
import notice from '@/common/notice'
export default {
name: 'fimsMaintainManagement',
data () {
data() {
return {
// 搜索
searchForm: {
......@@ -299,12 +299,12 @@ export default {
},
watch: {
'searchForm.createTime' (value) {
'searchForm.createTime'(value) {
!value && this.loadingGetList()
}
},
mounted () {
mounted() {
this.loadingGetList()
this.loadBaseData()
},
......@@ -312,7 +312,7 @@ export default {
methods: {
...mapActions('d2admin/base', ['load']),
async loadBaseData () {
async loadBaseData() {
const modelToOptions = { 'stationCode': 'station', 'subsystemTypeCode': 'subsys' }
const data = await this.load()
if (data) {
......@@ -323,22 +323,22 @@ export default {
}
},
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
var time = [{attr: 'startTime', addTime: '00:00:00'}, {attr: 'endTime', addTime: '23:59:59'}]
this.searchForm.createTime && this.searchForm.createTime.map((value, i) => this.searchForm[time[i].attr] = value + ' ' + time[i].addTime)
getParams() {
var time = [{ attr: 'startTime', addTime: '00:00:00' }, { attr: 'endTime', addTime: '23:59:59' }]
this.searchForm.createTime && this.searchForm.createTime.map((value, i) => (this.searchForm[time[i].attr] = value + ' ' + time[i].addTime))
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
...this.searchForm
}
},
getList () {
getList() {
const params = this.getParams()
delete params.createTime
// console.log(params)
......@@ -351,7 +351,7 @@ export default {
this.tableLoading = false
})
},
exportOrder () {
exportOrder() {
const params = this.getParams()
delete params.createTime
exportApi(params).then(res => {
......@@ -363,24 +363,24 @@ export default {
},
/* 接口请求-end */
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
},
handleDelete (row) {
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
......
......@@ -15,7 +15,7 @@
<script>
export default {
name: 'DetailDialog',
data () {
data() {
return {
}
},
......@@ -29,10 +29,10 @@ export default {
pdfUrl: String
},
mounted () {},
mounted() {},
methods: {
handleClose () {
handleClose() {
this.$emit('closeDialog')
}
}
......
......@@ -114,14 +114,14 @@
<script>
import DetailDialog from './detailDialog'
import { getListApi, detailApi, removeApi, exportApi, downloadApi } from '@api/materiaOrderManagement'
import { getListApi, removeApi, exportApi, downloadApi } from '@api/materiaOrderManagement'
import notice from '@/common/notice'
export default {
name: 'fimsMateriaOrderManagement',
components: {
DetailDialog
},
data () {
data() {
return {
detailVisible: false,
dialogTitle: '',
......@@ -189,31 +189,31 @@ export default {
},
watch: {
'searchForm.createTime' (value) {
'searchForm.createTime'(value) {
!value && this.loadingGetList()
}
},
mounted () {
mounted() {
this.loadingGetList()
},
methods: {
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
var time = [{attr: 'startTime', addTime: '00:00:00'}, {attr: 'endTime', addTime: '23:59:59'}]
this.searchForm.createTime && this.searchForm.createTime.map((value, i) => this.searchForm[time[i].attr] = value + ' ' + time[i].addTime)
getParams() {
var time = [{ attr: 'startTime', addTime: '00:00:00' }, { attr: 'endTime', addTime: '23:59:59' }]
this.searchForm.createTime && this.searchForm.createTime.map((value, i) => (this.searchForm[time[i].attr] = value + ' ' + time[i].addTime))
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
...this.searchForm
}
},
getList () {
getList() {
const params = this.getParams()
!params.orderCode && delete params.orderCode
delete params.createTime
......@@ -228,7 +228,7 @@ export default {
})
},
exportFile () {
exportFile() {
const params = this.getParams()
!params.orderCode && delete params.orderCode
delete params.createTime
......@@ -241,29 +241,29 @@ export default {
},
/* 接口请求-end */
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
},
handleDetailClose () {
handleDetailClose() {
this.detailVisible = !this.detailVisible
},
// 表格-查看详情
handleDetail (row) {
handleDetail(row) {
downloadApi({
orderCode: row.orderCode
}).then(res => {
......@@ -275,7 +275,7 @@ export default {
})
},
handleDelete (row) {
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
......
......@@ -58,7 +58,7 @@ import { getListApi } from '@api/materialList'
import notice from '@/common/notice'
export default {
name: 'fimsMaterialList',
data () {
data() {
return {
searchForm: {
keyWord: ''
......@@ -95,24 +95,24 @@ export default {
}
},
mounted () {
mounted() {
this.loadingGetList()
},
methods: {
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
getParams() {
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
...this.searchForm
}
},
getList () {
getList() {
const params = this.getParams()
getListApi(params).then(res => {
this.tableData = res.deviceList
......@@ -125,18 +125,18 @@ export default {
},
/* 接口请求-end */
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
......
......@@ -81,7 +81,7 @@ import { BaseData } from '@/common/constants'
import notice from '@/common/notice'
export default {
name: 'FimsReportingLogs',
data () {
data() {
return {
tableLoading: false,
searchForm: {
......@@ -124,18 +124,18 @@ export default {
},
watch: {
'searchForm.reportTime' (value) {
'searchForm.reportTime'(value) {
!value && this.loadingGetList()
}
},
mounted () {
mounted() {
this.loadingGetList()
this.loadBaseData()
},
methods: {
async loadBaseData () {
async loadBaseData() {
const data = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
this.baseData.station = data
},
......@@ -170,7 +170,7 @@ export default {
})
},
handleExport () {
handleExport() {
const params = this.getParams()
delete params.reportTime
exportApi(params).then(res => {
......@@ -184,18 +184,18 @@ export default {
},
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
......
......@@ -74,7 +74,7 @@ import { constants } from 'fs';
import { isExistApi } from '@api/subSysManagement'
export default {
name: 'EditDialog',
data () {
data() {
return {
disabled: false,
title: '添加子系统',
......@@ -117,7 +117,7 @@ export default {
},
watch: {
isVisible (val) {
isVisible(val) {
this.disabled = !!this.editForm.subsystemCode
this.title = !this.editForm.subsystemCode ? '添加子系统' : '编辑子系统'
this.$refs.editRuleForm && this.$refs.editRuleForm.resetFields()
......@@ -125,21 +125,21 @@ export default {
},
methods: {
async isCodeExist (rule, value, callback) {
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()
}
},
validateCode (value) {
validateCode(value) {
this.$refs.editRuleForm.validateField('subsystemCode')
},
handleClose () {
handleClose() {
this.$emit('closeDialog')
},
handleConfirm () {
handleConfirm() {
this.$refs.editRuleForm.validate((vaild) => {
if (vaild) {
this.$emit('confirmDialog')
......
......@@ -124,7 +124,7 @@ export default {
components: {
EditDialog
},
data () {
data() {
return {
// 远程搜索-返回数组
// remoteOptionArr: {
......@@ -201,13 +201,13 @@ export default {
}
},
mounted () {
mounted() {
this.loadingGetList()
this.loadBaseData()
},
methods: {
async loadBaseData () {
async loadBaseData() {
const data = await this.$store.dispatch('d2admin/base/get', BaseData.SUBSYS.KEY)
this.baseData.subsys = data
},
......@@ -223,12 +223,12 @@ export default {
// this.loadingGetList()
// },
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
getParams() {
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
......@@ -245,7 +245,7 @@ export default {
// })
// },
getList () {
getList() {
const params = this.getParams()
getListApi(params).then(res => {
this.tableData = res.subsystemList
......@@ -257,10 +257,10 @@ export default {
})
},
editSubSystem (value) {
editSubSystem(value) {
// console.log(value)
const params = _.cloneDeep(this.editFormReset)
Object.keys(params).map(key => params[key] = value[key])
Object.keys(params).map(key => (params[key] = value[key]))
params.subsystemType = this.baseData.subsys.find(item => item.confCode === params.subsystemTypeCode).confValue
if (!value.id) {
delete params.id
......@@ -280,39 +280,39 @@ export default {
},
/* 接口请求-end */
// 搜索
handleSearch () {
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
},
handleEditClose () {
handleEditClose() {
this.editVisible = !this.editVisible
},
handleEditConfirm () {
handleEditConfirm() {
var editParams = JSON.parse(JSON.stringify(this.editForm))
this.editSubSystem(editParams)
},
// 表格-编辑
handleEdit (row) {
handleEdit(row) {
this.editForm = JSON.parse(JSON.stringify(row))
this.editVisible = !this.editVisible
},
handleDelete (row) {
handleDelete(row) {
this.$confirm('确认删除?', '删除', {
comfirmButtonText: '确认',
cancelButtonText: '取消',
......
export default {
beforeRouteEnter (to, from, next) {
beforeRouteEnter(to, from, next) {
next(instance => instance.$router.replace(JSON.parse(from.params.route)))
},
render: h => h()
......
export default {
beforeRouteEnter (to, from, next) {
beforeRouteEnter(to, from, next) {
next(instance => instance.$router.replace(from.fullPath))
},
render: h => h()
......
......@@ -71,9 +71,8 @@
<script>
import { mapState } from 'vuex'
import { get } from 'lodash'
export default {
data () {
data() {
return {
uploading: false
}
......@@ -85,7 +84,7 @@ export default {
},
methods: {
get: _.get,
handleShowMore (log) {
handleShowMore(log) {
// 打印一条日志的所有信息到控制台
this.$notify({
type: 'info',
......@@ -100,7 +99,7 @@ export default {
console.groupEnd()
},
// 日志上传
handleUpload () {
handleUpload() {
this.uploading = true
this.$notify({
type: 'info',
......
......@@ -90,11 +90,11 @@ export default {
}
},
computed: {
dialogVisible () {
dialogVisible() {
return this.isVisible
}
},
data () {
data() {
return {
POST_DISABLED,
company: [],
......@@ -186,12 +186,12 @@ export default {
},
methods: {
...mapActions('d2admin/base', ['load']),
handleClose () {
handleClose() {
this.$refs.regForm.resetFields()
this.$event.$emit('e-reg-dialog', false)
},
// 提交注册数据
submit () {
submit() {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm
......@@ -201,21 +201,21 @@ export default {
notice.okTips('注册信息已提交,请等待管理员审核')
this.handleClose()
} else {
notice.errorTips(`注册失败!`)
notice.errorTips('注册失败!')
}
})
}
})
},
// 加载业务所需所有数据
async fetchData () {
async fetchData() {
const { station, post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
Object.freeze(this.baseData)
}
},
mounted () {
mounted() {
this.fetchData()
}
}
......
......@@ -90,7 +90,7 @@ export default {
components: {
DialogReg: () => import('./dialogReg')
},
data () {
data() {
return {
registerDialogVisible: false,
timeInterval: null,
......@@ -118,20 +118,20 @@ export default {
})
}
},
mounted () {
mounted() {
this.timeInterval = setInterval(() => this.refreshTime(), 1000)
this.$event.$on('e-reg-dialog', res => (this.registerDialogVisible = res))
},
beforeDestroy () {
beforeDestroy() {
clearInterval(this.timeInterval)
},
methods: {
...mapActions('d2admin/account', ['login']),
refreshTime () {
refreshTime() {
this.time = dayjs().format('HH:mm:ss')
},
// 提交登录信息
submit () {
submit() {
// console.log(navigator.userAgent.toLocaleLowerCase())
this.$refs.loginForm.validate(valid => {
if (valid) {
......
......@@ -109,10 +109,9 @@
import { getListApi, reportApi, exportApi } from '@api/systemMonitor'
import notice from '@/common/notice'
import { mapActions } from 'vuex'
import { cloneDeep } from 'lodash'
export default {
name: 'index',
data () {
data() {
return {
subSystemRadio: '全部',
tag: Object.freeze({
......@@ -226,7 +225,7 @@ export default {
}
},
mounted () {
mounted() {
this.$echarts = echarts
this.loadingGetList()
this.loadBaseData()
......@@ -237,7 +236,7 @@ export default {
methods: {
...mapActions('d2admin/base', ['load']),
async loadBaseData () {
async loadBaseData() {
// this.baseData.station = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
const { station, subsys } = await this.load()
this.baseData.station = _.cloneDeep(station)
......@@ -245,12 +244,12 @@ export default {
this.baseData.subsys.unshift({ confCode: '', confValue: '全部' })
},
loadingGetList () {
loadingGetList() {
this.tableLoading = true
this.getList()
},
/* 接口请求-start */
getParams () {
getParams() {
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
......@@ -258,7 +257,7 @@ export default {
}
},
getList () {
getList() {
const params = this.getParams()
getListApi(params).then(res => {
this.tableData = res.subsystemList
......@@ -269,7 +268,7 @@ export default {
this.tableLoading = false
})
},
getPie (label = '') {
getPie(label = '') {
const params = {
subsystemTypeCode: label ? this.baseData.subsys.find(item => item.confValue === label).confCode : ''
}
......@@ -279,7 +278,7 @@ export default {
notice.errorTips()
})
},
exportFile () {
exportFile() {
const params = this.getParams()
exportApi(params).then(res => {
this.$open(res.url)
......@@ -293,11 +292,11 @@ export default {
// offlineNum 离网数量
// normalNum 正常数量
// breakdownNum 故障数量
drawPie (params) {
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
item = this.totalOptions.series[1]
item.data[0].value = params.breakdownNum ? params.breakdownNum : 0
item.data[1].value = params.normalNum ? params.normalNum : 0
......@@ -306,19 +305,19 @@ export default {
},
// 搜索
handleSearch () {
handleSearch() {
// 调接口
this.loadingGetList()
},
// 页码
handleSizeChange (value) {
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange (value) {
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!