haiwei-ui 1.3.2 → 1.3.4
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/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-dialog ref="dialog" :id="id" :class="class_" :top="draggable_ ? '' : top" :modal="modal"
|
|
2
|
+
<el-dialog ref="dialog" :id="id" :class="class_" :top="draggable_ ? '' : top" :modal="modal"
|
|
3
|
+
:close-on-click-modal="closeOnClickModal_" :fullscreen="hasFullscreen"
|
|
4
|
+
:visible.sync="visible_" :show-close="false" :append-to-body="true" :destroy-on-close="destroyOnClose" v-on="on">
|
|
3
5
|
<!--头部-->
|
|
4
6
|
<template v-slot:title>
|
|
5
7
|
<section v-if="icon" class="nm-dialog-icon">
|
|
@@ -310,16 +312,13 @@
|
|
|
310
312
|
onOpen() {
|
|
311
313
|
this.$nextTick(() => {
|
|
312
314
|
this.resize()
|
|
313
|
-
|
|
314
315
|
on(window, 'resize', this.resize)
|
|
315
316
|
if (!this.noScrollbar) {
|
|
316
317
|
addResizeListener(this.elScrollbarViewEl, this.resize)
|
|
317
318
|
}
|
|
318
|
-
|
|
319
319
|
if (!this.draggable_) return
|
|
320
320
|
on(this.titleEl, 'mousedown', this.handleDragDown)
|
|
321
321
|
})
|
|
322
|
-
|
|
323
322
|
this.$emit('open')
|
|
324
323
|
},
|
|
325
324
|
onOpened() {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<nm-dialog ref="dialog" class="nm-form-dialog" :title="title" :icon="icon" :width="width" :height="height"
|
|
3
|
-
|
|
2
|
+
<nm-dialog ref="dialog" class="nm-form-dialog" :title="title" :icon="icon" :width="width" :height="height"
|
|
3
|
+
:footer="footer" :fullscreen="fullscreen" :close-on-click-modal="closeOnClickModal" :loading="showLoading"
|
|
4
|
+
:footer-close-button="footerCloseButton" :draggable="draggable" :drag-out-page="dragOutPage"
|
|
5
|
+
:drag-min-width="dragMinWidth" :visible.sync="visible_" v-on="dialogOn">
|
|
6
|
+
<nm-form ref="form" no-loading :model="model" :rules="rules" :action="action" :label-width="labelWidth"
|
|
7
|
+
:label-position="labelPosition" :customValidate="validate" :success-msg="successMsg"
|
|
8
|
+
:success-msg-text="successMsgText" :disabled="disabled" :inline="inline"
|
|
9
|
+
:customResetFunction="customResetFunction" v-on="formOn" @validate="onValidate">
|
|
4
10
|
<slot />
|
|
5
11
|
</nm-form>
|
|
6
12
|
|
|
@@ -18,195 +24,213 @@
|
|
|
18
24
|
</nm-dialog>
|
|
19
25
|
</template>
|
|
20
26
|
<script>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
import visible from '../../mixins/components/visible'
|
|
28
|
+
export default {
|
|
29
|
+
name: 'FormDialog',
|
|
30
|
+
mixins: [visible],
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
loading_: false,
|
|
34
|
+
formOn: {
|
|
35
|
+
success: this.onSuccess,
|
|
36
|
+
error: this.onError,
|
|
37
|
+
reset: this.onReset,
|
|
38
|
+
'validate-error': this.onValidateError
|
|
39
|
+
},
|
|
40
|
+
dialogOn: {
|
|
41
|
+
open: this.onOpen,
|
|
42
|
+
opened: this.onOpened,
|
|
43
|
+
close: this.onClose,
|
|
44
|
+
closed: this.onClosed
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
props: {
|
|
49
|
+
/** 标题 */
|
|
50
|
+
title: String,
|
|
51
|
+
/** 图标 */
|
|
52
|
+
icon: String,
|
|
53
|
+
/** 宽度 */
|
|
54
|
+
width: String,
|
|
55
|
+
/** Dialog 的高度 */
|
|
56
|
+
height: [Number, String],
|
|
57
|
+
/** 显示尾部 */
|
|
58
|
+
footer: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true
|
|
61
|
+
},
|
|
62
|
+
/** 是否可以通过点击 modal 关闭 Dialog */
|
|
63
|
+
closeOnClickModal: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: null
|
|
66
|
+
},
|
|
67
|
+
/** 是否显示全屏按钮 */
|
|
68
|
+
fullscreen: Boolean,
|
|
69
|
+
/** 表单模型 */
|
|
70
|
+
model: {
|
|
71
|
+
type: Object,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
/** 验证规则 */
|
|
75
|
+
rules: Object,
|
|
76
|
+
/** 提交请求 */
|
|
77
|
+
action: Function,
|
|
78
|
+
/** 行内表单 */
|
|
79
|
+
inline: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
83
|
+
/** 标签的宽度 */
|
|
84
|
+
labelWidth: String,
|
|
85
|
+
/** 表单域标签的位置,如果值为 left 或者 right 时,则需要设置 label-width */
|
|
86
|
+
labelPosition: String,
|
|
87
|
+
// 自定义验证
|
|
88
|
+
validate: Function,
|
|
89
|
+
/** 是否显示成功提示消息 */
|
|
90
|
+
successMsg: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: true
|
|
93
|
+
},
|
|
94
|
+
/** 成功提示消息文本 */
|
|
95
|
+
successMsgText: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: '保存成功'
|
|
98
|
+
},
|
|
99
|
+
/** Ok按钮 */
|
|
100
|
+
btnOk: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: true
|
|
103
|
+
},
|
|
104
|
+
/** Ok按钮文本 */
|
|
105
|
+
btnOkText: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: '保存'
|
|
108
|
+
},
|
|
109
|
+
/** reset按钮 */
|
|
110
|
+
btnReset: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: true
|
|
113
|
+
},
|
|
114
|
+
/** 自定义重置操作 */
|
|
115
|
+
customResetFunction: Function,
|
|
116
|
+
// 保存成功后是否关闭对话框
|
|
117
|
+
closeWhenSuccess: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: true
|
|
120
|
+
},
|
|
121
|
+
/** 禁用表单 */
|
|
122
|
+
disabled: Boolean,
|
|
123
|
+
/** 显示加载动画 */
|
|
124
|
+
loading: Boolean,
|
|
125
|
+
/** 不显示加载动画 */
|
|
126
|
+
noLoading: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: false
|
|
129
|
+
},
|
|
130
|
+
/** 打开时是否清楚验证信息 */
|
|
131
|
+
clearValidateOnOpen: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: true
|
|
134
|
+
},
|
|
135
|
+
/** 是否显示底部关闭按钮 */
|
|
136
|
+
footerCloseButton: Boolean,
|
|
137
|
+
/** 可拖拽的 */
|
|
138
|
+
draggable: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
default: null
|
|
141
|
+
},
|
|
142
|
+
/** 是否可拖出页面 */
|
|
143
|
+
dragOutPage: Boolean,
|
|
144
|
+
/** 拖拽出页面后保留的最小宽度 */
|
|
145
|
+
dragMinWidth: Number
|
|
146
|
+
},
|
|
147
|
+
computed: {
|
|
148
|
+
showLoading() {
|
|
149
|
+
return !this.noLoading && (this.loading_ || this.loading)
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
methods: {
|
|
153
|
+
/** 提交 */
|
|
154
|
+
async submit() {
|
|
155
|
+
// 触发 before-submit 钩子
|
|
156
|
+
if (this.$listeners['before-submit']) {
|
|
157
|
+
this.loading_ = true
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
// 直接传递 this.model,让父组件直接修改它
|
|
161
|
+
await new Promise((resolve, reject) => {
|
|
162
|
+
this.$emit('before-submit', this.model, resolve, reject)
|
|
163
|
+
})
|
|
164
|
+
} catch (error) {
|
|
165
|
+
// 如果 before-submit 中调用了 reject,会进入这里
|
|
166
|
+
this.loading_ = false
|
|
167
|
+
this.$emit('error', error)
|
|
168
|
+
return
|
|
39
169
|
}
|
|
40
170
|
}
|
|
171
|
+
|
|
172
|
+
// 继续原有提交逻辑(this.model 已经被父组件修改过了)
|
|
173
|
+
this.loading_ = true
|
|
174
|
+
this.$refs.form.submit()
|
|
41
175
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type: Object,
|
|
66
|
-
required: true
|
|
67
|
-
},
|
|
68
|
-
/** 验证规则 */
|
|
69
|
-
rules: Object,
|
|
70
|
-
/** 提交请求 */
|
|
71
|
-
action: Function,
|
|
72
|
-
/** 行内表单 */
|
|
73
|
-
inline: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: false
|
|
76
|
-
},
|
|
77
|
-
/** 标签的宽度 */
|
|
78
|
-
labelWidth: String,
|
|
79
|
-
/** 表单域标签的位置,如果值为 left 或者 right 时,则需要设置 label-width */
|
|
80
|
-
labelPosition: String,
|
|
81
|
-
// 自定义验证
|
|
82
|
-
validate: Function,
|
|
83
|
-
/** 是否显示成功提示消息 */
|
|
84
|
-
successMsg: {
|
|
85
|
-
type: Boolean,
|
|
86
|
-
default: true
|
|
87
|
-
},
|
|
88
|
-
/** 成功提示消息文本 */
|
|
89
|
-
successMsgText: {
|
|
90
|
-
type: String,
|
|
91
|
-
default: '保存成功'
|
|
92
|
-
},
|
|
93
|
-
/** Ok按钮 */
|
|
94
|
-
btnOk: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
default: true
|
|
97
|
-
},
|
|
98
|
-
/** Ok按钮文本 */
|
|
99
|
-
btnOkText: {
|
|
100
|
-
type: String,
|
|
101
|
-
default: '保存'
|
|
102
|
-
},
|
|
103
|
-
/** reset按钮 */
|
|
104
|
-
btnReset: {
|
|
105
|
-
type: Boolean,
|
|
106
|
-
default: true
|
|
107
|
-
},
|
|
108
|
-
/** 自定义重置操作 */
|
|
109
|
-
customResetFunction: Function,
|
|
110
|
-
// 保存成功后是否关闭对话框
|
|
111
|
-
closeWhenSuccess: {
|
|
112
|
-
type: Boolean,
|
|
113
|
-
default: true
|
|
114
|
-
},
|
|
115
|
-
/** 禁用表单 */
|
|
116
|
-
disabled: Boolean,
|
|
117
|
-
/** 显示加载动画 */
|
|
118
|
-
loading: Boolean,
|
|
119
|
-
/** 不显示加载动画 */
|
|
120
|
-
noLoading: {
|
|
121
|
-
type: Boolean,
|
|
122
|
-
default: false
|
|
123
|
-
},
|
|
124
|
-
/** 打开时是否清楚验证信息 */
|
|
125
|
-
clearValidateOnOpen: {
|
|
126
|
-
type: Boolean,
|
|
127
|
-
default: true
|
|
128
|
-
},
|
|
129
|
-
/** 是否显示底部关闭按钮 */
|
|
130
|
-
footerCloseButton: Boolean,
|
|
131
|
-
/** 可拖拽的 */
|
|
132
|
-
draggable: {
|
|
133
|
-
type: Boolean,
|
|
134
|
-
default: null
|
|
135
|
-
},
|
|
136
|
-
/** 是否可拖出页面 */
|
|
137
|
-
dragOutPage: Boolean,
|
|
138
|
-
/** 拖拽出页面后保留的最小宽度 */
|
|
139
|
-
dragMinWidth: Number
|
|
140
|
-
},
|
|
141
|
-
computed: {
|
|
142
|
-
showLoading() {
|
|
143
|
-
return !this.noLoading && (this.loading_ || this.loading)
|
|
176
|
+
/** 重置 */
|
|
177
|
+
reset() {
|
|
178
|
+
this.$nextTick(() => {
|
|
179
|
+
this.$refs.form.reset()
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
/** 清除验证信息 */
|
|
183
|
+
clearValidate() {
|
|
184
|
+
this.$refs.form.clearValidate()
|
|
185
|
+
},
|
|
186
|
+
/** 打开loading */
|
|
187
|
+
openLoading() {
|
|
188
|
+
this.loading_ = true
|
|
189
|
+
},
|
|
190
|
+
/** 关闭loading */
|
|
191
|
+
closeLoading() {
|
|
192
|
+
this.loading = false
|
|
193
|
+
},
|
|
194
|
+
// 成功
|
|
195
|
+
onSuccess(data) {
|
|
196
|
+
// 关闭对话框
|
|
197
|
+
if (this.closeWhenSuccess) {
|
|
198
|
+
setTimeout(this.hide, 800)
|
|
144
199
|
}
|
|
200
|
+
this.loading_ = false
|
|
201
|
+
this.$emit('success', data)
|
|
145
202
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
203
|
+
onReset() {
|
|
204
|
+
this.$emit('reset')
|
|
205
|
+
},
|
|
206
|
+
onError() {
|
|
207
|
+
this.loading_ = false
|
|
208
|
+
this.$emit('error')
|
|
209
|
+
},
|
|
210
|
+
onValidateError() {
|
|
211
|
+
this.loading_ = false
|
|
212
|
+
this.$emit('validate-error')
|
|
213
|
+
},
|
|
214
|
+
onOpen() {
|
|
215
|
+
if (this.clearValidateOnOpen) {
|
|
154
216
|
this.$nextTick(() => {
|
|
155
|
-
this.$refs.form.
|
|
217
|
+
this.$refs.form.clearValidate()
|
|
156
218
|
})
|
|
157
|
-
},
|
|
158
|
-
/** 清除验证信息 */
|
|
159
|
-
clearValidate() {
|
|
160
|
-
this.$refs.form.clearValidate()
|
|
161
|
-
},
|
|
162
|
-
/** 打开loading */
|
|
163
|
-
openLoading() {
|
|
164
|
-
this.loading_ = true
|
|
165
|
-
},
|
|
166
|
-
/** 关闭loading */
|
|
167
|
-
closeLoading() {
|
|
168
|
-
this.loading = false
|
|
169
|
-
},
|
|
170
|
-
// 成功
|
|
171
|
-
onSuccess(data) {
|
|
172
|
-
// 关闭对话框
|
|
173
|
-
if (this.closeWhenSuccess) {
|
|
174
|
-
setTimeout(this.hide, 800)
|
|
175
|
-
}
|
|
176
|
-
this.loading_ = false
|
|
177
|
-
this.$emit('success', data)
|
|
178
|
-
},
|
|
179
|
-
onReset() {
|
|
180
|
-
this.$emit('reset')
|
|
181
|
-
},
|
|
182
|
-
onError() {
|
|
183
|
-
this.loading_ = false
|
|
184
|
-
this.$emit('error')
|
|
185
|
-
},
|
|
186
|
-
onValidateError() {
|
|
187
|
-
this.loading_ = false
|
|
188
|
-
this.$emit('validate-error')
|
|
189
|
-
},
|
|
190
|
-
onOpen() {
|
|
191
|
-
if (this.clearValidateOnOpen) {
|
|
192
|
-
this.$nextTick(() => {
|
|
193
|
-
this.$refs.form.clearValidate()
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
this.$emit('open')
|
|
197
|
-
},
|
|
198
|
-
onOpened() {
|
|
199
|
-
this.$emit('opened')
|
|
200
|
-
},
|
|
201
|
-
onClose() {
|
|
202
|
-
this.$emit('close')
|
|
203
|
-
},
|
|
204
|
-
onClosed() {
|
|
205
|
-
this.$emit('closed')
|
|
206
|
-
},
|
|
207
|
-
onValidate(prop, valid, msg) {
|
|
208
|
-
this.$emit('validate', prop, valid, msg)
|
|
209
219
|
}
|
|
220
|
+
this.$emit('open')
|
|
221
|
+
},
|
|
222
|
+
onOpened() {
|
|
223
|
+
this.$emit('opened')
|
|
224
|
+
},
|
|
225
|
+
onClose() {
|
|
226
|
+
this.$emit('close')
|
|
227
|
+
},
|
|
228
|
+
onClosed() {
|
|
229
|
+
this.$emit('closed')
|
|
230
|
+
},
|
|
231
|
+
onValidate(prop, valid, msg) {
|
|
232
|
+
this.$emit('validate', prop, valid, msg)
|
|
210
233
|
}
|
|
211
234
|
}
|
|
235
|
+
}
|
|
212
236
|
</script>
|
package/packages/utils/http.js
CHANGED
|
@@ -58,6 +58,52 @@ Http.prototype.put = (url, params, config) => {
|
|
|
58
58
|
return axios.put(url, params, config)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* 通用文件上传接口
|
|
63
|
+
* @param {string} url - 上传接口URL
|
|
64
|
+
* @param {File|Blob} file - 要上传的文件对象
|
|
65
|
+
* @param {string} [fieldName='file'] - 文件字段名称,默认为'file'
|
|
66
|
+
* @param {Object} [formData={}] - 额外的表单数据
|
|
67
|
+
* @param {Object} [config={}] - 额外的axios配置
|
|
68
|
+
* @returns {Promise} 返回Promise对象
|
|
69
|
+
* @example
|
|
70
|
+
* // 基本使用
|
|
71
|
+
* $http.upload('/api/upload', file)
|
|
72
|
+
*
|
|
73
|
+
* // 自定义字段名和额外参数
|
|
74
|
+
* $http.upload('/api/upload', file, 'avatar', { userId: 123 })
|
|
75
|
+
*
|
|
76
|
+
* // 完整配置
|
|
77
|
+
* $http.upload('/api/upload', file, 'document', { category: 'pdf' }, {
|
|
78
|
+
* onUploadProgress: progressEvent => {
|
|
79
|
+
* const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
|
80
|
+
* console.log(`上传进度: ${percentCompleted}%`)
|
|
81
|
+
* }
|
|
82
|
+
* })
|
|
83
|
+
*/
|
|
84
|
+
Http.prototype.upload = (url, file, fieldName = 'file', formData = {}, config = {}) => {
|
|
85
|
+
// 创建FormData对象
|
|
86
|
+
const data = new FormData()
|
|
87
|
+
|
|
88
|
+
// 添加文件
|
|
89
|
+
data.append(fieldName, file)
|
|
90
|
+
|
|
91
|
+
// 添加额外的表单数据
|
|
92
|
+
Object.keys(formData).forEach(key => {
|
|
93
|
+
data.append(key, formData[key])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// 合并配置,设置Content-Type为multipart/form-data
|
|
97
|
+
const config_ = Object.assign({}, config, {
|
|
98
|
+
headers: {
|
|
99
|
+
'Content-Type': 'multipart/form-data',
|
|
100
|
+
...config.headers
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
return axios.post(url, data, config_)
|
|
105
|
+
}
|
|
106
|
+
|
|
61
107
|
Http.prototype.download = (url, params, config) => {
|
|
62
108
|
const config_ = Object.assign({ responseType: 'blob' }, config, {
|
|
63
109
|
// 参数
|
|
@@ -74,17 +120,21 @@ Http.prototype.download = (url, params, config) => {
|
|
|
74
120
|
}
|
|
75
121
|
|
|
76
122
|
Http.prototype.preview = (url, params, config) => {
|
|
77
|
-
const config_ = Object.assign(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
123
|
+
const config_ = Object.assign(
|
|
124
|
+
{ responseType: 'blob', headers: { preview: true } },
|
|
125
|
+
config,
|
|
126
|
+
{
|
|
127
|
+
// 参数
|
|
128
|
+
params,
|
|
129
|
+
// 修改参数序列化方法
|
|
130
|
+
paramsSerializer: p => {
|
|
131
|
+
// 使用逗号分隔参数
|
|
132
|
+
return qs.stringify(p, {
|
|
133
|
+
allowDots: true
|
|
134
|
+
})
|
|
135
|
+
}
|
|
86
136
|
}
|
|
87
|
-
|
|
137
|
+
)
|
|
88
138
|
return axios.get(url, config_)
|
|
89
139
|
}
|
|
90
140
|
|
|
@@ -121,12 +171,12 @@ if (!window.$http) window.$http = new Http()
|
|
|
121
171
|
|
|
122
172
|
// 消息提醒显示时长(ms)
|
|
123
173
|
const messageDuration = 1500
|
|
124
|
-
|
|
174
|
+
// 是否显示了账户在其他地方登录的提示框
|
|
125
175
|
let showLoginOnOtherPlaces = false
|
|
126
176
|
|
|
127
|
-
|
|
177
|
+
// 处理文件下载请求
|
|
128
178
|
const handleDownload = response => {
|
|
129
|
-
|
|
179
|
+
// 如果返回的是application/json,则表示返回的是json,没有要下载的问题,可能是逻辑处理失败
|
|
130
180
|
if (response.data.type === 'application/json') {
|
|
131
181
|
var reader = new FileReader()
|
|
132
182
|
reader.onload = e => {
|
|
@@ -158,12 +208,12 @@ const handleDownload = response => {
|
|
|
158
208
|
fileName = decodeURI(cd.split("''")[1])
|
|
159
209
|
}
|
|
160
210
|
|
|
161
|
-
|
|
211
|
+
// 如果文件名不存在,则使用时间戳
|
|
162
212
|
if (!fileName) {
|
|
163
213
|
fileName = dayjs().format('YYYYMMDDHHMMSSS')
|
|
164
214
|
}
|
|
165
215
|
|
|
166
|
-
|
|
216
|
+
// 通过模拟a标签点击事件下载文件
|
|
167
217
|
const link = document.createElement('a')
|
|
168
218
|
link.href = url
|
|
169
219
|
link.setAttribute('download', fileName)
|
|
@@ -172,7 +222,7 @@ const handleDownload = response => {
|
|
|
172
222
|
document.body.removeChild(link)
|
|
173
223
|
}
|
|
174
224
|
|
|
175
|
-
|
|
225
|
+
// 刷新令牌
|
|
176
226
|
const refreshToken = () => {
|
|
177
227
|
let t = token.get()
|
|
178
228
|
if (t && t.refreshToken) {
|
|
@@ -279,9 +329,9 @@ export default config => {
|
|
|
279
329
|
case 401:
|
|
280
330
|
return refreshToken()
|
|
281
331
|
.then(data => {
|
|
282
|
-
|
|
332
|
+
// 重新初始化令牌
|
|
283
333
|
store.commit('app/token/init', data)
|
|
284
|
-
|
|
334
|
+
// 重新发一起一次上次的的请求
|
|
285
335
|
error.config.headers.Authorization = 'Bearer ' + data.accessToken
|
|
286
336
|
return axios.request(error.config)
|
|
287
337
|
})
|
|
@@ -309,7 +359,7 @@ export default config => {
|
|
|
309
359
|
)
|
|
310
360
|
break
|
|
311
361
|
case 622:
|
|
312
|
-
|
|
362
|
+
// 单账户登录功能
|
|
313
363
|
if (!showLoginOnOtherPlaces) {
|
|
314
364
|
showLoginOnOtherPlaces = true
|
|
315
365
|
MessageBox.confirm('账户已在别处登录, 请重新登录~', '提示', {
|
|
@@ -352,4 +402,4 @@ export default config => {
|
|
|
352
402
|
return Promise.reject(error)
|
|
353
403
|
}
|
|
354
404
|
)
|
|
355
|
-
}
|
|
405
|
+
}
|