Parcourir la source

!132 修改单词拼写错误:praseStrEmpty -> parseStrEmpty
Merge pull request !132 from 我的世界有我/master

若依 il y a 4 ans
Parent
commit
81ccdc49ec
2 fichiers modifiés avec 347 ajouts et 347 suppressions
  1. 127 127
      ruoyi-ui/src/api/system/user.js
  2. 220 220
      ruoyi-ui/src/utils/ruoyi.js

+ 127 - 127
ruoyi-ui/src/api/system/user.js

@@ -1,127 +1,127 @@
1
-import request from '@/utils/request'
2
-import { praseStrEmpty } from "@/utils/ruoyi";
3
-
4
-// 查询用户列表
5
-export function listUser(query) {
6
-  return request({
7
-    url: '/system/user/list',
8
-    method: 'get',
9
-    params: query
10
-  })
11
-}
12
-
13
-// 查询用户详细
14
-export function getUser(userId) {
15
-  return request({
16
-    url: '/system/user/' + praseStrEmpty(userId),
17
-    method: 'get'
18
-  })
19
-}
20
-
21
-// 新增用户
22
-export function addUser(data) {
23
-  return request({
24
-    url: '/system/user',
25
-    method: 'post',
26
-    data: data
27
-  })
28
-}
29
-
30
-// 修改用户
31
-export function updateUser(data) {
32
-  return request({
33
-    url: '/system/user',
34
-    method: 'put',
35
-    data: data
36
-  })
37
-}
38
-
39
-// 删除用户
40
-export function delUser(userId) {
41
-  return request({
42
-    url: '/system/user/' + userId,
43
-    method: 'delete'
44
-  })
45
-}
46
-
47
-// 用户密码重置
48
-export function resetUserPwd(userId, password) {
49
-  const data = {
50
-    userId,
51
-    password
52
-  }
53
-  return request({
54
-    url: '/system/user/resetPwd',
55
-    method: 'put',
56
-    data: data
57
-  })
58
-}
59
-
60
-// 用户状态修改
61
-export function changeUserStatus(userId, status) {
62
-  const data = {
63
-    userId,
64
-    status
65
-  }
66
-  return request({
67
-    url: '/system/user/changeStatus',
68
-    method: 'put',
69
-    data: data
70
-  })
71
-}
72
-
73
-// 查询用户个人信息
74
-export function getUserProfile() {
75
-  return request({
76
-    url: '/system/user/profile',
77
-    method: 'get'
78
-  })
79
-}
80
-
81
-// 修改用户个人信息
82
-export function updateUserProfile(data) {
83
-  return request({
84
-    url: '/system/user/profile',
85
-    method: 'put',
86
-    data: data
87
-  })
88
-}
89
-
90
-// 用户密码重置
91
-export function updateUserPwd(oldPassword, newPassword) {
92
-  const data = {
93
-    oldPassword,
94
-    newPassword
95
-  }
96
-  return request({
97
-    url: '/system/user/profile/updatePwd',
98
-    method: 'put',
99
-    params: data
100
-  })
101
-}
102
-
103
-// 用户头像上传
104
-export function uploadAvatar(data) {
105
-  return request({
106
-    url: '/system/user/profile/avatar',
107
-    method: 'post',
108
-    data: data
109
-  })
110
-}
111
-
112
-// 查询授权角色
113
-export function getAuthRole(userId) {
114
-  return request({
115
-    url: '/system/user/authRole/' + userId,
116
-    method: 'get'
117
-  })
118
-}
119
-
120
-// 保存授权角色
121
-export function updateAuthRole(data) {
122
-  return request({
123
-    url: '/system/user/authRole',
124
-    method: 'put',
125
-    params: data
126
-  })
127
-}
1
+import request from '@/utils/request'
2
+import { parseStrEmpty } from "@/utils/ruoyi";
3
+
4
+// 查询用户列表
5
+export function listUser(query) {
6
+  return request({
7
+    url: '/system/user/list',
8
+    method: 'get',
9
+    params: query
10
+  })
11
+}
12
+
13
+// 查询用户详细
14
+export function getUser(userId) {
15
+  return request({
16
+    url: '/system/user/' + parseStrEmpty(userId),
17
+    method: 'get'
18
+  })
19
+}
20
+
21
+// 新增用户
22
+export function addUser(data) {
23
+  return request({
24
+    url: '/system/user',
25
+    method: 'post',
26
+    data: data
27
+  })
28
+}
29
+
30
+// 修改用户
31
+export function updateUser(data) {
32
+  return request({
33
+    url: '/system/user',
34
+    method: 'put',
35
+    data: data
36
+  })
37
+}
38
+
39
+// 删除用户
40
+export function delUser(userId) {
41
+  return request({
42
+    url: '/system/user/' + userId,
43
+    method: 'delete'
44
+  })
45
+}
46
+
47
+// 用户密码重置
48
+export function resetUserPwd(userId, password) {
49
+  const data = {
50
+    userId,
51
+    password
52
+  }
53
+  return request({
54
+    url: '/system/user/resetPwd',
55
+    method: 'put',
56
+    data: data
57
+  })
58
+}
59
+
60
+// 用户状态修改
61
+export function changeUserStatus(userId, status) {
62
+  const data = {
63
+    userId,
64
+    status
65
+  }
66
+  return request({
67
+    url: '/system/user/changeStatus',
68
+    method: 'put',
69
+    data: data
70
+  })
71
+}
72
+
73
+// 查询用户个人信息
74
+export function getUserProfile() {
75
+  return request({
76
+    url: '/system/user/profile',
77
+    method: 'get'
78
+  })
79
+}
80
+
81
+// 修改用户个人信息
82
+export function updateUserProfile(data) {
83
+  return request({
84
+    url: '/system/user/profile',
85
+    method: 'put',
86
+    data: data
87
+  })
88
+}
89
+
90
+// 用户密码重置
91
+export function updateUserPwd(oldPassword, newPassword) {
92
+  const data = {
93
+    oldPassword,
94
+    newPassword
95
+  }
96
+  return request({
97
+    url: '/system/user/profile/updatePwd',
98
+    method: 'put',
99
+    params: data
100
+  })
101
+}
102
+
103
+// 用户头像上传
104
+export function uploadAvatar(data) {
105
+  return request({
106
+    url: '/system/user/profile/avatar',
107
+    method: 'post',
108
+    data: data
109
+  })
110
+}
111
+
112
+// 查询授权角色
113
+export function getAuthRole(userId) {
114
+  return request({
115
+    url: '/system/user/authRole/' + userId,
116
+    method: 'get'
117
+  })
118
+}
119
+
120
+// 保存授权角色
121
+export function updateAuthRole(data) {
122
+  return request({
123
+    url: '/system/user/authRole',
124
+    method: 'put',
125
+    params: data
126
+  })
127
+}

