From d6157c06771caadcaa09a11d25ddfa144d7fe9f5 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期二, 05 一月 2021 16:56:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/utils/constant.js | 65 ++
src/mock/modules/enterprise.js | 124 ++++
src/utils/axios.js | 214 ++++++++
src/mock/modules/regionType.js | 32 +
.idea/jsLinters/eslint.xml | 6
src/api/enterprise.js | 12
src/utils/tools.js | 1044 ++++++++++++++++++++++++++++++++++++++++
src/components/panel/TopEnterprisePanel.vue | 22
8 files changed, 1,512 insertions(+), 7 deletions(-)
diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml
new file mode 100644
index 0000000..541945b
--- /dev/null
+++ b/.idea/jsLinters/eslint.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="EslintConfiguration">
+ <option name="fix-on-save" value="true" />
+ </component>
+</project>
\ No newline at end of file
diff --git a/src/api/enterprise.js b/src/api/enterprise.js
new file mode 100644
index 0000000..9bd6772
--- /dev/null
+++ b/src/api/enterprise.js
@@ -0,0 +1,12 @@
+import $http from '@/utils/axios'
+let $HOST = ''
+// 濡傛灉涓嶆槸寮�鍙戠増鏈寚瀹歶rl鍦板潃
+if (process.env.NODE_ENV !== 'development') {
+ $HOST = process.env.VUE_APP_API_HOST
+}
+
+export const EnterpriseList = $HOST + '/enterprise/list'
+
+export function listEnterprise (data) {
+ return $http.get(EnterpriseList, data)
+}
diff --git a/src/components/panel/TopEnterprisePanel.vue b/src/components/panel/TopEnterprisePanel.vue
index 306c7eb..3d94cbc 100644
--- a/src/components/panel/TopEnterprisePanel.vue
+++ b/src/components/panel/TopEnterprisePanel.vue
@@ -1,6 +1,6 @@
<template>
<div class="top-enterprise-panel">
- <el-form :inline="true" :model="formInline" ref="form" style="margin-left:5px">
+ <el-form :inline="true" ref="form" style="margin-left:5px" size="mini">
<el-form-item label="鍒嗙被锛�">
<el-select v-model="form.regionType" @change="handlePipelineType">
<el-option
@@ -12,9 +12,9 @@
</el-select>
</el-form-item>
<el-form-item label="浼佷笟鍚嶇О锛�">
- <el-select v-model="form.pipelineType" @change="handlePipelineType">
+ <el-select v-model="form.enterprise">
<el-option
- v-for="item in pipelineTypeOptions"
+ v-for="item in enterpriseOptions"
:key="item.value"
:label="item.label"
:value="item.value">
@@ -22,7 +22,7 @@
</el-select>
</el-form-item>
<el-form-item label="妯$硦鎼滅储锛�">
- <el-input v-model="form.name" placeholder="鍦ㄦ杈撳叆杞藉叿鍙�"></el-input>
+ <el-input v-model="form.name" placeholder="璇疯緭鍏ュ叧閿瓧鎼滅储"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">鏌ヨ</el-button>
@@ -32,6 +32,8 @@
</template>
<script>
+import { listEnterprise } from '@/api/enterprise'
+
export default {
name: 'TopEnterprisePanel',
components: {},
@@ -79,7 +81,8 @@
label: '鑼傚悕娑︽粦娌�'
}],
form: {
- regionType: ''
+ regionType: '',
+ enterprise: ''
}
}
},
@@ -90,15 +93,20 @@
handleClick (tab, event) {
console.log(tab, event)
},
- handleSearch () {
+ handlePipelineType (item) {
+ },
+ loadData () {
+ listEnterprise({}).then((res) => {
+ console.log(res)
+ })
},
onSubmit () {
}
},
mounted () {
- this.handleSearch()
+ this.loadData()
}
}
</script>
diff --git a/src/mock/modules/enterprise.js b/src/mock/modules/enterprise.js
new file mode 100644
index 0000000..51bb282
--- /dev/null
+++ b/src/mock/modules/enterprise.js
@@ -0,0 +1,124 @@
+// modules/user.js
+const listEnterprise = {
+ url: '/enterprise/list',
+ type: 'get',
+ response: () => {
+ return {
+ code: 200,
+ data: {
+ 1: [{
+ value: '1',
+ label: '閲戦櫟鐭冲寲'
+ }, {
+ value: '2',
+ label: '鎵瓙鐭冲寲锛堟嘲宸烇級'
+ }, {
+ value: '3',
+ label: '鎵瓙鐭冲寲锛堟竻姹燂級'
+ }, {
+ value: '4',
+ label: '闀垮箔鐐煎寲'
+ }, {
+ value: '5',
+ label: '浠緛鍖栫氦'
+ }, {
+ value: '6',
+ label: '鍗楀寲鍏徃'
+ }, {
+ value: '7',
+ label: '鑽嗛棬鐭冲寲'
+ }, {
+ value: '8',
+ label: '婀栧寳鍖栬偉'
+ }, {
+ value: '9',
+ label: '宸撮櫟鐭冲寲'
+ }, {
+ value: '10',
+ label: '涔濇睙鐭冲寲'
+ }, {
+ value: '11',
+ label: '涓煩鐭冲寲锛堟姹夛級'
+ }, {
+ value: '12',
+ label: '鍥涘窛缁村凹绾�'
+ }, {
+ value: '13',
+ label: '涓婃捣娑︽粦娌瑰叕鍙�'
+ }, {
+ value: '14',
+ label: '鑽嗛棬娑︽粦娌瑰叕鍙�'
+ }],
+ 2: [{
+ value: '2',
+ label: '娲涢槼鐭冲寲'
+ }, {
+ value: '2',
+ label: '涓師鐭冲寲'
+ }],
+ 3: [{
+ value: '1',
+ label: '鍖楁捣鐐煎寲'
+ }, {
+ value: '2',
+ label: '鑼傚悕鐭冲寲'
+ }, {
+ value: '3',
+ label: '婀涙睙涓滃叴'
+ }, {
+ value: '4',
+ label: '骞垮窞鐭冲寲'
+ }, {
+ value: '5',
+ label: '娴峰崡鐐煎寲'
+ }, {
+ value: '6',
+ label: '鑼傚悕娑︽粦娌�'
+ }],
+ 4: [{
+ value: '1',
+ label: '澶╂触鐭冲寲'
+ }, {
+ value: '2',
+ label: '娴庡崡鐐煎寲'
+ }, {
+ value: '3',
+ label: '榻愰瞾鐭冲寲'
+ }],
+ 5: [{
+ value: '1',
+ label: '鐕曞北鐭冲寲'
+ }],
+ 6: [{
+ value: '1',
+ label: '鍌寲鍓備笂娴峰叕鍙�'
+ }, {
+ value: '2',
+ label: '鍌寲鍓備笂娴风珛寰楀叕鍙�'
+ }, {
+ value: '3',
+ label: '鍌寲鍓傞暱宀叕鍙�'
+ }, {
+ value: '4',
+ label: '鍌寲鍓傚崡浜叕鍙�'
+ }, {
+ value: '5',
+ label: '鍌寲鍓傞綈椴佸叕鍙�'
+ }, {
+ value: '6',
+ label: '鍌寲鍓傛姎椤哄叕鍙�'
+ }, {
+ value: '7',
+ label: '鍌寲鍓傚寳浜叕鍙�'
+ }, {
+ value: '8',
+ label: '鍌寲鍓傚寳浜ゥ杈惧叕鍙�'
+ }]
+ }
+ }
+ }
+}
+
+module.exports = [
+ listEnterprise
+]
diff --git a/src/mock/modules/regionType.js b/src/mock/modules/regionType.js
new file mode 100644
index 0000000..14b229e
--- /dev/null
+++ b/src/mock/modules/regionType.js
@@ -0,0 +1,32 @@
+const listRegion = {
+ url: '/region/list',
+ type: 'get',
+ response: () => {
+ return {
+ code: 200,
+ data: [{
+ value: '1',
+ label: '闀挎睙娴佸煙'
+ }, {
+ value: '2',
+ label: '榛勬渤娴佸煙'
+ }, {
+ value: '3',
+ label: '鍗楅儴娌挎捣姘村煙'
+ }, {
+ value: '4',
+ label: '鐜袱娴锋按鍩�'
+ }, {
+ value: '5',
+ label: '鍏朵粬鍦板煙'
+ }, {
+ value: '6',
+ label: '鍌寲鍓傚叕鍙�'
+ }]
+ }
+ }
+}
+
+module.exports = [
+ listRegion
+]
diff --git a/src/utils/axios.js b/src/utils/axios.js
new file mode 100644
index 0000000..a5bb1ab
--- /dev/null
+++ b/src/utils/axios.js
@@ -0,0 +1,214 @@
+import Vue from 'vue'
+import axios from 'axios'
+import * as $CONST from '@/utils/constant'
+import * as $T from '@/utils/tools'
+// import $store from '@/store'
+
+/**
+ * 瀹氫箟浼犲叆鍙傛暟鏁版嵁鏍煎紡
+ *
+ * === 鍒犻櫎鏁版嵁 ===
+ * {
+ * key:['dataId1','dataId2']
+ * }
+ *
+ */
+
+/**
+ * 瀹氫箟杩斿洖鐨刯son鏁版嵁鏍煎紡
+ *
+ * === 鍒嗛〉鏁版嵁 ===
+ * {
+ * code:200, --- 鐩墠妗嗘灦璁や负0鍜�200閮芥槸鎴愬姛鐘舵��
+ * message:'鎸変笟鍔¤嚜瀹氫箟',
+ * data:{
+ * records:[{...},{...}], --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴��
+ * total:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴��
+ * size:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴��
+ * current:xx, --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴��
+ * pages:xx --- 鍙寜鑷繁涓氬姟鏇挎崲灞炴��
+ * },
+ * }
+ *
+ * === 鍒楄〃鏁版嵁 ===
+ *
+ * {
+ * code:200,
+ * message:'鎸変笟鍔¤嚜瀹氫箟',
+ * data:[{..},{..}...]
+ * }
+ *
+ * === 涓�鏉℃暟鎹� ===
+ *
+ * {
+ * code:200,
+ * message:'鎸変笟鍔¤嚜瀹氫箟',
+ * data:{...}
+ * }
+ *
+ * === 鏃犺繑鍥炴暟鎹� ===
+ *
+ * {
+ * code:200,
+ * message:'鎸変笟鍔¤嚜瀹氫箟',
+ * data: null
+ * }
+ *
+ * === 鏍戝舰缁撴瀯 ===
+ *
+ * {
+ * code:200,
+ * message:'鎸変笟鍔¤嚜瀹氫箟'
+ * data:[{
+ * prop:xx,
+ * ...
+ * children: [
+ * prop:xx,
+ * ...
+ * children:[...]
+ * ]
+ * },
+ * {
+ * prop:xx,
+ * ...
+ * children: [
+ * prop:xx,
+ * ...
+ * children:[...]
+ * ]
+ * }]
+ * }
+ *
+ */
+
+// 鍒涘缓axios瀹炰緥
+const Service = axios.create({
+ timeout: 1000
+})
+
+const CancelToken = axios.CancelToken
+
+/*
+ function showDebugInfo(config) {
+ console.group('%cMethod::' + config.method + '::Url::' + config.url, 'color:red;font-size:12px;')
+ console.log('%c淇濆瓨/鏇存柊/鏌ョ湅鍦哄悎锛屼紶鍏ョ殑鍙傛暟::', 'font-size:12px;')
+ console.log(config.hasOwnProperty('params') ? JSON.stringify(config.params) : JSON.stringify(config.data))
+ console.groupEnd()
+ }
+
+ function filterOauthData(config) {
+ let url = config.url
+ if (config.method === 'post' && $t.isExistOauthApi(url)) {
+ // post璇锋眰鐨勫満鍚堜笅锛岃拷鍔犺鑹插悕绉�
+ }
+
+ if (config.method === 'get' && $t.isExistOauthApi(url)) {
+ // get璇锋眰鐨勫満鍚堜笅锛岃拷鍔犺鑹插悕绉�
+ if (config.hasOwnProperty('params')) {
+ config.params['userCode'] = ''
+ } else {
+ config['params'] = {}
+ config.params['userCode'] = ''
+ }
+ }
+ return config
+ } */
+
+// request鎷︽埅鍣�
+Service.interceptors.request.use(
+ config => {
+ // 涓存椂杩藉姞
+ // if ($store.state.user.account) {
+ // config.headers.account = $store.state.user.account
+ // }
+ const copyConfig = Object.assign({}, config)
+ // copyConfig = filterOauthData(copyConfig)
+ // showDebugInfo(copyConfig)
+ copyConfig.cancelToken = new CancelToken((c) => {
+ // 椤甸潰澶辨晥鍦烘櫙锛屽彇娑坧adding涓姹�
+ Vue.prototype.$cancels.push(c)
+ // todo 蹇�熷弻鍑诲彇娑堥噸澶嶈姹�
+ // 閲嶅璇锋眰鍦烘櫙锛屽彇娑堟帀涓婁竴涓湭padding涓姹�
+ })
+ return copyConfig
+ },
+ error => {
+ Promise.reject(error)
+ })
+
+// respone鎷︽埅鍣�
+Service.interceptors.response.use(
+ response => {
+ const res = response.data
+ if (Number(res.code) !== 200 && Number(res.code) !== 0) {
+ $T.warning(res.message)
+ return Promise.reject(res.message)
+ } else {
+ return res
+ }
+ },
+ error => {
+ if (error.message && error.message.includes('timeout')) {
+ $T.fail($CONST.MSG_SYS_TIME_OUT)
+ return Promise.reject(error)
+ }
+
+ if (!error.response) {
+ $T.fail($CONST.MSG_SYS_ERR)
+ return Promise.reject(error)
+ }
+
+ switch (error.response.status) {
+ // http status handler
+ case 404:
+ $T.fail($CONST.MSG_SYS_404)
+ break
+ case 500:
+ $T.fail($CONST.MSG_SYS_ERR)
+ break
+ case 503:
+ $T.fail($CONST.MSG_SYS_503)
+ break
+ }
+
+ return Promise.reject(error)
+ }
+)
+
+const $http = {}
+$http.$service = Service
+$http.$axios = axios
+$http.get = function (url, params = {}) {
+ if ($T.isInlineParams(url)) {
+ // 涓ユ牸閬靛惊restful鏍囧噯鐨剈rl鐨勫満鏅�
+ url = $T.replaceUrlParams(url, params)
+ params = {}
+ }
+ return Service({
+ url: url,
+ method: 'get',
+ params: $T.filterParams(params)
+ })
+}
+$http.post = function (url, data = {}) {
+ return Service({
+ url: url,
+ method: 'post',
+ data: data
+ })
+}
+$http.put = function (url, data = {}) {
+ return Service({
+ url: url,
+ method: 'put',
+ data: data
+ })
+}
+$http.delete = function (url, data = {}) {
+ return Service({
+ url: url,
+ method: 'delete',
+ data: data
+ })
+}
+export default $http
diff --git a/src/utils/constant.js b/src/utils/constant.js
new file mode 100644
index 0000000..f80da21
--- /dev/null
+++ b/src/utils/constant.js
@@ -0,0 +1,65 @@
+/* 鏃ユ湡璁剧疆
+ -------------------------- */
+export const PICKER_OPTIONS_SHORTCUTS = [
+ {
+ text: '浠婂ぉ',
+ onClick (picker) {
+ const end = new Date()
+ const start = new Date(new Date().toDateString())
+ end.setTime(start.getTime())
+ picker.$emit('pick', [start, end])
+ }
+ }, {
+ text: '鏈�杩戜竴鍛�',
+ onClick (picker) {
+ const end = new Date(new Date().toDateString())
+ const start = new Date()
+ start.setTime(end.getTime() - 3600 * 1000 * 24 * 7)
+ picker.$emit('pick', [start, end])
+ }
+ }, {
+ text: '鏈�杩戜竴涓湀',
+ onClick (picker) {
+ const end = new Date(new Date().toDateString())
+ const start = new Date()
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
+ picker.$emit('pick', [start, end])
+ }
+ }, {
+ text: '鏈�杩戜笁涓湀',
+ onClick (picker) {
+ const end = new Date(new Date().toDateString())
+ const start = new Date()
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
+ picker.$emit('pick', [start, end])
+ }
+ }]
+
+/* 绯荤粺閿欒娑堟伅
+ -------------------------- */
+export const MSG_SYS_ERR = '鏈嶅姟鍣ㄥ唴閮ㄨ繍琛岄敊璇紝璇风◢鍚庨噸璇曪紒'
+export const MSG_SYS_TIME_OUT = '褰撳墠缃戠粶鐜杈冨樊锛岃闂秴鏃讹紝璇峰埛鏂伴噸璇曪紒'
+export const MSG_SYS_404 = '璇锋眰鐨勮祫婧愪笉瀛樺湪锛�'
+export const MSG_SYS_503 = '鏈嶅姟鍣ㄦ鍦ㄧ淮鎶わ紝璇风◢绛夛紒'
+export const MSG_SYS_SUCCESS = '鎿嶄綔鎴愬姛锛�'
+export const MSG_SYS_FAIL = '鎿嶄綔澶辫触锛�'
+export const MSG_SYS_CANCELED = '鎿嶄綔宸插彇娑堬紒'
+export const MSG_SYS_WARNING = '璀﹀憡锛屾湭鎸夎鍒欐搷浣滐紒'
+
+export const MSG_RULES_NUMBER = '蹇呴』涓烘暟瀛楀�硷紒'
+export const MSG_RULES_REQUIRED = '涓嶈兘涓虹┖锛�'
+
+export const MSG_BUSINESS_DELETE = '鍒犻櫎璇ユ暟鎹�, 鏄惁缁х画锛�'
+export const MSG_BUSINESS_SUBMIT = '鎻愪氦璇ユ暟鎹�, 鏄惁缁х画锛�'
+export const MSG_BUSINESS_SELECTED = '璇烽�夋嫨瑕佹搷浣滅殑鏁版嵁锛�'
+export const MSG_BUSINESS_START = '鍚敤璇ユ暟鎹�, 鏄惁缁х画锛�'
+export const MSG_BUSINESS_STOP = '鍋滅敤璇ユ暟鎹�, 鏄惁缁х画锛�'
+export const MSG_BUSINESS_IMPORT = '璇疯�愬績绛夊緟锛屾暟鎹鍏ヤ腑...'
+export const MSG_BUSINESS_EXPORT = '璇疯�愬績绛夊緟锛屾暟鎹鍑轰腑...'
+export const MSG_BUSINESS_EXPORT_ALL = '瀵煎嚭鏉′欢绛涢�夊嚭鐨勫叏閮ㄦ暟鎹�'
+export const MSG_BUSINESS_UPLOAD = '璇疯�愬績绛夊緟锛屾枃浠朵笂浼犱腑...'
+export const MSG_BUSINESS_UPLOAD_SUCCESS = '涓婁紶鎴愬姛锛�'
+export const MSG_BUSINESS_UPLOAD_FAIL = '涓婁紶澶辫触锛�'
+export const MSG_BUSINESS_UPLOAD_IMG = '涓婁紶鍥剧墖鍙兘鏄� JPG/PNG 鏍煎紡锛�'
+export const MSG_BUSINESS_UPLOAD_SIZE_2M = '涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 2MB锛�'
+export const MSG_BUSINESS_UPLOAD_SIZE_10M = '涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 10MB锛�'
diff --git a/src/utils/tools.js b/src/utils/tools.js
new file mode 100644
index 0000000..9aeb1f0
--- /dev/null
+++ b/src/utils/tools.js
@@ -0,0 +1,1044 @@
+
+import * as $CONST from './constant'
+// import { notify } from '@nutui/nutui'
+
+export const _ = require('lodash')
+const notify = window.vm.$notify
+/**
+ * 闆嗗悎杞崲涓篔SON
+ * @param obj collection鏁版嵁
+ * @author TJ 2019/03/11
+ * @example 鐣�
+ */
+export function collectionToJson (collection) {
+ if (!_.isArray(collection)) return []
+ const arr = []
+ // 鏁版嵁浣�
+ _.forEach(collection, function (item) {
+ const tempObj = {}
+ if (Object.prototype.hasOwnProperty.call(item, 'data') && _.isArray(item.data)) {
+ _.forEach(item.data, function (obj) {
+ tempObj[_.trim(obj.name)] = _.trim(obj.value)
+ })
+ }
+ arr.push(tempObj)
+ })
+ return arr
+}
+
+/**
+ * collection鏁版嵁杞崲涓烘爣鍑咼SON
+ * @param obj collection鏁版嵁
+ * @author TJ 2019/03/11
+ * @example 鐣�
+ */
+export function transformStandardJson (obj) {
+ let body = {}
+ let data = null
+ let pages = null
+ const collection = obj.collection
+ if (_.isObject(collection)) {
+ // 閿欒鐨勫満鏅�
+ if (Object.prototype.hasOwnProperty.call(collection, 'items')) {
+ return {
+ code: 300,
+ body: null,
+ msg: collection.error
+ }
+ }
+ // 鏁版嵁浣�
+ if (Object.prototype.hasOwnProperty.call(collection, 'items') && _.isArray(collection.items)) {
+ data = collectionToJson(collection.items)
+ }
+ // 鍒嗛〉淇℃伅
+ if (Object.prototype.hasOwnProperty.call(collection, 'page') && _.isArray(collection.data)) {
+ pages = collectionToJson([collection.page])
+ }
+ // 缁勮body鏁版嵁
+ body = {
+ data: data
+ }
+
+ if (pages) {
+ _.extend(body, {
+ total: pages[0].totalElements,
+ pageIndex: 0,
+ pageSize: pages[0].size,
+ pages: pages[0].totalPages
+ })
+ }
+
+ return {
+ code: 200,
+ body: body,
+ msg: '鎿嶄綔鎴愬姛'
+ }
+ }
+}
+
+/**
+ * POST PUT绛夎姹傚弬鏁拌浆鎹㈡垚闆嗗悎
+ * @param json object
+ * @returns collection
+ * @author TJ 2019/03/11
+ * @example 鐣�
+ */
+export function transformParams (obj) {
+ const collection = {
+ version: '1.0',
+ href: '',
+ items: [],
+ templates: []
+ }
+ if (_.isObject(obj)) {
+ const arr = []
+ _.each(obj, function (val, key) {
+ let newVal = val
+ if (_.isArray(val)) {
+ newVal = val.join(',')
+ }
+ arr.push({
+ name: key,
+ value: newVal
+ })
+ })
+
+ const o = {
+ data: arr
+ }
+ collection.templates.push(o)
+ }
+ return {
+ collection: collection
+ }
+}
+
+/**
+ * 灏嗗唴瀹瑰瓨鍌ㄥ埌sessionStorage
+ * @param key {string} key
+ * @param content {Object} 瀛樺偍json瀵硅薄
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function setSessionStorage (key, content) {
+ if (!key) return false
+ const jsonContent = JSON.stringify(content)
+ jsonContent ? sessionStorage.setItem(key, jsonContent) : sessionStorage.setItem(key, content)
+}
+
+/**
+ * 鑾峰彇瀛樺偍鍒皊essionStorage鐨勫唴瀹�
+ * @param key {string} key
+ * @return {object} 杩斿洖json瀵硅薄
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function getSessionStorage (key) {
+ const item = sessionStorage.getItem(key)
+ if (!item) return false
+ const result = JSON.parse(sessionStorage.getItem(key))
+ return result || item
+}
+
+/**
+ * 鍒犻櫎瀛樺偍鍒皊essionStorage鐨勫唴瀹�
+ * @param key {string} key
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function removeSessionStorage (key) {
+ sessionStorage.removeItem(key)
+}
+
+/**
+ * 灏嗗唴瀹瑰瓨鍌ㄥ埌localStorage
+ * @param key {string} key
+ * @param content {Object} 瀛樺偍json瀵硅薄
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function setLocalStorage (key, content) {
+ if (!key) return false
+ const jsonContent = JSON.stringify(content)
+ jsonContent ? localStorage.setItem(key, jsonContent) : localStorage.setItem(key, content)
+}
+
+/**
+ * 鑾峰彇瀛樺偍鍒發ocalStorage鐨勫唴瀹�
+ * @param key {string} key
+ * @return {object} 杩斿洖json瀵硅薄
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function getLocalStorage (key) {
+ const item = localStorage.getItem(key)
+ if (!item) return false
+ const result = JSON.parse(localStorage.getItem(key))
+ return result || item
+}
+
+/**
+ * localStorage
+ * @param key {string} key
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function removeLocalStorage (key) {
+ localStorage.removeItem(key)
+}
+
+/**
+ * 鍒ゆ柇json瀵硅薄鏄惁涓虹┖瀵硅薄
+ * @param obj {object} json瀵硅薄
+ * @return {boolean} 绌哄璞¤繑鍥� true 鍚﹀垯杩斿洖 false
+ * @author TJ 2018/05/28
+ * @example 鐣�
+ */
+export function isEmptyObject (obj) {
+ if (obj === null) return true
+ return Object.keys(obj).length === 0
+}
+
+/**
+ * 杩囨护鍙傛暟
+ * @param params {object} 闇�瑕佹牸寮忓寲鐨勬椂闂�
+ * @return {object} 鏍煎紡鍖栧悗鐨勬椂闂�
+ * @author TJ 2017/05/28
+ * @example 鐣�
+ */
+export function filterParams (params) {
+ if (!_.isObject(params)) {
+ return params
+ }
+ const newParams = {}
+ _.each(params, function (v, k) {
+ // 杩囨护鎺夋潯浠舵槸绌虹殑椤�
+ if (typeof v === 'string' && (v.length === 0 || v === '*鍏�*閮�*')) {
+
+ } else {
+ newParams[k] = v
+ }
+ })
+ return newParams
+}
+
+/**
+ * 灏唍ull杞崲涓虹┖瀵硅薄
+ * @param params {obj}
+ * @author TJ 2018/05/31
+ */
+export function emptyObjectWrapper (obj) {
+ return obj === null ? {} : obj
+}
+
+/**
+ * 鏍煎紡鍖栨椂闂�
+ * @param time {string} 闇�瑕佹牸寮忓寲鐨勬椂闂�
+ * @param cFormat {string} 鏃堕棿鏍煎紡
+ * @return {string} 鏍煎紡鍖栧悗鐨勬椂闂�
+ * @author TJ 2017/07/21
+ * @example 鐣�
+ */
+export function parseTime (time, cFormat) {
+ if (!time) return false
+ if (arguments.length === 0) {
+ return false
+ }
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+ let date
+ if (typeof time === 'object') {
+ date = time
+ } else {
+ if (('' + time).length === 10) time = parseInt(time) * 1000
+ if (('' + time).length === 8 && ('' + time).indexOf('-') === -1 && ('' + time).indexOf('/') === -1) {
+ time = time.substring(0, 4) + '-' + time.substring(4, 6) + '-' + time.substring(6, 8)
+ }
+
+ date = new Date(time)
+ }
+ const formatObj = {
+ y: date.getFullYear(),
+ m: date.getMonth() + 1,
+ d: date.getDate(),
+ h: date.getHours(),
+ i: date.getMinutes(),
+ s: date.getSeconds(),
+ a: date.getDay()
+ }
+ const timeStr = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
+ let value = formatObj[key]
+ if (key === 'a') return ['涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�', '鏃�'][value - 1]
+ if (result.length > 0 && value < 10) {
+ value = '0' + value
+ }
+ return value || 0
+ })
+ return timeStr
+}
+
+/**
+ * 灏嗘椂闂存暟缁勫垎鍓叉垚寮�濮嬫椂闂村拰缁撴潫鏃堕棿
+ * @param time {array}
+ * @return {object}
+ * @author TJ 2017/08/01
+ * @example 鐣�
+ */
+export function formatTime (time) {
+ if (Array.isArray(time)) {
+ if (!time[0] || !time[1]) return false
+ var start = parseTime(time[0], '{y}-{m}-{d}')
+ var end = parseTime(time[1], '{y}-{m}-{d}')
+ return {
+ start: start,
+ end: end
+ }
+ }
+
+ return false
+}
+
+/**
+ * 鏉冮檺API鎷兼帴鐢ㄦ埛鍚�
+ * @param api {String}
+ * @return {boolean}
+ * @author TJ 2017/08/01
+ * @example 鐣�
+ */
+export function getJoinOauthApi (url) {
+ const name = window._loginName ? window._loginName : ''
+ if (url.includes('?')) {
+ url += '&createId=' + name
+ } else {
+ url += 'createId=' + name
+ }
+ return url
+}
+
+/**
+ * 鎷兼帴鏌ヨURL
+ * @param url {String}
+ * @param obj {obj}
+ * @return {String}
+ * @author TJ 2017/08/01
+ * @example 鐣�
+ */
+export function joinQueryUrl (url, obj) {
+ let str = ''
+ let fullUrl = ''
+ for (const key in obj) {
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) return
+ if (str) {
+ str += '&'
+ }
+ str += key + '=' + obj[key]
+ }
+ if (url.includes('?')) {
+ fullUrl = url + '&' + str
+ } else {
+ fullUrl = url + '?' + str
+ }
+ return fullUrl
+}
+
+/**
+ * 鍒ゆ柇鍙傛暟鏄惁宓屽叆鍦╱rl涓�
+ * @param url {String}
+ * @return {Boolean}
+ * @author TJ 2018/08/27
+ */
+export function isInlineParams (url) {
+ const splitChar = '{$'
+ if (url && url.indexOf(splitChar) > -1) {
+ return true
+ } else {
+ return false
+ }
+}
+
+/**
+ * 鏇挎崲url閲岀殑鍙傛暟
+ * @param url {String}
+ * @param params {obj}
+ * @author TJ 2018/05/31
+ */
+export function replaceUrlParams (url, params) {
+ if (url) {
+ if (!isInlineParams(url)) {
+ return url
+ }
+ // 姝e垯鍖归厤{}锛岀敓鎴愭暟缁�
+ const patt = /\{.*?\}/g
+ const arr = url.match(patt) ? url.match(patt) : []
+ arr.forEach(function (item) {
+ const key = item.replace('{', '').replace('}', '').replace('$', '')
+ url = url.replace(item, params[key])
+ })
+ }
+ return url
+}
+
+/**
+ * 閰嶇疆Echart涓婚棰滆壊
+ * @param {obj} echart 瀹炰緥
+ * @author TJ 2017/10/17
+ * @return 鏃犺繑鍥炵粨鏋�
+ */
+export function resgisterTheme (echart) {
+ /* eslint-disable */
+ let theme = {
+ 'color': [
+ '#29d0b0',
+ '#2d99ed',
+ '#fd8667',
+ '#72ccff',
+ '#f7c5a0',
+ '#d4a4eb',
+ '#fdc547',
+ '#76f2f2',
+ '#da4d00',
+ '#b0419e'
+ ],
+ 'backgroundColor': 'transparents',
+ 'textStyle': {
+ 'itemStyle': {
+ 'normal': {
+ 'color': '#fff'
+ }
+ }
+ },
+ 'title': {
+ 'textStyle': {
+ 'color': '#ffffff'
+ },
+ 'subtextStyle': {
+ 'color': '#dddddd'
+ }
+ },
+ 'line': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': '1'
+ }
+ },
+ 'lineStyle': {
+ 'normal': {
+ 'width': '1'
+ }
+ },
+ 'symbolSize': '4',
+ 'symbol': 'circle',
+ 'smooth': false
+ },
+ 'radar': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': '4'
+ }
+ },
+ 'lineStyle': {
+ 'normal': {
+ 'width': '3'
+ }
+ },
+ 'symbolSize': '1',
+ 'symbol': 'circle',
+ 'smooth': true
+ },
+ 'bar': {
+ 'itemStyle': {
+ 'normal': {
+ 'barBorderWidth': 0,
+ 'barBorderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'barBorderWidth': 0,
+ 'barBorderColor': '#ccc'
+ }
+ }
+ },
+ 'pie': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'scatter': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'boxplot': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'parallel': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'sankey': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'funnel': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ },
+ 'emphasis': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ }
+ },
+ 'gauge': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 1,
+ 'borderColor': '#fff'
+ },
+ 'emphasis': {
+ 'borderWidth': 1,
+ 'borderColor': '#fff'
+ }
+ }
+ },
+ 'candlestick': {
+ 'itemStyle': {
+ 'normal': {
+ 'color': '#fc97af',
+ 'color0': 'transparent',
+ 'borderColor': '#fc97af',
+ 'borderColor0': '#87f7cf',
+ 'borderWidth': '2'
+ }
+ }
+ },
+ 'graph': {
+ 'itemStyle': {
+ 'normal': {
+ 'borderWidth': 0,
+ 'borderColor': '#ccc'
+ }
+ },
+ 'lineStyle': {
+ 'normal': {
+ 'width': '1',
+ 'color': '#ffffff'
+ }
+ },
+ 'symbolSize': '5',
+ 'symbol': 'circle',
+ 'smooth': true,
+ 'color': [
+ '#29d0b0',
+ '#2d99ed',
+ '#fd8667',
+ '#72ccff',
+ '#f7c5a0',
+ '#d4a4eb',
+ '#fdc547',
+ '#76f2f2',
+ '#da4d00',
+ '#b0419e'
+ ],
+ 'label': {
+ 'normal': {
+ 'textStyle': {
+ 'color': '#293441'
+ }
+ }
+ }
+ },
+ 'map': {
+ 'itemStyle': {
+ 'normal': {
+ 'areaColor': '#f3f3f3',
+ 'borderColor': '#999999',
+ 'borderWidth': 0.5
+ },
+ 'emphasis': {
+ 'areaColor': 'rgba(255,178,72,1)',
+ 'borderColor': '#eb8146',
+ 'borderWidth': 1
+ }
+ },
+ 'label': {
+ 'normal': {
+ 'textStyle': {
+ 'color': '#893448'
+ }
+ },
+ 'emphasis': {
+ 'textStyle': {
+ 'color': 'rgb(137,52,72)'
+ }
+ }
+ }
+ },
+ 'geo': {
+ 'itemStyle': {
+ 'normal': {
+ 'areaColor': '#f3f3f3',
+ 'borderColor': '#999999',
+ 'borderWidth': 0.5
+ },
+ 'emphasis': {
+ 'areaColor': 'rgba(255,178,72,1)',
+ 'borderColor': '#eb8146',
+ 'borderWidth': 1
+ }
+ },
+ 'label': {
+ 'normal': {
+ 'textStyle': {
+ 'color': '#893448'
+ }
+ },
+ 'emphasis': {
+ 'textStyle': {
+ 'color': 'rgb(137,52,72)'
+ }
+ }
+ }
+ },
+ 'categoryAxis': {
+ 'axisLine': {
+ 'show': true,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisTick': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisLabel': {
+ 'show': true,
+ 'textStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'splitLine': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': [
+ '#e6e6e6'
+ ]
+ }
+ },
+ 'splitArea': {
+ 'show': false,
+ 'areaStyle': {
+ 'color': [
+ 'rgba(250,250,250,0.05)',
+ 'rgba(200,200,200,0.02)'
+ ]
+ }
+ }
+ },
+ 'valueAxis': {
+ 'axisLine': {
+ 'show': true,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisTick': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisLabel': {
+ 'show': true,
+ 'textStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'splitLine': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': [
+ '#e6e6e6'
+ ]
+ }
+ },
+ 'splitArea': {
+ 'show': false,
+ 'areaStyle': {
+ 'color': [
+ 'rgba(250,250,250,0.05)',
+ 'rgba(200,200,200,0.02)'
+ ]
+ }
+ }
+ },
+ 'logAxis': {
+ 'axisLine': {
+ 'show': true,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisTick': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': '#333'
+ }
+ },
+ 'axisLabel': {
+ 'show': true,
+ 'textStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'splitLine': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': [
+ '#e6e6e6'
+ ]
+ }
+ },
+ 'splitArea': {
+ 'show': false,
+ 'areaStyle': {
+ 'color': [
+ 'rgba(250,250,250,0.05)',
+ 'rgba(200,200,200,0.02)'
+ ]
+ }
+ }
+ },
+ 'timeAxis': {
+ 'axisLine': {
+ 'show': true,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisTick': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'axisLabel': {
+ 'show': true,
+ 'textStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'splitLine': {
+ 'show': false,
+ 'lineStyle': {
+ 'color': [
+ '#fff'
+ ]
+ }
+ },
+ 'splitArea': {
+ 'show': false,
+ 'areaStyle': {
+ 'color': [
+ 'rgba(250,250,250,0.05)',
+ 'rgba(200,200,200,0.02)'
+ ]
+ }
+ }
+ },
+ 'toolbox': {
+ 'iconStyle': {
+ 'normal': {
+ 'borderColor': '#999999'
+ },
+ 'emphasis': {
+ 'borderColor': '#666666'
+ }
+ }
+ },
+ 'legend': {
+ 'textStyle': {
+ 'color': '#e0e0e0'
+ }
+ },
+ 'tooltip': {
+ 'axisPointer': {
+ 'lineStyle': {
+ 'color': '#cccccc',
+ 'width': 1
+ },
+ 'crossStyle': {
+ 'color': '#cccccc',
+ 'width': 1
+ }
+ }
+ },
+ 'timeline': {
+ 'lineStyle': {
+ 'color': '#87f7cf',
+ 'width': 1
+ },
+ 'itemStyle': {
+ 'normal': {
+ 'color': '#87f7cf',
+ 'borderWidth': 1
+ },
+ 'emphasis': {
+ 'color': '#f7f494'
+ }
+ },
+ 'controlStyle': {
+ 'normal': {
+ 'color': '#87f7cf',
+ 'borderColor': '#87f7cf',
+ 'borderWidth': 0.5
+ },
+ 'emphasis': {
+ 'color': '#87f7cf',
+ 'borderColor': '#87f7cf',
+ 'borderWidth': 0.5
+ }
+ },
+ 'checkpointStyle': {
+ 'color': '#fc97af',
+ 'borderColor': 'rgba(252,151,175,0.3)'
+ },
+ 'label': {
+ 'normal': {
+ 'textStyle': {
+ 'color': '#87f7cf'
+ }
+ },
+ 'emphasis': {
+ 'textStyle': {
+ 'color': '#87f7cf'
+ }
+ }
+ }
+ },
+ 'visualMap': {
+ 'color': [
+ '#fc97af',
+ '#87f7cf'
+ ]
+ },
+ 'dataZoom': {
+ 'backgroundColor': 'rgba(255,255,255,0)',
+ 'dataBackgroundColor': 'rgba(114,204,255,1)',
+ 'fillerColor': 'rgba(114,204,255,0.2)',
+ 'handleColor': '#72ccff',
+ 'handleSize': '100%',
+ 'textStyle': {
+ 'color': '#fff'
+ }
+ },
+ 'markPoint': {
+ 'label': {
+ 'normal': {
+ 'textStyle': {
+ 'color': '#293441'
+ }
+ },
+ 'emphasis': {
+ 'textStyle': {
+ 'color': '#293441'
+ }
+ }
+ }
+ }
+ }
+ echart.registerTheme('dark', theme)
+ /* eslint-enable */
+}
+
+/**
+ * 鏍规嵁璺敱鍒囨崲鐨偆鏍囪瘑锛岄粯璁ょ毊鑲ゆ湭钃濊壊
+ * @author TJ 2019/05/29
+ */
+export function changeThemeClass (toRouterName) {
+ const darkSkinRouterName = []
+
+ if (darkSkinRouterName.includes(toRouterName)) {
+ document.body.className = 'dark'
+ } else {
+ document.body.className = 'blue'
+ }
+}
+
+/**
+ * 鍒ゆ柇瑕佹煡璇㈢殑鏁扮粍鏄惁鑷冲皯鏈変竴涓厓绱犲寘鍚湪鐩爣鏁扮粍涓�
+ * @param {Array} target 鐩爣鏁扮粍
+ * @param {Array} arr 闇�瑕佹煡璇㈢殑鏁扮粍
+ */
+export const hasOneOf = (targetarr, arr) => {
+ return targetarr.some(_ => arr.indexOf(_) > -1)
+}
+
+/**
+ * 鍒ゆ柇涓や釜瀵硅薄鏄惁鐩哥瓑锛岃繖涓や釜瀵硅薄鐨勫�煎彧鑳芥槸鏁板瓧鎴栧瓧绗︿覆
+ * @param {Object} obj1 瀵硅薄
+ * @param {Object} obj2 瀵硅薄
+ */
+export const objEqual = (obj1, obj2) => {
+ const keysArr1 = Object.keys(obj1)
+ const keysArr2 = Object.keys(obj2)
+ if (keysArr1.length !== keysArr2.length) return false
+ else if (keysArr1.length === 0 && keysArr2.length === 0) return true
+ /* eslint-disable-next-line */
+ else return !keysArr1.some(key => obj1[key] != obj2[key])
+}
+
+/**
+ * 鍒ゆ柇鍊兼槸鍚︿负鐪�,涓嶅寘鎷0鐨勫垽鏂�
+ * @param {String} val 瀛楃
+ */
+export function isTrue (val) {
+ return !_.isNull(val) && !_.isUndefined(val) && val !== ''
+}
+
+/**
+ * 瑙f瀽URL鍙傛暟
+ *
+ * @param {String} url
+ * @return {object}
+ */
+export function getQueryObject (url = window.location.href) {
+ if (!url) return
+ const search = url.substring(url.lastIndexOf('?') + 1)
+ const obj = {}
+ const reg = /([^?&=]+)=([^?&=]*)/g
+ search.replace(reg, function (rs, $1, $2) {
+ const name = decodeURIComponent($1)
+ let val = decodeURIComponent($2)
+ val = String(val)
+ obj[name] = val
+ // return rs
+ })
+ return obj
+}
+
+/**
+ * 閫掑綊鏌ヨ鏍戣妭鐐�
+ *
+ * @param {object} treeData 鏍戠粨鏋勬暟鎹泦鍚�
+ * @param {string} prop 灞炴�у瓧娈�
+ * @param {string} propValue 灞炴�у搴旂殑鍊�
+ * @return {object} 鑺傜偣瀵硅薄
+ */
+export function recursion (tree, prop, propValue) {
+ if (!tree || !Array.isArray(tree)) return false
+ let result = {}
+
+ function handelTree (tree) {
+ for (const o of tree) {
+ if (o.children && Array.isArray(o.children) && o.children.length) {
+ if (o[prop] !== propValue) {
+ // 閫掑綊
+ handelTree(o.children)
+ } else {
+ result = o
+ break
+ }
+ } else {
+ if (o[prop] === propValue) {
+ result = o
+ }
+ }
+ }
+ return result
+ }
+
+ return handelTree(tree)
+}
+
+export function success (msg = $CONST.MSG_SYS_SUCCESS) {
+ notify.success(msg)
+}
+
+export function fail (msg = $CONST.MSG_SYS_FAIL) {
+ notify.warn(msg)
+}
+
+export function error (msg = $CONST.MSG_SYS_ERR) {
+ notify.danger(msg)
+}
+
+export function warning (msg = $CONST.MSG_SYS_WARNING) {
+ notify.warn(msg)
+}
+
+export function info (msg = $CONST.MSG_SYS_CANCELED) {
+ notify.primary(msg)
+}
+
+/**
+ * 寮傛鍔犺浇缁勪欢
+ * @author TJ 2019/05/30
+ */
+
+/* eslint-disable */
+export function lazyLoadView(AsyncView) {
+ const AsyncComponent = () => ({
+ // 闇�瑕佸姞杞界殑缁勪欢 (搴旇鏄竴涓� `Promise` 瀵硅薄)
+ component: AsyncView,
+ // 寮傛缁勪欢鍔犺浇鏃朵娇鐢ㄧ殑缁勪欢
+ loading: '',
+ // 鍔犺浇澶辫触鏃朵娇鐢ㄧ殑缁勪欢
+ error: '',
+ // 灞曠ず鍔犺浇鏃剁粍浠剁殑寤舵椂鏃堕棿銆傞粯璁ゅ�兼槸 200 (姣)
+ delay: 200,
+ // 濡傛灉鎻愪緵浜嗚秴鏃舵椂闂翠笖缁勪欢鍔犺浇涔熻秴鏃朵簡锛�
+ // 鍒欎娇鐢ㄥ姞杞藉け璐ユ椂浣跨敤鐨勭粍浠躲�傞粯璁ゅ�兼槸锛歚Infinity`
+ timeout: 3000
+ })
+
+ return Promise.resolve({
+ functional: true,
+ render(h, { data, children }) {
+ // Transparently pass any props or children
+ // to the view component.
+ return h(AsyncComponent, data, children)
+ }
+ })
+}
--
Gitblit v1.8.0