n20-common-lib 3.2.44 → 3.2.46

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,10 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "3.2.44",
3
+ "version": "3.2.46",
4
4
  "private": false,
5
5
  "scripts": {
6
- "serve": "pnpm --dir ../packages/docs run serve",
6
+ "serve": "vue-cli-service serve",
7
+ "serve:docs": "pnpm --dir ../packages/docs run serve",
7
8
  "prepublishOnly": "npm run build:css",
8
9
  "build": "node versionInfo.js && npm run build:css && vue-cli-service build --testTheme",
9
10
  "test:unit": "vue-cli-service test:unit",
@@ -57,10 +57,10 @@
57
57
  <span v-if="requiredTypes.includes(row[keys.type])" style="color: red" class="m-r-s">*</span>
58
58
  <el-select
59
59
  v-model="row[keys.type]"
60
- :disabled="row._typeDisabled"
60
+ :disabled="row._typeDisabled || row._typeUpdating"
61
61
  :placeholder="'请选择' | $lc"
62
62
  style="width: calc(100% - 16px)"
63
- @change="$emit('typeChange', row[keys.type])"
63
+ @change="handleTypeChange(row)"
64
64
  >
65
65
  <el-option
66
66
  v-for="item in typeOptions"
@@ -789,14 +789,16 @@ export default {
789
789
  }
790
790
  }
791
791
 
792
+ let file = files.map((item) => item.raw)
792
793
  let FD = new FormData()
