imatrix-ui 2.9.9-dw → 2.9.11-boe1

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 (181) hide show
  1. package/lib/super-ui.css +1 -1
  2. package/lib/super-ui.umd.min.js +5 -35
  3. package/package.json +2 -2
  4. package/src/api/sso-service.js +19 -1
  5. package/src/i18n/i18n.js +1 -1
  6. package/src/i18n/langs/cn.js +14 -4
  7. package/src/i18n/langs/en.js +16 -5
  8. package/src/permission.js +1 -1
  9. package/src/plugins.js +3 -3
  10. package/src/router/index.js +10 -0
  11. package/src/store/modules/tab-content.js +6 -0
  12. package/src/store/modules/user.js +19 -0
  13. package/src/styles/index.scss +74 -4
  14. package/src/styles/theme/black/font-style.scss +70 -0
  15. package/src/styles/theme/black/index.scss +6 -30
  16. package/src/styles/theme/blue/font-style.scss +37 -0
  17. package/src/styles/theme/blue/index.scss +2 -18
  18. package/src/styles/theme/blue2/font-style.scss +70 -0
  19. package/src/styles/theme/blue2/index.scss +3 -13
  20. package/src/styles/theme/dark-blue/index.scss +27 -5
  21. package/src/styles/theme/dark-blue/message.scss +8 -0
  22. package/src/styles/theme/dark-blue/sidebar.scss +7 -37
  23. package/src/styles/theme/dark-blue/table.scss +1 -1
  24. package/src/styles/theme/gray/card-style.scss +13 -1
  25. package/src/styles/theme/gray/font-style.scss +38 -0
  26. package/src/styles/theme/gray/index.scss +13 -25
  27. package/src/styles/theme/gray/scrollbar-style.scss +32 -0
  28. package/src/styles/theme/gray/sidebar.scss +7 -14
  29. package/src/utils/auth-api.js +45 -1
  30. package/src/utils/common-util.js +21 -81
  31. package/src/utils/range-selector.js +185 -0
  32. package/src/utils/request.js +6 -3
  33. package/src/utils/util.js +12 -10
  34. package/src/views/dsc-component/Sidebar/Item.vue +7 -5
  35. package/src/views/dsc-component/Sidebar/SidebarItem.vue +2 -3
  36. package/src/views/dsc-component/Sidebar/index.vue +12 -20
  37. package/src/views/dsc-component/tabs/tab-content.vue +1 -5
  38. package/src/views/layout/NewLayout.vue +6 -65
  39. package/src/views/layout/components/Menubar/Item.vue +23 -7
  40. package/src/views/layout/components/Menubar/Link.vue +11 -2
  41. package/src/views/layout/components/Menubar/SidebarItem.vue +50 -7
  42. package/src/views/layout/components/Menubar/index.vue +51 -16
  43. package/src/views/layout/components/tabs/tab-content.vue +160 -0
  44. package/src/views/layout/tab-content-iframe-index.vue +31 -0
  45. package/src/views/layout/tab-content-index.vue +85 -0
  46. package/src/views/login/index.vue +1 -1
  47. package/packages/breadcrumb/index.js +0 -6
  48. package/packages/breadcrumb/src/breadcrumb.vue +0 -71
  49. package/packages/department-tree/index.js +0 -6
  50. package/packages/department-tree/src/department-tree.vue +0 -108
  51. package/packages/department-tree-inline/index.js +0 -6
  52. package/packages/department-tree-inline/src/department-multi-tree-inline.vue +0 -402
  53. package/packages/department-tree-inline/src/department-single-tree-inline.vue +0 -284
  54. package/packages/department-tree-inline/src/department-tree-inline.vue +0 -86
  55. package/packages/department-tree-inline/src/department-tree-service.js +0 -245
  56. package/packages/department-tree-inline/src/search-result.vue +0 -176
  57. package/packages/department-user-tree/index.js +0 -6
  58. package/packages/department-user-tree/src/department-user-multiple-tree.vue +0 -116
  59. package/packages/department-user-tree/src/department-user-single-tree.vue +0 -76
  60. package/packages/department-user-tree/src/department-user-tree.vue +0 -101
  61. package/packages/department-user-tree-inline/index.js +0 -6
  62. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +0 -626
  63. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +0 -269
  64. package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +0 -79
  65. package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +0 -230
  66. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +0 -122
  67. package/packages/department-user-tree-inline/src/search-result.vue +0 -197
  68. package/packages/directives/prevent-reclick.js +0 -19
  69. package/packages/dynamic-source-select/index.js +0 -6
  70. package/packages/dynamic-source-select/src/dynamic-source-select-service.js +0 -70
  71. package/packages/dynamic-source-select/src/dynamic-source-select.vue +0 -440
  72. package/packages/dynamic-source-select/src/events.js +0 -55
  73. package/packages/fs-preview/index.js +0 -6
  74. package/packages/fs-preview/src/fs-preview.vue +0 -226
  75. package/packages/fs-upload/index.js +0 -6
  76. package/packages/fs-upload/src/fs-upload-multi.vue +0 -420
  77. package/packages/fs-upload/src/fs-upload-single.vue +0 -312
  78. package/packages/fs-upload/src/fs-upload.vue +0 -189
  79. package/packages/fs-upload/src/see-big-picture.vue +0 -55
  80. package/packages/fs-upload-list/index.js +0 -6
  81. package/packages/fs-upload-list/src/fs-upload-list.vue +0 -287
  82. package/packages/hamburger/index.js +0 -6
  83. package/packages/hamburger/src/hamburger.vue +0 -38
  84. package/packages/index.js +0 -121
  85. package/packages/multipart-upload/index.js +0 -6
  86. package/packages/multipart-upload/src/index.vue +0 -73
  87. package/packages/multipart-upload/src/multipart-upload-form.vue +0 -297
  88. package/packages/multipart-upload/src/multipart-upload-list.vue +0 -378
  89. package/packages/organization-input/index.js +0 -6
  90. package/packages/organization-input/src/organization-input.vue +0 -542
  91. package/packages/plugins/export-data-new.js +0 -453
  92. package/packages/plugins/export-data.js +0 -361
  93. package/packages/plugins/index.js +0 -15
  94. package/packages/plugins/public-method.js +0 -43
  95. package/packages/remove-department/index.js +0 -6
  96. package/packages/remove-department/src/remove-department.vue +0 -172
  97. package/packages/remove-department/src/remove-dept-service.js +0 -20
  98. package/packages/remove-user/index.js +0 -6
  99. package/packages/remove-user/src/remove-user-service.js +0 -20
  100. package/packages/remove-user/src/remove-user.vue +0 -195
  101. package/packages/remove-workgroup/index.js +0 -6
  102. package/packages/remove-workgroup/src/remove-workgroup-service.js +0 -20
  103. package/packages/remove-workgroup/src/remove-workgroup.vue +0 -159
  104. package/packages/rich-editor/index.js +0 -7
  105. package/packages/rich-editor/index.vue +0 -278
  106. package/packages/rich-editor/langs/zh-Hans.js +0 -1
  107. package/packages/rich-editor/viewer.vue +0 -103
  108. package/packages/scan-code-input/index.js +0 -6
  109. package/packages/scan-code-input/src/events.js +0 -33
  110. package/packages/scan-code-input/src/scan-code-input-colse.vue +0 -131
  111. package/packages/scan-code-input/src/scan-code-input.vue +0 -116
  112. package/packages/secret-info/index.js +0 -7
  113. package/packages/secret-info/index.vue +0 -90
  114. package/packages/super-grid/index.js +0 -7
  115. package/packages/super-grid/src/apis.js +0 -763
  116. package/packages/super-grid/src/columns-config.vue +0 -335
  117. package/packages/super-grid/src/custom-formatter.js +0 -250
  118. package/packages/super-grid/src/dynamic-input.vue +0 -1279
  119. package/packages/super-grid/src/eventBus.js +0 -2
  120. package/packages/super-grid/src/events.js +0 -55
  121. package/packages/super-grid/src/formValidatorUtil.js +0 -226
  122. package/packages/super-grid/src/formatter.js +0 -181
  123. package/packages/super-grid/src/group-column.vue +0 -100
  124. package/packages/super-grid/src/header-context-menu.vue +0 -87
  125. package/packages/super-grid/src/index-column.vue +0 -51
  126. package/packages/super-grid/src/normal-column.vue +0 -769
  127. package/packages/super-grid/src/public-methods.js +0 -31
  128. package/packages/super-grid/src/row-operation.vue +0 -161
  129. package/packages/super-grid/src/search-button.vue +0 -66
  130. package/packages/super-grid/src/search-condition-input.vue +0 -61
  131. package/packages/super-grid/src/search-condition-list.vue +0 -59
  132. package/packages/super-grid/src/search-form-advancedQuery.vue +0 -653
  133. package/packages/super-grid/src/search-form-dialog.vue +0 -79
  134. package/packages/super-grid/src/search-form-item.vue +0 -386
  135. package/packages/super-grid/src/search-form-number.vue +0 -38
  136. package/packages/super-grid/src/search-form-open.vue +0 -162
  137. package/packages/super-grid/src/search-form-ordinarySearch.vue +0 -188
  138. package/packages/super-grid/src/search-form.vue +0 -634
  139. package/packages/super-grid/src/search-methods.js +0 -387
  140. package/packages/super-grid/src/selection-column.vue +0 -43
  141. package/packages/super-grid/src/store.js +0 -3
  142. package/packages/super-grid/src/super-grid-service.js +0 -561
  143. package/packages/super-grid/src/super-grid.vue +0 -2829
  144. package/packages/super-grid/src/utils.js +0 -763
  145. package/packages/super-grid/src/view-image-dialog.vue +0 -130
  146. package/packages/super-nine-grid/index.js +0 -7
  147. package/packages/super-nine-grid/src/apis.js +0 -103
  148. package/packages/super-nine-grid/src/custom-formatter.js +0 -66
  149. package/packages/super-nine-grid/src/formatter.js +0 -132
  150. package/packages/super-nine-grid/src/search-form-number.vue +0 -38
  151. package/packages/super-nine-grid/src/search-form.vue +0 -430
  152. package/packages/super-nine-grid/src/search-methods.js +0 -134
  153. package/packages/super-nine-grid/src/store.js +0 -3
  154. package/packages/super-nine-grid/src/super-grid-service.js +0 -91
  155. package/packages/super-nine-grid/src/super-nine-grid.vue +0 -872
  156. package/packages/super-nine-grid/src/utils.js +0 -261
  157. package/packages/svg-icon/index.js +0 -6
  158. package/packages/svg-icon/src/svg-icon.vue +0 -43
  159. package/packages/utils/utils.js +0 -152
  160. package/packages/utils/value-set.js +0 -86
  161. package/packages/valid-code/index.js +0 -7
  162. package/packages/valid-code/src/valid-code.vue +0 -95
  163. package/packages/workflow-button/index.js +0 -6
  164. package/packages/workflow-button/src/workflow-button.vue +0 -325
  165. package/packages/workflow-history-list/index.js +0 -6
  166. package/packages/workflow-history-list/src/api.js +0 -7
  167. package/packages/workflow-history-list/src/workflow-history-list.vue +0 -185
  168. package/packages/workgroup-tree/index.js +0 -6
  169. package/packages/workgroup-tree/src/workgroup-tree.vue +0 -76
  170. package/packages/workgroup-tree-inline/index.js +0 -6
  171. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +0 -317
  172. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +0 -43
  173. package/packages/workgroup-user-tree/index.js +0 -6
  174. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +0 -100
  175. package/packages/workgroup-user-tree-inline/index.js +0 -6
  176. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +0 -163
  177. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +0 -436
  178. package/packages/year-range-picker/index.js +0 -6
  179. package/packages/year-range-picker/src/year-range-picker.vue +0 -51
  180. package/src/index.js +0 -93
  181. package/src/styles/theme/gray/form-style.scss +0 -41
