vue2-client 1.18.69 → 1.19.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
+ **1.19.0 -2026-01-05 @江超**
5
+ - 移除对旧字典的支持(暂时保留方法)
6
+
4
7
  **1.16.72 -2024-12-19 @张振宇**
5
8
  - 修复代码检查发现的错误
6
9
  - 优化 XAddNativeFormOA 组件中的变量作用域问题
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.18.69",
3
+ "version": "1.19.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -136,21 +136,7 @@ export default {
136
136
  console.warn(`Config '${configName}' did not return a valid 'value' array for options. Result:`, res)
137
137
  }
138
138
  } else {
139
- // 全局字典
140
- if (this.$appdata && typeof this.$appdata.getDictionaryList === 'function') {
141
- const dictionaryList = this.$appdata.getDictionaryList(item.keyName)
142
- if (Array.isArray(dictionaryList)) {
143
- fetchedOptions = dictionaryList.map(opt => ({
144
- label: opt.text,
145
- value: opt.value + '',
146
- ...opt // 将所有原始属性也添加到选项中
147
- }))
148
- } else {
149
- console.warn(`Global dictionary '${item.keyName}' did not return an array. Result:`, dictionaryList)
150
- }
151
- } else {
152
- console.error('$appdata.getDictionaryList is not available. Please ensure it\'s globally provided.')
153
- }
139
+ // 移除对旧字典的解析
154
140
  }