+ 220 - 220
ruoyi-ui/src/utils/ruoyi.js

@@ -1,220 +1,220 @@
1
-/**
2
- * 通用js方法封装处理
3
- * Copyright (c) 2019 ruoyi
4
- */
5
-
6
-// 日期格式化
7
-export function parseTime(time, pattern) {
8
-	if (arguments.length === 0 || !time) {
9
-		return null
10
-	}
11
-	const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
12
-	let date
13
-	if (typeof time === 'object') {
14
-		date = time
15
-	} else {
16
-		if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
17
-			time = parseInt(time)
18
-		} else if (typeof time === 'string') {
19
-			time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm),'');
20
-		}
21
-		if ((typeof time === 'number') && (time.toString().length === 10)) {
22
-			time = time * 1000
23
-		}
24
-		date = new Date(time)
25
-	}
26
-	const formatObj = {
27
-		y: date.getFullYear(),
28
-		m: date.getMonth() + 1,
29
-		d: date.getDate(),
30
-		h: date.getHours(),
31
-		i: date.getMinutes(),
32
-		s: date.getSeconds(),
33
-		a: date.getDay()
34
-	}
35
-	const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
36
-		let value = formatObj[key]
37
-		// Note: getDay() returns 0 on Sunday
38
-		if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
39
-		if (result.length > 0 && value < 10) {
40
-			value = '0' + value
41
-		}
42
-		return value || 0
43
-	})
44
-	return time_str
45
-}
46
-
47
-// 表单重置
48
-export function resetForm(refName) {
49
-	if (this.$refs[refName]) {
50
-		this.$refs[refName].resetFields();
51
-	}
52
-}
53
-
54
-// 添加日期范围
55
-export function addDateRange(params, dateRange, propName) {
56
-	let search = params;
57
-	search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
58
-	dateRange = Array.isArray(dateRange) ? dateRange : [];
59
-	if (typeof (propName) === 'undefined') {
60
-		search.params['beginTime'] = dateRange[0];
61
-		search.params['endTime'] = dateRange[1];
62
-	} else {
63
-		search.params['begin' + propName] = dateRange[0];
64
-		search.params['end' + propName] = dateRange[1];
65
-	}
66
-	return search;
67
-}
68
-
69
-// 回显数据字典
70
-export function selectDictLabel(datas, value) {
71
-	var actions = [];
72
-	Object.keys(datas).some((key) => {
73
-		if (datas[key].value == ('' + value)) {
74
-			actions.push(datas[key].label);
75
-			return true;
76
-		}
77
-	})
78
-	return actions.join('');
79
-}
80
-
81
-// 回显数据字典(字符串数组)
82
-export function selectDictLabels(datas, value, separator) {
83
-	var actions = [];
84
-	var currentSeparator = undefined === separator ? "," : separator;
85
-	var temp = value.split(currentSeparator);
86
-	Object.keys(value.split(currentSeparator)).some((val) => {
87
-		Object.keys(datas).some((key) => {
88
-			if (datas[key].value == ('' + temp[val])) {
89
-				actions.push(datas[key].label + currentSeparator);
90
-			}
91
-		})
92
-	})
93
-	return actions.join('').substring(0, actions.join('').length - 1);
94
-}
95
-
96
-// 字符串格式化(%s )
97
-export function sprintf(str) {
98
-	var args = arguments, flag = true, i = 1;
99
-	str = str.replace(/%s/g, function () {
100
-		var arg = args[i++];
101
-		if (typeof arg === 'undefined') {
102
-			flag = false;
103
-			return '';
104
-		}
105
-		return arg;
106
-	});
107
-	return flag ? str : '';
108
-}
109
-
110
-// 转换字符串,undefined,null等转化为""
111
-export function praseStrEmpty(str) {
112
-	if (!str || str == "undefined" || str == "null") {
113
-		return "";
114
-	}
115
-	return str;
116
-}
117
-
118
-// 数据合并
119
-export function mergeRecursive(source, target) {
120
-    for (var p in target) {
121
-        try {
122
-            if (target[p].constructor == Object) {
123
-                source[p] = mergeRecursive(source[p], target[p]);
124
-            } else {
125
-                source[p] = target[p];
126
-            }
127
-        } catch(e) {
128
-            source[p] = target[p];
129
-        }
130
-    }
131
-    return source;
132
-};
133
-
134
-/**
135
- * 构造树型结构数据
136
- * @param {*} data 数据源
137
- * @param {*} id id字段 默认 'id'
138
- * @param {*} parentId 父节点字段 默认 'parentId'
139
- * @param {*} children 孩子节点字段 默认 'children'
140
- */
141
-export function handleTree(data, id, parentId, children) {
142
-	let config = {
143
-		id: id || 'id',
144
-		parentId: parentId || 'parentId',
145
-		childrenList: children || 'children'
146
-	};
147
-
148
-	var childrenListMap = {};
149
-	var nodeIds = {};
150
-	var tree = [];
151
-
152
-	for (let d of data) {
153
-		let parentId = d[config.parentId];
154
-		if (childrenListMap[parentId] == null) {
155
-			childrenListMap[parentId] = [];
156
-		}
157
-		nodeIds[d[config.id]] = d;
158
-		childrenListMap[parentId].push(d);
159
-	}
160
-
161
-	for (let d of data) {
162
-		let parentId = d[config.parentId];
163
-		if (nodeIds[parentId] == null) {
164
-			tree.push(d);
165
-		}
166
-	}
167
-
168
-	for (let t of tree) {
169
-		adaptToChildrenList(t);
170
-	}
171
-
172
-	function adaptToChildrenList(o) {
173
-		if (childrenListMap[o[config.id]] !== null) {
174
-			o[config.childrenList] = childrenListMap[o[config.id]];
175
-		}
176
-		if (o[config.childrenList]) {
177
-			for (let c of o[config.childrenList]) {
178
-				adaptToChildrenList(c);
179
-			}
180
-		}
181
-	}
182
-	return tree;
183
-}
184
-
185
-/**
186
-* 参数处理
187
-* @param {*} params  参数
188
-*/
189
-export function tansParams(params) {
190
-	let result = ''
191
-	for (const propName of Object.keys(params)) {
192
-		const value = params[propName];
193
-		var part = encodeURIComponent(propName) + "=";
194
-		if (value !== null && typeof (value) !== "undefined") {
195
-			if (typeof value === 'object') {
196
-				for (const key of Object.keys(value)) {
197
-					if (value[key] !== null && typeof (value[key]) !== 'undefined') {
198
-						let params = propName + '[' + key + ']';
199
-						var subPart = encodeURIComponent(params) + "=";
200
-						result += subPart + encodeURIComponent(value[key]) + "&";
201
-					}
202
-				}
203
-			} else {
204
-				result += part + encodeURIComponent(value) + "&";
205
-			}
206
-		}
207
-	}
208
-	return result
209
-}
210
-
211
-// 验证是否为blob格式
212
-export async function blobValidate(data) {
213
-    try {
214
-      const text = await data.text();
215
-      JSON.parse(text);
216
-      return false;
217
-    } catch (error) {
218
-      return true;
219
-    }
220
-}
1
+/**
2
+ * 通用js方法封装处理
3
+ * Copyright (c) 2019 ruoyi
4
+ */
5
+
6
+// 日期格式化
7
+export function parseTime(time, pattern) {
8
+	if (arguments.length === 0 || !time) {
9
+		return null
10
+	}
11
+	const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
12
+	let date
13
+	if (typeof time === 'object') {
14
+		date = time
15
+	} else {
16
+		if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
17
+			time = parseInt(time)
18
+		} else if (typeof time === 'string') {
19
+			time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm),'');
20
+		}
21
+		if ((typeof time === 'number') && (time.toString().length === 10)) {
22
+			time = time * 1000
23
+		}
24
+		date = new Date(time)
25
+	}
26
+	const formatObj = {
27
+		y: date.getFullYear(),
28
+		m: date.getMonth() + 1,
29
+		d: date.getDate(),
30
+		h: date.getHours(),
31
+		i: date.getMinutes(),
32
+		s: date.getSeconds(),
33
+		a: date.getDay()
34
+	}
35
+	const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
36
+		let value = formatObj[key]
37
+		// Note: getDay() returns 0 on Sunday
38
+		if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
39
+		if (result.length > 0 && value < 10) {
40
+			value = '0' + value
41
+		}
42
+		return value || 0
43
+	})
44
+	return time_str
45
+}
46
+
47
+// 表单重置
48
+export function resetForm(refName) {
49
+	if (this.$refs[refName]) {
50
+		this.$refs[refName].resetFields();
51
+	}
52
+}
53
+
54
+// 添加日期范围
55
+export function addDateRange(params, dateRange, propName) {
56
+	let search = params;
57
+	search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
58
+	dateRange = Array.isArray(dateRange) ? dateRange : [];
59
+	if (typeof (propName) === 'undefined') {
60
+		search.params['beginTime'] = dateRange[0];
61
+		search.params['endTime'] = dateRange[1];
62
+	} else {
63
+		search.params['begin' + propName] = dateRange[0];
64
+		search.params['end' + propName] = dateRange[1];
65
+	}
66
+	return search;
67
+}
68
+
69
+// 回显数据字典
70
+export function selectDictLabel(datas, value) {
71
+	var actions = [];
72
+	Object.keys(datas).some((key) => {
73
+		if (datas[key].value == ('' + value)) {
74
+			actions.push(datas[key].label);
75
+			return true;
76
+		}
77
+	})
78
+	return actions.join('');
79
+}
80
+
81
+// 回显数据字典(字符串数组)
82
+export function selectDictLabels(datas, value, separator) {
83
+	var actions = [];
84
+	var currentSeparator = undefined === separator ? "," : separator;
85
+	var temp = value.split(currentSeparator);
86
+	Object.keys(value.split(currentSeparator)).some((val) => {
87
+		Object.keys(datas).some((key) => {
88
+			if (datas[key].value == ('' + temp[val])) {
89
+				actions.push(datas[key].label + currentSeparator);
90
+			}
91
+		})
92
+	})
93
+	return actions.join('').substring(0, actions.join('').length - 1);
94
+}
95
+
96
+// 字符串格式化(%s )
97
+export function sprintf(str) {
98
+	var args = arguments, flag = true, i = 1;
99
+	str = str.replace(/%s/g, function () {
100
+		var arg = args[i++];
101
+		if (typeof arg === 'undefined') {
102
+			flag = false;
103
+			return '';
104
+		}
105
+		return arg;
106
+	});
107
+	return flag ? str : '';
108
+}
109
+
110
+// 转换字符串,undefined,null等转化为""
111
+export function parseStrEmpty(str) {
112
+	if (!str || str == "undefined" || str == "null") {
113
+		return "";
114
+	}
115
+	return str;
116
+}
117
+
118
+// 数据合并
119
+export function mergeRecursive(source, target) {
120
+    for (var p in target) {
121
+        try {
122
+            if (target[p].constructor == Object) {
123
+                source[p] = mergeRecursive(source[p], target[p]);
124
+            } else {
125
+                source[p] = target[p];
126
+            }
127
+        } catch(e) {
128
+            source[p] = target[p];
129
+        }
130
+    }
131
+    return source;
132
+};
133
+
134
+/**
135
+ * 构造树型结构数据
136
+ * @param {*} data 数据源
137
+ * @param {*} id id字段 默认 'id'
138
+ * @param {*} parentId 父节点字段 默认 'parentId'
139
+ * @param {*} children 孩子节点字段 默认 'children'
140
+ */
141
+export function handleTree(data, id, parentId, children) {
142
+	let config = {
143
+		id: id || 'id',
144
+		parentId: parentId || 'parentId',
145
+		childrenList: children || 'children'
146
+	};
147
+
148
+	var childrenListMap = {};
149
+	var nodeIds = {};
150
+	var tree = [];
151
+
152
+	for (let d of data) {
153
+		let parentId = d[config.parentId];
154
+		if (childrenListMap[parentId] == null) {
155
+			childrenListMap[parentId] = [];
156
+		}
157
+		nodeIds[d[config.id]] = d;
158
+		childrenListMap[parentId].push(d);
159
+	}
160
+
161
+	for (let d of data) {
162
+		let parentId = d[config.parentId];
163
+		if (nodeIds[parentId] == null) {
164
+			tree.push(d);
165
+		}
166
+	}
167
+
168
+	for (let t of tree) {
169
+		adaptToChildrenList(t);
170
+	}
171
+
172
+	function adaptToChildrenList(o) {
173
+		if (childrenListMap[o[config.id]] !== null) {
174
+			o[config.childrenList] = childrenListMap[o[config.id]];
175
+		}
176
+		if (o[config.childrenList]) {
177
+			for (let c of o[config.childrenList]) {
178
+				adaptToChildrenList(c);
179
+			}
180
+		}
181
+	}
182
+	return tree;
183
+}
184
+
185
+/**
186
+* 参数处理
187
+* @param {*} params  参数
188
+*/
189
+export function tansParams(params) {
190
+	let result = ''
191
+	for (const propName of Object.keys(params)) {
192
+		const value = params[propName];
193
+		var part = encodeURIComponent(propName) + "=";
194
+		if (value !== null && typeof (value) !== "undefined") {
195
+			if (typeof value === 'object') {
196
+				for (const key of Object.keys(value)) {
197
+					if (value[key] !== null && typeof (value[key]) !== 'undefined') {
198
+						let params = propName + '[' + key + ']';
199
+						var subPart = encodeURIComponent(params) + "=";
200
+						result += subPart + encodeURIComponent(value[key]) + "&";
201
+					}
202
+				}
203
+			} else {
204
+				result += part + encodeURIComponent(value) + "&";
205
+			}
206
+		}
207
+	}
208
+	return result
209
+}
210
+
211
+// 验证是否为blob格式
212
+export async function blobValidate(data) {
213
+    try {
214
+      const text = await data.text();
215
+      JSON.parse(text);
216
+      return false;
217
+    } catch (error) {
218
+      return true;
219
+    }
220
+}