n20-common-lib 2.22.65 → 2.22.68

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,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "2.22.65",
3
+ "version": "2.22.68",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -9,7 +9,7 @@
9
9
  "test:unit": "vue-cli-service test:unit",
10
10
  "lint": "vue-cli-service lint",
11
11
  "build:Jenkins_1": "vue-cli-service build --serverConfig ./server-config-jenkins.jsonc",
12
- "build:css": "node build_css",
12
+ "build:css": "node build_css.js",
13
13
  "build:dev": "vue-cli-service build",
14
14
  "build:doc": "node versionInfo.js && vue-cli-service build --testTheme",
15
15
  "build:gzip": "vue-cli-service build --gzip",
@@ -57,23 +57,26 @@
57
57
  <slot slot="header" slot-scope="scope" name="type-header" :column="scope.column">{{ '附件类型' | $lc }}</slot>
58
58
  <slot slot-scope="{ row }" name="type" :row="row">
59
59
  <span v-if="readonly">{{ row[keys.type] | typeFiter(typeOptions) }}</span>
60
- <div v-else class="flex-box flex-v">
60
+ <div v-else class="flex-box flex-v file-upload-table__type-cell">
61
61
  <span v-if="requiredTypes.includes(row[keys.type])" style="color: red" class="m-r-s">*</span>
62
- <el-select
63
- v-model="row[keys.type]"
64
- :disabled="row._typeDisabled || row._typeUpdating"
65
- :placeholder="'请选择' | $lc"
66
- style="width: calc(100% - 16px)"
67
- @change="handleTypeChange(row)"
68
- >
69
- <el-option
70
- v-for="item in typeOptions"
71
- :key="item.type"
72
- :disabled="item.disabled"
73
- :value="item.type"
74
- :label="item.label"
75
- />
76
- </el-select>
62
+ <div class="file-upload-table__type-content">
63
+ <el-select
64
+ v-model="row[keys.type]"
65
+ :class="{ 'file-upload-table__type-error': row._typeError }"
66
+ :disabled="row._typeDisabled || row._typeUpdating"
67
+ :placeholder="'请选择' | $lc"
68
+ style="width: 100%"
69
+ @change="handleTypeChange(row)"
70
+ >
71
+ <el-option
72
+ v-for="item in typeOptions"
73
+ :key="item.type"
74
+ :disabled="item.disabled"
75
+ :value="item.type"
76
+ :label="item.label"
77
+ />
78
+ </el-select>
79
+ </div>
77
80
  </div>
78
81
  </slot>
79
82
  </el-table-column>
@@ -86,10 +89,11 @@
86
89
  v-title
87
90
  :value="row[keys.name] ? row[keys.name].replace(/\.[A-z0-9]+$/, '') : ''"
88
91
  disabled
89
- :placeholder="'请输入' | $lc"
92
+ :placeholder="'上传后自动带出' | $lc"
90
93
  />
91
94
  </slot>
92
95
  </el-table-column>
96
+ <slot name="type-after"></slot>
93
97
  <el-table-column v-if="readonly" :label="'附件上传' | $lc" :prop="keys.name">
94
98
  <slot slot="header" slot-scope="scope" name="upload-header" :column="scope.column"
95
99
  >{{ '附件上传' | $lc }}
@@ -113,7 +117,7 @@
113
117
  :action="apiPrefix ? apiPrefix + action : action"
114
118
  :multiple="multiple"
115
119
  :headers="headers"
116
- :disabled="!row[keys.type] || row._typeDisabled || row._uploadDisabled"
120
+ :disabled="row._typeDisabled || row._uploadDisabled"
117
121
  :accept="row[keys.type] | acceptFilter(typeOptions, fileAccept)"
118
122
  :size="row[keys.type] | sizeFilter(typeOptions, fileSize)"
119
123
  :http-request="uploadHttpRequest ? (options) => uploadHttpRequest(options, row) : undefined"
@@ -126,6 +130,7 @@
126
130
  : onSuccessFn(response, file, fileList, row)
127
131
  "
128
132
  :on-error="(err, file, fileList) => errorFn(err, file, fileList, row, $index)"
133
+ @click.native.capture="handleUploadClick($event, row)"
129
134
  />
130
135
  </slot>
131
136
  </el-table-column>
@@ -561,12 +566,19 @@ export default {
561
566
  return false
562
567
  }
563
568
  this.setTableData()
569
+ this.setSingleTypeForEmptyRows()
564
570
  },
565
571
  immediate: true,
566
572
  deep: true
567
573
  },
568
574
  tableKey() {
569
575
  this.initSortable()
576
+ },
577
+ tableData: {
578
+ handler() {
579
+ this.setSingleTypeForEmptyRows()
580
+ },
581
+ immediate: true
570
582
  }
571
583
  },