793
- files.forEach((item) => {
794
- FD.append('file', item.raw)
794
+ file.forEach((item) => {
795
+ FD.append('file', item)
795
796
  })
796
797
 
797
- let remoteFileUpload = JSON.parse(this.fileData?.data || '{}')
798
- remoteFileUpload.bussValues = this.typeOptions.map((item) => item.type)
799
- FD.append('remoteFileUpload', JSON.stringify(remoteFileUpload))
798
+ let requestData = JSON.parse(this.fileData?.data || '{}')
799
+ requestData.bussId = requestData.bussId ?? this.fileData?.bussId ?? ''
800
+ requestData.bussValues = this.typeOptions.map((item) => item.type)
801
+ FD.append('data', JSON.stringify(requestData))
800
802
 
801
803
  this.batchUploading = true
802
804
  let { data } = await axios.post(
@@ -838,7 +840,12 @@ export default {
838
840
  _name: item.fileName,
839
841
  _percent: 100,
840
842
  _status: 'success',
841
- _typeDisabled: false
843
+ _typeDisabled: false,
844
+ _typeUpdating: false,
845
+ _shouldUpdateFileType: !item.attno,
846
+ _lastFileType: item.attno,
847
+ _lastFileTypeName: item.attname,
848
+ _lastBussValue: item.bussValue
842
849
  }
843
850
  row[this.keys.rowKey] = item.beid
844
851
  row[this.keys.type] = item.attno
@@ -848,6 +855,67 @@ export default {
848
855
  row[this.keys.user] = row[this.keys.user] || userInfo.uname
849
856
  return row
850
857
  },
858
+ handleTypeChange(row) {
859
+ let type = row[this.keys.type]
860
+ this.$emit('typeChange', type)
861
+ if (!row._shouldUpdateFileType || !type) {
862
+ return
863
+ }
864
+ this.updateFileBuss(row, type)
865
+ },
866
+ async updateFileBuss(row, type) {
867
+ let previousType = row._lastFileType
868
+ let previousTypeName = row._lastFileTypeName
869
+ let previousBussValue = row._lastBussValue
870
+ let typeOption = this.typeOptions.find((item) => item.type === type)
871
+ let typeName = typeOption?.attname || typeOption?.label || ''
872
+ let bussValue = typeOption?.bussValue
873
+
874
+ this.$set(row, 'attno', type)
875
+ this.$set(row, 'attname', typeName)
876
+ if (bussValue !== undefined) {
877
+ this.$set(row, 'bussValue', bussValue)
878
+ }
879
+ this.$set(row, '_typeUpdating', true)
880
+
881
+ try {
882
+ await axios.post(
883
+ this.apiPrefix
884
+ ? `${this.apiPrefix}/neams/eamsbaserecord/updateFlieBuss`
885
+ : '/neams/eamsbaserecord/updateFlieBuss',
886
+ [
887
+ {
888
+ beid: row.beid,
889
+ reid: row.reid,
890
+ appno: row.appno,
891
+ syscode: row.syscode,
892
+ bussValue: row.bussValue,
893
+ bussId: row.bussId,
894
+ bussName: row.bussName,
895
+ attno: row.attno,
896
+ attname: row.attname,
897
+ filePath: row.filePath,
898
+ fileName: row.fileName,
899
+ fmid: row.fmid
900
+ }
901
+ ],
902
+ {
903
+ noMsg: true
904
+ }
905
+ )
906
+ this.$set(row, '_lastFileType', type)
907
+ this.$set(row, '_lastFileTypeName', typeName)
908
+ this.$set(row, '_lastBussValue', row.bussValue)
909
+ } catch (err) {
910
+ this.$set(row, this.keys.type, previousType)
911
+ this.$set(row, 'attno', previousType)
912
+ this.$set(row, 'attname', previousTypeName)
913
+ this.$set(row, 'bussValue', previousBussValue)
914
+ this.$message.error(err?.msg || $lc('附件类型更新失败'))
915
+ } finally {
916
+ this.$set(row, '_typeUpdating', false)
917
+ }
918
+ },
851
919
  batchSuccess(response, file, fileList) {
852
920
  // 创建完整的行对象,初始化状态字段
853
921
  let row = {
@@ -1,6 +1,6 @@
1
1
  import axios from './axios'
2
- import { getItem, setItem } from './storageEdit'
3
2
  import { persistPermissionItems } from './permissionStorage'
3
+ import { getItem, setItem } from './storageEdit'
4
4
 
5
5
  /**
6
6
  * @description: 按需/按模块 加载权限
@@ -1,296 +1,23 @@
1
- /*
2
- * 用于 n20 权限存储压缩的专用 Worker。
3
- * 压缩算法兼容 lz-string 1.5.0。
4
- * 不包含网络、cookie、DOM 或存储访问。
5
- */
6
- ;(function () {
7
- 'use strict'
8
-
9
- var BASE64_ALPHABET =
10
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
11
-
12
- function compressToBase64(input) {
13
- if (input == null) return ''
14
-
15
- var result = compress(input, 6, function (value) {
16
- return BASE64_ALPHABET.charAt(value)
17
- })
18
-
19
- switch (result.length % 4) {
20
- case 1:
21
- return result + '==='
22
- case 2:
23
- return result + '=='
24
- case 3:
25
- return result + '='
26
- default:
27
- return result
28
- }
29
- }
30
-
31
- function compress(uncompressed, bitsPerChar, getCharFromInt) {
32
- if (uncompressed == null) return ''
33
-
34
- var index
35
- var value
36
- var bitIndex
37
- var contextDictionary = {}
38
- var contextDictionaryToCreate = {}
39
- var contextCharacter = ''
40
- var contextWordAndCharacter = ''
41
- var contextWord = ''
42
- var contextEnlargeIn = 2
43
- var contextDictionarySize = 3
44
- var contextNumberOfBits = 2
45
- var contextData = []
46
- var contextDataValue = 0
47
- var contextDataPosition = 0
48
-
49
- for (index = 0; index < uncompressed.length; index += 1) {
50
- contextCharacter = uncompressed.charAt(index)
51
-
52
- if (
53
- !Object.prototype.hasOwnProperty.call(
54
- contextDictionary,
55
- contextCharacter
56
- )
57
- ) {
58
- contextDictionary[contextCharacter] = contextDictionarySize++
59
- contextDictionaryToCreate[contextCharacter] = true
60
- }
61
-
62
- contextWordAndCharacter = contextWord + contextCharacter
63
- if (
64
- Object.prototype.hasOwnProperty.call(
65
- contextDictionary,
66
- contextWordAndCharacter
67
- )
68
- ) {
69
- contextWord = contextWordAndCharacter
70
- continue
71
- }
72
-
73
- if (
74
- Object.prototype.hasOwnProperty.call(
75
- contextDictionaryToCreate,
76
- contextWord
77
- )
78
- ) {
79
- if (contextWord.charCodeAt(0) < 256) {
80
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
81
- contextDataValue <<= 1
82
- if (contextDataPosition === bitsPerChar - 1) {
83
- contextDataPosition = 0
84
- contextData.push(getCharFromInt(contextDataValue))
85
- contextDataValue = 0
86
- } else {
87
- contextDataPosition++
88
- }
89
- }
90
-
91
- value = contextWord.charCodeAt(0)
92
- for (bitIndex = 0; bitIndex < 8; bitIndex++) {
93
- contextDataValue = (contextDataValue << 1) | (value & 1)
94
- if (contextDataPosition === bitsPerChar - 1) {
95
- contextDataPosition = 0
96
- contextData.push(getCharFromInt(contextDataValue))
97
- contextDataValue = 0
98
- } else {
99
- contextDataPosition++
100
- }
101
- value >>= 1
102
- }
103
- } else {
104
- value = 1
105
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
106
- contextDataValue = (contextDataValue << 1) | value
107
- if (contextDataPosition === bitsPerChar - 1) {
108
- contextDataPosition = 0
109
- contextData.push(getCharFromInt(contextDataValue))
110
- contextDataValue = 0
111
- } else {
112
- contextDataPosition++
113
- }
114
- value = 0
115
- }
116
-
117
- value = contextWord.charCodeAt(0)
118
- for (bitIndex = 0; bitIndex < 16; bitIndex++) {
119
- contextDataValue = (contextDataValue << 1) | (value & 1)
120
- if (contextDataPosition === bitsPerChar - 1) {
121
- contextDataPosition = 0
122
- contextData.push(getCharFromInt(contextDataValue))
123
- contextDataValue = 0
124
- } else {
125
- contextDataPosition++
126
- }
127
- value >>= 1
128
- }
129
- }
130
-
131
- contextEnlargeIn--
132
- if (contextEnlargeIn === 0) {
133
- contextEnlargeIn = Math.pow(2, contextNumberOfBits)
134
- contextNumberOfBits++
135
- }
136
- delete contextDictionaryToCreate[contextWord]
137
- } else {
138
- value = contextDictionary[contextWord]
139
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
140
- contextDataValue = (contextDataValue << 1) | (value & 1)
141
- if (contextDataPosition === bitsPerChar - 1) {
142
- contextDataPosition = 0
143
- contextData.push(getCharFromInt(contextDataValue))
144
- contextDataValue = 0
145
- } else {
146
- contextDataPosition++
147
- }
148
- value >>= 1
149
- }
150
- }
151
-
152
- contextEnlargeIn--
153
- if (contextEnlargeIn === 0) {
154
- contextEnlargeIn = Math.pow(2, contextNumberOfBits)
155
- contextNumberOfBits++
156
- }
157
-
158
- contextDictionary[contextWordAndCharacter] = contextDictionarySize++
159
- contextWord = String(contextCharacter)
160
- }
161
-
162
- if (contextWord !== '') {
163
- if (
164
- Object.prototype.hasOwnProperty.call(
165
- contextDictionaryToCreate,
166
- contextWord
167
- )
168
- ) {
169
- if (contextWord.charCodeAt(0) < 256) {
170
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
171
- contextDataValue <<= 1
172
- if (contextDataPosition === bitsPerChar - 1) {
173
- contextDataPosition = 0
174
- contextData.push(getCharFromInt(contextDataValue))
175
- contextDataValue = 0
176
- } else {
177
- contextDataPosition++
178
- }
179
- }
180
-
181
- value = contextWord.charCodeAt(0)
182
- for (bitIndex = 0; bitIndex < 8; bitIndex++) {
183
- contextDataValue = (contextDataValue << 1) | (value & 1)
184
- if (contextDataPosition === bitsPerChar - 1) {
185
- contextDataPosition = 0
186
- contextData.push(getCharFromInt(contextDataValue))
187
- contextDataValue = 0
188
- } else {
189
- contextDataPosition++
190
- }
191
- value >>= 1
192
- }
193
- } else {
194
- value = 1
195
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
196
- contextDataValue = (contextDataValue << 1) | value
197
- if (contextDataPosition === bitsPerChar - 1) {
198
- contextDataPosition = 0
199
- contextData.push(getCharFromInt(contextDataValue))
200
- contextDataValue = 0
201
- } else {
202
- contextDataPosition++
203
- }
204
- value = 0
205
- }
206
-
207
- value = contextWord.charCodeAt(0)
208
- for (bitIndex = 0; bitIndex < 16; bitIndex++) {
209
- contextDataValue = (contextDataValue << 1) | (value & 1)
210
- if (contextDataPosition === bitsPerChar - 1) {
211
- contextDataPosition = 0
212
- contextData.push(getCharFromInt(contextDataValue))
213
- contextDataValue = 0
214
- } else {
215
- contextDataPosition++
216
- }
217
- value >>= 1
218
- }
219
- }
220
-
221
- contextEnlargeIn--
222
- if (contextEnlargeIn === 0) {
223
- contextEnlargeIn = Math.pow(2, contextNumberOfBits)
224
- contextNumberOfBits++
225
- }
226
- delete contextDictionaryToCreate[contextWord]
227
- } else {
228
- value = contextDictionary[contextWord]
229
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
230
- contextDataValue = (contextDataValue << 1) | (value & 1)
231
- if (contextDataPosition === bitsPerChar - 1) {
232
- contextDataPosition = 0
233
- contextData.push(getCharFromInt(contextDataValue))
234
- contextDataValue = 0
235
- } else {
236
- contextDataPosition++
237
- }
238
- value >>= 1
239
- }
240
- }
241
-
242
- contextEnlargeIn--
243
- if (contextEnlargeIn === 0) {
244
- contextEnlargeIn = Math.pow(2, contextNumberOfBits)
245
- contextNumberOfBits++
246
- }
247
- }
248
-
249
- value = 2
250
- for (bitIndex = 0; bitIndex < contextNumberOfBits; bitIndex++) {
251
- contextDataValue = (contextDataValue << 1) | (value & 1)
252
- if (contextDataPosition === bitsPerChar - 1) {
253
- contextDataPosition = 0
254
- contextData.push(getCharFromInt(contextDataValue))
255
- contextDataValue = 0
256
- } else {
257
- contextDataPosition++
258
- }
259
- value >>= 1
260
- }
261
-
262
- while (true) {
263
- contextDataValue <<= 1
264
- if (contextDataPosition === bitsPerChar - 1) {
265
- contextData.push(getCharFromInt(contextDataValue))
266
- break
267
- }
268
- contextDataPosition++
269
- }
270
-
271
- return contextData.join('')
1
+ import LZString from 'lz-string'
2
+
3
+ self.onmessage = function ({ data }) {
4
+ if (
5
+ !data ||
6
+ (typeof data.id !== 'number' && typeof data.id !== 'string') ||
7
+ typeof data.value !== 'string'
8
+ ) {
9
+ return
272
10
  }
273
11
 
274
- self.onmessage = function (event) {
275
- var message = event.data
276
- if (
277
- !message ||
278
- (typeof message.id !== 'number' && typeof message.id !== 'string') ||
279
- typeof message.value !== 'string'
280
- ) {
281
- return
282
- }
283
-
284
- try {
285
- self.postMessage({
286
- id: message.id,
287
- compressed: compressToBase64(message.value)
288
- })
289
- } catch (error) {
290
- self.postMessage({
291
- id: message.id,
292
- error: error && error.message ? error.message : 'Compression failed'
293
- })
294
- }
12
+ try {
13
+ self.postMessage({
14
+ id: data.id,
15
+ compressed: LZString.compressToBase64(data.value)
16
+ })
17
+ } catch (error) {
18
+ self.postMessage({
19
+ id: data.id,
20
+ error: error && error.message ? error.message : 'Compression failed'
21
+ })
295
22
  }
296
- })()
23
+ }
@@ -1,4 +1,5 @@
1
1
  import PermissionStorageWorker from 'worker-loader?filename=js/permission-storage-worker.[contenthash:8].js!./permission-storage-worker.v1.js'
2
+
2
3
  import { setItem } from './storageEdit'
3
4
 
4
5
  const LARGE_STORAGE_THRESHOLD = 524288
@@ -61,9 +62,7 @@ function getCompressionWorker() {
61
62
  function compressInWorker(value) {
62
63
  const worker = getCompressionWorker()
63
64
  if (!worker) {
64
- return Promise.reject(
65
- new Error('Permission compression worker is unavailable')
66
- )
65
+ return Promise.reject(new Error('Permission compression worker is unavailable'))
67
66
  }
68
67
 
69
68
  return new Promise((resolve, reject) => {
@@ -83,10 +82,7 @@ function writeCompressedValue(key, compressed) {
83
82
  const rawSetItem = storage._setItem
84
83
  const rawRemoveItem = storage._removeItem
85
84
 
86
- if (
87
- typeof rawSetItem !== 'function' ||
88
- typeof rawRemoveItem !== 'function'
89
- ) {
85
+ if (typeof rawSetItem !== 'function' || typeof rawRemoveItem !== 'function') {
90
86
  throw new Error('Extended Storage API is unavailable')
91
87
  }
92
88
 
@@ -101,10 +97,7 @@ function writeCompressedValue(key, compressed) {
101
97
  }
102
98
 
103
99
  async function persistItem({ key, value, serialized }) {
104
- if (
105
- typeof serialized !== 'string' ||
106
- serialized.length <= LARGE_STORAGE_THRESHOLD
107
- ) {
100
+ if (typeof serialized !== 'string' || serialized.length <= LARGE_STORAGE_THRESHOLD) {
108
101
  window.sessionStorage.setItem(key, serialized)
109
102
  return
110
103
  }