vue2-client 1.19.43 → 1.19.44

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.
@@ -0,0 +1 @@
1
+ VUE_APP_API_BASE_URL=http://localhost:8001
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.19.43",
3
+ "version": "1.19.44",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="32" height="32" viewBox="0 0 32 32"><g><path d="M16,6.193552C12.580641,6.193552,9.8064489,8.9677448,9.8064489,12.387104C9.8064489,15.806449,12.580641,18.580641,16,18.580641C19.419361,18.580641,22.193602,15.806449,22.193602,12.387104C22.193602,8.9677448,19.419361,6.193552,16,6.193552C16,6.193552,16,6.193552,16,6.193552ZM16,15.483871C14.29032,15.483871,12.903233,14.096769,12.903233,12.387104C12.903233,10.677424,14.29032,9.2903204,16,9.2903204C17.7096,9.2903204,19.096802,10.677424,19.096802,12.387104C19.096802,14.096769,17.7096,15.483871,16,15.483871C16,15.483871,16,15.483871,16,15.483871ZM16,0C7.1612964,0,0,7.1612964,0,16C0,24.838722,7.1612964,32,16,32C24.838722,32,32,24.838722,32,16C32,7.1612964,24.838722,0,16,0C16,0,16,0,16,0ZM16,28.903204C12.793552,28.903204,9.8645124,27.722561,7.6064487,25.78064C8.5677443,24.296803,10.212896,23.290403,12.096769,23.232321C13.438704,23.645123,14.716129,23.851683,16,23.851683C17.28384,23.851683,18.561281,23.65168,19.903202,23.232321C21.787041,23.296803,23.43232,24.296803,24.3936,25.78064C22.135521,27.722561,19.206402,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204ZM26.496801,23.47744C24.922562,21.451681,22.490402,20.128962,19.716162,20.128962C19.058081,20.128962,18.038723,20.748322,16,20.748322C13.967746,20.748322,12.941936,20.128962,12.283874,20.128962C9.5161285,20.128962,7.0838728,21.451681,5.5032325,23.47744C3.9935522,21.367682,3.0967681,18.787043,3.0967681,16C3.0967681,8.883873,8.883873,3.0967681,16,3.0967681C23.116163,3.0967681,28.903204,8.883873,28.903204,16C28.903204,18.787043,28.006401,21.367682,26.496801,23.47744C26.496801,23.47744,26.496801,23.47744,26.496801,23.47744Z" fill="#D15DFF" fill-opacity="1"/></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="32" height="32" viewBox="0 0 32 32"><g><path d="M16,6.193552C12.580641,6.193552,9.8064489,8.9677448,9.8064489,12.387104C9.8064489,15.806449,12.580641,18.580641,16,18.580641C19.419361,18.580641,22.193602,15.806449,22.193602,12.387104C22.193602,8.9677448,19.419361,6.193552,16,6.193552C16,6.193552,16,6.193552,16,6.193552ZM16,15.483871C14.29032,15.483871,12.903233,14.096769,12.903233,12.387104C12.903233,10.677424,14.29032,9.2903204,16,9.2903204C17.7096,9.2903204,19.096802,10.677424,19.096802,12.387104C19.096802,14.096769,17.7096,15.483871,16,15.483871C16,15.483871,16,15.483871,16,15.483871ZM16,0C7.1612964,0,0,7.1612964,0,16C0,24.838722,7.1612964,32,16,32C24.838722,32,32,24.838722,32,16C32,7.1612964,24.838722,0,16,0C16,0,16,0,16,0ZM16,28.903204C12.793552,28.903204,9.8645124,27.722561,7.6064487,25.78064C8.5677443,24.296803,10.212896,23.290403,12.096769,23.232321C13.438704,23.645123,14.716129,23.851683,16,23.851683C17.28384,23.851683,18.561281,23.65168,19.903202,23.232321C21.787041,23.296803,23.43232,24.296803,24.3936,25.78064C22.135521,27.722561,19.206402,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204ZM26.496801,23.47744C24.922562,21.451681,22.490402,20.128962,19.716162,20.128962C19.058081,20.128962,18.038723,20.748322,16,20.748322C13.967746,20.748322,12.941936,20.128962,12.283874,20.128962C9.5161285,20.128962,7.0838728,21.451681,5.5032325,23.47744C3.9935522,21.367682,3.0967681,18.787043,3.0967681,16C3.0967681,8.883873,8.883873,3.0967681,16,3.0967681C23.116163,3.0967681,28.903204,8.883873,28.903204,16C28.903204,18.787043,28.006401,21.367682,26.496801,23.47744C26.496801,23.47744,26.496801,23.47744,26.496801,23.47744Z" fill="#D15DFF" fill-opacity="1"/></g></svg>
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="32" height="32" viewBox="0 0 32 32"><g><path d="M16,6.193552C12.580641,6.193552,9.8064489,8.9677448,9.8064489,12.387104C9.8064489,15.806449,12.580641,18.580641,16,18.580641C19.419361,18.580641,22.193602,15.806449,22.193602,12.387104C22.193602,8.9677448,19.419361,6.193552,16,6.193552C16,6.193552,16,6.193552,16,6.193552ZM16,15.483871C14.29032,15.483871,12.903233,14.096769,12.903233,12.387104C12.903233,10.677424,14.29032,9.2903204,16,9.2903204C17.7096,9.2903204,19.096802,10.677424,19.096802,12.387104C19.096802,14.096769,17.7096,15.483871,16,15.483871C16,15.483871,16,15.483871,16,15.483871ZM16,0C7.1612964,0,0,7.1612964,0,16C0,24.838722,7.1612964,32,16,32C24.838722,32,32,24.838722,32,16C32,7.1612964,24.838722,0,16,0C16,0,16,0,16,0ZM16,28.903204C12.793552,28.903204,9.8645124,27.722561,7.6064487,25.78064C8.5677443,24.296803,10.212896,23.290403,12.096769,23.232321C13.438704,23.645123,14.716129,23.851683,16,23.851683C17.28384,23.851683,18.561281,23.65168,19.903202,23.232321C21.787041,23.296803,23.43232,24.296803,24.3936,25.78064C22.135521,27.722561,19.206402,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204ZM26.496801,23.47744C24.922562,21.451681,22.490402,20.128962,19.716162,20.128962C19.058081,20.128962,18.038723,20.748322,16,20.748322C13.967746,20.748322,12.941936,20.128962,12.283874,20.128962C9.5161285,20.128962,7.0838728,21.451681,5.5032325,23.47744C3.9935522,21.367682,3.0967681,18.787043,3.0967681,16C3.0967681,8.883873,8.883873,3.0967681,16,3.0967681C23.116163,3.0967681,28.903204,8.883873,28.903204,16C28.903204,18.787043,28.006401,21.367682,26.496801,23.47744C26.496801,23.47744,26.496801,23.47744,26.496801,23.47744Z" fill="#0057FE" fill-opacity="1"/></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="32" height="32" viewBox="0 0 32 32"><g><path d="M16,6.193552C12.580641,6.193552,9.8064489,8.9677448,9.8064489,12.387104C9.8064489,15.806449,12.580641,18.580641,16,18.580641C19.419361,18.580641,22.193602,15.806449,22.193602,12.387104C22.193602,8.9677448,19.419361,6.193552,16,6.193552C16,6.193552,16,6.193552,16,6.193552ZM16,15.483871C14.29032,15.483871,12.903233,14.096769,12.903233,12.387104C12.903233,10.677424,14.29032,9.2903204,16,9.2903204C17.7096,9.2903204,19.096802,10.677424,19.096802,12.387104C19.096802,14.096769,17.7096,15.483871,16,15.483871C16,15.483871,16,15.483871,16,15.483871ZM16,0C7.1612964,0,0,7.1612964,0,16C0,24.838722,7.1612964,32,16,32C24.838722,32,32,24.838722,32,16C32,7.1612964,24.838722,0,16,0C16,0,16,0,16,0ZM16,28.903204C12.793552,28.903204,9.8645124,27.722561,7.6064487,25.78064C8.5677443,24.296803,10.212896,23.290403,12.096769,23.232321C13.438704,23.645123,14.716129,23.851683,16,23.851683C17.28384,23.851683,18.561281,23.65168,19.903202,23.232321C21.787041,23.296803,23.43232,24.296803,24.3936,25.78064C22.135521,27.722561,19.206402,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204C16,28.903204,16,28.903204,16,28.903204ZM26.496801,23.47744C24.922562,21.451681,22.490402,20.128962,19.716162,20.128962C19.058081,20.128962,18.038723,20.748322,16,20.748322C13.967746,20.748322,12.941936,20.128962,12.283874,20.128962C9.5161285,20.128962,7.0838728,21.451681,5.5032325,23.47744C3.9935522,21.367682,3.0967681,18.787043,3.0967681,16C3.0967681,8.883873,8.883873,3.0967681,16,3.0967681C23.116163,3.0967681,28.903204,8.883873,28.903204,16C28.903204,18.787043,28.006401,21.367682,26.496801,23.47744C26.496801,23.47744,26.496801,23.47744,26.496801,23.47744Z" fill="#0057FE" fill-opacity="1"/></g></svg>
@@ -1,3 +1,3 @@
1
- import HFormGroup from './HFormGroup.vue'
2
-
3
- export default HFormGroup
1
+ import HFormGroup from './HFormGroup.vue'
2
+
3
+ export default HFormGroup
@@ -106,7 +106,10 @@ export default {
106
106
  previewVisible: false,
107
107
  previewImage: '',
108
108
  previewImageName: '',
109
- showScanner: false
109
+ showScanner: false,
110
+ uploadQueue: [],
111
+ isUploading: false,
112
+ uploadControllers: new Map()
110
113
  }