155
141
  } catch (error) {
156
142
  console.error(`Error fetching options for item '${item.key}':`, error)
@@ -73,15 +73,7 @@ export default {
73
73
  methods: {
74
74
  // todo 修改方式 想办法不使用回调方式
75
75
  async updateDictionary () {
76
- const result = this.$appdata.getParam(this.badgeKey, this.value)
77
- if (result) {
78
- this.dictionary = result
79
- return
80
- }
81
76
  this.dictionary = await this.$appdata.getDictValue(this.badgeKey, this.value, undefined, this.env === 'dev', this.serviceName)
82
- },
83
- badgeFilter (key, value) {
84
- return this.$appdata.getParam(key, value)
85
77
  }
86
78
  }
87
79
  }
@@ -144,22 +144,6 @@
144
144
  </template>
145
145
  </a-select-option>
146
146
  </template>
147
- <template v-else>
148
- <a-select-option
149
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
150
- :key="item.value"
151
- :value="item.value + ''"
152
- >
153
- <!-- 徽标(badge) -->
154
- <x-badge
155
- :badge-key="attr.keyName"
156
- :replaceText="item.text"
157
- :value="item.value"
158
- :service-name="serviceName"
159
- :env="env"
160
- />
161
- </a-select-option>
162
- </template>
163
147
  </template>
164
148
  </a-select>
165
149
  <a-select
@@ -259,15 +243,6 @@
259
243
  </template>
260
244
  </a-select-option>
261
245
  </template>
262
- <template v-else>
263
- <a-select-option
264
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
265
- :key="item.value"
266
- :value="item.value + ''"
267
- >
268
- {{ item.text }}
269
- </a-select-option>
270
- </template>
271
246
  </template>
272
247
  </a-select>
273
248
  <a-select
@@ -333,11 +308,6 @@
333
308
  {{ item.label }}
334
309
  </a-radio>
335
310
  </template>
336
- <template v-else>
337
- <a-radio v-for="(item, index) in $appdata.getDictionaryList(attr.keyName)" :key="index" :value="item.value">
338
- {{ item.text }}
339
- </a-radio>
340
- </template>
341
311
  </template>
342
312
  </a-radio-group>
343
313
  </a-form-model-item>
@@ -12,7 +12,7 @@
12
12
  <div class="title-content">
13
13
  <div class="title-dot"></div>
14
14
  <a-icon v-if="attrs.icon && !attrs.customIcon" :type="attrs.icon" class="title-icon" />
15
- <XIcon v-if="attrs.customIcon" :name="attrs.customIcon" class="title-icon" />
15
+ <XIcon v-if="attrs.customIcon" :name="attrs.customIcon" class="title-icon"/>
16
16
  <span>{{ config.label }}</span>
17
17
  </div>
18
18
  <div
@@ -33,7 +33,7 @@
33
33
  </template>
34
34
 
35
35
  <script setup>
36
- import { ref, computed, onMounted, useAttrs } from 'vue'
36
+ import {ref, computed, onMounted, useAttrs} from 'vue'
37
37
  import XIcon from '../XIcon/XIcon.vue'
38
38
 
39
39
  const props = defineProps({
@@ -101,11 +101,36 @@ const isShowTopLine = computed(() => {
101
101
  const isShowBottomLine = computed(() => {
102
102
  return attrs.showBottomLine === 'true' || attrs.showBottomLine === true
103
103
  })
104
+ // 暴露方法供外部调用,动态修改标题
105
+ const updateTitle = (newTitle) => {
106
+ if (newTitle !== undefined && newTitle !== null) {
107
+ config.value.label = String(newTitle)
108
+ config.value.type = 'title'
109
+ config.value.line = ''
110
+ config.value.color = ''
111
+ config.value.lineLength = ''
112
+ config.value.clickName = ''
113
+ // 强制更新(以防万一)
114
+ config.value = {...config.value}
115
+ }
116
+ }
117
+
118
+ // 暴露方法供外部调用,动态修改 queryParamsName
119
+ const updateQueryParamsName = (newParams) => {
120
+ parseConfig(newParams)
121
+ }
122
+
104
123
  const handleClick = () => {
105
124
  if (config.value.clickName) {
106
125
  emit(config.value.clickName)
107
126
  }
108
127
  }
128
+
129
+ // 暴露组件方法
130
+ defineExpose({
131
+ updateTitle,
132
+ updateQueryParamsName
133
+ })
109
134
  const parseConfig = (data) => {
110
135
  // 如果设置了title属性,直接使用title作为标签
111
136
  if (props.title) {
@@ -156,6 +181,7 @@ const parseConfig = (data) => {
156
181
  }
157
182
  }
158
183
 
184
+
159
185
  onMounted(() => {
160
186
  parseConfig(props.queryParamsName)
161
187
  })
@@ -181,6 +207,7 @@ onMounted(() => {
181
207
  overflow: hidden;
182
208
  text-overflow: ellipsis;
183
209
  }
210
+
184
211
  .underline {
185
212
  position: absolute;
186
213
  bottom: 0;
@@ -193,6 +220,7 @@ onMounted(() => {
193
220
  .x-button-container {
194
221
  text-align: right;
195
222
  }
223
+
196
224
  .x-title-center {
197
225
  &.x-title-container,
198
226
  .x-title-container {
@@ -201,6 +229,7 @@ onMounted(() => {
201
229
  }
202
230
  }
203
231
  }
232
+
204
233
  .x-title-littlefont {
205
234
  &.x-title-container,
206
235
  .x-title-container {
@@ -239,6 +268,7 @@ onMounted(() => {
239
268
  align-items: baseline;
240
269
  }
241
270
  }
271
+
242
272
  // 顶部分割线
243
273
  .top-line {
244
274
  width: 100%;
@@ -248,6 +278,7 @@ onMounted(() => {
248
278
  margin: 8px 0;
249
279
  opacity: 1;
250
280
  }
281
+
251
282
  .x-title-dot,
252
283
  .x-title-nodot {
253
284
  &.x-title-container,
@@ -271,12 +302,14 @@ onMounted(() => {
271
302
  }
272
303
  }
273
304
  }
305
+
274
306
  .x-title-yizhu-title {
275
307
  &.x-title-container,
276
308
  .x-title-container {
277
309
  margin-top: 3px;
278
310
  margin-left: 6px;
279
311
  margin-bottom: 7px;
312
+
280
313
  :deep(.x-title) {
281
314
  height: 26px;
282
315
  opacity: 1;
@@ -290,10 +323,12 @@ onMounted(() => {
290
323
  }
291
324
  }
292
325
  }
326
+
293
327
  .x-title-left-title {
294
328
  &.x-title-container,
295
329
  .x-title-container {
296
330
  margin: 15px auto 15px 6px;
331
+
297
332
  :deep(.x-title) {
298
333
  height: 26px;
299
334
  opacity: 1;
@@ -304,6 +339,7 @@ onMounted(() => {
304
339
  }
305
340
  }
306
341
  }
342
+
307
343
  // nodot 样式特有部分
308
344
  .x-title-nodot {
309
345
  &.x-title-container,
@@ -314,12 +350,14 @@ onMounted(() => {
314
350
  }
315
351
  }
316
352
  }
353
+
317
354
  .x-title-line-style {
318
355
  background: #0057FE;
319
356
  height: 2px;
320
357
  }
358
+
321
359
  .x-title-compact {
322
- :deep(.x-title){
360
+ :deep(.x-title) {
323
361
  height: 23px;
324
362
  opacity: 1;
325
363
  font-family: "Source Han Sans";
@@ -1,131 +1,146 @@
1
- import { manageApi, post } from '@vue2-client/services/api'
1
+ import { manageApi } from '@vue2-client/services/api'
2
2
  import { handleTree } from '@vue2-client/utils/util'
3
3
  import { indexedDB } from '@vue2-client/utils/indexedDB'
4
4
  import { getConfigByName } from '@vue2-client/services/api/common'
5
5
 
6
+ // 字典缓存
7
+ const dictCache = new Map()
8
+
6
9
  const GetAppDataService = {
7
10
  install (Vue) {
8
- // 给vue增添对话框显示方法
9
11
  Vue.$appdata = Vue.prototype.$appdata = GetAppDataService
10
12
  },
13
+
11
14
  async load () {
12
- const params = {}
13
- await post(manageApi.getDictionaryValue, {}).then((res) => {
14
- Object.assign(params, res)
15
- const badgeItemArray = {}
16
- for (const key of Object.keys(params)) {
17
- badgeItemArray[key] = {}
18
- for (const item of params[key]) {
19
- let status
20
- if (!item.status) {
21
- status = 'none'
22
- } else {
23
- status = item.status
24
- }
25
- badgeItemArray[key][item.value] = {
26
- status: status,
27
- text: item.text
28
- }
29
- }
30
- }
31
- // 追加参数
32
- localStorage.setItem(process.env.VUE_APP_DICTIONARY_KEY, JSON.stringify(params))
33
- localStorage.setItem(process.env.VUE_APP_BADGE_KEY, JSON.stringify(badgeItemArray))
34
- })
15
+ localStorage.setItem(
16
+ process.env.VUE_APP_DICTIONARY_KEY,
17
+ JSON.stringify({})
18
+ )
19
+ localStorage.setItem(
20
+ process.env.VUE_APP_BADGE_KEY,
21
+ JSON.stringify({})
22
+ )
35
23
  },
24
+
36
25
  // 返回树形省市区
37
26
  async getDivisionsOhChinaForTree () {
38
- // 获取省市区数据
39
27
  return new Promise((resolve, reject) => {
40
28
  try {
41
- indexedDB.getByWeb('divisionsOhChina', manageApi.getDivisionsOhChina, {}, res => {
42
- resolve(res)
43
- }, processRes => {
44
- return handleTree(processRes, 'code', 'parentcode')
45
- })
29
+ indexedDB.getByWeb(
30
+ 'divisionsOhChina',
31
+ manageApi.getDivisionsOhChina,
32
+ {},
33
+ res => resolve(res),
34
+ processRes => handleTree(processRes, 'code', 'parentcode')
35
+ )
46
36
  } catch (e) {
47
37
  reject(e)
48
38
  }
49
39
  })
50
40
  },
51
- // 旧版获取配置中心字典
52
- getDictionaryList (key) {
53
- const str = localStorage.getItem(process.env.VUE_APP_DICTIONARY_KEY)
54
- const object = JSON.parse(str)
55
- return object[key]
56
- },
57
- async getDictValue (dictKey, value, func, isDev = false, serviceName = process.env.VUE_APP_SYSTEM_NAME) {
58
- const processResult = (result) => {
59
- if (!result.value) {
60
- return {
61
- status: 'none',
62
- text: value
63
- }
64
- }
65
- const item = result.value.find(item => item.value == value)
66
- if (item) {
67
- return {
68
- status: item.status || 'none',
69
- text: item.label
70
- }
71
- }
41
+ // 用于徽标解析字典值
42
+ parseDictValue (dictList, value) {
43
+ if (!Array.isArray(dictList)) {
72
44
  return {
73
45
  status: 'none',
74
46
  text: value
75
47
  }
76
48
  }
77
- if (func) {
78
- getConfigByName(dictKey, serviceName, result => {
79
- func(processResult(result))
80
- }, isDev)
49
+
50
+ const item = dictList.find(i => i.value == value)
51
+ if (item) {
52
+ return {
53
+ status: item.status || 'none',
54
+ text: item.label
55
+ }
56
+ }
57
+
58
+ return {
59
+ status: 'none',
60
+ text: value
61
+ }
62
+ },
63
+
64
+ // 获取徽标字典值
65
+ async getDictValue (
66
+ dictKey,
67
+ value,
68
+ callback,
69
+ isDev = false,
70
+ serviceName = process.env.VUE_APP_SYSTEM_NAME
71
+ ) {
72
+ const dictList = await this.getDictByKeyAsync(
73
+ dictKey,
74
+ serviceName,
75
+ isDev
76
+ )
77
+ const result = this.parseDictValue(dictList, value)
78
+
79
+ if (typeof callback === 'function') {
80
+ callback(result)
81
81
  } else {
82
- const result = await new Promise((resolve) => {
83
- getConfigByName(dictKey, serviceName, resolve, isDev)
84
- })
85
- return processResult(result)
82
+ return result
86
83
  }
87
84
  },
85
+
88
86
  // 获取琉璃字典(Callback 版本)
89
- getDictByKey(dictKey, serviceName, callback, isDev) {
90
- this.getDictByKeyAsync(dictKey, serviceName, isDev).then(callback)
91
- },
92
- // 获取琉璃字典(Promise 版本)
93
- getDictByKeyAsync(dictKey, serviceName = process.env.VUE_APP_SYSTEM_NAME, isDev) {
94
- return new Promise(resolve => {
95
- getConfigByName(dictKey, serviceName, res => resolve(res.value), isDev)
96
- })
87
+ getDictByKey (dictKey, serviceName, callback, isDev) {
88
+ this.getDictByKeyAsync(dictKey, serviceName, isDev)
89
+ .then(res => {
90
+ if (typeof callback === 'function') {
91
+ callback(res)
92
+ }
93
+ })
97
94
  },
98
95
 
99
- getParam (key, value, callback) {
100
- const str = localStorage.getItem(process.env.VUE_APP_BADGE_KEY)
101
- const object = JSON.parse(str)
102
- if (object && object[key]) {
103
- const result = object[key]
104
- if (Object.prototype.hasOwnProperty.call(result, value)) {
105
- return result[value]
106
- } else {
107
- return { status: 'none', text: value }
108
- }
96
+ // 获取琉璃字典(Promise 版本,核心实现)
97
+ async getDictByKeyAsync (
98
+ dictKey,
99
+ serviceName = process.env.VUE_APP_SYSTEM_NAME,
100
+ isDev = false
101
+ ) {
102
+ const cacheKey = `${serviceName}:${dictKey}`
103
+
104
+ if (dictCache.has(cacheKey)) {
105
+ return dictCache.get(cacheKey)
109
106
  }
110
- return null
107
+
108
+ const dictList = await new Promise(resolve => {
109
+ getConfigByName(
110
+ dictKey,
111
+ serviceName,
112
+ res => resolve(res?.value || []),
113
+ isDev
114
+ )
115
+ })
116
+
117
+ dictCache.set(cacheKey, dictList)
118
+ return dictList
111
119
  },
120
+
112
121
  getParams () {
113
122
  const str = localStorage.getItem(process.env.VUE_APP_DICTIONARY_KEY)
114
- return JSON.parse(str)
123
+ return str ? JSON.parse(str) : {}
115
124
  },
125
+
116
126
  getSingleValues () {
117
127
  const str = localStorage.getItem(process.env.VUE_APP_BADGE_KEY)
118
- return JSON.parse(str)
128
+ return str ? JSON.parse(str) : {}
119
129
  },
130
+
120
131
  getWebConfigByKey (key) {
121
132
  const str = localStorage.getItem(process.env.VUE_APP_WEB_CONFIG_KEY)
133
+ if (!str) return undefined
122
134
  const object = JSON.parse(str)
123
- return object[key]
135
+ return object?.[key]
124
136
  },
137
+
125
138
  getStylesByKey (key) {
126
139
  const str = localStorage.getItem(process.env.VUE_APP_WEB_STYLES_KEY)
140
+ if (!str) return undefined
127
141
  const object = JSON.parse(str)
128
- return object[key]
129
- },
142
+ return object?.[key]
143
+ }
130
144
  }
145
+
131
146
  export default GetAppDataService
@@ -1125,7 +1125,7 @@ export default {
1125
1125
  if (stepDefine.formType === 'select') {
1126
1126
  let dictList
1127
1127
  if (stepDefine.selectType === 'key') {
1128
- dictList = this.$appdata.getDictionaryList(stepDefine.selectKey)
1128
+ dictList = []
1129
1129
  } else if (stepDefine.selectType === 'config') {
1130
1130
  const configName = stepDefine.selectKey.substring(7)
1131
1131
  dictList = await this.$appdata.getDictByKeyAsync(configName)
@@ -787,7 +787,7 @@ export default {
787
787
  if (stepDefine.formType === 'select') {
788
788
  let dictList
789
789
  if (stepDefine.selectType === 'key') {
790
- dictList = this.$appdata.getDictionaryList(stepDefine.selectKey)
790
+ dictList = []
791
791
  } else if (stepDefine.selectType === 'config') {
792
792
  const configName = stepDefine.selectKey.substring(7)
793
793
  dictList = await this.$appdata.getDictByKeyAsync(configName)