n20-common-lib 3.2.40 → 3.2.42

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,9 +1,9 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "3.2.40",
3
+ "version": "3.2.42",
4
4
  "private": false,
5
5
  "scripts": {
6
- "serve": "vue-cli-service serve",
6
+ "serve": "pnpm --dir ../packages/docs run serve",
7
7
  "prepublishOnly": "npm run build:css",
8
8
  "build": "node versionInfo.js && npm run build:css && vue-cli-service build --testTheme",
9
9
  "test:unit": "vue-cli-service test:unit",
@@ -22,6 +22,8 @@
22
22
  </template>
23
23
 
24
24
  <script>
25
+ import { $lc } from '../../utils/i18n/index'
26
+
25
27
  const LONG_TERM_DATE = new Date(9999, 11, 31, 23, 59, 59)
26
28
 
27
29
  export default {
@@ -45,7 +47,7 @@ export default {
45
47
  },
46
48
  longTermLabel: {
47
49
  type: String,
48
- default: $lc("长期")
50
+ default: $lc('长期')
49
51
  }
50
52
  },
51
53
  computed: {
@@ -268,7 +268,13 @@
268
268
  :close-on-click-modal="false"
269
269
  :destroy-on-open="true"
270
270
  >
271
- <el-select v-model="bathType" class="m-b-s w-100p" clearable @change="handleBathChange">
271
+ <el-select
272
+ v-if="!autoMatchBatchFileType"
273
+ v-model="bathType"
274
+ class="m-b-s w-100p"
275
+ clearable
276
+ @change="handleBathChange"
277
+ >
272
278
  <el-option
273
279
  v-for="item in typeOptions"
274
280
  :key="item.type"
@@ -278,7 +284,7 @@
278
284
  />
279
285
  </el-select>
280
286
  <Upload
281
- v-if="bathType"
287
+ v-if="autoMatchBatchFileType || bathType"
282
288
  ref="upload-batch"
283
289
  class="n20-upload-drag"
284
290
  :msg-type="null"
@@ -305,7 +311,7 @@
305
311
  </template>
306
312
  </Upload>
307
313
  <div class="dialog-footer">
308
- <el-button type="primary" @click="batchUploadFn">{{ '确认' | $lc }}</el-button>
314
+ <el-button type="primary" :loading="batchUploading" @click="batchUploadFn">{{ '确认' | $lc }}</el-button>
309
315
  <el-button plain @click="visibleBatch = false">{{ '取消' | $lc }}</el-button>
310
316
  </div>
311
317
  </Dialog>
@@ -434,6 +440,10 @@ export default {
434
440
  type: Boolean,
435
441
  default: false
436
442
  },
443
+ autoMatchBatchFileType: {
444
+ type: Boolean,
445
+ default: false
446
+ },
437
447
  showBatchPrint: {
438
448
  type: Boolean,
439
449
  default: false
@@ -498,6 +508,7 @@ export default {
498
508
  previewSameOrg: false,
499
509
  seeRow: {},
500
510
  officeStatus: false,
511
+ batchUploading: false,
501
512
  // 批量上传使用的文件数据(避免直接修改计算属性)
502
513
  _batchFileData: null
503
514
  }
@@ -752,11 +763,91 @@ export default {
752
763
  data: JSON.stringify(dto)
753
764
  }
754
765
  },
755
- batchUploadFn() {
766
+ async batchUploadFn() {
767
+ if (this.autoMatchBatchFileType) {
768
+ await this.autoMatchBatchUpload()
769
+ return
770
+ }
756
771
  let $uploadwrap = this.$refs['upload-batch']
757
772
  // 直接提交上传,关闭对话框的逻辑在 batchSuccess 回调中处理
758
773
  $uploadwrap.submit()
759
774
  },
775
+ async autoMatchBatchUpload() {
776
+ let $uploadwrap = this.$refs['upload-batch']
777
+ let uploadFiles = $uploadwrap?.$refs?.upload?.uploadFiles || []
778
+ let files = uploadFiles.filter((item) => item.status === 'ready' && item.raw)
779
+ if (!files.length) {
780
+ this.$message.warning($lc('请先选择上传文件'))
781
+ return
782
+ }
783
+
784
+ try {
785
+ for (let item of files) {
786
+ let result = await $uploadwrap.beforeUploadFn(item.raw)
787
+ if (result === false) {
788
+ return
789
+ }
790
+ }
791
+
792
+ let FD = new FormData()
793
+ files.forEach((item) => {
794
+ FD.append('file', item.raw)
795
+ })
796
+
797
+ let remoteFileUpload = JSON.parse(this.fileData?.data || '{}')
798
+ remoteFileUpload.bussValues = this.typeOptions.map((item) => item.type)
799
+ FD.append('remoteFileUpload', JSON.stringify(remoteFileUpload))
800
+
801
+ this.batchUploading = true
802
+ let { data } = await axios.post(
803
+ this.apiPrefix
804
+ ? `${this.apiPrefix}/neams/eamsbaserecord/batchSaveFile`
805
+ : '/neams/eamsbaserecord/batchSaveFile',
806
+ FD,
807
+ {
808
+ headers: Object.assign(auth.setHeaders(this.headers), { 'Content-Type': 'multipart/form-data' }),
809
+ loading: false,
810
+ noMsg: true,
811
+ timeout: 900000
812
+ }
813
+ )
814
+
815
+ let responseList = Array.isArray(data) ? data : []
816
+ let rows = responseList.map((item) => this.buildAutoMatchBatchRow(item))
817
+ this.tableData.splice(0, 0, ...rows)
818
+ let pendingFiles = [...files]
819
+ rows.forEach((row) => {
820
+ let fileIndex = pendingFiles.findIndex((item) => item.raw.name === row[this.keys.name])
821
+ let sourceFile = pendingFiles.splice(fileIndex > -1 ? fileIndex : 0, 1)[0]
822
+ this.$emit('on-success', sourceFile?.raw, row)
823
+ })
824
+
825
+ $uploadwrap.clearFiles()
826
+ $uploadwrap.fileList = []
827
+ this.visibleBatch = false
828
+ } catch (err) {
829
+ this.$message.error(err?.msg || $lc('上传失败'))
830
+ } finally {
831
+ this.batchUploading = false
832
+ }
833
+ },
834
+ buildAutoMatchBatchRow(item) {
835
+ let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
836
+ let row = {
837
+ ...item,
838
+ _name: item.fileName,
839
+ _percent: 100,
840
+ _status: 'success',
841
+ _typeDisabled: false
842
+ }
843
+ row[this.keys.rowKey] = item.beid
844
+ row[this.keys.type] = item.attno
845
+ row[this.keys.name] = item.fileName
846
+ row[this.keys.url] = this.keys.url === this.keys.rowKey ? item.beid : item.filePath || item.beid
847
+ row[this.keys.time] = row[this.keys.time] || dayjs().format('YYYY-MM-DD HH:mm:ss')
848
+ row[this.keys.user] = row[this.keys.user] || userInfo.uname
849
+ return row
850
+ },
760
851
  batchSuccess(response, file, fileList) {
761
852
  // 创建完整的行对象,初始化状态字段
762
853
  let row = {
package/src/utils/auth.js CHANGED
@@ -52,7 +52,7 @@ const auth = {
52
52
  }
53
53
  },
54
54
  setReqLang() {
55
- let langMap = { 'zh-cn': 'zh_CN', en: 'en_US', 'zh-hk': 'zh_TW', th: 'th_TH', vi: 'vi_VI' }
55
+ let langMap = { 'zh-cn': 'zh_CN', en: 'en_US', 'zh-hk': 'zh_TW', th: 'th_TH', vi: 'vi_VI', ja: 'ja_JP' }
56
56
  let langKey = window.localStorage.getItem('pageLang') || 'zh-cn'
57
57
  reqLang = langMap[langKey]
58
58
  },