58208073 by yuanbo

增加注释

1 parent 3bcc3c6b
...@@ -15,6 +15,11 @@ const mutations = { ...@@ -15,6 +15,11 @@ const mutations = {
15 } 15 }
16 16
17 const actions = { 17 const actions = {
18 /**
19 * @description: generateDic
20 * @param {*} commit
21 * @author: renchao
22 */
18 generateDic ({ commit }) { 23 generateDic ({ commit }) {
19 return new Promise(async (resolve) => { 24 return new Promise(async (resolve) => {
20 let { result: res } = await getAllDict() 25 let { result: res } = await getAllDict()
...@@ -22,6 +27,11 @@ const actions = { ...@@ -22,6 +27,11 @@ const actions = {
22 resolve(true) 27 resolve(true)
23 }) 28 })
24 }, 29 },
30 /**
31 * @description: resetdict
32 * @param {*} commit
33 * @author: renchao
34 */
25 resetdict ({ commit }) { 35 resetdict ({ commit }) {
26 commit('RESET_DICT') 36 commit('RESET_DICT')
27 } 37 }
......
...@@ -25,6 +25,12 @@ const mutations = { ...@@ -25,6 +25,12 @@ const mutations = {
25 } 25 }
26 const actions = { 26 const actions = {
27 // 添加全部菜单 27 // 添加全部菜单
28 /**
29 * @description: 添加全部菜单
30 * @param {*} commit
31 * @param {*} getMenuInfo
32 * @author: renchao
33 */
28 generateRoutes ({ commit }, getMenuInfo) { 34 generateRoutes ({ commit }, getMenuInfo) {
29 let Layout = r => require.ensure([], () => r(require(`@/layout`))) 35 let Layout = r => require.ensure([], () => r(require(`@/layout`)))
30 function asyncRouter (routers) { 36 function asyncRouter (routers) {
...@@ -63,11 +69,22 @@ const actions = { ...@@ -63,11 +69,22 @@ const actions = {
63 }) 69 })
64 }, 70 },
65 // 重置路由 71 // 重置路由
72 /**
73 * @description: 重置路由
74 * @param {*} commit
75 * @author: renchao
76 */
66 resetRoutes ({ commit }) { 77 resetRoutes ({ commit }) {
67 commit('RESET_ROUTE') 78 commit('RESET_ROUTE')
68 } 79 }
69 } 80 }
70 // 树转数组 81 // 树转数组
82 /**
83 * @description: 树转数组
84 * @param {*} root
85 * @param {*} fVisit
86 * @author: renchao
87 */
71 function dfs (root, fVisit) { 88 function dfs (root, fVisit) {
72 let stack = Array.isArray(root) ? [...root] : [root]; 89 let stack = Array.isArray(root) ? [...root] : [root];
73 while (stack.length) { 90 while (stack.length) {
...@@ -81,6 +98,12 @@ function dfs (root, fVisit) { ...@@ -81,6 +98,12 @@ function dfs (root, fVisit) {
81 } 98 }
82 // 数组转树 99 // 数组转树
83 //需要插入父节点id,pid为null或'',就是找root节点,然后root节点再去找自己的子节点 100 //需要插入父节点id,pid为null或'',就是找root节点,然后root节点再去找自己的子节点
101 /**
102 * @description: 数组转树
103 * @param {*} data
104 * @param {*} pid
105 * @author: renchao
106 */
84 function array2Tree (data, pid) { 107 function array2Tree (data, pid) {
85 let res = []; 108 let res = [];
86 data.forEach(item => { 109 data.forEach(item => {
......
1 /* 1 /*
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-03-07 09:38:47 4 * @LastEditTime: 2023-03-07 09:38:47
5 */ 5 */
...@@ -20,6 +20,11 @@ const mutations = { ...@@ -20,6 +20,11 @@ const mutations = {
20 }; 20 };
21 21
22 const actions = { 22 const actions = {
23 /**
24 * @description: getUserInfo
25 * @param {*} commit
26 * @author: renchao
27 */
23 getUserInfo ({ commit }) { 28 getUserInfo ({ commit }) {
24 return new Promise(async (resolve) => { 29 return new Promise(async (resolve) => {
25 let { result: res } = await getUserInfo(); 30 let { result: res } = await getUserInfo();
...@@ -27,6 +32,11 @@ const actions = { ...@@ -27,6 +32,11 @@ const actions = {
27 resolve(true); 32 resolve(true);
28 }); 33 });
29 }, 34 },
35 /**
36 * @description: resetState
37 * @param {*} commit
38 * @author: renchao
39 */
30 resetState ({ commit }) { 40 resetState ({ commit }) {
31 commit("RESET_USER"); 41 commit("RESET_USER");
32 }, 42 },
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
3 var CreatedOKLodopObject, CLodopIsLocal, CLodopJsState; 3 var CreatedOKLodopObject, CLodopIsLocal, CLodopJsState;
4 4
5 //==判断是否需要CLodop(那些不支持插件的浏览器):== 5 //==判断是否需要CLodop(那些不支持插件的浏览器):==
6 /**
7 * @description: ==判断是否需要CLodop(那些不支持插件的浏览器):==
8 * @author: renchao
9 */
6 function needCLodop () { 10 function needCLodop () {
7 try { 11 try {
8 var ua = navigator.userAgent; 12 var ua = navigator.userAgent;
...@@ -45,6 +49,10 @@ function needCLodop () { ...@@ -45,6 +49,10 @@ function needCLodop () {
45 } 49 }
46 50
47 //==加载引用CLodop的主JS,用双端口8000和18000(以防其中一个被占):== 51 //==加载引用CLodop的主JS,用双端口8000和18000(以防其中一个被占):==
52 /**
53 * @description: ==加载引用CLodop的主JS,用双端口8000和18000(以防其中一个被占):==
54 * @author: renchao
55 */
48 function loadCLodop () { 56 function loadCLodop () {
49 if (CLodopJsState == "loading" || CLodopJsState == "complete") return; 57 if (CLodopJsState == "loading" || CLodopJsState == "complete") return;
50 CLodopJsState = "loading"; 58 CLodopJsState = "loading";
...@@ -63,7 +71,12 @@ function loadCLodop () { ...@@ -63,7 +71,12 @@ function loadCLodop () {
63 if (needCLodop()) { loadCLodop(); }//加载 71 if (needCLodop()) { loadCLodop(); }//加载
64 72
65 //==获取LODOP对象主过程,判断是否安装、需否升级:== 73 //==获取LODOP对象主过程,判断是否安装、需否升级:==
66 74 /**
75 * @description: ==获取LODOP对象主过程,判断是否安装、需否升级:==
76 * @param {*} oOBJECT
77 * @param {*} oEMBED
78 * @author: renchao
79 */
67 export function getLodop (oOBJECT, oEMBED) { 80 export function getLodop (oOBJECT, oEMBED) {
68 var strHtmInstall = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='install_lodop32.zip' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>"; 81 var strHtmInstall = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='install_lodop32.zip' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
69 var strHtmUpdate = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='install_lodop32.zip' target='_self'>执行升级</a>,升级后请重新进入。</font>"; 82 var strHtmUpdate = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='install_lodop32.zip' target='_self'>执行升级</a>,升级后请重新进入。</font>";
......
1 /* 1 /*
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-05-11 16:31:01 4 * @LastEditTime: 2023-05-11 16:31:01
5 */ 5 */
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
7 var Layout; 7 var Layout;
8 let ApiUrl = localStorage.getItem('ApiUrl') 8 let ApiUrl = localStorage.getItem('ApiUrl')
9 Layout = r => require.ensure([], () => r(require(`@/layout1`))) 9 Layout = r => require.ensure([], () => r(require(`@/layout1`)))
10 /**
11 * @description: filterAsyncRouter
12 * @param {*} routers
13 * @author: renchao
14 */
10 export default function filterAsyncRouter (routers) { 15 export default function filterAsyncRouter (routers) {
11 routers.forEach(item => { 16 routers.forEach(item => {
12 if (!item.children) { 17 if (!item.children) {
...@@ -27,6 +32,11 @@ export default function filterAsyncRouter (routers) { ...@@ -27,6 +32,11 @@ export default function filterAsyncRouter (routers) {
27 }) 32 })
28 return routers 33 return routers
29 } 34 }
35 /**
36 * @description: loadView
37 * @param {*} view
38 * @author: renchao
39 */
30 function loadView (view) { 40 function loadView (view) {
31 return r => require.ensure([], () => r(require(`@/views${view}.vue`))) 41 return r => require.ensure([], () => r(require(`@/views${view}.vue`)))
32 } 42 }
......
...@@ -28,6 +28,10 @@ export default { ...@@ -28,6 +28,10 @@ export default {
28 window.removeEventListener('resize', this.resize) 28 window.removeEventListener('resize', this.resize)
29 }, 29 },
30 methods: { 30 methods: {
31 /**
32 * @description: calcRate
33 * @author: renchao
34 */
31 calcRate () { 35 calcRate () {
32 const appRef = this.$refs["appRef"] 36 const appRef = this.$refs["appRef"]
33 if (!appRef) return 37 if (!appRef) return
...@@ -47,6 +51,10 @@ export default { ...@@ -47,6 +51,10 @@ export default {
47 } 51 }
48 } 52 }
49 }, 53 },
54 /**
55 * @description: resize
56 * @author: renchao
57 */
50 resize () { 58 resize () {
51 clearTimeout(this.drawTiming) 59 clearTimeout(this.drawTiming)
52 this.drawTiming = setTimeout(() => { 60 this.drawTiming = setTimeout(() => {
......
...@@ -2,17 +2,33 @@ import store from '@/store' ...@@ -2,17 +2,33 @@ import store from '@/store'
2 // table 内部过滤器 由于过滤器只能在模板中使用 所以 就有了 jsx内部方法过滤器 2 // table 内部过滤器 由于过滤器只能在模板中使用 所以 就有了 jsx内部方法过滤器
3 export default class filter { 3 export default class filter {
4 // 业务来源 4 // 业务来源
5 /**
6 * @description: 业务来源
7 * @param {*} val
8 * @author: renchao
9 */
5 busSource(val) { 10 busSource(val) {
6 let status = { 1: '办事大厅', 2: '微信小程序' } 11 let status = { 1: '办事大厅', 2: '微信小程序' }
7 return status[val] 12 return status[val]
8 } 13 }
9 14
10 //申请分类(1:正常申请,2:一并申请,3:补录申请) 15 //申请分类(1:正常申请,2:一并申请,3:补录申请)
16 /**
17 * @description: 申请分类(1:正常申请,2:一并申请,3:补录申请)
18 * @param {*} val
19 * @author: renchao
20 */
11 sqfls(val) { 21 sqfls(val) {
12 let status = { 1: '正常申请', 2: '一并申请', 3: '补录申请' } 22 let status = { 1: '正常申请', 2: '一并申请', 3: '补录申请' }
13 return status[val] 23 return status[val]
14 } 24 }
15 // 字典 25 // 字典
26 /**
27 * @description: 字典
28 * @param {*} val
29 * @param {*} code
30 * @author: renchao
31 */
16 dicStatus(val, code) { 32 dicStatus(val, code) {
17 let data = store.getters.dicData[code], 33 let data = store.getters.dicData[code],
18 name = '' 34 name = ''
...@@ -25,6 +41,11 @@ export default class filter { ...@@ -25,6 +41,11 @@ export default class filter {
25 return name 41 return name
26 } 42 }
27 } 43 }
44 /**
45 * @description: stateStatus
46 * @param {*} val
47 * @author: renchao
48 */
28 stateStatus(val) { 49 stateStatus(val) {
29 let index = val + 1; 50 let index = val + 1;
30 // -1 : 不存在 ,0 : 待激活,1:正常,2:暂停,3 : 出错, 4:阻塞 51 // -1 : 不存在 ,0 : 待激活,1:正常,2:暂停,3 : 出错, 4:阻塞
......
1 /* 1 /*
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-03-16 13:31:27 4 * @LastEditTime: 2023-03-16 13:31:27
5 */ 5 */
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
7 import Vue from 'vue' 7 import Vue from 'vue'
8 const title = Vue.prototype.BASE_API.TITLE 8 const title = Vue.prototype.BASE_API.TITLE
9 9
10 /**
11 * @description: getPageTitle
12 * @param {*} pageTitle
13 * @author: renchao
14 */
10 export default function getPageTitle (pageTitle) { 15 export default function getPageTitle (pageTitle) {
11 if (pageTitle) { 16 if (pageTitle) {
12 return `${pageTitle} - ${title}` 17 return `${pageTitle} - ${title}`
......
1 /** 1 /**
2 * @description: debounce
2 * @param {Function} fn 防抖函数 3 * @param {Function} fn 防抖函数
3 * @param {Number} delay 延迟时间 4 * @param {Number} delay 延迟时间
5 * @author: renchao
4 */ 6 */
5 export function debounce(fn, delay) { 7 export function debounce(fn, delay) {
6 var timer; 8 var timer;
...@@ -15,8 +17,10 @@ export function debounce(fn, delay) { ...@@ -15,8 +17,10 @@ export function debounce(fn, delay) {
15 } 17 }
16 18
17 /** 19 /**
20 * @description: formatTime
18 * @param {date} time 需要转换的时间 21 * @param {date} time 需要转换的时间
19 * @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss 22 * @param {String} fmt 需要转换的格式 如 yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
23 * @author: renchao
20 */ 24 */
21 export function formatTime(time, fmt) { 25 export function formatTime(time, fmt) {
22 if (!time) return ''; 26 if (!time) return '';
......
...@@ -18,23 +18,41 @@ export default { ...@@ -18,23 +18,41 @@ export default {
18 } 18 }
19 }, 19 },
20 methods: { 20 methods: {
21 /**
22 * @description: handleSizeChange
23 * @param {*} val
24 * @author: renchao
25 */
21 handleSizeChange (val) { 26 handleSizeChange (val) {
22 this.pageData.currentPage = 1 27 this.pageData.currentPage = 1
23 this.pageData.pageSize = val 28 this.pageData.pageSize = val
24 this.queryClick() 29 this.queryClick()
25 }, 30 },
31 /**
32 * @description: handleCurrentChange
33 * @param {*} val
34 * @author: renchao
35 */
26 handleCurrentChange (val) { 36 handleCurrentChange (val) {
27 this.pageData.currentPage = val 37 this.pageData.currentPage = val
28 if (this.queryClick) { 38 if (this.queryClick) {
29 this.queryClick() 39 this.queryClick()
30 } 40 }
31 }, 41 },
42 /**
43 * @description: handleDel
44 * @author: renchao
45 */
32 handleDel () { 46 handleDel () {
33 let deleteAfterPage = Math.ceil((this.tableData.total - 1) / this.pageData.pageSize) 47 let deleteAfterPage = Math.ceil((this.tableData.total - 1) / this.pageData.pageSize)
34 let currentPage = this.pageData.currentPage > deleteAfterPage ? deleteAfterPage : this.pageData.currentPage 48 let currentPage = this.pageData.currentPage > deleteAfterPage ? deleteAfterPage : this.pageData.currentPage
35 this.pageData.currentPage = currentPage < 1 ? 1 : currentPage 49 this.pageData.currentPage = currentPage < 1 ? 1 : currentPage
36 }, 50 },
37 // 重置表单 51 // 重置表单
52 /**
53 * @description: 重置表单
54 * @author: renchao
55 */
38 resetForm () { 56 resetForm () {
39 if (!this.form) return 57 if (!this.form) return
40 Object.keys(this.form).forEach((key) => { 58 Object.keys(this.form).forEach((key) => {
......
1 /*
2 * @Description:
3 * @Autor: renchao
4 * @LastEditTime: 2023-05-11 16:31:01
5 */
1 import { Message } from "element-ui"; 6 import { Message } from "element-ui";
7 /**
8 * @description: removeTreeListItem
9 * @param {*} treeList
10 * @param {*} dictId
11 * @param {*} idName
12 * @author: renchao
13 */
2 export function removeTreeListItem (treeList, dictId, idName = 'dictid') { 14 export function removeTreeListItem (treeList, dictId, idName = 'dictid') {
3 if (!treeList || !treeList.length) { 15 if (!treeList || !treeList.length) {
4 return 16 return
...@@ -12,6 +24,12 @@ export function removeTreeListItem (treeList, dictId, idName = 'dictid') { ...@@ -12,6 +24,12 @@ export function removeTreeListItem (treeList, dictId, idName = 'dictid') {
12 } 24 }
13 } 25 }
14 // 创造id 26 // 创造id
27 /**
28 * @description: 创造id
29 * @param {*} len
30 * @param {*} radix
31 * @author: renchao
32 */
15 export function getUuid (len, radix) { 33 export function getUuid (len, radix) {
16 var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split( 34 var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split(
17 "" 35 ""
...@@ -34,6 +52,11 @@ export function getUuid (len, radix) { ...@@ -34,6 +52,11 @@ export function getUuid (len, radix) {
34 } 52 }
35 return uuid.join(""); 53 return uuid.join("");
36 } 54 }
55 /**
56 * @description: judgeSort
57 * @param {*} arr
58 * @author: renchao
59 */
37 export function judgeSort (arr) { 60 export function judgeSort (arr) {
38 if (arr.length) { 61 if (arr.length) {
39 for (let i in arr) { 62 for (let i in arr) {
...@@ -47,6 +70,13 @@ export function judgeSort (arr) { ...@@ -47,6 +70,13 @@ export function judgeSort (arr) {
47 return arr 70 return arr
48 } 71 }
49 // 上下移动 72 // 上下移动
73 /**
74 * @description: 上下移动
75 * @param {*} bsmDict
76 * @param {*} operate
77 * @param {*} data
78 * @author: renchao
79 */
50 export function realMove (bsmDict, operate, data) { 80 export function realMove (bsmDict, operate, data) {
51 function changeSort (arr, bsmDict) { 81 function changeSort (arr, bsmDict) {
52 if (arr.length) { 82 if (arr.length) {
...@@ -72,6 +102,12 @@ export function realMove (bsmDict, operate, data) { ...@@ -72,6 +102,12 @@ export function realMove (bsmDict, operate, data) {
72 data = judgeSort(changeSort(data, bsmDict)); 102 data = judgeSort(changeSort(data, bsmDict));
73 } 103 }
74 // 获取所有父节点 104 // 获取所有父节点
105 /**
106 * @description: 获取所有父节点
107 * @param {*} treeData
108 * @param {*} bsmDict
109 * @author: renchao
110 */
75 export function findParents (treeData, bsmDict) { 111 export function findParents (treeData, bsmDict) {
76 if (treeData.length == 0) return 112 if (treeData.length == 0) return
77 for (let i = 0; i < treeData.length; i++) { 113 for (let i = 0; i < treeData.length; i++) {
...@@ -88,6 +124,12 @@ export function findParents (treeData, bsmDict) { ...@@ -88,6 +124,12 @@ export function findParents (treeData, bsmDict) {
88 } 124 }
89 } 125 }
90 // 上移下移 126 // 上移下移
127 /**
128 * @description: 上移下移
129 * @param {*} index
130 * @param {*} data
131 * @author: renchao
132 */
91 export function upward (index, data) { 133 export function upward (index, data) {
92 if (index > 0) { 134 if (index > 0) {
93 let upData = data[index - 1]; 135 let upData = data[index - 1];
...@@ -99,6 +141,12 @@ export function upward (index, data) { ...@@ -99,6 +141,12 @@ export function upward (index, data) {
99 }); 141 });
100 } 142 }
101 } 143 }
144 /**
145 * @description: down
146 * @param {*} index
147 * @param {*} data
148 * @author: renchao
149 */
102 export function down (index, data) { 150 export function down (index, data) {
103 if ((index + 1) == data.length) { 151 if ((index + 1) == data.length) {
104 Message({ 152 Message({
...@@ -111,6 +159,12 @@ export function down (index, data) { ...@@ -111,6 +159,12 @@ export function down (index, data) {
111 } 159 }
112 } 160 }
113 161
162 /**
163 * @description: timeFormat
164 * @param {*} date
165 * @param {*} end
166 * @author: renchao
167 */
114 export function timeFormat (date, end) { 168 export function timeFormat (date, end) {
115 if (!date || typeof (date) === "string") { 169 if (!date || typeof (date) === "string") {
116 this.error("参数异常,请检查..."); 170 this.error("参数异常,请检查...");
...@@ -126,6 +180,11 @@ export function timeFormat (date, end) { ...@@ -126,6 +180,11 @@ export function timeFormat (date, end) {
126 return y + "-" + m + "-" + d + ' 00:00:00'; 180 return y + "-" + m + "-" + d + ' 00:00:00';
127 } 181 }
128 } 182 }
183 /**
184 * @description: getFirstDayOfSeason
185 * @param {*} d
186 * @author: renchao
187 */
129 export function getFirstDayOfSeason (d) { 188 export function getFirstDayOfSeason (d) {
130 let date = d || new Date() 189 let date = d || new Date()
131 var month = date.getMonth(); 190 var month = date.getMonth();
......
1 /*
2 * @Description:
3 * @Autor: renchao
4 * @LastEditTime: 2023-05-11 16:31:01
5 */
1 import Popup from '@/components/Popup/index' 6 import Popup from '@/components/Popup/index'
7 /**
8 * @description: popupDialog
9 * @param {*} title
10 * @param {*} url
11 * @param {*} params
12 * @param {*} width
13 * @param {*} height
14 * @param {*} btnShow
15 * @param {*} callback
16 * @author: renchao
17 */
2 export function popupDialog (title, url, params, width = '75%', height, btnShow = false, callback) { 18 export function popupDialog (title, url, params, width = '75%', height, btnShow = false, callback) {
3 // Popup.install 19 // Popup.install
4 Popup(title, url, { 20 Popup(title, url, {
...@@ -15,6 +31,10 @@ export function popupDialog (title, url, params, width = '75%', height, btnShow ...@@ -15,6 +31,10 @@ export function popupDialog (title, url, params, width = '75%', height, btnShow
15 }) 31 })
16 } 32 }
17 33
34 /**
35 * @description: popupCacel
36 * @author: renchao
37 */
18 export function popupCacel () { 38 export function popupCacel () {
19 Popup1().close() 39 Popup1().close()
20 }
...\ No newline at end of file ...\ No newline at end of file
40 }
......
1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
1 const deleteDomStr = content => { 5 const deleteDomStr = content => {
2 return `<div class="customer-message-wrapper"><h5 class="title">您确认要执行该操作用于以下信息:</h5><p class="content">${content}</p><p class="result">执行后,数据将<span >无法恢复</span></p></div>` 6 return `<div class="customer-message-wrapper"><h5 class="title">您确认要执行该操作用于以下信息:</h5><p class="content">${content}</p><p class="result">执行后,数据将<span >无法恢复</span></p></div>`
3 } 7 }
......
...@@ -95,6 +95,11 @@ service.interceptors.response.use( ...@@ -95,6 +95,11 @@ service.interceptors.response.use(
95 } 95 }
96 ) 96 )
97 //对错误信息的处理函数 97 //对错误信息的处理函数
98 /**
99 * @description: 对错误信息的处理函数
100 * @param {*} errMes
101 * @author: renchao
102 */
98 function handleErrorData (errMes) { 103 function handleErrorData (errMes) {
99 if (errMes.message) { 104 if (errMes.message) {
100 Message.error(errMes.message); 105 Message.error(errMes.message);
......
1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
1 import Loading from '@/components/Loading/index.js'; 5 import Loading from '@/components/Loading/index.js';
2 // 定义 loading 6 // 定义 loading
3 let loading 7 let loading
4 8
5 // loading开始 方法 9 // loading开始 方法
10 /**
11 * @description: loading开始 方法
12 * @param {*} loadingText
13 * @author: renchao
14 */
6 function startLoading (loadingText = '正在加载中...') { 15 function startLoading (loadingText = '正在加载中...') {
7 loading = Loading.service({ 16 loading = Loading.service({
8 text: loadingText, 17 text: loadingText,
...@@ -13,6 +22,10 @@ function startLoading (loadingText = '正在加载中...') { ...@@ -13,6 +22,10 @@ function startLoading (loadingText = '正在加载中...') {
13 } 22 }
14 23
15 // loading结束 方法 24 // loading结束 方法
25 /**
26 * @description: loading开始 方法
27 * @author: renchao
28 */
16 function endLoading () { 29 function endLoading () {
17 loading.close() 30 loading.close()
18 } 31 }
...@@ -23,6 +36,13 @@ let loadingCount = 0 ...@@ -23,6 +36,13 @@ let loadingCount = 0
23 * 调用一次startLoadingAddCount() 方法 开启Loading 并 loadingCount + 1 36 * 调用一次startLoadingAddCount() 方法 开启Loading 并 loadingCount + 1
24 * 调用一次endLoadingSubCount() 方法 loadingCount - 1 直到为0 关闭loading 37 * 调用一次endLoadingSubCount() 方法 loadingCount - 1 直到为0 关闭loading
25 */ 38 */
39 /**
40 * @description: 调用一次startLoadingAddCount() 方法 开启Loading 并 loadingCount + 1
41 * 调用一次endLoadingSubCount() 方法 loadingCount - 1 直到为0 关闭loading
42 * @param {*} LoadingText
43 * @param {*} target
44 * @author: renchao
45 */
26 export function startLoadingAddCount (LoadingText, target) { 46 export function startLoadingAddCount (LoadingText, target) {
27 if (loadingCount === 0) { 47 if (loadingCount === 0) {
28 startLoading(LoadingText, target) 48 startLoading(LoadingText, target)
...@@ -30,9 +50,13 @@ export function startLoadingAddCount (LoadingText, target) { ...@@ -30,9 +50,13 @@ export function startLoadingAddCount (LoadingText, target) {
30 loadingCount++ 50 loadingCount++
31 } 51 }
32 52
53 /**
54 * @description: endLoadingSubCount
55 * @author: renchao
56 */
33 export function endLoadingSubCount () { 57 export function endLoadingSubCount () {
34 loadingCount-- 58 loadingCount--
35 if (loadingCount === 0) { 59 if (loadingCount === 0) {
36 endLoading() 60 endLoading()
37 } 61 }
38 }
...\ No newline at end of file ...\ No newline at end of file
62 }
......
1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
1 import Vue from 'vue' 5 import Vue from 'vue'
2 6
3 // 下载,导出 7 // 下载,导出
8 /**
9 * @description: 下载,导出
10 * @param {*} name
11 * @param {*} href
12 * @author: renchao
13 */
4 Vue.prototype.$download = function (name, href) { 14 Vue.prototype.$download = function (name, href) {
5 var a = document.createElement('a') // 创建a标签 15 var a = document.createElement('a') // 创建a标签
6 var e = document.createEvent('MouseEvents') // 创建鼠标事件对象 16 var e = document.createEvent('MouseEvents') // 创建鼠标事件对象
...@@ -10,6 +20,12 @@ Vue.prototype.$download = function (name, href) { ...@@ -10,6 +20,12 @@ Vue.prototype.$download = function (name, href) {
10 a.dispatchEvent(e) // 给指定的元素,执行事件click事件 20 a.dispatchEvent(e) // 给指定的元素,执行事件click事件
11 } 21 }
12 // 导出json文件 22 // 导出json文件
23 /**
24 * @description: 导出json文件
25 * @param {*} data
26 * @param {*} name
27 * @author: renchao
28 */
13 Vue.prototype.$downloadJson = function (data, name) { 29 Vue.prototype.$downloadJson = function (data, name) {
14 // 1 生成文件的 blob 对象 30 // 1 生成文件的 blob 对象
15 const blobData = new Blob([JSON.stringify(data)], { 31 const blobData = new Blob([JSON.stringify(data)], {
...@@ -46,6 +62,13 @@ const validConfig = [ ...@@ -46,6 +62,13 @@ const validConfig = [
46 } 62 }
47 ] 63 ]
48 // 校验手机号 64 // 校验手机号
65 /**
66 * @description: 校验手机号
67 * @param {*} rule
68 * @param {*} value
69 * @param {*} callback
70 * @author: renchao
71 */
49 const checkTel = (rule, value, callback) => { 72 const checkTel = (rule, value, callback) => {
50 const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/ 73 const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
51 const rel = /^[0]\d{2,3}-[1-9]\d{7}$/ 74 const rel = /^[0]\d{2,3}-[1-9]\d{7}$/
...@@ -57,6 +80,13 @@ const checkTel = (rule, value, callback) => { ...@@ -57,6 +80,13 @@ const checkTel = (rule, value, callback) => {
57 }, 500) 80 }, 500)
58 } 81 }
59 // 检验系统代码 82 // 检验系统代码
83 /**
84 * @description: 检验系统代码
85 * @param {*} rule
86 * @param {*} value
87 * @param {*} callback
88 * @author: renchao
89 */
60 const checkCode = (rule, value, callback) => { 90 const checkCode = (rule, value, callback) => {
61 const rel = /^[0-9A-Z]+$/ 91 const rel = /^[0-9A-Z]+$/
62 if (!value) return callback(new Error('请输入代码')) 92 if (!value) return callback(new Error('请输入代码'))
...@@ -84,6 +114,11 @@ const checkCode = (rule, value, callback) => { ...@@ -84,6 +114,11 @@ const checkCode = (rule, value, callback) => {
84 // } 114 // }
85 // } 115 // }
86 // 日期格式转换 "yyyy-MM-dd HH:mm:ss" 116 // 日期格式转换 "yyyy-MM-dd HH:mm:ss"
117 /**
118 * @description: 日期格式转换 "yyyy-MM-dd HH:mm:ss"
119 * @param {*} date
120 * @author: renchao
121 */
87 Vue.prototype.$formdate = function (date) { 122 Vue.prototype.$formdate = function (date) {
88 if (!date) { 123 if (!date) {
89 return "" 124 return ""
...@@ -98,18 +133,39 @@ Vue.prototype.$formdate = function (date) { ...@@ -98,18 +133,39 @@ Vue.prototype.$formdate = function (date) {
98 return YY + MM + DD + " " + hh + mm + ss 133 return YY + MM + DD + " " + hh + mm + ss
99 } 134 }
100 // 时间格式过滤 135 // 时间格式过滤
136 /**
137 * @description: 时间格式过滤
138 * @param {*} timeStr
139 * @author: renchao
140 */
101 Vue.filter('timeFilter', function (timeStr) { 141 Vue.filter('timeFilter', function (timeStr) {
102 if (timeStr) { 142 if (timeStr) {
103 return timeStr.substring(0, 10) 143 return timeStr.substring(0, 10)
104 } 144 }
105 }) 145 })
146 /**
147 * @description: getType
148 * @param {*} o
149 * @author: renchao
150 */
106 export function getType (o) { 151 export function getType (o) {
107 return Object.prototype.toString.call(o).slice(8, -1) 152 return Object.prototype.toString.call(o).slice(8, -1)
108 } 153 }
154 /**
155 * @description: isKeyType
156 * @param {*} o
157 * @param {*} type
158 * @author: renchao
159 */
109 export function isKeyType (o, type) { 160 export function isKeyType (o, type) {
110 return getType(o).toLowerCase() === type.toLowerCase() 161 return getType(o).toLowerCase() === type.toLowerCase()
111 } 162 }
112 // 深拷贝全局挂载 163 // 深拷贝全局挂载
164 /**
165 * @description: 深拷贝全局挂载
166 * @param {*} sth
167 * @author: renchao
168 */
113 Vue.prototype.$deepCopy = function (sth) { 169 Vue.prototype.$deepCopy = function (sth) {
114 // 深度复制数组 170 // 深度复制数组
115 // if (Object.prototype.toString.call(obj) === "[object Array]") { 171 // if (Object.prototype.toString.call(obj) === "[object Array]") {
...@@ -153,6 +209,10 @@ Vue.prototype.$deepCopy = function (sth) { ...@@ -153,6 +209,10 @@ Vue.prototype.$deepCopy = function (sth) {
153 return null 209 return null
154 } 210 }
155 // 递归处理树形数据children为空数组 211 // 递归处理树形数据children为空数组
212 /**
213 * @description: 递归处理树形数据children为空数组
214 * @author: renchao
215 */
156 Vue.prototype.$dealArrChildren = arr => { 216 Vue.prototype.$dealArrChildren = arr => {
157 if (arr.length) { 217 if (arr.length) {
158 for (const i in arr) { 218 for (const i in arr) {
...@@ -166,6 +226,10 @@ Vue.prototype.$dealArrChildren = arr => { ...@@ -166,6 +226,10 @@ Vue.prototype.$dealArrChildren = arr => {
166 return arr 226 return arr
167 } 227 }
168 // 过滤对象中为空的属性 228 // 过滤对象中为空的属性
229 /**
230 * @description: 过滤对象中为空的属性
231 * @author: renchao
232 */
169 Vue.prototype.$filterNullObj = obj => { 233 Vue.prototype.$filterNullObj = obj => {
170 if (!(typeof obj === 'object')) { 234 if (!(typeof obj === 'object')) {
171 return 235 return
...@@ -181,6 +245,10 @@ Vue.prototype.$filterNullObj = obj => { ...@@ -181,6 +245,10 @@ Vue.prototype.$filterNullObj = obj => {
181 return obj 245 return obj
182 } 246 }
183 // 递归处理树形数据可选择项 247 // 递归处理树形数据可选择项
248 /**
249 * @description: 递归处理树形数据可选择项
250 * @author: renchao
251 */
184 Vue.prototype.$dealArrNotDisabled = arr => { 252 Vue.prototype.$dealArrNotDisabled = arr => {
185 if (arr.length) { 253 if (arr.length) {
186 for (const i in arr) { 254 for (const i in arr) {
...@@ -207,6 +275,12 @@ Vue.prototype.$dealArrNotDisabled = arr => { ...@@ -207,6 +275,12 @@ Vue.prototype.$dealArrNotDisabled = arr => {
207 return arr 275 return arr
208 } 276 }
209 // 递归处理树形数据不可选择项 277 // 递归处理树形数据不可选择项
278 /**
279 * @description: 递归处理树形数据不可选择项
280 * @param {*} arr
281 * @param {*} id
282 * @author: renchao
283 */
210 Vue.prototype.$dealArrDisabled = (arr, id) => { 284 Vue.prototype.$dealArrDisabled = (arr, id) => {
211 if (arr.length) { 285 if (arr.length) {
212 for (const i in arr) { 286 for (const i in arr) {
...@@ -233,6 +307,12 @@ Vue.prototype.$dealArrDisabled = (arr, id) => { ...@@ -233,6 +307,12 @@ Vue.prototype.$dealArrDisabled = (arr, id) => {
233 return arr 307 return arr
234 } 308 }
235 // 根据子节点id递归获取子节点路径id数组 309 // 根据子节点id递归获取子节点路径id数组
310 /**
311 * @description: 根据子节点id递归获取子节点路径id数组
312 * @param {*} val
313 * @param {*} id
314 * @author: renchao
315 */
236 Vue.prototype.$getNodeRoute = (val, id) => { 316 Vue.prototype.$getNodeRoute = (val, id) => {
237 let cid_list = [] 317 let cid_list = []
238 val.forEach((item, index) => { 318 val.forEach((item, index) => {
...@@ -279,6 +359,10 @@ Vue.prototype.$getNodeRoute = (val, id) => { ...@@ -279,6 +359,10 @@ Vue.prototype.$getNodeRoute = (val, id) => {
279 return result(cid_list) 359 return result(cid_list)
280 } 360 }
281 // 扁平化树形数组 361 // 扁平化树形数组
362 /**
363 * @description: 扁平化树形数组
364 * @author: renchao
365 */
282 Vue.prototype.$treeConvertToArr = tree => { 366 Vue.prototype.$treeConvertToArr = tree => {
283 let arrs = [] 367 let arrs = []
284 const result = [] 368 const result = []
...@@ -446,6 +530,11 @@ Vue.prototype.$setChildArr = ( ...@@ -446,6 +530,11 @@ Vue.prototype.$setChildArr = (
446 } 530 }
447 } 531 }
448 // 处理localStorage获取值转换boolean为string问题 json字符串转为json 532 // 处理localStorage获取值转换boolean为string问题 json字符串转为json
533 /**
534 * @description: 对错误信息的处理函数
535 * @param {*} errMes
536 * @author: renchao
537 */
449 Vue.prototype.$getLocalStorage = (name, type) => { 538 Vue.prototype.$getLocalStorage = (name, type) => {
450 let data = localStorage.getItem(name) 539 let data = localStorage.getItem(name)
451 if (type === 'boolean') { 540 if (type === 'boolean') {
......
1 1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
2 import XLSX2 from "xlsx"; 5 import XLSX2 from "xlsx";
3 import XLSX from "xlsx-style"; 6 import XLSX from "xlsx-style";
4 /** 7 /**
...@@ -18,6 +21,11 @@ export function getType (o) { ...@@ -18,6 +21,11 @@ export function getType (o) {
18 export function isKeyType (o, type) { 21 export function isKeyType (o, type) {
19 return getType(o).toLowerCase() === type.toLowerCase(); 22 return getType(o).toLowerCase() === type.toLowerCase();
20 } 23 }
24 /**
25 * @description: deepCopy
26 * @param {*} sth
27 * @author: renchao
28 */
21 export function deepCopy (sth) { 29 export function deepCopy (sth) {
22 let copy; 30 let copy;
23 if (null == sth || "object" != typeof sth) return sth; 31 if (null == sth || "object" != typeof sth) return sth;
...@@ -58,7 +66,11 @@ export function hideCode (str, frontLen, endLen = 0) { ...@@ -58,7 +66,11 @@ export function hideCode (str, frontLen, endLen = 0) {
58 return str.substring(0, frontLen) + xing + str.substring(str.length - endLen); 66 return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
59 }; 67 };
60 // 数组去重 68 // 数组去重
61 69 /**
70 * @description: 数组去重
71 * @param {*} arr
72 * @author: renchao
73 */
62 export function unique (arr) { 74 export function unique (arr) {
63 var obj = {}; 75 var obj = {};
64 return arr.filter(function (item, index, arr) { 76 return arr.filter(function (item, index, arr) {
...@@ -66,7 +78,12 @@ export function unique (arr) { ...@@ -66,7 +78,12 @@ export function unique (arr) {
66 }) 78 })
67 } 79 }
68 // 创造id 80 // 创造id
69 81 /**
82 * @description: 创造id
83 * @param {*} len
84 * @param {*} radix
85 * @author: renchao
86 */
70 export function getUuid (len, radix) { 87 export function getUuid (len, radix) {
71 var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split( 88 var chars = "0123456789abcdefghijklmnopqrstuvwxyz".split(
72 "" 89 ""
...@@ -91,6 +108,12 @@ export function getUuid (len, radix) { ...@@ -91,6 +108,12 @@ export function getUuid (len, radix) {
91 } 108 }
92 109
93 //js计算两个时间戳之间的时间差 (月) 110 //js计算两个时间戳之间的时间差 (月)
111 /**
112 * @description: js计算两个时间戳之间的时间差 (月)
113 * @param {*} startTime
114 * @param {*} endTime
115 * @author: renchao
116 */
94 export function intervalTime (startTime, endTime) { 117 export function intervalTime (startTime, endTime) {
95 // var timestamp=new Date().getTime(); //计算当前时间戳 118 // var timestamp=new Date().getTime(); //计算当前时间戳
96 var timestamp = (Date.parse(new Date())) / 1000;//计算当前时间戳 (毫秒级) 119 var timestamp = (Date.parse(new Date())) / 1000;//计算当前时间戳 (毫秒级)
...@@ -109,12 +132,22 @@ export function intervalTime (startTime, endTime) { ...@@ -109,12 +132,22 @@ export function intervalTime (startTime, endTime) {
109 return mon 132 return mon
110 } 133 }
111 // 日期转时间戳 134 // 日期转时间戳
135 /**
136 * @description: 日期转时间戳
137 * @param {*} str_time
138 * @author: renchao
139 */
112 export function js_strto_time (str_time) { 140 export function js_strto_time (str_time) {
113 var str = str_time.replace(/-/g, '/') // 将-替换成/,因为下面这个构造函数只支持/分隔的日期字符串 141 var str = str_time.replace(/-/g, '/') // 将-替换成/,因为下面这个构造函数只支持/分隔的日期字符串
114 var date = new Date(str) // 构造一个日期型数据,值为传入的字符串 142 var date = new Date(str) // 构造一个日期型数据,值为传入的字符串
115 return date.getTime() 143 return date.getTime()
116 } 144 }
117 // 时间戳转日期 145 // 时间戳转日期
146 /**
147 * @description: 时间戳转日期
148 * @param {*} timestamp
149 * @author: renchao
150 */
118 export function timestampToTime (timestamp) { 151 export function timestampToTime (timestamp) {
119 var date = new Date(timestamp)//时间戳为10位需*1000,时间戳为13位的话不需乘1000 152 var date = new Date(timestamp)//时间戳为10位需*1000,时间戳为13位的话不需乘1000
120 var Y = date.getFullYear() + '-' 153 var Y = date.getFullYear() + '-'
...@@ -123,7 +156,11 @@ export function timestampToTime (timestamp) { ...@@ -123,7 +156,11 @@ export function timestampToTime (timestamp) {
123 return Y + M + D 156 return Y + M + D
124 } 157 }
125 158
126 159 /**
160 * @description: formatDate
161 * @param {*} value
162 * @author: renchao
163 */
127 function formatDate (value) { 164 function formatDate (value) {
128 var date = new Date(value); 165 var date = new Date(value);
129 var y = date.getFullYear(), 166 var y = date.getFullYear(),
...@@ -135,6 +172,11 @@ function formatDate (value) { ...@@ -135,6 +172,11 @@ function formatDate (value) {
135 return t; 172 return t;
136 } 173 }
137 174
175 /**
176 * @description: getCurrentDate
177 * @param {*} date
178 * @author: renchao
179 */
138 export function getCurrentDate (date = 'firstDay') { 180 export function getCurrentDate (date = 'firstDay') {
139 var now = new Date() // 当前日期 181 var now = new Date() // 当前日期
140 var nowYear = now.getFullYear() //当前年 182 var nowYear = now.getFullYear() //当前年
...@@ -147,6 +189,11 @@ export function getCurrentDate (date = 'firstDay') { ...@@ -147,6 +189,11 @@ export function getCurrentDate (date = 'firstDay') {
147 } 189 }
148 } 190 }
149 191
192 /**
193 * @description: setExport2Excel
194 * @param {*} exportName
195 * @author: renchao
196 */
150 export function setExport2Excel (exportName) { 197 export function setExport2Excel (exportName) {
151 /* generate workbook object from table */ 198 /* generate workbook object from table */
152 var wb = XLSX2.utils.table_to_sheet(document.querySelector("#mytable"), { raw: true });//mytable为表格的id名 199 var wb = XLSX2.utils.table_to_sheet(document.querySelector("#mytable"), { raw: true });//mytable为表格的id名
...@@ -210,6 +257,12 @@ export function setExport2Excel (exportName) { ...@@ -210,6 +257,12 @@ export function setExport2Excel (exportName) {
210 openDownloadDialog(filedata, exportName + ".xlsx") 257 openDownloadDialog(filedata, exportName + ".xlsx")
211 } 258 }
212 //为合并项添加边框 259 //为合并项添加边框
260 /**
261 * @description: 为合并项添加边框
262 * @param {*} range
263 * @param {*} ws
264 * @author: renchao
265 */
213 function addRangeBorder (range, ws) { 266 function addRangeBorder (range, ws) {
214 let arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]; 267 let arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
215 268
...@@ -226,6 +279,12 @@ function addRangeBorder (range, ws) { ...@@ -226,6 +279,12 @@ function addRangeBorder (range, ws) {
226 return ws; 279 return ws;
227 } 280 }
228 //将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载 281 //将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
282 /**
283 * @description: 将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
284 * @param {*} sheet
285 * @param {*} sheetName
286 * @author: renchao
287 */
229 function sheet2blob (sheet, sheetName) { 288 function sheet2blob (sheet, sheetName) {
230 sheetName = sheetName || 'sheet1'; 289 sheetName = sheetName || 'sheet1';
231 var workbook = { 290 var workbook = {
...@@ -251,6 +310,12 @@ function sheet2blob (sheet, sheetName) { ...@@ -251,6 +310,12 @@ function sheet2blob (sheet, sheetName) {
251 } 310 }
252 return blob; 311 return blob;
253 } 312 }
313 /**
314 * @description: openDownloadDialog
315 * @param {*} url
316 * @param {*} saveName
317 * @author: renchao
318 */
254 function openDownloadDialog (url, saveName) { 319 function openDownloadDialog (url, saveName) {
255 if (typeof url == 'object' && url instanceof Blob) { 320 if (typeof url == 'object' && url instanceof Blob) {
256 url = URL.createObjectURL(url); // 创建blob地址 321 url = URL.createObjectURL(url); // 创建blob地址
...@@ -267,9 +332,11 @@ function openDownloadDialog (url, saveName) { ...@@ -267,9 +332,11 @@ function openDownloadDialog (url, saveName) {
267 aLink.dispatchEvent(event); 332 aLink.dispatchEvent(event);
268 } 333 }
269 334
270 335 /**
271 336 * @description: judgeListComplete
272 337 * @param {*} list
338 * @author: renchao
339 */
273 export function judgeListComplete (list) { 340 export function judgeListComplete (list) {
274 function judgeObjectComplete (obj) { 341 function judgeObjectComplete (obj) {
275 let flag = false 342 let flag = false
......
1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
1 import Cookies from 'js-cookie' 5 import Cookies from 'js-cookie'
2 6
3 const cookies = {} 7 const cookies = {}
......
1 /**
2 * @description: deleteDomStr
3 * @author: renchao
4 */
1 import cookies from './util.cookies' 5 import cookies from './util.cookies'
6 /**
7 * @description: getUrlParam
8 * @param {*} paraName
9 * @author: renchao
10 */
2 export function getUrlParam(paraName) { 11 export function getUrlParam(paraName) {
3 let url = document.location.toString(); 12 let url = document.location.toString();
4 let arrObj = url.split('?'); 13 let arrObj = url.split('?');
...@@ -21,7 +30,11 @@ export function getUrlParam(paraName) { ...@@ -21,7 +30,11 @@ export function getUrlParam(paraName) {
21 return ''; 30 return '';
22 } 31 }
23 } 32 }
24 33 /**
34 * @description: setToken
35 * @param {*} token
36 * @author: renchao
37 */
25 export function setToken(token) { 38 export function setToken(token) {
26 if (token === undefined) { 39 if (token === undefined) {
27 if (process.env.NODE_ENV === 'development') { 40 if (process.env.NODE_ENV === 'development') {
...@@ -37,7 +50,10 @@ export function setToken(token) { ...@@ -37,7 +50,10 @@ export function setToken(token) {
37 } 50 }
38 } 51 }
39 } 52 }
40 53 /**
54 * @description: getToken
55 * @author: renchao
56 */
41 export function getToken() { 57 export function getToken() {
42 if (process.env.NODE_ENV === 'development') { 58 if (process.env.NODE_ENV === 'development') {
43 return sessionStorage.getItem('token') 59 return sessionStorage.getItem('token')
......
1 /** 1 /**
2 * @description: isExternal
2 * @param {string} path 3 * @param {string} path
3 * @returns {Boolean} 4 * @returns {Boolean}
4 */ 5 */
...@@ -7,16 +8,37 @@ export function isExternal (path) { ...@@ -7,16 +8,37 @@ export function isExternal (path) {
7 } 8 }
8 // ex: {validator:validateCode,trigger:'blur'} 9 // ex: {validator:validateCode,trigger:'blur'}
9 // 验证code 10 // 验证code
11 /**
12 * @description: 验证code
13 * @param {*} rule
14 * @param {*} value
15 * @param {*} callback
16 * @author: renchao
17 */
10 export const validateCode = (rule, value, callback) => { 18 export const validateCode = (rule, value, callback) => {
11 const reg = /^[A-Z]{1}[A-Za-z0-9]*$/ 19 const reg = /^[A-Z]{1}[A-Za-z0-9]*$/
12 !reg.test(value) ? callback('字母开头、数字和字母组成') : callback() 20 !reg.test(value) ? callback('字母开头、数字和字母组成') : callback()
13 } 21 }
14 // 验证 网址 22 // 验证 网址
23 /**
24 * @description: 验证 网址
25 * @param {*} rule
26 * @param {*} value
27 * @param {*} callback
28 * @author: renchao
29 */
15 export const validateUrl = (rule, value, callback) => { 30 export const validateUrl = (rule, value, callback) => {
16 const reg = /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/ 31 const reg = /^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?$/
17 !reg.test(value) ? callback('URL格式不正确') : callback() 32 !reg.test(value) ? callback('URL格式不正确') : callback()
18 } 33 }
19 // 验证 电话 34 // 验证 电话
35 /**
36 * @description: 验证 电话
37 * @param {*} rule
38 * @param {*} value
39 * @param {*} callback
40 * @author: renchao
41 */
20 export const validatePhone = (rule, value, callback) => { 42 export const validatePhone = (rule, value, callback) => {
21 const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/ 43 const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
22 const rel = /^[0]\d{2,3}-[1-9]\d{7}$/ 44 const rel = /^[0]\d{2,3}-[1-9]\d{7}$/
......