imatrix-ui 0.0.15 → 0.1.1-up

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.
Files changed (171) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +7 -0
  3. package/components/dynamic-source-select/dynamic-source-select-service.js +106 -0
  4. package/components/dynamic-source-select/dynamic-source-select.vue +673 -0
  5. package/components/dynamic-source-select/events.js +77 -0
  6. package/components/fs-preview/fs-preview.vue +287 -0
  7. package/components/index.js +26 -0
  8. package/components/plugins/export-data-new.js +623 -0
  9. package/components/plugins/export-data.js +431 -0
  10. package/components/plugins/index.js +15 -0
  11. package/components/plugins/public-method.js +47 -0
  12. package/components/rich-editor/index-bak.vue +306 -0
  13. package/components/rich-editor/index.vue +236 -0
  14. package/components/rich-editor/langs/zh-Hans.js +438 -0
  15. package/components/rich-editor/viewer.vue +105 -0
  16. package/components/super-grid/apis.js +1065 -0
  17. package/components/super-grid/columns-config.vue +430 -0
  18. package/components/super-grid/custom-formatter.js +330 -0
  19. package/components/super-grid/dynamic-input.vue +1706 -0
  20. package/components/super-grid/eventBus.js +2 -0
  21. package/components/super-grid/events.js +56 -0
  22. package/components/super-grid/formValidatorUtil.js +300 -0
  23. package/components/super-grid/formatter.js +190 -0
  24. package/components/super-grid/group-column.vue +100 -0
  25. package/components/super-grid/header-context-menu.vue +82 -0
  26. package/components/super-grid/index-column.vue +69 -0
  27. package/components/super-grid/normal-column.vue +1148 -0
  28. package/components/super-grid/public-methods.js +30 -0
  29. package/components/super-grid/row-operation.vue +193 -0
  30. package/components/super-grid/search-button.vue +74 -0
  31. package/components/super-grid/search-condition-input.vue +73 -0
  32. package/components/super-grid/search-condition-list.vue +68 -0
  33. package/components/super-grid/search-form-advancedQuery.vue +820 -0
  34. package/components/super-grid/search-form-dialog.vue +77 -0
  35. package/components/super-grid/search-form-item.vue +470 -0
  36. package/components/super-grid/search-form-number.vue +111 -0
  37. package/components/super-grid/search-form-open.vue +178 -0
  38. package/components/super-grid/search-form-ordinarySearch.vue +218 -0
  39. package/components/super-grid/search-form.vue +756 -0
  40. package/components/super-grid/search-methods.js +484 -0
  41. package/components/super-grid/selection-column.vue +46 -0
  42. package/components/super-grid/store.js +3 -0
  43. package/components/super-grid/super-grid-service.js +682 -0
  44. package/components/super-grid/super-grid.vue +2893 -0
  45. package/components/super-grid/utils.js +851 -0
  46. package/components/super-grid/view-image-dialog.vue +173 -0
  47. package/components/utils/gogocodeTransfer.js +59 -0
  48. package/components/utils/utils.js +180 -0
  49. package/components/utils/value-set.js +98 -0
  50. package/components/z-test-utton/index.vue +82 -0
  51. package/package.json +29 -40
  52. package/public/index.html +13 -0
  53. package/public/vite.svg +1 -0
  54. package/src/api/sso-service.js +172 -19
  55. package/src/api/tab.js +36 -0
  56. package/src/api/user-service.js +11 -11
  57. package/src/assets/401/401.gif +0 -0
  58. package/src/assets/404/404-cloud.png +0 -0
  59. package/src/assets/404/404.png +0 -0
  60. package/src/assets/cloud.png +0 -0
  61. package/src/directives/permission/index.js +13 -13
  62. package/src/directives/permission/permission.js +20 -15
  63. package/src/i18n/i18n.js +16 -0
  64. package/src/i18n/langs/cn.js +254 -0
  65. package/src/i18n/langs/en.js +264 -0
  66. package/src/permission.js +157 -71
  67. package/src/plugins.js +18 -18
  68. package/src/router/index.js +96 -69
  69. package/src/store/getters.js +15 -10
  70. package/src/store/index.js +19 -19
  71. package/src/store/modules/app.js +54 -42
  72. package/src/store/modules/permission.js +137 -73
  73. package/src/store/modules/tab-content.js +36 -0
  74. package/src/store/modules/user.js +293 -80
  75. package/src/styles/display-layout.scss +34 -0
  76. package/src/styles/element-ui.scss +29 -29
  77. package/src/styles/index.scss +157 -78
  78. package/src/styles/mixin.scss +27 -27
  79. package/src/styles/theme/black/font-style.scss +70 -0
  80. package/src/styles/theme/black/index.scss +306 -0
  81. package/src/styles/theme/black/sidebar.scss +189 -0
  82. package/src/styles/theme/blue/font-style.scss +46 -0
  83. package/src/styles/theme/blue/index.scss +172 -0
  84. package/src/styles/{sidebar.scss → theme/blue/sidebar.scss} +171 -141
  85. package/src/styles/theme/blue2/font-style.scss +70 -0
  86. package/src/styles/theme/blue2/index.scss +188 -0
  87. package/src/styles/theme/blue2/sidebar.scss +201 -0
  88. package/src/styles/theme/dark-blue/button.scss +9 -0
  89. package/src/styles/theme/dark-blue/card.scss +62 -0
  90. package/src/styles/theme/dark-blue/checkbox.scss +10 -0
  91. package/src/styles/theme/dark-blue/dark-blue-var.scss +8 -0
  92. package/src/styles/theme/dark-blue/dialog.scss +21 -0
  93. package/src/styles/theme/dark-blue/element-variables.scss +7 -0
  94. package/src/styles/theme/dark-blue/font.scss +71 -0
  95. package/src/styles/theme/dark-blue/form.scss +51 -0
  96. package/src/styles/theme/dark-blue/index.scss +269 -0
  97. package/src/styles/theme/dark-blue/input.scss +15 -0
  98. package/src/styles/theme/dark-blue/message.scss +8 -0
  99. package/src/styles/theme/dark-blue/pagination.scss +14 -0
  100. package/src/styles/theme/dark-blue/scrollbar-style.scss +32 -0
  101. package/src/styles/theme/dark-blue/sidebar.scss +266 -0
  102. package/src/styles/theme/dark-blue/tab.scss +83 -0
  103. package/src/styles/theme/dark-blue/table.scss +60 -0
  104. package/src/styles/theme/dark-blue/tree.scss +31 -0
  105. package/src/styles/theme/dark-blue/var.scss +1028 -0
  106. package/src/styles/theme/gray/card-style.scss +54 -0
  107. package/src/styles/theme/gray/font-style.scss +70 -0
  108. package/src/styles/theme/gray/index.scss +172 -0
  109. package/src/styles/theme/gray/input-style.scss +19 -0
  110. package/src/styles/theme/gray/scrollbar-style.scss +32 -0
  111. package/src/styles/theme/gray/sidebar.scss +231 -0
  112. package/src/styles/theme/gray/tab-style.scss +81 -0
  113. package/src/styles/transition.scss +47 -46
  114. package/src/utils/auth-api.js +159 -0
  115. package/src/utils/auth.js +61 -15
  116. package/src/utils/calculator/calculator-factory-wf.js +558 -0
  117. package/src/utils/calculator/calculator-factory.js +145 -0
  118. package/src/utils/calculator/calculator-util.js +166 -0
  119. package/src/utils/common-util.js +305 -0
  120. package/src/utils/eventBus.js +2 -0
  121. package/src/utils/iconUtils.js +28 -0
  122. package/src/utils/index.js +102 -86
  123. package/src/utils/jump-page-utils.js +814 -0
  124. package/src/utils/local-storage.js +33 -31
  125. package/src/utils/menu.js +19 -0
  126. package/src/utils/permission.js +31 -26
  127. package/src/utils/permissionAuth.js +90 -0
  128. package/src/utils/range-selector.js +188 -0
  129. package/src/utils/request.js +270 -116
  130. package/src/utils/restful-interface-utils.js +57 -0
  131. package/src/utils/util.js +698 -0
  132. package/src/utils/validate.js +34 -33
  133. package/src/utils/watermark.js +108 -0
  134. package/src/utils/workflow-util.js +93 -0
  135. package/src/views/404.vue +248 -228
  136. package/src/views/dsc-component/Sidebar/Item.vue +84 -0
  137. package/src/views/dsc-component/Sidebar/Link.vue +38 -0
  138. package/src/views/dsc-component/Sidebar/SidebarItem.vue +196 -0
  139. package/src/views/dsc-component/Sidebar/index.vue +220 -0
  140. package/src/views/dsc-component/tabs/tab-content.vue +199 -0
  141. package/src/views/error-page/401.vue +106 -91
  142. package/src/views/error-page/404.vue +248 -228
  143. package/src/views/layout/EmptyLayout.vue +3 -0
  144. package/src/views/layout/Layout.vue +81 -68
  145. package/src/views/layout/NewLayout.vue +18 -0
  146. package/src/views/layout/components/AppMain.vue +39 -29
  147. package/src/views/layout/components/Breadcrumb/index.vue +156 -0
  148. package/src/views/layout/components/Menubar/Item.vue +57 -0
  149. package/src/views/layout/components/Menubar/Link.vue +38 -0
  150. package/src/views/layout/components/Menubar/SidebarItem.vue +164 -0
  151. package/src/views/layout/components/Menubar/index.vue +210 -0
  152. package/src/views/layout/components/Sidebar/Item.vue +53 -29
  153. package/src/views/layout/components/Sidebar/Link.vue +38 -39
  154. package/src/views/layout/components/Sidebar/SidebarItem.vue +135 -100
  155. package/src/views/layout/components/Sidebar/index.vue +141 -48
  156. package/src/views/layout/components/iframe-page.vue +38 -0
  157. package/src/views/layout/components/index.js +4 -3
  158. package/src/views/layout/components/tabs/tab-content.vue +207 -0
  159. package/src/views/layout/mixin/ResizeHandler.js +41 -41
  160. package/src/views/layout/tab-content-iframe-index.vue +38 -0
  161. package/src/views/layout/tab-content-index.vue +93 -0
  162. package/src/views/login/authredirect.vue +10 -10
  163. package/src/views/login/index.vue +296 -203
  164. package/src/views/login/update-password.vue +243 -0
  165. package/src/views/redirect/index.vue +14 -12
  166. package/src/views/wf-history/tache-subprocess-history.vue +45 -0
  167. package/vite.config.js +31 -0
  168. package/lib/super-ui.css +0 -1
  169. package/lib/super-ui.umd.min.js +0 -2
  170. package/src/styles/variables.scss +0 -4
  171. package/src/views/layout/components/Navbar.vue +0 -92
