n20-common-lib 2.22.68 → 2.22.70

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.68",
3
+ "version": "2.22.70",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -0,0 +1,87 @@
1
+ import getJsonc from '../../assets/getJsonc.js'
2
+ import axios from '../../utils/axios'
3
+
4
+ const DYNAMIC_CONFIG_URL = '/bems/portal/sysAppConfig/listAllConfig'
5
+ const DYNAMIC_CONFIG_QUERY = {
6
+ systemNos: ['BEMS'],
7
+ menuNos: ['BG_CONFIG'],
8
+ moduleNos: ['activiti'],
9
+ groupNos: [],
10
+ configKeys: []
11
+ }
12
+
13
+ let backendConfigPromise
14
+
15
+ function parseConfigValue(value) {
16
+ if (typeof value !== 'string') return value
17
+ try {
18
+ return JSON.parse(value)
19
+ } catch (error) {
20
+ return value
21
+ }
22
+ }
23
+
24
+ function setConfigValue(target, path, value) {
25
+ path.reduce((current, key, index) => {
26
+ if (index === path.length - 1) {
27
+ current[key] = value
28
+ return current
29
+ }
30
+ if (!current[key] || typeof current[key] !== 'object') {
31
+ current[key] = {}
32
+ }
33
+ return current[key]
34
+ }, target)
35
+ }
36
+
37
+ function decodeConfigList(base64) {
38
+ if (!base64) return []
39
+ const binary = window.atob(base64)
40
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0))
41
+ const configList = JSON.parse(new TextDecoder('utf-8').decode(bytes))
42
+ return Array.isArray(configList) ? configList : []
43
+ }
44
+
45
+ function mergeConfigList(configList) {
46
+ return configList.reduce((config, item) => {
47
+ if (!item || !item.configKey) return config
48
+ setConfigValue(config, item.configKey.split('.'), parseConfigValue(item.configValue))
49
+ return config
50
+ }, {})
51
+ }
52
+
53
+ async function getBackendConfig() {
54
+ if (!backendConfigPromise) {
55
+ backendConfigPromise = (async () => {
56
+ const { data } = await axios.post(DYNAMIC_CONFIG_URL, DYNAMIC_CONFIG_QUERY, {
57
+ loading: false,
58
+ noMsg: true
59
+ })
60
+ const config = mergeConfigList(decodeConfigList(data))
61
+ return {
62
+ ...config,
63
+ ...(config.nstc && config.nstc.activiti ? config.nstc.activiti : {})
64
+ }
65
+ })()
66
+ }
67
+
68
+ try {
69
+ return await backendConfigPromise
70
+ } catch (error) {
71
+ // 接口不可用时不缓存失败结果,后续组件实例仍可重新探测新配置接口。
72
+ backendConfigPromise = undefined
73
+ throw error
74
+ }
75
+ }
76
+
77
+ /**
78
+ * 优先读取后台管理配置,低版本门户未提供接口时回退 JSONC。
79
+ * @returns {Promise<Object>}
80
+ */
81
+ export default async function getApprovalConfig() {
82
+ try {
83
+ return await getBackendConfig()
84
+ } catch (error) {
85
+ return getJsonc('portal/server-config.jsonc', null, true)
86
+ }
87
+ }
@@ -341,6 +341,7 @@
341
341
  <script>
342
342
  import selectSpr from './selectSpr.vue'
343
343
  import getJsonc from '../../assets/getJsonc.js'
344
+ import getApprovalConfig from './getApprovalConfig'
344
345
  import { closeTagsForBackPage } from '../../plugins/CompatibleOld'
345
346
  import axios from '../../utils/axios'
346
347
  import { $lc } from '../../utils/i18n/index'
@@ -642,21 +643,19 @@ export default {
642
643
  }
643
644
  },
644
645
  // 意见是否必填
645
- getConfiguration() {
646
- getJsonc('portal/server-config.jsonc', null, true)
647
- .then(({ opinionRequired, showApproveTo }) => {
648
- this.requiredC = opinionRequired ?? this.required
649
- this.showApproveTo = showApproveTo ?? true
650
- })
651
- .catch(() => {
652
- this.requiredC = this.required
653
- })
654
- .finally(() => {
655
- // 读取该工作流是否意见必填
656
- if (this.$route.query.remarkIsMust !== undefined) {
657
- this.requiredC = this.$route.query.remarkIsMust === '1'
658
- }
659
- })
646
+ async getConfiguration() {
647
+ try {
648
+ const { opinionRequired, showApproveTo } = await getApprovalConfig()
649
+ this.requiredC = opinionRequired ?? this.required
650
+ this.showApproveTo = showApproveTo ?? true
651
+ } catch (error) {
652
+ this.requiredC = this.required
653
+ } finally {
654
+ // 工作流节点配置优先于全局审批意见必填配置。
655
+ if (this.$route.query.remarkIsMust !== undefined) {
656
+ this.requiredC = this.$route.query.remarkIsMust === '1'
657
+ }
658
+ }
660
659
  },
661
660
  getTodoList() {
662
661
  return new Promise((resolve) => {
@@ -150,10 +150,6 @@ export default {
150
150
  display: inline-block;
151
151
  }
152
152
 
153
- .n20-date-picker > .n20-date-editor {
154
- width: 100%;
155
- }
156
-
157
153
  .n20-date-picker.has-long-term {
158
154
  display: inline-flex;
159
155
  align-items: center;
@@ -161,7 +157,6 @@ export default {
161
157
 
162
158
  .n20-date-picker.has-long-term > .n20-date-editor {
163
159
  flex: 1;
164
- width: auto;
165
160
  min-width: 0;
166
161
  }
167
162
 
@@ -80,6 +80,7 @@
80
80
  </div>
81
81
  </slot>
82
82
  </el-table-column>
83
+ <slot name="type-after"></slot>
83
84
  <el-table-column :label="'附件名称' | $lc" :prop="keys.name" sortable="custom">
84
85
  <slot slot="header" slot-scope="scope" name="name-header" :column="scope.column">{{ '附件名称' | $lc }}</slot>
85
86
  <slot slot-scope="{ row }" name="name" :row="row">
@@ -93,7 +94,7 @@
93
94
  />
94
95
  </slot>
95
96
  </el-table-column>
96
- <slot name="type-after"></slot>
97
+
97
98
  <el-table-column v-if="readonly" :label="'附件上传' | $lc" :prop="keys.name">
98
99
  <slot slot="header" slot-scope="scope" name="upload-header" :column="scope.column"
99
100
  >{{ '附件上传' | $lc }}