572
584
  mounted() {
@@ -844,11 +856,17 @@ export default {
844
856
 
845
857
  let requestData = JSON.parse(this.fileData?.data || '{}')
846
858
  requestData.bussId = requestData.bussId ?? this.fileData?.bussId ?? ''
847
- requestData.bussValues = this.typeOptions.map((item) => item.type)
859
+ // bussValues 应为业务编码列表(与 updateFlieBuss/getByBussValues 契约一致),而非附件类型编号(attno)
860
+ let bussValues = [...new Set(this.typeOptions.map((item) => item.bussValue).filter(Boolean))]
861
+ requestData.bussValues = bussValues.length ? bussValues : [requestData.bussValue].filter(Boolean)
862
+ if (!requestData.bussValues.length) {
863
+ this.$message.warning($lc('附件类型业务编码缺失,无法自动识别上传,请检查附件类型配置'))
864
+ return
865
+ }
848
866
  FD.append('data', JSON.stringify(requestData))
849
867
 
850
868
  this.batchUploading = true
851
- let { data } = await axios.post(
869
+ let res = await axios.post(
852
870
  this.apiPrefix
853
871
  ? `${this.apiPrefix}/neams/eamsbaserecord/batchSaveFile`
854
872
  : '/neams/eamsbaserecord/batchSaveFile',
@@ -861,7 +879,14 @@ export default {
861
879
  }
862
880
  )
863
881
 
864
- let responseList = Array.isArray(data) ? data : []
882
+ // axios 封装会把 code:0 短路成 200 误判成功(utils/axios.js 拦截器 falsy 缺陷),此处必须二次校验
883
+ if (!res || Number(res.code) !== 200 || !Array.isArray(res.data)) {
884
+ throw { msg: (res && res.msg) || $lc('批量上传失败') }
885
+ }
886
+ let responseList = res.data
887
+ if (responseList.length < files.length) {
888
+ this.$message.warning($lc('部分文件上传失败,请检查附件列表'))
889
+ }
865
890
  let rows = responseList.map((item) => this.buildAutoMatchBatchRow(item))
866
891
  rows.forEach((row) => {
867
892
  let type = row[this.keys.type]
@@ -879,7 +904,8 @@ export default {
879
904
  let pendingFiles = [...files]
880
905
  rows.forEach((row) => {
881
906
  let fileIndex = pendingFiles.findIndex((item) => item.raw.name === row[this.keys.name])
882
- let sourceFile = pendingFiles.splice(fileIndex > -1 ? fileIndex : 0, 1)[0]
907
+ if (fileIndex === -1) return // 匹配不到不消费文件,避免错配
908
+ let sourceFile = pendingFiles.splice(fileIndex, 1)[0]
883
909
  this.$emit('on-success', sourceFile?.raw, row)
884
910
  })
885
911
 
@@ -917,6 +943,9 @@ export default {
917
943
  },
918
944
  handleTypeChange(row) {
919
945
  let type = row[this.keys.type]
946
+ if (type) {
947
+ this.$set(row, '_typeError', false)
948
+ }
920
949
  this.$emit('typeChange', type)
921
950
  if (!row._shouldUpdateFileType || !type) {
922
951
  return
@@ -1022,6 +1051,32 @@ export default {
1022
1051
  addRow() {
1023
1052
  this.$emit('add-row')
1024
1053
  },
1054
+ setSingleTypeForEmptyRows() {
1055
+ if (this.readonly || this.typeOptions.length !== 1) {
1056
+ return
1057
+ }
1058
+
1059
+ let type = this.typeOptions[0].type
1060
+ this.tableData.forEach((row) => {
1061
+ let isEmptyRow = !row[this.keys.url] && !row[this.keys.name] && !row._name
1062
+ if (isEmptyRow && !row[this.keys.type]) {
1063
+ // 新增行可能由业务侧异步写入,通过监听数据确保唯一附件类型仍能自动带出。
1064
+ this.$set(row, this.keys.type, type)
1065
+ this.$set(row, '_typeError', false)
1066
+ }
1067
+ })
1068
+ },
1069
+ handleUploadClick(event, row) {
1070
+ if (row[this.keys.type]) {
1071
+ return
1072
+ }
1073
+
1074
+ // 文件选择窗口打开前完成类型校验,避免用户选完文件后才收到错误提示。
1075
+ event.preventDefault()
1076
+ event.stopPropagation()
1077
+ this.$set(row, '_typeError', true)
1078
+ this.$message.warning($lc('请先选择附件类型'))
1079
+ },
1025
1080
  downRows() {
1026
1081
  if (!this.selectionList.length) {
1027
1082
  return this.$message({
@@ -1304,4 +1359,16 @@ export default {
1304
1359
  color: #fff !important;
1305
1360
  background: #42b983 !important;
1306
1361
  }
1362
+
1363
+ .file-upload-table__type-cell {
1364
+ align-items: flex-start;
1365
+ }
1366
+
1367
+ .file-upload-table__type-content {
1368
+ width: calc(100% - 16px);
1369
+ }
1370
+
1371
+ .file-upload-table__type-error .el-input__inner {
1372
+ border-color: var(--color-danger);
1373
+ }
1307
1374
  </style>
package/src/i18n.json CHANGED
@@ -9364,5 +9364,17 @@
9364
9364
  "th": "กลับไปยังขั้นตอนก่อนหน้า",
9365
9365
  "vi": "Quay lại bước trước",
9366
9366
  "ja": "前のステップに戻る"
9367
+ },
9368
+ "请先选择附件类型": {
9369
+ "en": "Please select an attachment type",
9370
+ "th": "โปรดเลือกประเภทไฟล์แนบ",
9371
+ "vi": "Vui lòng chọn loại tệp đính kèm",
9372
+ "ja": "添付ファイルの種類を選択してください"
9373
+ },
9374
+ "上传后自动带出": {
9375
+ "en": "Automatically filled after upload",
9376
+ "th": "กรอกโดยอัตโนมัติหลังอัปโหลด",
9377
+ "vi": "Tự động điền sau khi tải lên",
9378
+ "ja": "アップロード後に自動入力されます"
9367
9379
  }
9368
9380
  }