xs-common-plugins 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/workspace.xml +15 -5
- package/package.json +1 -1
- package/src/common/common.js +308 -295
package/.idea/workspace.xml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
5
|
</component>
|
|
6
6
|
<component name="ChangeListManager">
|
|
7
|
-
<list default="true" id="18da8823-8844-430e-8765-342a5b83382e" name="更改" comment="
|
|
7
|
+
<list default="true" id="18da8823-8844-430e-8765-342a5b83382e" name="更改" comment="chore(common): 移除对话框点击遮罩关闭功能并更新包信息 - 移除了 el-dialog 的 close-on-click-modal 属性配置 - 将包版本从 1.4.11 更新到 1.4.12 - 清空了作者信息字段">
|
|
8
8
|
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
9
9
|
<change beforePath="$PROJECT_DIR$/src/common/common.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/common/common.js" afterDir="false" />
|
|
10
10
|
</list>
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"node.js.selected.package.tslint": "(autodetect)",
|
|
44
44
|
"nodejs_interpreter_path": "node",
|
|
45
45
|
"nodejs_package_manager_path": "npm",
|
|
46
|
-
"settings.editor.selected.configurable": "
|
|
46
|
+
"settings.editor.selected.configurable": "editor.preferences.fonts.default",
|
|
47
47
|
"to.speed.mode.migration.done": "true",
|
|
48
48
|
"ts.external.directory.path": "/Applications/WebStorm.app/Contents/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
|
49
49
|
"vue.rearranger.settings.migration": "true"
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
<workItem from="1766654268352" duration="129000" />
|
|
72
72
|
<workItem from="1768291265910" duration="1000" />
|
|
73
73
|
<workItem from="1772155854565" duration="1270000" />
|
|
74
|
-
<workItem from="1772171331103" duration="
|
|
74
|
+
<workItem from="1772171331103" duration="200000" />
|
|
75
|
+
<workItem from="1772172034321" duration="488000" />
|
|
75
76
|
</task>
|
|
76
77
|
<task id="LOCAL-00001" summary="fix(table): 更新单元格分析逻辑以正确处理括号- 替换正则表达式检测为 includes 方法检测括号和 null - 确保只在包含成对括号且不含 null 时才匹配 chore: 升级版本号至 1.4.9">
|
|
77
78
|
<option name="closed" value="true" />
|
|
@@ -97,7 +98,15 @@
|
|
|
97
98
|
<option name="project" value="LOCAL" />
|
|
98
99
|
<updated>1772155919495</updated>
|
|
99
100
|
</task>
|
|
100
|
-
<
|
|
101
|
+
<task id="LOCAL-00004" summary="chore(common): 移除对话框点击遮罩关闭功能并更新包信息 - 移除了 el-dialog 的 close-on-click-modal 属性配置 - 将包版本从 1.4.11 更新到 1.4.12 - 清空了作者信息字段">
|
|
102
|
+
<option name="closed" value="true" />
|
|
103
|
+
<created>1772171500658</created>
|
|
104
|
+
<option name="number" value="00004" />
|
|
105
|
+
<option name="presentableId" value="LOCAL-00004" />
|
|
106
|
+
<option name="project" value="LOCAL" />
|
|
107
|
+
<updated>1772171500658</updated>
|
|
108
|
+
</task>
|
|
109
|
+
<option name="localTasksCounter" value="5" />
|
|
101
110
|
<servers />
|
|
102
111
|
</component>
|
|
103
112
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -119,6 +128,7 @@
|
|
|
119
128
|
<MESSAGE value="fix(table): 更新单元格分析逻辑以正确处理括号- 替换正则表达式检测为 includes 方法检测括号和 null - 确保只在包含成对括号且不含 null 时才匹配 chore: 升级版本号至 1.4.9" />
|
|
120
129
|
<MESSAGE value="feat(common): 添加弹窗ESC关闭功能并优化OSS服务 - 在popup函数中新增closeOnPressEscape参数,默认值为false - 将closeOnPressEscape参数传递给对话框配置 - 优化OSS服务中的getOssToken函数,防止重复请求 - 添加getIng变量控制请求状态 -" />
|
|
121
130
|
<MESSAGE value="feat(common): 添加弹窗ESC关闭功能并优化OSS服务 - 在popup函数中新增closeOnPressEscape参数,默认值为false - 将closeOnPressEscape参数传递给对话框配置 - 优化OSS服务中的getOssToken函数,防止重复请求 - 添加getIng变量控制请求状态 - 在请求完成后重置getIng状态 - 更新版本号从1.4.10到1.4.11" />
|
|
122
|
-
<
|
|
131
|
+
<MESSAGE value="chore(common): 移除对话框点击遮罩关闭功能并更新包信息 - 移除了 el-dialog 的 close-on-click-modal 属性配置 - 将包版本从 1.4.11 更新到 1.4.12 - 清空了作者信息字段" />
|
|
132
|
+
<option name="LAST_COMMIT_MESSAGE" value="chore(common): 移除对话框点击遮罩关闭功能并更新包信息 - 移除了 el-dialog 的 close-on-click-modal 属性配置 - 将包版本从 1.4.11 更新到 1.4.12 - 清空了作者信息字段" />
|
|
123
133
|
</component>
|
|
124
134
|
</project>
|
package/package.json
CHANGED
package/src/common/common.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Vue from 'vue'
|
|
2
2
|
import ask from '@/automatically/api'
|
|
3
|
-
import router from '@/router/index'
|
|
4
3
|
import store from '@/store/index'
|
|
5
|
-
import {OrgEnum} from '@/utils/enum'
|
|
4
|
+
import { OrgEnum } from '@/utils/enum'
|
|
6
5
|
import filterRules from '@/utils/filterRules'
|
|
7
|
-
import request from
|
|
6
|
+
import request from 'xs-request'
|
|
8
7
|
import moduleCfg from '@/modules/module.config.js'
|
|
9
8
|
|
|
10
9
|
|
|
@@ -18,42 +17,42 @@ const common = {}
|
|
|
18
17
|
* @param {Function} callBack 返回函数, 页面在接口返回后自行处理
|
|
19
18
|
*/
|
|
20
19
|
common.getList = (that, url, query, callBack) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
let newQuery = {}
|
|
21
|
+
if (query) newQuery = query
|
|
22
|
+
else {
|
|
23
|
+
let obj = Object.assign({}, that.data)
|
|
24
|
+
if (obj.pageInfo === undefined) {
|
|
25
|
+
that.$set(obj, 'pageInfo', { page: 1, pageSize: 30 })
|
|
26
|
+
} // 移除空项查询条件
|
|
27
|
+
for (const key in obj) {
|
|
28
|
+
if (obj[key] == null || obj[key] === '')
|
|
29
|
+
delete obj[key]
|
|
30
|
+
}
|
|
31
|
+
delete obj.data
|
|
32
|
+
newQuery = obj
|
|
33
|
+
}
|
|
34
|
+
let request = common.getObject(url)
|
|
35
|
+
request(query ? query : newQuery).then((res) => {
|
|
36
|
+
if (callBack) {
|
|
37
|
+
callBack(res)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (res.code == 0) {
|
|
41
|
+
that.data = res.data
|
|
42
|
+
}
|
|
43
|
+
})
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
*根据请求URL解析对象
|
|
49
48
|
**/
|
|
50
49
|
common.getObject = (url, obj = ask) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
let value = obj
|
|
51
|
+
let keys = url.split('.')
|
|
52
|
+
for (let i = 1; i < keys.length; i++) {
|
|
53
|
+
value = value[keys[i]]
|
|
54
|
+
}
|
|
55
|
+
return value
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/**
|
|
@@ -69,19 +68,19 @@ common.getObject = (url, obj = ask) => {
|
|
|
69
68
|
|
|
70
69
|
*/
|
|
71
70
|
common.saveData = (that, url, query, ref, callBack) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
let newQuery = query ? query : JSON.parse(JSON.stringify(that.postForm)) // 深拷贝, 避免影响页面显示
|
|
72
|
+
if (ref === false) {
|
|
73
|
+
common.handleData(that, url, newQuery, callBack)
|
|
74
|
+
} else {
|
|
75
|
+
let newRef = ref ? ref : that.$refs.pageDetail.$refs.postForm
|
|
76
|
+
newRef.validate(res => {
|
|
77
|
+
if (!res) return
|
|
78
|
+
if (that.beforeSaveData) {
|
|
79
|
+
newQuery = that['beforeSaveData'](newQuery)
|
|
80
|
+
}
|
|
81
|
+
common.handleData(that, url, newQuery, callBack)
|
|
82
|
+
})
|
|
83
|
+
}
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
86
|
* 保存数据 一般作为 common.saveData 的内嵌方法使用, 不推荐单独使用 (表单提交,原则上要经过表单校验)
|
|
@@ -91,19 +90,19 @@ common.saveData = (that, url, query, ref, callBack) => {
|
|
|
91
90
|
* @param {*} callBack 接口返回后, 页面要进行后续操作
|
|
92
91
|
*/
|
|
93
92
|
|
|
94
|
-
common.handleData
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if(callBack) callBack(null)
|
|
93
|
+
common.handleData = (that, url, query, callBack) => {
|
|
94
|
+
let newQuery = query ? query : that.postForm
|
|
95
|
+
if (that.loading !== undefined) that.loading = true
|
|
96
|
+
let request = common.getObject(url)
|
|
97
|
+
request(newQuery ? newQuery : undefined).then((res) => {
|
|
98
|
+
if (that.loading !== undefined) that.loading = false
|
|
99
|
+
if (res.code == 0) {
|
|
100
|
+
that.$message('保存成功')
|
|
101
|
+
if (!callBack) that.$emit('close')
|
|
102
|
+
}
|
|
103
|
+
if (callBack) callBack(res.data)
|
|
104
|
+
}).finally(() => {
|
|
105
|
+
if (callBack) callBack(null)
|
|
107
106
|
})
|
|
108
107
|
|
|
109
108
|
}
|
|
@@ -117,13 +116,14 @@ common.handleData = (that, url, query, callBack)=> {
|
|
|
117
116
|
* @param {Function} callBack 返回函数, 页面在接口返回后要进行其他处理
|
|
118
117
|
*/
|
|
119
118
|
common.getById = (that, url, query, callBack) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
let request = common.getObject(url)
|
|
120
|
+
request(query).then((res) => {
|
|
121
|
+
if (res.code == 0) {
|
|
122
|
+
if (callBack) {
|
|
123
|
+
callBack(res.data)
|
|
124
|
+
} else that.postForm = res.data
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
@@ -134,14 +134,16 @@ common.getById = (that, url, query, callBack) => {
|
|
|
134
134
|
* @param {Function} callBack 返回函数, 页面在接口返回后要进行其他处理
|
|
135
135
|
*/
|
|
136
136
|
common.updateById = (that, url, query, callBack) => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
let newQuery = query ? query : that.postForm
|
|
138
|
+
let request = common.getObject(url)
|
|
139
|
+
request(newQuery).then((res) => {
|
|
140
|
+
if (res.code == 0) {
|
|
141
|
+
that.$message('操作成功')
|
|
142
|
+
if (callBack) {
|
|
143
|
+
callBack(res.data)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
})
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
149
|
* 判断多条数据 返回 true/false 或者 重新拼接好的 ids []
|
|
@@ -158,21 +160,21 @@ common.updateById = (that, url, query, callBack) => {
|
|
|
158
160
|
* this.$common.updateData(that, 'ask.xxx.xxx', {保存对象})
|
|
159
161
|
* }
|
|
160
162
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
163
|
+
common.checkRows = async (that, row, title, prop = 'id', check = true) => {
|
|
164
|
+
if (row.length == 0) {
|
|
165
|
+
common.message(that, `请选择数据`, 'error')
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
if (check) {
|
|
169
|
+
try {
|
|
170
|
+
await common.confirm(that, `您确定进行${title}操作`, '操作提醒')
|
|
171
|
+
return prop ? row.map(item => item[prop]) : row
|
|
172
|
+
} catch (error) {
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
return true
|
|
177
|
+
}
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
/**
|
|
@@ -183,13 +185,13 @@ common.updateById = (that, url, query, callBack) => {
|
|
|
183
185
|
* @param {Function} callBack 接口响应成功后, 界面上自行处理返回事件, 不传, 默认执行页面 getList 方法 (刷新列表页)
|
|
184
186
|
*/
|
|
185
187
|
common.updateData = (that, url, query, callBack) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
let request = common.getObject(url)
|
|
189
|
+
request(Object.assign({}, query)).then(res => {
|
|
190
|
+
if (res.code !== 0) return
|
|
191
|
+
common.message(that, res.message)
|
|
192
|
+
if (callBack) callBack(res)
|
|
193
|
+
else that.getList && that.getList()
|
|
194
|
+
})
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
|
|
@@ -200,10 +202,10 @@ common.updateData = (that, url, query, callBack) => {
|
|
|
200
202
|
* @param {String} type 类型 可选值:查看element ui 文档, 默认 success
|
|
201
203
|
*/
|
|
202
204
|
common.message = (that, message, type) => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
that.$message({
|
|
206
|
+
message: message,
|
|
207
|
+
type: type ? type : 'success'
|
|
208
|
+
})
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
/**
|
|
@@ -214,21 +216,21 @@ common.message = (that, message, type) => {
|
|
|
214
216
|
* @param {Function} callBack 返回函数, 页面在接口返回后要进行其他处理
|
|
215
217
|
*/
|
|
216
218
|
common.confirm = (that, message, title, callBack) => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
let result = that.$confirm(message, title ? title : '提示', {
|
|
220
|
+
confirmButtonText: '确定',
|
|
221
|
+
cancelButtonText: '取消',
|
|
222
|
+
type: 'none'
|
|
223
|
+
})
|
|
224
|
+
if (callBack) {
|
|
225
|
+
result.then(() => {
|
|
226
|
+
callBack(true)
|
|
227
|
+
})
|
|
228
|
+
.catch(() => {
|
|
229
|
+
callBack(false)
|
|
230
|
+
})
|
|
231
|
+
} else {
|
|
232
|
+
return result
|
|
233
|
+
}
|
|
232
234
|
}
|
|
233
235
|
|
|
234
236
|
|
|
@@ -248,17 +250,27 @@ common.confirm = (that, message, title, callBack) => {
|
|
|
248
250
|
*
|
|
249
251
|
*/
|
|
250
252
|
common.popup = (options) => {
|
|
251
|
-
if (!options) return
|
|
252
|
-
const { title, component, srcData, width, showButton, callBack, props, dialogCfg
|
|
253
|
-
if (!component) return
|
|
253
|
+
if (!options) return
|
|
254
|
+
const { title, component, srcData, width, showButton, callBack, props, dialogCfg = {} } = common.clone(options)
|
|
255
|
+
if (!component) return
|
|
256
|
+
|
|
257
|
+
// 添加默认值
|
|
258
|
+
if (!Object.hasOwn(dialogCfg, 'close-on-click-modal')) {
|
|
259
|
+
dialogCfg['close-on-click-modal'] = false
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 添加默认值
|
|
263
|
+
if (!Object.hasOwn(dialogCfg, 'close-on-press-escape')) {
|
|
264
|
+
dialogCfg['close-on-press-escape'] = true
|
|
265
|
+
}
|
|
254
266
|
|
|
255
|
-
const div = document.createElement(
|
|
256
|
-
document.body.appendChild(div)
|
|
267
|
+
const div = document.createElement('div')
|
|
268
|
+
document.body.appendChild(div)
|
|
257
269
|
|
|
258
270
|
const dialogComponent = {
|
|
259
|
-
computed:{
|
|
271
|
+
computed: {
|
|
260
272
|
loading() {
|
|
261
|
-
return this.$store.getters?.loading || false
|
|
273
|
+
return this.$store.getters?.loading || false
|
|
262
274
|
}
|
|
263
275
|
},
|
|
264
276
|
components: {
|
|
@@ -267,68 +279,70 @@ common.popup = (options) => {
|
|
|
267
279
|
props: {
|
|
268
280
|
title: {
|
|
269
281
|
type: String,
|
|
270
|
-
default: '弹窗组件'
|
|
282
|
+
default: '弹窗组件'
|
|
271
283
|
},
|
|
272
284
|
srcData: {
|
|
273
285
|
type: Object,
|
|
274
|
-
default: null
|
|
286
|
+
default: null
|
|
275
287
|
},
|
|
276
288
|
showButton: {
|
|
277
289
|
type: Boolean,
|
|
278
|
-
default: false
|
|
290
|
+
default: false
|
|
279
291
|
},
|
|
280
292
|
width: {
|
|
281
293
|
type: String,
|
|
282
|
-
default: '30%'
|
|
294
|
+
default: '30%'
|
|
283
295
|
},
|
|
284
296
|
dialogCfg: {
|
|
285
297
|
type: Object,
|
|
286
|
-
default: null
|
|
298
|
+
default: null
|
|
287
299
|
},
|
|
288
300
|
props: {
|
|
289
301
|
type: Object,
|
|
290
|
-
default: null
|
|
302
|
+
default: null
|
|
291
303
|
},
|
|
292
304
|
callBack: {
|
|
293
305
|
type: Function,
|
|
294
|
-
default: null
|
|
295
|
-
},
|
|
296
|
-
closeOnPressEscape:{
|
|
297
|
-
type: Boolean,
|
|
298
|
-
default: false,
|
|
306
|
+
default: null
|
|
299
307
|
}
|
|
300
308
|
},
|
|
301
309
|
data() {
|
|
302
310
|
return {
|
|
303
311
|
visible: true,
|
|
304
|
-
}
|
|
312
|
+
}
|
|
305
313
|
},
|
|
306
314
|
methods: {
|
|
307
315
|
confirm() {
|
|
308
316
|
if (this.$refs.child.confirm) {
|
|
309
|
-
this.$refs.child.confirm()
|
|
317
|
+
this.$refs.child.confirm()
|
|
310
318
|
}
|
|
311
319
|
},
|
|
312
320
|
beforeClose(done) {
|
|
313
321
|
if (this.$refs.child.beforeClose) {
|
|
314
|
-
this.$refs.child.beforeClose(done)
|
|
322
|
+
this.$refs.child.beforeClose(done)
|
|
315
323
|
} else {
|
|
316
|
-
done()
|
|
324
|
+
done()
|
|
317
325
|
}
|
|
326
|
+
setTimeout(() => {
|
|
327
|
+
div.remove()
|
|
328
|
+
Vue.nextTick(() => {
|
|
329
|
+
this.$destroy()
|
|
330
|
+
})
|
|
331
|
+
}, 300)
|
|
318
332
|
},
|
|
319
333
|
cancel() {
|
|
320
|
-
this.visible = false
|
|
334
|
+
this.visible = false
|
|
321
335
|
},
|
|
322
336
|
close(res) {
|
|
323
337
|
if (this.callBack) {
|
|
324
|
-
this.callBack(res)
|
|
338
|
+
this.callBack(res)
|
|
325
339
|
}
|
|
326
|
-
this.visible = false
|
|
340
|
+
this.visible = false
|
|
327
341
|
}
|
|
328
342
|
},
|
|
329
343
|
template: `
|
|
330
344
|
<div>
|
|
331
|
-
<el-dialog :title="title"
|
|
345
|
+
<el-dialog :title="title" v-el-drag-dialog :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
|
|
332
346
|
<child ref="child" :srcData="srcData" v-bind="props" @close="close" @cancel="cancel"/>
|
|
333
347
|
<div v-if="showButton" style="text-align: right;margin-top: 10px">
|
|
334
348
|
<el-button size="medium" type="primary" @click="confirm" v-loading="loading">确认</el-button>
|
|
@@ -336,8 +350,8 @@ common.popup = (options) => {
|
|
|
336
350
|
</div>
|
|
337
351
|
</el-dialog>
|
|
338
352
|
</div>
|
|
339
|
-
|
|
340
|
-
}
|
|
353
|
+
`
|
|
354
|
+
}
|
|
341
355
|
|
|
342
356
|
return new Vue({
|
|
343
357
|
el: div,
|
|
@@ -351,14 +365,13 @@ common.popup = (options) => {
|
|
|
351
365
|
showButton,
|
|
352
366
|
callBack,
|
|
353
367
|
props,
|
|
354
|
-
dialogCfg
|
|
355
|
-
closeOnPressEscape
|
|
368
|
+
dialogCfg
|
|
356
369
|
},
|
|
357
|
-
});
|
|
358
|
-
},
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
370
|
|
|
371
|
+
})
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
}
|
|
362
375
|
|
|
363
376
|
|
|
364
377
|
/**
|
|
@@ -366,26 +379,25 @@ common.popup = (options) => {
|
|
|
366
379
|
*/
|
|
367
380
|
common.clone = (obj) => {
|
|
368
381
|
if (obj === null || typeof obj !== 'object') {
|
|
369
|
-
return obj
|
|
382
|
+
return obj
|
|
370
383
|
}
|
|
371
384
|
|
|
372
385
|
if (obj instanceof Date) {
|
|
373
|
-
return new Date(obj.getTime())
|
|
386
|
+
return new Date(obj.getTime())
|
|
374
387
|
}
|
|
375
388
|
|
|
376
|
-
const clone = Array.isArray(obj) ? [] : {}
|
|
389
|
+
const clone = Array.isArray(obj) ? [] : {}
|
|
377
390
|
|
|
378
391
|
for (const key in obj) {
|
|
379
392
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
380
|
-
clone[key] = common.clone(obj[key])
|
|
393
|
+
clone[key] = common.clone(obj[key])
|
|
381
394
|
}
|
|
382
395
|
}
|
|
383
396
|
|
|
384
|
-
return clone
|
|
397
|
+
return clone
|
|
385
398
|
}
|
|
386
399
|
|
|
387
400
|
|
|
388
|
-
|
|
389
401
|
/**
|
|
390
402
|
*导出数据报表
|
|
391
403
|
*@param query 默认 列表上的 query 条件去掉 data
|
|
@@ -393,24 +405,24 @@ common.clone = (obj) => {
|
|
|
393
405
|
*@param {String} url 请求方法
|
|
394
406
|
*@param {String} fileName 文件名
|
|
395
407
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
408
|
+
common.exportExcel = async (url, query, fileName = 'demo', headers = { responseType: 'arraybuffer' }) => {
|
|
409
|
+
let newQuery = JSON.parse(JSON.stringify(query))
|
|
410
|
+
delete newQuery.data
|
|
411
|
+
for (const key in newQuery) {
|
|
412
|
+
if (newQuery[key] == null || newQuery[key] === '')
|
|
413
|
+
delete newQuery[key]
|
|
414
|
+
}
|
|
415
|
+
const httpRequest = common.getObject(url)
|
|
416
|
+
const response = await httpRequest(newQuery, headers)
|
|
417
|
+
const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' })
|
|
418
|
+
const objectUrl = URL.createObjectURL(blob)
|
|
419
|
+
const a = document.createElement('a')
|
|
420
|
+
document.body.appendChild(a)
|
|
421
|
+
a.style = 'display: none'
|
|
422
|
+
a.href = objectUrl
|
|
423
|
+
a.download = `${fileName}.xlsx`
|
|
424
|
+
a.click()
|
|
425
|
+
document.body.removeChild(a)
|
|
414
426
|
}
|
|
415
427
|
|
|
416
428
|
/**
|
|
@@ -420,14 +432,14 @@ common.clone = (obj) => {
|
|
|
420
432
|
* @param {String} name 完整的按钮名称
|
|
421
433
|
*
|
|
422
434
|
*/
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
435
|
+
common.getBtnListByEnum = (enumName, methodName, name = '') => {
|
|
436
|
+
let enums = OrgEnum[enumName]
|
|
437
|
+
let list = []
|
|
438
|
+
enums.filter(item => {
|
|
439
|
+
if (item.Id == null) return
|
|
440
|
+
list.push({ name: name + item.Text, methodName, type: item.Id, row: item })
|
|
441
|
+
})
|
|
442
|
+
return list
|
|
431
443
|
}
|
|
432
444
|
|
|
433
445
|
/**
|
|
@@ -435,11 +447,11 @@ common.clone = (obj) => {
|
|
|
435
447
|
* @param {List} list 必填项字段名列表
|
|
436
448
|
*/
|
|
437
449
|
common.requiredList = (list) => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
450
|
+
let obj = {}
|
|
451
|
+
list.forEach(key => {
|
|
452
|
+
obj[key] = filterRules({ required: true })
|
|
453
|
+
})
|
|
454
|
+
return obj
|
|
443
455
|
}
|
|
444
456
|
|
|
445
457
|
/**
|
|
@@ -448,42 +460,42 @@ common.requiredList = (list) => {
|
|
|
448
460
|
* @param {*} type 要格式化的类型 [date, price, price, money, enum, list(前端自定义枚举)]
|
|
449
461
|
* @returns
|
|
450
462
|
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
463
|
+
common.format = (value, type = 'date') => {
|
|
464
|
+
let newType = ['money', 'date', 'mdate'].includes(type) ? type : type.split('.').length > 1 ? 'enum' : 'list'
|
|
465
|
+
switch (newType) {
|
|
466
|
+
case 'money':
|
|
467
|
+
return Number(value).toFixed(4)
|
|
468
|
+
case 'date':
|
|
469
|
+
if (value === '1970-01-01T00:00:00') return '/'
|
|
470
|
+
return value ? value.replace('T', ' ').substr(0, 19) : ''
|
|
471
|
+
case 'mdate':
|
|
472
|
+
if (value === '1970-01-01T00:00:00') return '/'
|
|
473
|
+
return value ? value.replace('T', ' ').substr(5, 19) : ''
|
|
474
|
+
case 'price':
|
|
475
|
+
if (typeof (value) === 'number') {
|
|
476
|
+
return value.toFixed(2).toString().replace(/,/g, '').replace(/\d+/, function(n) { // 先提取整数部分
|
|
477
|
+
return n.replace(/(\d)(?=(\d{3})+$)/g, function($1) { // 对整数部分添加分隔符
|
|
478
|
+
return $1 + ','
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
} else return ''
|
|
482
|
+
case 'enum':
|
|
483
|
+
return getValueByType('enum', type, value)
|
|
484
|
+
case 'list':
|
|
485
|
+
return getValueByType('list', type, value)
|
|
486
|
+
default:
|
|
487
|
+
break
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function getValueByType(type, name, value) {
|
|
491
|
+
if (type === 'enum') {
|
|
492
|
+
let row = OrgEnum[name].find(item => item.Id == value)
|
|
493
|
+
return row ? row.Text : ''
|
|
494
|
+
} else if (type === 'list') {
|
|
495
|
+
let row = moduleCfg.format ? moduleCfg.format[name].find(item => item.id == value) : null
|
|
496
|
+
return row ? row.name : ''
|
|
497
|
+
}
|
|
498
|
+
}
|
|
487
499
|
}
|
|
488
500
|
|
|
489
501
|
/**
|
|
@@ -494,19 +506,19 @@ common.requiredList = (list) => {
|
|
|
494
506
|
* @param {Function} callBack 自定义事件, 传此参数, 接口响应后, 后续事情自定义
|
|
495
507
|
* @param {String} methodName 接口响应后, 调用界面哪个方法
|
|
496
508
|
*/
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
common.getReportCfg = (that, url, query, callBack, methodName = 'getReportList') => {
|
|
510
|
+
let request = common.getObject(url)
|
|
511
|
+
request(query).then(res => {
|
|
512
|
+
if (callBack) {
|
|
513
|
+
callBack(res)
|
|
514
|
+
} else {
|
|
515
|
+
that.config.reportList = res.data
|
|
516
|
+
if (res.data[0]) {
|
|
517
|
+
that.reportCfgVal = JSON.parse(res.data[0].jsonCfg)
|
|
518
|
+
that[methodName]()
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
})
|
|
510
522
|
}
|
|
511
523
|
|
|
512
524
|
/**
|
|
@@ -517,23 +529,23 @@ common.requiredList = (list) => {
|
|
|
517
529
|
* @param {*} callBack 接口响应后, 自定义事件
|
|
518
530
|
*/
|
|
519
531
|
common.getReportList = (that, url, query, callBack) => {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
532
|
+
let newQuery = {}
|
|
533
|
+
if (query) newQuery = query
|
|
534
|
+
else {
|
|
535
|
+
let obj = Object.assign({}, that.data)
|
|
536
|
+
delete obj.data
|
|
537
|
+
// 移除空项查询条件
|
|
538
|
+
for (const key in obj) {
|
|
539
|
+
if (obj[key] == null || obj[key] === '')
|
|
540
|
+
delete obj[key]
|
|
541
|
+
}
|
|
542
|
+
newQuery = Object.assign(obj, { report: that.reportCfgVal })
|
|
543
|
+
}
|
|
544
|
+
let request = common.getObject(url)
|
|
545
|
+
request(newQuery).then(res => {
|
|
546
|
+
if (callBack) callBack(res)
|
|
547
|
+
else that.data = res.data
|
|
548
|
+
})
|
|
537
549
|
}
|
|
538
550
|
|
|
539
551
|
|
|
@@ -550,35 +562,38 @@ common.getReportList = (that, url, query, callBack) => {
|
|
|
550
562
|
*/
|
|
551
563
|
|
|
552
564
|
common.dic = async (props, val) => {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
565
|
+
let isArray = Array.isArray(val)
|
|
566
|
+
let server = props[0] || ''
|
|
567
|
+
let tableName = props[1] || ''
|
|
568
|
+
let prop = props[2] || 'name'
|
|
569
|
+
let key = server + tableName
|
|
570
|
+
if (store.getters.dic[key]) {
|
|
571
|
+
if (isArray) return await getDicVal()
|
|
572
|
+
let row = store.getters.dic[key].find(item => item.id == val)
|
|
573
|
+
if (row && (row.isNull || row[prop] === null)) {
|
|
574
|
+
return ''
|
|
575
|
+
}
|
|
576
|
+
if (row) return row[prop]
|
|
577
|
+
if (!row) return await getDicVal()
|
|
578
|
+
|
|
579
|
+
} else {
|
|
580
|
+
return await getDicVal()
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
async function getDicVal() {
|
|
584
|
+
let servers = props[0] || ''
|
|
585
|
+
let tableName = props[1] || ''
|
|
586
|
+
let key = servers + tableName
|
|
587
|
+
let url = servers + '/UserAll/Search/Dic/' + tableName
|
|
588
|
+
let res = await request.post(url, isArray ? val : [val])
|
|
589
|
+
if (res.code !== 0) return
|
|
590
|
+
store.commit('dic/SET_ASK', { key, val: res.data })
|
|
591
|
+
if (isArray) return res.data
|
|
592
|
+
else {
|
|
593
|
+
let row = res.data.find(item => item.id == val)
|
|
594
|
+
return row ? row[prop] : ''
|
|
595
|
+
}
|
|
596
|
+
}
|
|
582
597
|
}
|
|
583
598
|
/**
|
|
584
599
|
* 快速给页面变量赋值
|
|
@@ -587,17 +602,17 @@ common.dic = async (props, val) => {
|
|
|
587
602
|
* @param {*} prop 要为哪个字段名赋值
|
|
588
603
|
*/
|
|
589
604
|
common.getLabelList = (that, prop, url, query) => {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
605
|
+
common.getObject(url)(query).then(res => {
|
|
606
|
+
that[prop] = res.data
|
|
607
|
+
})
|
|
593
608
|
}
|
|
594
609
|
|
|
595
|
-
common.checkRows2 = async (that, row, title, prop =
|
|
596
|
-
if(row.length == 0) {
|
|
597
|
-
common.message(that, `请选择数据`, 'error')
|
|
598
|
-
return false
|
|
610
|
+
common.checkRows2 = async (that, row, title, prop = 'id', check = true) => {
|
|
611
|
+
if (row.length == 0) {
|
|
612
|
+
common.message(that, `请选择数据`, 'error')
|
|
613
|
+
return false
|
|
599
614
|
}
|
|
600
|
-
if(check) {
|
|
615
|
+
if (check) {
|
|
601
616
|
try {
|
|
602
617
|
return prop ? row.map(item => item[prop]) : row
|
|
603
618
|
} catch (error) {
|
|
@@ -608,12 +623,12 @@ common.checkRows2 = async (that, row, title, prop = "id", check = true) => {
|
|
|
608
623
|
}
|
|
609
624
|
}
|
|
610
625
|
|
|
611
|
-
common.checkStatus = async (that, row, title, prop =
|
|
612
|
-
if(row.length == 0) {
|
|
626
|
+
common.checkStatus = async (that, row, title, prop = 'status', check = true) => {
|
|
627
|
+
if (row.length == 0) {
|
|
613
628
|
//common.message(that, `请选择数据`, 'error');
|
|
614
|
-
return false
|
|
629
|
+
return false
|
|
615
630
|
}
|
|
616
|
-
if(check) {
|
|
631
|
+
if (check) {
|
|
617
632
|
try {
|
|
618
633
|
//await common.confirm(that, `您确定进行${title}操作`, '操作提醒')
|
|
619
634
|
return prop ? row.map(item => item[prop]) : row
|
|
@@ -626,6 +641,4 @@ common.checkStatus = async (that, row, title, prop = "status", check = true) =>
|
|
|
626
641
|
}
|
|
627
642
|
|
|
628
643
|
|
|
629
|
-
|
|
630
|
-
|
|
631
644
|
export default common
|