@@ -1,763 +0,0 @@
1
- import store from './store'
2
- import {
3
- setCurrentRow,
4
- isEditOptionFunction,
5
- isLastEditRowSave,
6
- isHasEditOption,
7
- scrollYToBottom
8
- } from './utils'
9
- import formValidatorService from './formValidatorUtil'
10
- import Vue from 'vue'
11
- import {
12
- getEntityFieldValue,
13
- getI18n,
14
- setEntityFieldValue,
15
- getPropValue
16
- } from '../../../src/utils/util'
17
- import eventBus from './eventBus'
18
- const apis = {
19
- // 刷新列表数据
20
- refresh(parentRowIds, isLineEdit, toolbarFieldParam, isDeleteSubTableData) {
21
- return new Promise((resolve, reject) => {
22
- if (isDeleteSubTableData) {
23
- // 清空options.subTableData
24
- const gridParams = store.get(this.code)
25
- this.$set(gridParams.options, 'subTableData', null)
26
- }
27
- if (toolbarFieldParam && toolbarFieldParam.length > 0) {
28
- this.toolbarFieldParam = toolbarFieldParam
29
- }
30
- if (this.$refs) {
31
- if (typeof (parentRowIds) !== 'undefined' && parentRowIds !== null && parentRowIds instanceof Array && parentRowIds.length > 0) {
32
- // 树形数据时,刷新父记录对应的子记录集合时
33
- if (this.$refs.sf) {
34
- let param = this.$refs.sf.packageSearchParam()
35
- if (param && param.length > 0) {
36
- if (toolbarFieldParam && toolbarFieldParam.length > 0) {
37
- if (param.length === 1) {
38
- param[0].leftBracket = '('
39
- param[0].rightBracket = ')'
40
- }
41
- if (param[param.length - 1].joinSign === 'or') {
42
- param[param.length - 1].joinSign = 'and'
43
- }
44
- // 拼接
45
- Array.prototype.push.apply(param, toolbarFieldParam)
46
- }
47
- } else {
48
- if (toolbarFieldParam) {
49
- param = []
50
- param = toolbarFieldParam
51
- }
52
- }
53
- this.search(param, false, parentRowIds).then(() => resolve()).catch(error => reject(error))
54
- } else {
55
- this.search(toolbarFieldParam, false, parentRowIds).then(() => resolve()).catch(error => reject(error))
56
- }
57
- } else {
58
- // 刷新列表数据
59
- if (this.$refs.sf) {
60
- let param = this.$refs.sf.packageSearchParam()
61
- if (param && param.length > 0) {
62
- if (toolbarFieldParam && toolbarFieldParam.length > 0) {
63
- if (param.length === 1) {
64
- param[0].leftBracket = '('
65
- param[0].rightBracket = ')'
66
- }
67
- if (param[param.length - 1].joinSign === 'or') {
68
- param[param.length - 1].joinSign = 'and'
69
- }
70
- // 拼接
71
- // param.concat(toolbarFieldParam)
72
- Array.prototype.push.apply(param, toolbarFieldParam)
73
- }
74
- } else {
75
- if (toolbarFieldParam) {
76
- param = []
77
- param = toolbarFieldParam
78
- }
79
- }
80
- this.search(param, false).then(() => resolve()).catch(error => reject(error))
81
- } else {
82
- this.search(toolbarFieldParam, false).then(() => resolve()).catch(error => reject(error))
83
- }
84
- }
85
- } else {
86
- resolve()
87
- }
88
- })
89
- },
90
- // 显示查询
91
- showSearchForm() {
92
- this.showSearch = true
93
- this.$emit('showSearch')
94
- },
95
- // 取消查询
96
- cancelSearch() {
97
- this.showSearch = false
98
- this.$emit('cancelSearch')
99
- },
100
- // 获得查询条件
101
- getSearchForm() {
102
- const gridParams = store.get(this.code)
103
- if (gridParams.searchForm) {
104
- return gridParams.searchForm
105
- } else {
106
- return []
107
- }
108
- },
109
- // 新建行
110
- createRow(listCode, row) {
111
- return new Promise((resolve, reject) => {
112
- if (!listCode) {
113
- listCode = store.get('_list_code')
114
- }
115
- const gridParams = store.get(listCode)
116
- const gridData = gridParams.gridData
117
- gridParams.superGrid.clearSort()
118
- // console.log('创建行记录的条件1', gridParams.lineEdit)
119
- // console.log('创建行记录的条件2', gridParams.lineEdit.editable)
120
- // console.log('创建行记录的条件3', gridParams.loaded)
121
- if (gridParams.lineEdit && gridParams.lineEdit.editable &&
122
- (typeof (gridParams.loaded) !== 'undefined' && gridParams.loaded === true)) {
123
- // gridParams.loaded表示列表数据是否已加载成功,加载成功才允许新建记录
124
- // 插入行前的回调
125
- let canCreate = true
126
- if (isEditOptionFunction('beforeInsertRow', listCode)) {
127
- const isSubTableShowPage = gridParams.isSubTableShowPage
128
- // 每页显示多少条
129
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
130
- const isMobile = false
131
- canCreate = gridParams.options.lineEditOptions.beforeInsertRow.call(this, isSubTableShowPage ? gridParams.subTableData : gridParams.gridData, gridParams.$rowIndex, isMobile, this.baseURL, isSubTableShowPage ? gridParams.gridData : null, pageSize)
132
- }
133
- // console.log('创建行记录执行前判断', canCreate)
134
- // console.log('创建行记录gridParams.options.isFormSubTable=', gridParams.options.isFormSubTable)
135
- if (canCreate === undefined || canCreate === true) {
136
- if (gridParams.options && gridParams.options.isFormSubTable) {
137
- // 如果是表单子表模式,则不需要判断上一行是否是编辑状态
138
- // 取消上一行的编辑状态
139
- let myGridData = gridParams.gridData
140
- if (gridParams.isSubTableShowPage !== undefined && gridParams.isSubTableShowPage === true) {
141
- // 子表集合
142
- myGridData = gridParams.subTableData
143
- }
144
- const editRows = myGridData.filter((row) => (row.$editing !== undefined && row.$editing === true))
145
- if (editRows && editRows.length > 0) {
146
- editRows.forEach(editRow => {
147
- setEntityFieldValue(editRow, '$editing', false)
148
- // Vue.set(editRow, '$editing', false)
149
- })
150
- }
151
- gridParams.isEditRow = false
152
- } else {
153
- if ((!isLastEditRowSave(listCode)) || (typeof (gridParams.isCreateRow) !== 'undefined' && gridParams.isCreateRow === true)) {
154
- // 最后编辑的一行没有保存 或(说明刚刚新建的行还没有保存 或 撤销编辑),则提示
155
- Vue.prototype.$message({
156
- showClose: true,
157
- message: getI18n().t('superGrid.pleaseSaveLine', {
158
- row: (gridParams.$rowIndex + 1)
159
- }),
160
- type: 'warning'
161
- })
162
- reject(new Error('please save line'))
163
- return
164
- }
165
- // 取消上一行的编辑状态
166
- if (typeof (gridParams.$rowIndex) !== 'undefined' && gridParams.$rowIndex !== null &&
167
- gridParams.$rowIndex < gridParams.gridData.length) {
168
- // 表示是有效行
169
- const lastEditRow = gridParams.gridData[gridParams.$rowIndex]
170
- setEntityFieldValue(lastEditRow, '$editing', false)
171
- // Vue.set(lastEditRow, '$editing', false)
172
- gridParams.isEditRow = false
173
- }
174
- }
175
- // 新建行
176
- row = this.getNewRow(gridParams.defaultValueColumns, gridParams.additionalParamMap, gridParams.contextParameter, row)
177
-
178
- // console.log('创建行记录要添加的新行1', row)
179
- setEntityFieldValue(row, '$editing', true)
180
- // Vue.set(row, '$editing', true)
181
- gridParams.isEditRow = true
182
- // console.log('创建行记录要添加的新行2', row)
183
- // console.log('创建行所属的list1', gridData)
184
- if (gridParams.options && gridParams.options.isFormSubTable) {
185
- // 表单的子表行编辑时显示是添加到最后面
186
- if (gridParams.isSubTableShowPage !== undefined && gridParams.isSubTableShowPage === true) {
187
- // 子表集合添加该新建的行。会触发watch subTableData的监控
188
- gridParams.isChangePage = true
189
- gridParams.subTableData.splice(gridParams.subTableData.length, 0, row)
190
- } else {
191
- // 子表不分页
192
- gridData.splice(gridData.length, 0, row)
193
- if (gridParams.lineEdit.editingCell) {
194
- gridParams.lineEdit.editingCell.row = gridData.length
195
- }
196
- }
197
-
198
- gridParams.$rowIndex = gridData.length
199
- // 滚动条滚到最后
200
- this.$nextTick(() => {
201
- scrollYToBottom(listCode)
202
- })
203
- } else {
204
- // 表格行编辑新建时是添加到最前面
205
- gridData.splice(0, 0, row)
206
- if (gridParams.lineEdit.editingCell) {
207
- gridParams.lineEdit.editingCell.row = 0
208
- }
209
-
210
- gridParams.$rowIndex = 0
211
- }
212
-
213
- // console.log('创建行所属的list2', gridData)
214
- // console.log('创建行所属的打印gridParams.gridData', gridParams.gridData)
215
- const orgRow = Object.assign({}, row)
216
- gridParams.orgGridData.splice(0, 0, orgRow)
217
- if (!gridParams.lineEdit.editingCell) {
218
- gridParams.lineEdit.editingCell = {}
219
- gridParams.lineEdit.validateErrorField = ''
220
- }
221
- // 插入行后的回调
222
- if (isEditOptionFunction('afterInsertRow', listCode)) {
223
- const isSubTableShowPage = gridParams.isSubTableShowPage
224
- // 每页显示多少条
225
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
226
- const isMobile = false
227
- gridParams.options.lineEditOptions.afterInsertRow.call(this, isSubTableShowPage ? gridParams.subTableData : gridParams.gridData, gridParams.$rowIndex, isMobile, this.baseURL, isSubTableShowPage ? gridParams.gridData : null, pageSize)
228
- }
229
-
230
- gridParams.isCreateRow = true
231
- resolve(row)
232
- } else {
233
- reject(new Error('can not create'))
234
- }
235
- } else {
236
- reject(new Error('list not editable or data not loaded completely'))
237
- }
238
- })
239
- },
240
- // 获取一个新的对象,已经解析完默认值
241
- getNewRow(defaultValueColumns, additionalParamMap, contextParameter, row, listCode) {
242
- if (!row) {
243
- row = {}
244
- }
245
- if (!listCode) {
246
- listCode = store.get('_list_code')
247
- }
248
- const gridParams = store.get(listCode)
249
- if (gridParams && gridParams.allColumns) {
250
- this.setColumnsDefaultValue(gridParams.allColumns, row)
251
- }
252
- if (defaultValueColumns && defaultValueColumns.length > 0) {
253
- for (var i = 0; i < defaultValueColumns.length; i++) {
254
- const col = defaultValueColumns[i]
255
- if (col && col.prop) {
256
- const propValue = getEntityFieldValue(row, col.prop)
257
- if (col.prop !== '$selection' && col.prop !== '$index') {
258
- if (col.defaultValue && col.defaultValue !== '' && (propValue === undefined || propValue === '' || propValue === null)) {
259
- const value = getPropValue(col.defaultValue, row, additionalParamMap, contextParameter)
260
- setEntityFieldValue(row, col.prop, value)
261
- }
262
- }
263
- }
264
- }
265
- }
266
- return row
267
- },
268
- // 设置默认值null
269
- setColumnsDefaultValue(allColumns, row) {
270
- for (let i = 0; i < allColumns.length; i++) {
271
- const column = allColumns[i]
272
- const prop = column.prop
273
- if (prop === '$index' || prop === '$selection' || prop === 'operation') {
274
- continue
275
- }
276
- if (column.hasOwnProperty('children')) {
277
- // 表示是组合表头,需要判断子表头是否显示
278
- this.setChildrenColumnsDefaultValue(column.children, row)
279
- } else {
280
- if (row[prop] === undefined) {
281
- // 不是操作列,才需要设值
282
- setEntityFieldValue(row, prop, null)
283
- }
284
- }
285
- }
286
- setEntityFieldValue(row, '$editing', false)
287
- },
288
- setChildrenColumnsDefaultValue(children, row) {
289
- for (let i = 0; i < children.length; i++) {
290
- const column = children[i]
291
- const prop = column.prop
292
- if (column.hasOwnProperty('children')) {
293
- // 表示是组合表头,需要判断子表头是否显示
294
- this.setChildrenColumnsDefaultValue(column.children, row)
295
- } else {
296
- if (row[prop] === undefined) {
297
- if (prop !== 'operation') {
298
- // 不是操作列,才需要设值
299
- setEntityFieldValue(row, prop, null)
300
- }
301
- }
302
- }
303
- }
304
- },
305
- // 编辑行
306
- editRow(rowIndex, listCode, isSaveCallback) {
307
- if (!listCode) {
308
- listCode = store.get('_list_code')
309
- }
310
- const gridParams = store.get(listCode)
311
- if (gridParams && gridParams.lineEdit && gridParams.lineEdit.editable) {
312
- if (typeof (gridParams.$rowIndex) !== 'undefined' && gridParams.$rowIndex !== null && gridParams.$rowIndex !== rowIndex) {
313
- // 不是当前编辑行时
314
- if (typeof (gridParams.options.lineEditOptions.autoSave) === 'undefined' ||
315
- (isHasEditOption('autoSave', listCode) && gridParams.options.lineEditOptions.autoSave === true)) {
316
- // 自动保存行数据
317
- if (!isSaveCallback) {
318
- // 点击了“编辑”按钮时需要走,不是自动保存行数据后回调方法中调用的editRow时
319
- this.saveRow(gridParams.$rowIndex, listCode)
320
- .then((res) => {
321
- this.editRow(rowIndex, listCode, true)
322
- })
323
- return
324
- }
325
- } else {
326
- // 如果不自动保存,则提示数据没有保存,让用户自己保存
327
- if (!isLastEditRowSave(listCode)) {
328
- // 最后编辑的一行没有保存,则提示
329
- Vue.prototype.$message({
330
- showClose: true,
331
- message: getI18n().t('superGrid.pleaseSaveLine', {
332
- row: (gridParams.$rowIndex + 1)
333
- }),
334
- type: 'warning'
335
- })
336
- return
337
- }
338
- }
339
- }
340
-
341
- let canEdit = true
342
- if (isEditOptionFunction('beforeEdit', listCode)) {
343
- const isSubTableShowPage = gridParams.isSubTableShowPage
344
- // 每页显示多少条
345
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
346
- canEdit = gridParams.options.lineEditOptions.beforeEdit.call(this, {
347
- gridData: isSubTableShowPage ? gridParams.subTableData : gridParams.gridData,
348
- listCode: listCode,
349
- entity: gridParams.gridData[rowIndex],
350
- rowIndex: rowIndex,
351
- columns: gridParams.columns,
352
- isMobile: false,
353
- pageGridData: isSubTableShowPage ? gridParams.gridData : null,
354
- pageSize
355
- })
356
- }
357
- if (canEdit === undefined || canEdit === true) {
358
- // 取消上一行的编辑状态
359
- if (typeof (gridParams.$rowIndex) !== 'undefined' && gridParams.$rowIndex !== null &&
360
- gridParams.$rowIndex < gridParams.gridData.length) {
361
- const lastEditRow = gridParams.gridData[gridParams.$rowIndex]
362
- setEntityFieldValue(lastEditRow, '$editing', false)
363
- // Vue.set(lastEditRow, '$editing', false)
364
- gridParams.isEditRow = false
365
- }
366
- // 使指定行变为编辑状态
367
- const row = gridParams.gridData[rowIndex]
368
- setEntityFieldValue(row, '$editing', true)
369
- // Vue.set(row, '$editing', true)
370
- gridParams.$lastSaveRowIndex = null
371
- gridParams.$rowIndex = rowIndex
372
- gridParams.isEditRow = true
373
- // 使指定行变为编辑状态,触发获得焦点
374
- if (gridParams.lineEdit.editingCell) {
375
- gridParams.lineEdit.editingCell.row = rowIndex
376
- }
377
- }
378
- }
379
- },
380
- saveRow(rowIndex, listCode) {
381
- return new Promise((resolve, reject) => {
382
- const vm = this
383
- // 添加setTimeout是因为保存时事件和input等组件的@blur冲突,导致保存需要保存两次
384
- setTimeout(function() {
385
- vm.saveCurrentRow(rowIndex, listCode).then(data => {
386
- resolve(data)
387
- })
388
- }, 100)
389
- })
390
- },
391
- saveCurrentRow(rowIndex, listCode) {
392
- return new Promise((resolve, reject) => {
393
- if (!listCode) {
394
- listCode = store.get('_list_code')
395
- }
396
- const gridParams = store.get(listCode)
397
- if (gridParams.lineEdit && gridParams.lineEdit.editable) {
398
- if (typeof (gridParams.gridData[rowIndex].$editing) === 'undefined' || gridParams.gridData[rowIndex].$editing === false) {
399
- Vue.prototype.$message({
400
- showClose: true,
401
- message: getI18n().t('superGrid.noNeedToSaveRow', {
402
- row: (rowIndex + 1)
403
- }),
404
- type: 'warning'
405
- })
406
- return
407
- }
408
- // console.log('gridParams', gridParams)
409
- if (gridParams.$rowIndex !== rowIndex && !isLastEditRowSave(listCode)) {
410
- // 最后编辑的一行没有保存,则提示
411
- Vue.prototype.$message({
412
- showClose: true,
413
- message: getI18n().t('superGrid.pleaseSaveLine', {
414
- row: (gridParams.$rowIndex + 1)
415
- }),
416
- type: 'warning'
417
- })
418
- return
419
- }
420
- gridParams.$lastSaveRowIndex = null
421
- if ((gridParams.isHasDynamic !== undefined && gridParams.isHasDynamic === false) && !gridParams.lineEdit.urlToSaveRow && !isHasEditOption('urlToSaveRow', listCode) && !isEditOptionFunction('saveRow', listCode)) {
422
- Vue.prototype.$message({
423
- showClose: true,
424
- message: getI18n().t('superGrid.pleaseSetURLToSaveRowInformation'),
425
- type: 'warning'
426
- })
427
- return
428
- }
429
- if (!gridParams.canSaveRow) {
430
- // 防止重复保存
431
- return
432
- }
433
- gridParams.canSaveRow = false
434
- const row = gridParams.gridData[rowIndex]
435
- let needValidate = true
436
- if (isHasEditOption('isEnableValidate', listCode)) {
437
- // 表示配置了是否启用必填验证
438
- needValidate = gridParams.options.lineEditOptions['isEnableValidate']
439
- }
440
- let validateResult = true
441
- if (needValidate === true) {
442
- validateResult = formValidatorService.validator(row, listCode, rowIndex)
443
- }
444
- if (validateResult === true) {
445
- let canSave = true
446
- if (isEditOptionFunction('beforeSave', listCode)) {
447
- canSave = gridParams.options.lineEditOptions['beforeSave'].call(this, row, gridParams.columns)
448
- }
449
- if (canSave === undefined || canSave === true) {
450
- // 触发点击保存时的事件线,在 normal-column 监听处对字段控件是选项组的字段的值进行处理
451
- eventBus.$emit('un-edit', { row })
452
- let additionalParamMap = null
453
- if (gridParams.additionalParamMap && typeof (gridParams.additionalParamMap) === 'object') {
454
- additionalParamMap = gridParams.additionalParamMap
455
- } else if (gridParams.additionalParamMap && gridParams.additionalParamMap !== '') {
456
- additionalParamMap = JSON.parse(gridParams.additionalParamMap)
457
- }
458
- let saveRowRequest
459
- if (isEditOptionFunction('saveRow', listCode)) {
460
- // 表示保存方法,用户自己重写了
461
- saveRowRequest = gridParams.options.lineEditOptions['saveRow'].call(this, row, gridParams.columns, gridParams.$dataTypeMap, gridParams.dynamicColumnInfo, additionalParamMap, gridParams.mainDefaultValueColumns)
462
- }
463
- if (!saveRowRequest && gridParams.lineEdit && gridParams.lineEdit.urlToSaveRow) {
464
- // 使用默认的保存实现
465
- let urlToSaveRow = gridParams.lineEdit.urlToSaveRow
466
- if (isHasEditOption('urlToSaveRow', listCode)) {
467
- // 表示手动配置了保存行记录的url
468
- urlToSaveRow = gridParams.options.lineEditOptions['urlToSaveRow']
469
- }
470
- saveRowRequest = Vue.prototype.$http.post(Vue.prototype.baseURL + urlToSaveRow, row)
471
- }
472
- if (gridParams.isHasDynamic !== undefined && gridParams.isHasDynamic === true && !saveRowRequest) {
473
- // 表示有动态列,保存时使用平台封装好的请求
474
- const urlToSaveRow = '/common/dynamic-values'
475
- const dynamicValueDTO = {
476
- mainTableName: gridParams.basicInfo && gridParams.basicInfo.tableName ? gridParams.basicInfo.tableName : '',
477
- row: row,
478
- dynamicColumnInfo: gridParams.dynamicColumnInfo,
479
- additionalParamMap: additionalParamMap,
480
- dataTypeMap: gridParams.$dataTypeMap,
481
- dynamicServiceName: gridParams.dynamicServiceName,
482
- mainDefaultValueColumns: gridParams.mainDefaultValueColumns
483
- }
484
- saveRowRequest = Vue.prototype.$http.post(Vue.prototype.baseURL + urlToSaveRow, dynamicValueDTO)
485
- }
486
- if (saveRowRequest) {
487
- saveRowRequest.then(data => {
488
- this.afterSave(gridParams, rowIndex, listCode, data, row).then(data => {
489
- resolve(data)
490
- }).catch(error => {
491
- reject(error)
492
- })
493
- }).catch(error => {
494
- gridParams.canSaveRow = true
495
- if (isEditOptionFunction('saveError', listCode)) {
496
- gridParams.options.lineEditOptions['saveError'].call(this, row, gridParams.columns, rowIndex, error)
497
- }
498
- reject(error)
499
- })
500
- } else {
501
- gridParams.canSaveRow = true
502
- reject(getI18n().t('saveRowRequest is undefined'))
503
- }
504
- } else {
505
- gridParams.canSaveRow = true
506
- reject(getI18n().t('superGrid.theReturnValueOfTheBeforesaveCallbackMethodIsFalse'))
507
- }
508
- } else {
509
- gridParams.canSaveRow = true
510
- reject(getI18n().t('imatrixUIMessage.validationFailed'))
511
- }
512
- }
513
- })
514
- },
515
- afterSave(gridParams, rowIndex, listCode, data, row) {
516
- return new Promise((resolve, reject) => {
517
- gridParams.isCreateRow = false
518
- gridParams.canSaveRow = true
519
- gridParams.$rowIndex = null
520
- // 当前是否有正在编辑的行
521
- gridParams.isEditRow = false
522
- gridParams.$lastSaveRowIndex = rowIndex
523
- Vue.prototype.$message({
524
- showClose: true,
525
- message: getI18n().t('superGrid.lineSavedSuccessfully', {
526
- row: (rowIndex + 1)
527
- }),
528
- type: 'success'
529
- })
530
- if (typeof (gridParams.options.lineEditOptions.aftersaveIsCancelEditState) === 'undefined' ||
531
- (isHasEditOption('aftersaveIsCancelEditState', listCode) &&
532
- gridParams.options.lineEditOptions.aftersaveIsCancelEditState === true)) {
533
- // 取消编辑状态
534
- setEntityFieldValue(row, '$editing', false)
535
- // Vue.set(row, '$editing', false)
536
- gridParams.isEditRow = false
537
- }
538
-
539
- if (isEditOptionFunction('saveSuccess', listCode)) {
540
- gridParams.options.lineEditOptions['saveSuccess'].call(this, data, gridParams.columns, rowIndex, row)
541
- }
542
- Object.assign(gridParams.orgGridData[rowIndex], data)
543
- // 必须加这句,否则连续保存时报事务异常
544
- Object.assign(gridParams.gridData[rowIndex], data)
545
- // 必须调用这句话,刷新一下列表,否则当前页总条数和记录总条数都会显示错误
546
- this.refresh(false, true)
547
- .then(() => {
548
- if (typeof (gridParams.options.lineEditOptions.aftersaveIsCreateRow) === 'undefined' || gridParams.options.lineEditOptions.aftersaveIsCreateRow) {
549
- this.createRow(listCode)
550
- }
551
- resolve({
552
- rowIndex,
553
- listCode
554
- })
555
- })
556
- .catch((error) => reject(error))
557
- })
558
- },
559
- restoreRow(rowIndex, listCode) {
560
- // 撤销当前行的编辑的信息
561
- return new Promise((resolve, reject) => {
562
- this.restoreCurrentRow(rowIndex, listCode)
563
- resolve()
564
- })
565
- },
566
- /**
567
- * 撤销当前指定编辑行的信息
568
- */
569
- restoreCurrentRow(rowIndex, listCode) {
570
- if (!listCode) {
571
- listCode = store.get('_list_code')
572
- }
573
- const gridParams = store.get(listCode)
574
- // console.log('restoreCurrentRow-gridParams.$rowIndex,rowIndex', gridParams.$rowIndex, rowIndex)
575
- if (gridParams.lineEdit && gridParams.lineEdit.editable) {
576
- if (gridParams.$rowIndex !== null && gridParams.$rowIndex !== rowIndex && !isLastEditRowSave(listCode)) {
577
- // 最后编辑的一行没有保存,则提示
578
- Vue.prototype.$message({
579
- showClose: true,
580
- message: getI18n().t('superGrid.pleaseSaveLine', {
581
- row: (gridParams.$rowIndex + 1)
582
- }),
583
- type: 'warning'
584
- })
585
- return
586
- }
587
- // true表示没有编辑任何字段,false表示当前行有编辑的字段
588
- const isUnEditing = gridParams.$lastSaveRowIndex !== null && gridParams.$lastSaveRowIndex === rowIndex && typeof (gridParams.gridData[rowIndex].id) !== 'undefined'
589
- let isValidate = true
590
- // 撤销编辑前的回调
591
- if (isEditOptionFunction('beforeRestoreValidate', listCode)) {
592
- const isSubTableShowPage = gridParams.isSubTableShowPage
593
- // 每页显示多少条
594
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
595
- const isMobile = false
596
- isValidate = gridParams.options.lineEditOptions.beforeRestoreValidate.call(this, { rowIndex, gridData: isSubTableShowPage ? gridParams.subTableData : gridParams.gridData, entity: gridParams.gridData[rowIndex], isMobile, baseURL: this.baseURL, isEditing: !isUnEditing, pageGridData: isSubTableShowPage ? gridParams.gridData : null, pageSize })
597
- }
598
- if (isValidate === undefined || isValidate === true) {
599
- // 例如:自定义验证成功,再继续平台的验证
600
- if (isUnEditing === true) {
601
- // 当前行已保存,已是最新数据,无需再撤销编辑
602
- // console.log('gridParams.gridData[rowIndex].id=', gridParams.gridData[rowIndex].id)
603
- Vue.prototype.$message({
604
- showClose: true,
605
- message: getI18n().t('superGrid.lineNoNeedToUndoEdit', {
606
- row: (rowIndex + 1)
607
- }),
608
- type: 'warning'
609
- })
610
- return
611
- }
612
- } else {
613
- return
614
- }
615
- let canRestore = true
616
- // 撤销编辑前的回调
617
- if (isEditOptionFunction('beforeRestore', listCode)) {
618
- const isSubTableShowPage = gridParams.isSubTableShowPage
619
- // 每页显示多少条
620
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
621
- const isMobile = false
622
- canRestore = gridParams.options.lineEditOptions.beforeRestore.call(this, { rowIndex, gridData: isSubTableShowPage ? gridParams.subTableData : gridParams.gridData, entity: gridParams.gridData[rowIndex], isMobile, baseURL: Vue.prototype.baseURL, isEditing: !isUnEditing, pageGridData: isSubTableShowPage ? gridParams.gridData : null, pageSize })
623
- }
624
- if (canRestore === undefined || canRestore === true) {
625
- // 如果没有编辑过任何行
626
- if (!gridParams.orgGridData[rowIndex].id && !gridParams.orgGridData[rowIndex].ID) {
627
- // 表示没有保存行数据,需要删除该行记录
628
- this.deleteRow(rowIndex, listCode, true)
629
- } else {
630
- // 这样写会导致“如果字段值原来是空的,输入了内容后,取消编辑没法把输入的值清空”问题
631
- // Object.assign(gridParams.gridData[rowIndex], gridParams.orgGridData[rowIndex])
632
- // 所以改成如下写法
633
- Vue.set(gridParams.gridData, rowIndex, JSON.parse(JSON.stringify(gridParams.orgGridData[rowIndex])))
634
- if (gridParams.isSubTableShowPage !== undefined && gridParams.isSubTableShowPage === true) {
635
- // 子表集合移除该行。会触发watch subTableData的监控
636
- const lastPageRowIndex = (this.currentPage - 1) * this.pageSize
637
- const subTableRowIndex = lastPageRowIndex + rowIndex
638
- Vue.set(gridParams.subTableData, subTableRowIndex, gridParams.gridData[rowIndex])
639
- }
640
- Vue.prototype.$message({
641
- showClose: true,
642
- message: getI18n().t('superGrid.lineCancelledSuccessfully', {
643
- row: (rowIndex + 1)
644
- }),
645
- type: 'success'
646
- })
647
-
648
- if (typeof (gridParams.options.lineEditOptions.afterRestoreIsCancelEditState) === 'undefined' ||
649
- (isHasEditOption('afterRestoreIsCancelEditState', listCode) &&
650
- gridParams.options.lineEditOptions.afterRestoreIsCancelEditState === true)) {
651
- // 取消编辑状态
652
- setEntityFieldValue(gridParams.gridData[rowIndex], '$editing', false)
653
- // Vue.set(gridParams.gridData[rowIndex], '$editing', false)
654
- gridParams.isEditRow = false
655
- }
656
- }
657
- gridParams.$rowIndex = null
658
- gridParams.isCreateRow = false
659
- // 撤销编辑后回调
660
- if (isEditOptionFunction('afterRestore', listCode)) {
661
- gridParams.options.lineEditOptions.afterRestore.call(this, rowIndex, gridParams.orgGridData[rowIndex])
662
- }
663
- }
664
- }
665
- },
666
- deleteRow(rowIndex, listCode, isRestore) {
667
- return new Promise((resolve, reject) => {
668
- if (!listCode) {
669
- listCode = store.get('_list_code')
670
- }
671
- const gridParams = store.get(listCode)
672
- let canDelete = true
673
- // 删除行记录前的回调
674
- if (isEditOptionFunction('beforeDelete', listCode)) {
675
- const isSubTableShowPage = gridParams.isSubTableShowPage
676
- // 每页显示多少条
677
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
678
- const gridData = isSubTableShowPage ? gridParams.subTableData : gridParams.gridData
679
- const isMobile = false
680
- canDelete = gridParams.options.lineEditOptions.beforeDelete.call(this, rowIndex, gridParams.gridData[rowIndex], gridData, isMobile, this.baseURL, isSubTableShowPage ? gridParams.gridData : null, pageSize)
681
- }
682
- if (canDelete === undefined || canDelete === true) {
683
- if (gridParams.isSubTableShowPage !== undefined && gridParams.isSubTableShowPage === true) {
684
- // 子表集合添加该新建的行。会触发watch subTableData的监控
685
- gridParams.isChangePage = true
686
- const lastPageRowIndex = (this.currentPage - 1) * this.pageSize
687
- const subTableRowIndex = lastPageRowIndex + rowIndex
688
-
689
- gridParams.subTableData.splice(subTableRowIndex, 1)
690
- } else {
691
- gridParams.gridData.splice(rowIndex, 1)
692
- gridParams.orgGridData.splice(rowIndex, 1)
693
- }
694
- // TODO 注释下面的代码,是因为表单子表删除记录时会造成未保存新增的记录的字段被清空的问题,不知道当时为什么要加这个代码
695
- // Object.assign(gridParams.gridData, gridParams.orgGridData)
696
- gridParams.$lastSaveRowIndex = null
697
- gridParams.$rowIndex = null
698
- gridParams.isEditRow = false
699
- Vue.prototype.$message({
700
- showClose: true,
701
- message: getI18n().t('superGrid.deleteSuccessful'),
702
- type: 'success'
703
- })
704
- if (gridParams.gridData.length === 0) {
705
- if (gridParams.options && gridParams.options.isDefaultShowEdit !== null &&
706
- gridParams.options.isDefaultShowEdit !== undefined && gridParams.options.isDefaultShowEdit === true) {
707
- // 表示没有记录时,需要创建新行
708
- this.createRow(listCode)
709
- }
710
- }
711
- if (gridParams.isMulitiSelect) {
712
- gridParams.superGrid.clearSelection()
713
- }
714
- gridParams.isCreateRow = false
715
- if (isRestore !== undefined && isRestore === true) {
716
- // 表示是删除操作,执行删除记录后回调
717
- if (isEditOptionFunction('afterDelete', listCode)) {
718
- const isSubTableShowPage = gridParams.isSubTableShowPage
719
- // 每页显示多少条
720
- const pageSize = gridParams.pagination && gridParams.pagination.pageSize
721
- const isMobile = false
722
- gridParams.options.lineEditOptions.afterDelete.call(this, rowIndex, gridParams.orgGridData[rowIndex], isSubTableShowPage ? gridParams.subTableData : gridParams.gridData, isMobile, this.baseURL, isSubTableShowPage ? gridParams.gridData : null, pageSize)
723
- }
724
- }
725
- }
726
-
727
- resolve()
728
- })
729
- },
730
- // 行编辑时,点击自定义组件时,使当前行获得焦点
731
- focus(rowIndex, listCode) {
732
- setCurrentRow(rowIndex, listCode)
733
- },
734
- // 获得列表所有数据
735
- getGridData(listCode) {
736
- if (!listCode) {
737
- listCode = store.get('_list_code')
738
- }
739
- const gridParams = store.get(listCode)
740
- const isSubTableShowPage = gridParams.isSubTableShowPage
741
- if (isSubTableShowPage) {
742
- return gridParams.subTableData
743
- } else {
744
- return gridParams.gridData
745
- }
746
- },
747
- // 获得字段配置
748
- getColumns(listCode) {
749
- if (!listCode) {
750
- listCode = store.get('_list_code')
751
- }
752
- const gridParams = store.get(listCode)
753
- return gridParams.columns
754
- },
755
- getPagination(listCode) {
756
- if (!listCode) {
757
- listCode = store.get('_list_code')
758
- }
759
- const gridParams = store.get(listCode)
760
- return gridParams.pagination
761
- }
762
- }
763
- export default apis