@@ -0,0 +1,2 @@
1
+ import * as Vue from 'vue'
2
+ export default {}
@@ -0,0 +1,56 @@
1
+ import { $on, $off, $once, $emit } from '../utils/gogocodeTransfer'
2
+ const events = {
3
+ select: function (selection, row) {
4
+ $emit(this, 'select', selection, row)
5
+ },
6
+ selectAll: function (selection) {
7
+ $emit(this, 'select-all', selection)
8
+ },
9
+ selectionChange: function (selection) {
10
+ $emit(this, 'selection-change', selection)
11
+ },
12
+ cellMouseEnter: function (row, column, cell, event) {
13
+ $emit(this, 'cell-mouse-enter', row, column, cell, event)
14
+ },
15
+ cellMouseLeave: function (row, column, cell, event) {
16
+ $emit(this, 'cell-mouse-leave', row, column, cell, event)
17
+ },
18
+ cellClick: function (row, column, cell, event) {
19
+ $emit(this, 'cell-click', row, column, cell, event)
20
+ },
21
+ cellDblClick: function (row, column, cell, event) {
22
+ $emit(this, 'cell-dblclick', row, column, cell, event)
23
+ },
24
+ rowClick: function (row, column, event) {
25
+ $emit(this, 'row-click', row, column, event)
26
+ },
27
+ rowContextMenu: function (row, column, event) {
28
+ $emit(this, 'row-contextmenu', row, column, event)
29
+ },
30
+ rowDblClick: function (row, column, event) {
31
+ $emit(this, 'row-dblclick', row, column, event)
32
+ },
33
+ headerClick: function (column, event) {
34
+ $emit(this, 'header-click', column, event)
35
+ },
36
+ headerContextMenu: function (column, event) {
37
+ $emit(this, 'header-contextmenu', column, event)
38
+ },
39
+ // super-grid.vue中已经做了处理
40
+ // sortChange: function({ column, prop, order }) {
41
+ // this.$emit('sort-change', { column, prop, order })
42
+ // },
43
+ filterChange: function (filters) {
44
+ $emit(this, 'filter-change', filters)
45
+ },
46
+ currentChange: function (currentRow, oldCurrentRow) {
47
+ $emit(this, 'current-change', currentRow, oldCurrentRow)
48
+ },
49
+ headerDragEnd: function (newWidth, oldWidth, column, event) {
50
+ $emit(this, 'header-dragend', newWidth, oldWidth, column, event)
51
+ },
52
+ expandChange: function (row, expandedRows) {
53
+ $emit(this, 'expand-change', row, expandedRows)
54
+ },
55
+ }
56
+ export default events
@@ -0,0 +1,300 @@
1
+ import Validator from 'async-validator'
2
+ import store from './store'
3
+ import * as Vue from 'vue'
4
+ import { isDisableEdit } from './utils'
5
+ import { getI18n } from '../../src/utils/util'
6
+
7
+ function setObjectPropRule(editField, rules, leafRule) {
8
+ const rule = {}
9
+ const prop = editField.prop
10
+ if (!rules) {
11
+ rules = {}
12
+ }
13
+ let num = 0
14
+ const props = prop.split('.')
15
+ props.forEach((subProp) => {
16
+ let objectRule
17
+ if (num === props.length - 1) {
18
+ // 说明是最后一个
19
+ objectRule = getEndObjectRule(rule, props, subProp)
20
+ objectRule.fields[subProp] = leafRule
21
+ } else {
22
+ let lastObjectRule
23
+ if (num === 0) {
24
+ objectRule = rules
25
+ } else {
26
+ lastObjectRule = getLastObjectRule(rule, props, props[num - 1])
27
+ objectRule = lastObjectRule.fields
28
+ }
29
+ if (!objectRule[subProp]) {
30
+ objectRule[subProp] = {
31
+ type: 'object',
32
+ required: true,
33
+ fields: {},
34
+ }
35
+ }
36
+ if (num === 0) {
37
+ rule[subProp] = objectRule[subProp]
38
+ } else {
39
+ lastObjectRule.fields[subProp] = objectRule[subProp]
40
+ }
41
+ }
42
+ num++
43
+ })
44
+ return rule
45
+ }
46
+
47
+ function getLastObjectRule(rule, props, currentProp) {
48
+ let lastObjectdRule
49
+ for (let i = 0; i < props.length; i++) {
50
+ const subProp = props[i]
51
+ if (i === 0) {
52
+ lastObjectdRule = rule[subProp]
53
+ } else {
54
+ lastObjectdRule = lastObjectdRule.fields[props[i]]
55
+ }
56
+ if (subProp === currentProp) {
57
+ break
58
+ }
59
+ }
60
+ return lastObjectdRule
61
+ }
62
+
63
+ function getEndObjectRule(rule, props, currentProp) {
64
+ let lastObjectdRule
65
+ for (let i = 0; i < props.length; i++) {
66
+ if (i === 0) {
67
+ lastObjectdRule = rule[props[i]]
68
+ } else {
69
+ lastObjectdRule = lastObjectdRule.fields[props[i]]
70
+ }
71
+ if (i !== props.length - 1) {
72
+ const leafSubProp = props[i + 1]
73
+ if (leafSubProp === currentProp) {
74
+ break
75
+ }
76
+ }
77
+ }
78
+ return lastObjectdRule
79
+ }
80
+
81
+ /**
82
+ * @param {editFieldInfos} Array 编辑字段信息集合
83
+ */
84
+ function getValidator(listCode) {
85
+ if (!listCode) {
86
+ listCode = store.get('_list_code')
87
+ }
88
+ const gridParams = store.get(listCode)
89
+ const editFieldInfos = gridParams.columns
90
+ const rules = {}
91
+ if (editFieldInfos) {
92
+ editFieldInfos.forEach((editField) => {
93
+ const prop = editField.prop
94
+ if (prop && editField.validations && !isDisableEdit(prop, listCode)) {
95
+ const validations = JSON.parse(editField.validations)
96
+ validations.forEach((item) => {
97
+ if (item.pattern) {
98
+ // 后台传递的是正则字符串,不能直接使用
99
+ item.pattern = new RegExp(item.pattern)
100
+ }
101
+ })
102
+ if (prop.indexOf('.') > 0) {
103
+ setObjectPropRule(editField, rules, validations)
104
+ } else {
105
+ if (validations && validations.length > 0) {
106
+ rules[prop] = [...validations]
107
+ }
108
+ }
109
+ }
110
+ })
111
+ }
112
+ // console.log('rules', rules)
113
+ return rules
114
+ }
115
+ /**
116
+ * 验证实体
117
+ * @param {*} entity 实体记录
118
+ * @param {*} listCode 列表编码
119
+ * @param {*} $index 当前行下标
120
+ * @param {*} rules 验证规则
121
+ * @param {*} isSubTableShowPage 表单子表是否显示分页区域
122
+ * @param {*} pageNum 当前记录在子表中的第几页
123
+ * @returns void
124
+ */
125
+
126
+ function validator(
127
+ entity,
128
+ listCode,
129
+ $index,
130
+ rules,
131
+ isSubTableShowPage,
132
+ pageNum,
133
+ pageRowIndex
134
+ ) {
135
+ return validatorEntity(
136
+ entity,
137
+ listCode,
138
+ $index,
139
+ rules,
140
+ true,
141
+ isSubTableShowPage,
142
+ pageNum,
143
+ pageRowIndex
144
+ )
145
+ }
146
+
147
+ function validatorEntity(
148
+ entity,
149
+ listCode,
150
+ $index,
151
+ rules,
152
+ isShouldRepeateValdate,
153
+ isSubTableShowPage,
154
+ pageNum,
155
+ pageRowIndex
156
+ ) {
157
+ let result = false
158
+ let validateRules
159
+ if (rules) {
160
+ validateRules = rules
161
+ } else {
162
+ validateRules = getValidator(listCode)
163
+ }
164
+ const validator = new Validator(validateRules)
165
+ if (!listCode) {
166
+ listCode = store.get('_list_code')
167
+ }
168
+
169
+ const gridParams = store.get(listCode)
170
+ validator.validate(
171
+ entity,
172
+ {
173
+ first: true,
174
+ },
175
+ (errors, fields) => {
176
+ let fieldName
177
+ if (errors) {
178
+ const message = errors[0]['message']
179
+ fieldName = errors[0]['field']
180
+ if (
181
+ $index !== null &&
182
+ $index !== undefined &&
183
+ gridParams.gridData.length > $index
184
+ ) {
185
+ gridParams.gridData[$index]['validateErrorField'] = errors[0]['field']
186
+ if (
187
+ isSubTableShowPage !== undefined &&
188
+ isSubTableShowPage &&
189
+ pageNum !== undefined &&
190
+ pageRowIndex !== undefined
191
+ ) {
192
+ // 表示表单子表验证时
193
+ result =
194
+ getI18n().t('superGrid.pageRecordLine', {
195
+ pageNum: pageNum,
196
+ row: pageRowIndex,
197
+ }) +
198
+ ',' +
199
+ message
200
+ } else {
201
+ // 表示列表记录验证时
202
+ result =
203
+ getI18n().t('superGrid.recordLine', {
204
+ row: $index + 1,
205
+ }) +
206
+ ',' +
207
+ message
208
+ }
209
+ } else if (
210
+ gridParams.$rowIndex !== null &&
211
+ gridParams.$rowIndex !== undefined &&
212
+ gridParams.gridData.length > gridParams.$rowIndex
213
+ ) {
214
+ gridParams.gridData[gridParams.$rowIndex]['validateErrorField'] =
215
+ errors[0]['field']
216
+ result =
217
+ getI18n().t('superGrid.recordLine', {
218
+ row: gridParams.$rowIndex + 1,
219
+ }) +
220
+ ',' +
221
+ message
222
+ }
223
+ } else {
224
+ // 验证成功后,将最后验证失败的字段置空
225
+ if (
226
+ $index !== null &&
227
+ $index !== undefined &&
228
+ gridParams.gridData.length > $index
229
+ ) {
230
+ if (isSubTableShowPage !== undefined && isSubTableShowPage) {
231
+ gridParams.subTableData[$index]['validateErrorField'] = ''
232
+ } else {
233
+ gridParams.gridData[$index]['validateErrorField'] = ''
234
+ }
235
+ } else if (
236
+ gridParams.$rowIndex !== null &&
237
+ gridParams.$rowIndex !== undefined &&
238
+ gridParams.gridData.length > gridParams.$rowIndex
239
+ ) {
240
+ gridParams.gridData[gridParams.$rowIndex]['validateErrorField'] = ''
241
+ } else if (
242
+ $index !== null &&
243
+ $index !== undefined &&
244
+ isSubTableShowPage !== undefined &&
245
+ isSubTableShowPage &&
246
+ gridParams.gridData.length <= $index
247
+ ) {
248
+ // 表示可能是子表分页时,清空子表的
249
+ gridParams.subTableData[$index]['validateErrorField'] = ''
250
+ }
251
+
252
+ result = true
253
+ }
254
+ if (fieldName && isShouldRepeateValdate === true) {
255
+ // 将实体中字段名改为大写,然后再验证一次该字段是否已填值。因为mysql中jdbc获得实体记录字段名是小写的,但是验证规则中字段名是大写的,所以会导致字段验证失败
256
+ const reg1 = /[A-Z]+/ // 大写字母
257
+ if (
258
+ result !== undefined &&
259
+ result + '' !== 'true' &&
260
+ result + '' !== 'false' &&
261
+ gridParams.isSql !== undefined &&
262
+ gridParams.isSql === true &&
263
+ reg1.test(fieldName) &&
264
+ entity[fieldName.toLowerCase()] !== undefined
265
+ ) {
266
+ // 表示验证失败,需要重新验证一次
267
+ const copyEntity = JSON.parse(JSON.stringify(entity))
268
+ copyEntity[fieldName.toUpperCase()] = entity[fieldName.toLowerCase()]
269
+ delete copyEntity[fieldName.toLowerCase()]
270
+ result = validatorEntity(copyEntity, listCode, $index, rules, false)
271
+ }
272
+ if (
273
+ result !== undefined &&
274
+ result + '' !== 'true' &&
275
+ result + '' !== 'false'
276
+ ) {
277
+ // 表示验证失败
278
+ if (gridParams.showValidateError) {
279
+ gridParams.showValidateError = false
280
+ window.$vueApp.config.globalProperties.$message({
281
+ showClose: true,
282
+ message: result,
283
+ type: 'warning',
284
+ onClose: (messageEle) => {
285
+ gridParams.showValidateError = true
286
+ },
287
+ })
288
+ }
289
+ }
290
+ }
291
+ }
292
+ )
293
+
294
+ return result
295
+ }
296
+
297
+ export default {
298
+ validator,
299
+ getValidator,
300
+ }
@@ -0,0 +1,190 @@
1
+ import { isDynamicDataSourceSource } from './utils'
2
+ const formatter = {
3
+ number: function (inputValue, options) {
4
+ // 小数位数
5
+ const precision = options.precision
6
+ // 数字符号
7
+ const sign = options.sign
8
+ // 是否显示千分位
9
+ const isDelimiter = options.delimiter
10
+ // 是否显示科学计数法
11
+ const scientific = options.scientific
12
+ // 几位开始计算
13
+ let scientificNum = options.scientificNum
14
+ if (inputValue !== undefined && inputValue != null) {
15
+ if (precision > 0) {
16
+ // 表示有小数
17
+ inputValue = parseFloat(inputValue)
18
+ inputValue = inputValue.toFixed(precision)
19
+ }
20
+ if (isDelimiter) {
21
+ const inputValueStr = inputValue + ''
22
+ const value = inputValueStr.replace(
23
+ /\d{1,3}(?=(\d{3})+(\.\d*)?$)/g,
24
+ '$&,'
25
+ )
26
+ if (sign) {
27
+ return value + sign
28
+ } else {
29
+ return value
30
+ }
31
+ } else if (scientific != null) {
32
+ let isScientific = false
33
+ if (scientificNum) {
34
+ scientificNum = parseInt(scientificNum)
35
+ } else {
36
+ scientificNum = 11
37
+ }
38
+ if (inputValue.length >= scientificNum) {
39
+ isScientific = true
40
+ }
41
+ if (isScientific) {
42
+ inputValue = '' + inputValue
43
+ inputValue = parseFloat(inputValue)
44
+ inputValue = inputValue.toExponential() // 转换为标准的科学计数法形式(字符串)
45
+ // const tmpArray = eformat.match(/\d(?:\.(\d*))?e([+-]\d+)/) // 分离出小数值和指数值
46
+ // inputValue = inputValue.toFixed(Math.max(0, (tmpArray[1] || '').length - tmpArray[2]))
47
+ }
48
+ } else {
49
+ if (sign) {
50
+ return inputValue + sign
51
+ } else {
52
+ return inputValue
53
+ }
54
+ }
55
+ }
56
+
57
+ return inputValue
58
+ },
59
+ currency: function (value, options) {
60
+ // 单位:$ 或 ¥
61
+ const sign = options.sign
62
+ return sign + this.number(value, options)
63
+ },
64
+ date: function (value, options) {
65
+ // format格式,例如:yyyy-m-d,yyyy-m-d hh:mm:ss等等
66
+ const format = options.format
67
+ if (value != null) {
68
+ const date = new Date(value)
69
+ var y = date.getFullYear()
70
+ var m = date.getMonth() + 1
71
+ var d = date.getDate()
72
+ var h = date.getHours()
73
+ var min = date.getMinutes()
74
+ var s = date.getSeconds()
75
+ if (m < 10) {
76
+ m = '0' + m
77
+ }
78
+ if (d < 10) {
79
+ d = '0' + d
80
+ }
81
+ if (h < 10) {
82
+ h = '0' + h
83
+ }
84
+ if (min < 10) {
85
+ min = '0' + min
86
+ }
87
+ if (s < 10) {
88
+ s = '0' + s
89
+ }
90
+ const newValue = format
91
+ .replace('yyyy', y)
92
+ .replace('mm', min)
93
+ .replace('M', m)
94
+ .replace('m', m)
95
+ .replace('d', d)
96
+ .replace('hh', h)
97
+ .replace('ss', s)
98
+ // 判断格式化的值是否包含NaN,如果包含NaN取数据库的值
99
+ if (newValue.indexOf('NaN') === -1) {
100
+ return newValue
101
+ }
102
+ return value
103
+ }
104
+ return value
105
+ },
106
+ time: function (value, options) {
107
+ return this.date(value, options)
108
+ },
109
+ percent: function (value, options) {
110
+ if (value || value >= 0) {
111
+ return this.number(value, options) + '%'
112
+ }
113
+ return value
114
+ },
115
+ }
116
+
117
+ export function doFormat(column, value) {
118
+ value = doFormatWithValueSet(column, value)
119
+ if (value === undefined || value === null) {
120
+ return
121
+ }
122
+ // 获得默认的格式设置
123
+ if (column.formatter === undefined) {
124
+ if (column.dataType === 'DATE') {
125
+ // 默认的“DATE”类型的格式设置
126
+ column.formatter = {
127
+ type: 'date',
128
+ options: {
129
+ format: 'yyyy-m-d',
130
+ },
131
+ }
132
+ } else if (column.dataType === 'TIME') {
133
+ // 默认的“TIME”类型的格式设置
134
+ column.formatter = {
135
+ type: 'time',
136
+ options: {
137
+ format: 'yyyy-m-d hh:mm:ss',
138
+ },
139
+ }
140
+ }
141
+ }
142
+ const columnFormatter = column.formatter
143
+ if (
144
+ columnFormatter !== undefined &&
145
+ formatter[columnFormatter.type] !== undefined
146
+ ) {
147
+ return formatter[columnFormatter.type](value, columnFormatter.options)
148
+ } else {
149
+ return value
150
+ }
151
+ }
152
+
153
+ export function doFormatWithValueSet(column, value) {
154
+ if (value === undefined || value === null) {
155
+ return value
156
+ }
157
+ const valueSet = column.valueSet
158
+ // 先处理值设置再处理格式化设置:即会对值设置的结果进行格式化设置
159
+ if (valueSet !== undefined) {
160
+ if (
161
+ column.componentType === 'multiselect' &&
162
+ !isDynamicDataSourceSource(column)
163
+ ) {
164
+ if (typeof value === 'number') {
165
+ // 当value是0时, value instanceof Number 为false
166
+ value += ''
167
+ }
168
+ const beforeLabel = (value + '').split(',')
169
+ const label = []
170
+ beforeLabel.forEach((element) => {
171
+ const item = valueSet.filter((item) => {
172
+ return item.value === element + ''
173
+ })
174
+ if (item.length > 0) {
175
+ label.push(item[0].label)
176
+ }
177
+ })
178
+ value = label.join(',')
179
+ } else {
180
+ const item = valueSet.filter((item) => {
181
+ return item.value === value + ''
182
+ })
183
+ if (item.length > 0) {
184
+ // 数据库的原始值要显示成label值,后续对这个label进行格式化(不是处理原始值)
185
+ value = item[0].label
186
+ }
187
+ }
188
+ }
189
+ return value
190
+ }
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <el-table-column width="150" :align="column.groupHeader ? 'center' : ''">
3
+ <template v-slot:header>
4
+ <span class="cell--span" :title="label" v-html="label" />
5
+ </template>
6
+ <template v-if="customFormat">
7
+ <component
8
+ :is="child.prop ? 'NormalColumn' : 'GroupColumn'"
9
+ v-for="(child, index) in visibleChildren"
10
+ :key="child.label + index"
11
+ :column="child"
12
+ :is-sql="isSql"
13
+ :custom-format="child.prop ? customFormat[child.prop] : customFormat"
14
+ :list-code="listCode"
15
+ @findIndex="findIndex(scope.$index)"
16
+ @refresData="refresData"
17
+ @refresPortData="refresPortData"
18
+ @refresPortsData="refresPortsData"
19
+ @refresMainTableFields="refresMainTableFields"
20
+ />
21
+ </template>
22
+ <template v-else>
23
+ <component
24
+ :is="child.prop ? 'NormalColumn' : 'GroupColumn'"
25
+ v-for="(child, index) in visibleChildren"
26
+ :key="child.label + index"
27
+ :is-sql="isSql"
28
+ :column="child"
29
+ :list-code="listCode"
30
+ />
31
+ </template>
32
+ </el-table-column>
33
+ </template>
34
+
35
+ <script>
36
+ import NormalColumn from './normal-column.vue'
37
+ // todo 组件自己引用自己
38
+ // import GroupColumn from './group-column.vue'
39
+ import { doFormatWithValueSet } from './formatter'
40
+ export default {
41
+ name: 'GroupColumn',
42
+ components: {
43
+ NormalColumn,
44
+ // GroupColumn,
45
+ },
46
+ props: {
47
+ column: {
48
+ type: Object,
49
+ default: null,
50
+ },
51
+ // 操作列、占位符列内容显示的函数,格式为:{'属性名':方法},例如:{'name':viewUser,'operation':showOperation}
52
+ customFormat: {
53
+ type: Object,
54
+ default: null,
55
+ },
56
+ listCode: {
57
+ type: String,
58
+ default: null,
59
+ },
60
+ isSql: {
61
+ type: Boolean,
62
+ default: false,
63
+ },
64
+ },
65
+ data() {
66
+ return {
67
+ label: null, // 标题
68
+ }
69
+ },
70
+ computed: {
71
+ visibleChildren() {
72
+ if (this.column.children) {
73
+ return this.column.children.filter((column) => {
74
+ return column.show === undefined || column.show
75
+ })
76
+ } else {
77
+ return []
78
+ }
79
+ },
80
+ },
81
+ created() {
82
+ this.label = this.getHeader()
83
+ },
84
+ methods: {
85
+ getHeader() {
86
+ if (!this.column.titleValueSet) {
87
+ return this.column.label.replace(/\\n/g, '</br>')
88
+ } else {
89
+ return this.formatHeader()
90
+ }
91
+ },
92
+ formatHeader() {
93
+ return doFormatWithValueSet(
94
+ this.column.titleValueSetValue,
95
+ this.column.label
96
+ )
97
+ },
98
+ },
99
+ }
100
+ </script>