111
114
  },
112
115
  props: {
@@ -159,10 +162,10 @@ export default {
159
162
  }
160
163
  },
161
164
  computed: {
162
- ...mapState('account', { currUser: 'user' }),
165
+ ...mapState('account', {currUser: 'user'}),
163
166
  ...mapState('setting', ['compatible'])
164
167
  },
165
- created () {
168
+ created() {
166
169
  const list = this.model.type === 'file' ? [...this.files] : [...this.images]
167
170
  if (this.model.useType) {
168
171
  // {uid,url,name,f_use_type?,f_form_type?}
@@ -180,7 +183,7 @@ export default {
180
183
  }
181
184
  },
182
185
  methods: {
183
- async handlePreview (file) {
186
+ async handlePreview(file) {
184
187
  if (this.isImageFile(file)) {
185
188
  // 图片文件:预览
186
189
  this.previewImage = file.url
@@ -192,7 +195,7 @@ export default {
192
195
  }
193
196
  },
194
197
 
195
- async handleDownload (file) {
198
+ async handleDownload(file) {
196
199
  const link = document.createElement('a')
197
200
  link.href = file.url
198
201
  link.download = file.name || 'download'
@@ -202,13 +205,13 @@ export default {
202
205
  document.body.removeChild(link)
203
206
  },
204
207
 
205
- isImageFile (file) {
208
+ isImageFile(file) {
206
209
  const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
207
210
  const fileName = file.name ? file.name.toLowerCase() : ''
208
211
  return imageExtensions.some(ext => fileName.endsWith(ext))
209
212
  },
210
213
 
211
- confirmPhoto (img) {
214
+ confirmPhoto(img) {
212
215
  const fileName = `GaoPaiYi_${moment().format('YYYYMMDDHHmmss')}.png`
213
216
  const file = base64ToFile(img, fileName)
214
217
  file.uid = fileName
@@ -218,21 +221,50 @@ export default {
218
221
  this.uploadFiles(info)
219
222
  },
220
223
 
221
- useScannerUpload (e) {
224
+ useScannerUpload(e) {
222
225
  // 打开高拍仪
223
226
  this.showScanner = true
224
227
  },
225
228
 
226
- handleCancelScanner () {
229
+ handleCancelScanner() {
227
230
  // 关闭高拍仪弹窗
228
231
  this.showScanner = false
229
232
  },
233
+ uploadFiles(info) {
234
+ // 添加到上传队列
235
+ this.uploadQueue.push(info)
236
+ // 如果当前没有上传任务,开始处理队列
237
+ if (!this.isUploading) {
238
+ this.processUploadQueue()
239
+ }
240
+ },
241
+
242
+ // 处理上传队列
243
+ async processUploadQueue() {
244
+ if (this.uploadQueue.length === 0) {
245
+ this.isUploading = false
246
+ return
247
+ }
248
+ this.isUploading = true
249
+ // 从队列中取出第一个任务
250
+ const info = this.uploadQueue.shift()
251
+ await this.singleFileUpload(info)
252
+ // 继续处理队列中的下一个任务
253
+ this.processUploadQueue()
254
+ },
230
255
 
231
- uploadFiles (info) {
256
+ // 单个文件上传
257
+ async singleFileUpload(info) {
258
+ // 检查文件数量限制
232
259
  if (this.uploadedFileList.length >= this.model.acceptCount) {
233
260
  this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
234
261
  return
235
262
  }
263
+
264
+ // 创建取消控制器
265
+ const controller = new AbortController()
266
+ this.uploadControllers.set(info.file.uid, controller)
267
+
236
268
  // 初始化文件信息
237
269
  const fileInfo = {
238
270
  uid: info.file.uid,
@@ -241,66 +273,118 @@ export default {
241
273
  response: '',
242
274
  url: '',
243
275
  }
244
- // 放入上传列表中,以便于显示上传进度
245
- this.uploadedFileList.push(fileInfo)
246
- // 组装上传数据
247
- const headers = {
248
- 'Content-Type': 'multipart/form-data',
249
- }
250
- const formData = new FormData()
251
- formData.append('avatar', info.file)
252
- formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
253
- if (this.model.pathKey) {
254
- formData.append('pathKey', this.model.pathKey ?? 'Default')
255
- }
256
- // formData.append('stockAlias', this.model.stockAlias)
257
- formData.append('formType', this.model.type)
258
- formData.append('useType', this.model.useType ?? 'Default')
259
- formData.append('resUploadStock', this.model.resUploadStock ?? 1)
260
- formData.append('filename', info.file.name)
261
- formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
262
- formData.append('f_operator', this.currUser ? this.currUser.username : '')
263
276
 
264
- upload(formData, this.serviceName, { headers, timeout: 600 * 1000 }).then(res => {
265
- // 根据服务端返回的结果判断成功与否,设置文件条目的状态
277
+ // 使用不可变更新,避免状态冲突
278
+ this.uploadedFileList = [...this.uploadedFileList, fileInfo]
279
+
280
+ try {
281
+ // 组装上传数据
282
+ const headers = {
283
+ 'Content-Type': 'multipart/form-data',
284
+ }
285
+ const formData = new FormData()
286
+ formData.append('avatar', info.file)
287
+ formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
288
+ if (this.model.pathKey) {
289
+ formData.append('pathKey', this.model.pathKey ?? 'Default')
290
+ }
291
+ formData.append('formType', this.model.type)
292
+ formData.append('useType', this.model.useType ?? 'Default')
293
+ formData.append('resUploadStock', this.model.resUploadStock ?? 1)
294
+ formData.append('filename', info.file.name)
295
+ formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
296
+ formData.append('f_operator', this.currUser ? this.currUser.username : '')
297
+
298
+ const res = await upload(formData, this.serviceName, {
299
+ headers,
300
+ timeout: 600 * 1000,
301
+ signal: controller.signal // 添加取消信号
302
+ })
303
+
304
+ // 根据服务端返回的结果判断成功与否
266
305
  if (res.success || res.id) {
267
- fileInfo.status = 'done'
268
- let dataObj
269
- if (res.id) {
270
- dataObj = res
271
- } else if (typeof res.data === 'string') {
272
- dataObj = JSON.parse(res.data)
273
- } else {
274
- dataObj = res.data
275
- }
276
- fileInfo.response = dataObj
277
- fileInfo.id = dataObj.id
278
- // 如果新上传的图片是V4,需要携带serviceName前缀,但是同时也要回显老系统图片
279
- if (this.imgPrefix) {
280
- fileInfo.url = this.imgPrefix + dataObj.f_downloadpath
281
- } else {
282
- fileInfo.url = dataObj.f_downloadpath
283
- }
284
- if (this.outerContainerIndex !== undefined) {
285
- this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done'), this.outerContainerIndex)
286
- } else {
287
- this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
288
- this.$emit('setFilesAllInfo', this.uploadedFileList.filter(item => item.status === 'done').map(item => item))
289
- }
306
+ this.updateFileStatus(info.file.uid, 'done', res)
290
307
  this.$message.success('上传成功!')
291
308
  } else {
292
- fileInfo.status = 'error'
293
- fileInfo.response = res.data
309
+ this.updateFileStatus(info.file.uid, 'error', res.data)
310
+ this.$message.error('上传失败!')
311
+ }
312
+ } catch (error) {
313
+ if (error.name !== 'AbortError') {
314
+ // 非取消错误才显示错误信息
315
+ this.updateFileStatus(info.file.uid, 'error', error)
294
316
  this.$message.error('上传失败!')
295
317
  }
296
- }).catch((e) => {
297
- fileInfo.status = 'error'
298
- fileInfo.response = e
318
+ } finally {
319
+ // 清理取消控制器
320
+ this.uploadControllers.delete(info.file.uid)
321
+ }
322
+ },
323
+
324
+ // 更新文件状态
325
+ updateFileStatus(uid, status, response) {
326
+ this.uploadedFileList = this.uploadedFileList.map(item => {
327
+ if (item.uid === uid) {
328
+ const updatedItem = {
329
+ ...item,
330
+ status,
331
+ response
332
+ }
333
+
334
+ if (status === 'done') {
335
+ let dataObj
336
+ if (response.id) {
337
+ dataObj = response
338
+ } else if (typeof response.data === 'string') {
339
+ dataObj = JSON.parse(response.data)
340
+ } else {
341
+ dataObj = response.data
342
+ }
343
+
344
+ updatedItem.response = dataObj
345
+ updatedItem.id = dataObj.id
346
+ // 如果新上传的图片是V4,需要携带serviceName前缀
347
+ if (this.imgPrefix) {
348
+ updatedItem.url = this.imgPrefix + dataObj.f_downloadpath
349
+ } else {
350
+ updatedItem.url = dataObj.f_downloadpath
351
+ }
352
+ }
353
+
354
+ return updatedItem
355
+ }
356
+ return item
299
357
  })
358
+
359
+ this.emitFilesUpdate()
360
+ },
361
+
362
+ // 触发文件更新事件
363
+ emitFilesUpdate() {
364
+ const doneFiles = this.uploadedFileList.filter(item => item.status === 'done')
365
+
366
+ if (this.outerContainerIndex !== undefined) {
367
+ this.$emit('setFiles', doneFiles, this.outerContainerIndex)
368
+ } else {
369
+ this.$emit('setFiles', doneFiles.map(item => item.id))
370
+ this.$emit('setFilesAllInfo', doneFiles)
371
+ }
372
+ },
373
+
374
+ // 取消上传(可选功能)
375
+ cancelUpload(uid) {
376
+ const controller = this.uploadControllers.get(uid)
377
+ if (controller) {
378
+ controller.abort()
379
+
380
+ // 从上传列表中移除
381
+ this.uploadedFileList = this.uploadedFileList.filter(item => item.uid !== uid)
382
+ this.emitFilesUpdate()
383
+ }
300
384
  },
301
385
 
302
386
  // 删除文件
303
- deleteFileItem (file) {
387
+ deleteFileItem(file) {
304
388
  const that = this
305
389
  this.$confirm({
306
390
  title: '提醒',
@@ -309,35 +393,38 @@ export default {
309
393
  okType: 'danger',
310
394
  cancelText: '取消',
311
395
  zIndex: 2000,
312
- onOk () {
396
+ onOk() {
397
+ // 如果文件正在上传,先取消上传
398
+ if (file.status === 'uploading') {
399
+ that.cancelUpload(file.uid)
400
+ }
401
+
313
402
  // 阳春博能工单信息V4页面有时会删除V3照片, V3照片不能通过这个请求删除, 已经在外层进行删除处理
314
403
  if (file.id && !file.version) {
315
404
  switch (that.compatible) {
316
405
  case 'V3':
317
- fileDelete({ id: file.id, f_state: '删除' })
406
+ fileDelete({id: file.id, f_state: '删除'})
318
407
  .then(res => {
319
408
  }).catch(e => {
320
409
  })
321
410
  break
322
411
  case 'V4':
323
- fileDeleteV4({ id: file.id, resDeleteMode: 'server' })
412
+ fileDeleteV4({id: file.id, resDeleteMode: 'server'})
324
413
  .then(res => {
325
414
  }).catch(e => {
326
415
  })
327
416
  break
328
417
  }
329
418
  }
330
- // 找到当前文件所在列表的索引
331
- const index = that.uploadedFileList.indexOf(file)
332
419
  // 从列表中移除该文件
333
- that.uploadedFileList.splice(index, 1)
420
+ that.uploadedFileList = that.uploadedFileList.filter(item => item.uid !== file.uid)
334
421
  if (that.outerContainerIndex !== undefined) {
335
422
  that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done'), that.outerContainerIndex)
336
423
  } else {
337
424
  that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
338
425
  }
339
426
  },
340
- onCancel () {
427
+ onCancel() {
341
428
  console.log('取消删除')
342
429
  },
343
430
  })