imatrix-ui 2.8.39-dw → 2.8.39-pvtmp

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 (189) hide show
  1. package/lib/super-ui.css +1 -1
  2. package/lib/super-ui.umd.min.js +5 -35
  3. package/package.json +6 -4
  4. package/packages/breadcrumb/index.js +6 -0
  5. package/packages/breadcrumb/src/breadcrumb.vue +71 -0
  6. package/packages/department-tree/index.js +6 -0
  7. package/packages/department-tree/src/department-tree.vue +108 -0
  8. package/packages/department-tree-inline/index.js +6 -0
  9. package/packages/department-tree-inline/src/department-multi-tree-inline.vue +411 -0
  10. package/packages/department-tree-inline/src/department-single-tree-inline.vue +293 -0
  11. package/packages/department-tree-inline/src/department-tree-inline.vue +86 -0
  12. package/packages/department-tree-inline/src/department-tree-service.js +275 -0
  13. package/packages/department-tree-inline/src/search-result.vue +176 -0
  14. package/packages/department-user-tree/index.js +6 -0
  15. package/packages/department-user-tree/src/department-user-multiple-tree.vue +116 -0
  16. package/packages/department-user-tree/src/department-user-single-tree.vue +76 -0
  17. package/packages/department-user-tree/src/department-user-tree.vue +101 -0
  18. package/packages/department-user-tree-inline/index.js +6 -0
  19. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +639 -0
  20. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +274 -0
  21. package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +79 -0
  22. package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +248 -0
  23. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +142 -0
  24. package/packages/department-user-tree-inline/src/search-result.vue +197 -0
  25. package/packages/directives/prevent-reclick.js +19 -0
  26. package/packages/dynamic-source-select/index.js +6 -0
  27. package/packages/dynamic-source-select/src/dynamic-source-select-service.js +75 -0
  28. package/packages/dynamic-source-select/src/dynamic-source-select.vue +586 -0
  29. package/packages/dynamic-source-select/src/events.js +55 -0
  30. package/packages/fs-preview/index.js +6 -0
  31. package/packages/fs-preview/src/fs-preview.vue +226 -0
  32. package/packages/fs-upload/index.js +6 -0
  33. package/packages/fs-upload/src/fs-upload-multi.vue +420 -0
  34. package/packages/fs-upload/src/fs-upload-single.vue +312 -0
  35. package/packages/fs-upload/src/fs-upload.vue +189 -0
  36. package/packages/fs-upload/src/see-big-picture.vue +55 -0
  37. package/packages/fs-upload-list/index.js +6 -0
  38. package/packages/fs-upload-list/src/fs-upload-list.vue +287 -0
  39. package/packages/hamburger/index.js +6 -0
  40. package/packages/hamburger/src/hamburger.vue +38 -0
  41. package/packages/index.js +121 -0
  42. package/packages/multipart-upload/index.js +6 -0
  43. package/packages/multipart-upload/src/index.vue +73 -0
  44. package/packages/multipart-upload/src/multipart-upload-form.vue +297 -0
  45. package/packages/multipart-upload/src/multipart-upload-list.vue +378 -0
  46. package/packages/organization-input/index.js +6 -0
  47. package/packages/organization-input/src/organization-input.vue +542 -0
  48. package/packages/plugins/export-data-new.js +468 -0
  49. package/packages/plugins/export-data.js +361 -0
  50. package/packages/plugins/index.js +15 -0
  51. package/packages/plugins/public-method.js +43 -0
  52. package/packages/remove-department/index.js +6 -0
  53. package/packages/remove-department/src/remove-department.vue +172 -0
  54. package/packages/remove-department/src/remove-dept-service.js +20 -0
  55. package/packages/remove-user/index.js +6 -0
  56. package/packages/remove-user/src/remove-user-service.js +20 -0
  57. package/packages/remove-user/src/remove-user.vue +195 -0
  58. package/packages/remove-workgroup/index.js +6 -0
  59. package/packages/remove-workgroup/src/remove-workgroup-service.js +20 -0
  60. package/packages/remove-workgroup/src/remove-workgroup.vue +159 -0
  61. package/packages/rich-editor/index.js +7 -0
  62. package/packages/rich-editor/index.vue +278 -0
  63. package/packages/rich-editor/langs/zh-Hans.js +1 -0
  64. package/packages/rich-editor/viewer.vue +103 -0
  65. package/packages/scan-code-input/index.js +6 -0
  66. package/packages/scan-code-input/src/events.js +33 -0
  67. package/packages/scan-code-input/src/scan-code-input-colse.vue +131 -0
  68. package/packages/scan-code-input/src/scan-code-input.vue +116 -0
  69. package/packages/secret-info/index.js +7 -0
  70. package/packages/secret-info/index.vue +90 -0
  71. package/packages/super-grid/index.js +7 -0
  72. package/packages/super-grid/src/apis.js +825 -0
  73. package/packages/super-grid/src/columns-config.vue +335 -0
  74. package/packages/super-grid/src/custom-formatter.js +280 -0
  75. package/packages/super-grid/src/dynamic-input.vue +1286 -0
  76. package/packages/super-grid/src/eventBus.js +2 -0
  77. package/packages/super-grid/src/events.js +55 -0
  78. package/packages/super-grid/src/formValidatorUtil.js +226 -0
  79. package/packages/super-grid/src/formatter.js +181 -0
  80. package/packages/super-grid/src/group-column.vue +100 -0
  81. package/packages/super-grid/src/header-context-menu.vue +87 -0
  82. package/packages/super-grid/src/index-column.vue +51 -0
  83. package/packages/super-grid/src/normal-column.vue +775 -0
  84. package/packages/super-grid/src/public-methods.js +31 -0
  85. package/packages/super-grid/src/row-operation.vue +161 -0
  86. package/packages/super-grid/src/search-button.vue +66 -0
  87. package/packages/super-grid/src/search-condition-input.vue +61 -0
  88. package/packages/super-grid/src/search-condition-list.vue +59 -0
  89. package/packages/super-grid/src/search-form-advancedQuery.vue +654 -0
  90. package/packages/super-grid/src/search-form-dialog.vue +79 -0
  91. package/packages/super-grid/src/search-form-item.vue +405 -0
  92. package/packages/super-grid/src/search-form-number.vue +38 -0
  93. package/packages/super-grid/src/search-form-open.vue +170 -0
  94. package/packages/super-grid/src/search-form-ordinarySearch.vue +196 -0
  95. package/packages/super-grid/src/search-form.vue +642 -0
  96. package/packages/super-grid/src/search-methods.js +448 -0
  97. package/packages/super-grid/src/selection-column.vue +43 -0
  98. package/packages/super-grid/src/store.js +3 -0
  99. package/packages/super-grid/src/super-grid-service.js +595 -0
  100. package/packages/super-grid/src/super-grid.vue +2936 -0
  101. package/packages/super-grid/src/utils.js +782 -0
  102. package/packages/super-grid/src/view-image-dialog.vue +130 -0
  103. package/packages/super-nine-grid/index.js +7 -0
  104. package/packages/super-nine-grid/src/apis.js +103 -0
  105. package/packages/super-nine-grid/src/custom-formatter.js +66 -0
  106. package/packages/super-nine-grid/src/formatter.js +131 -0
  107. package/packages/super-nine-grid/src/search-form-number.vue +38 -0
  108. package/packages/super-nine-grid/src/search-form.vue +430 -0
  109. package/packages/super-nine-grid/src/search-methods.js +134 -0
  110. package/packages/super-nine-grid/src/store.js +3 -0
  111. package/packages/super-nine-grid/src/super-grid-service.js +93 -0
  112. package/packages/super-nine-grid/src/super-nine-grid.vue +883 -0
  113. package/packages/super-nine-grid/src/utils.js +261 -0
  114. package/packages/svg-icon/index.js +6 -0
  115. package/packages/svg-icon/src/svg-icon.vue +43 -0
  116. package/packages/utils/memory-cache-utils.js +90 -0
  117. package/packages/utils/utils.js +152 -0
  118. package/packages/utils/value-set.js +86 -0
  119. package/packages/valid-code/index.js +7 -0
  120. package/packages/valid-code/src/valid-code.vue +95 -0
  121. package/packages/workflow-button/index.js +6 -0
  122. package/packages/workflow-button/src/workflow-button.vue +325 -0
  123. package/packages/workflow-history-list/index.js +6 -0
  124. package/packages/workflow-history-list/src/api.js +7 -0
  125. package/packages/workflow-history-list/src/workflow-history-list.vue +197 -0
  126. package/packages/workgroup-tree/index.js +6 -0
  127. package/packages/workgroup-tree/src/workgroup-tree.vue +77 -0
  128. package/packages/workgroup-tree-inline/index.js +6 -0
  129. package/packages/workgroup-tree-inline/src/search-result.vue +168 -0
  130. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +458 -0
  131. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +71 -0
  132. package/packages/workgroup-user-tree/index.js +6 -0
  133. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +100 -0
  134. package/packages/workgroup-user-tree-inline/index.js +6 -0
  135. package/packages/workgroup-user-tree-inline/src/search-result.vue +197 -0
  136. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +192 -0
  137. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +584 -0
  138. package/packages/year-range-picker/index.js +6 -0
  139. package/packages/year-range-picker/src/year-range-picker.vue +51 -0
  140. package/src/api/sso-service.js +9 -1
  141. package/src/api/tab.js +3 -3
  142. package/src/i18n/i18n.js +1 -1
  143. package/src/i18n/langs/cn.js +15 -5
  144. package/src/i18n/langs/en.js +15 -5
  145. package/src/index.js +93 -0
  146. package/src/permission.js +51 -17
  147. package/src/plugins.js +3 -3
  148. package/src/store/getters.js +2 -1
  149. package/src/store/modules/app.js +10 -1
  150. package/src/store/modules/user.js +11 -18
  151. package/src/styles/display-layout.scss +34 -0
  152. package/src/styles/index.scss +32 -4
  153. package/src/styles/theme/dark-blue/button.scss +9 -0
  154. package/src/styles/theme/dark-blue/card.scss +64 -0
  155. package/src/styles/theme/dark-blue/checkbox.scss +10 -0
  156. package/src/styles/theme/dark-blue/dark-blue-var.scss +8 -0
  157. package/src/styles/theme/dark-blue/dialog.scss +21 -0
  158. package/src/styles/theme/dark-blue/element-variables.scss +7 -0
  159. package/src/styles/theme/dark-blue/font.scss +71 -0
  160. package/src/styles/theme/dark-blue/form.scss +51 -0
  161. package/src/styles/theme/dark-blue/index.scss +247 -0
  162. package/src/styles/theme/dark-blue/input.scss +15 -0
  163. package/src/styles/theme/dark-blue/pagination.scss +14 -0
  164. package/src/styles/theme/dark-blue/scrollbar-style.scss +32 -0
  165. package/src/styles/theme/dark-blue/sidebar.scss +296 -0
  166. package/src/styles/theme/dark-blue/tab.scss +83 -0
  167. package/src/styles/theme/dark-blue/table.scss +60 -0
  168. package/src/styles/theme/dark-blue/tree.scss +31 -0
  169. package/src/styles/theme/dark-blue/var.scss +1028 -0
  170. package/src/styles/theme/gray/input-style.scss +8 -0
  171. package/src/styles/theme/gray/sidebar.scss +14 -2
  172. package/src/utils/auth-api.js +171 -0
  173. package/src/utils/auth.js +75 -41
  174. package/src/utils/calculator/calculator-factory.js +2 -2
  175. package/src/utils/calculator/calculator-util.js +7 -7
  176. package/src/utils/common-util.js +134 -1
  177. package/src/utils/jump-page-utils.js +36 -10
  178. package/src/utils/menu.js +19 -0
  179. package/src/utils/permission.js +4 -0
  180. package/src/utils/permissionAuth.js +46 -25
  181. package/src/utils/request.js +65 -8
  182. package/src/utils/util.js +77 -29
  183. package/src/views/dsc-component/Sidebar/Item.vue +5 -5
  184. package/src/views/dsc-component/Sidebar/Link.vue +11 -2
  185. package/src/views/dsc-component/Sidebar/SidebarItem.vue +37 -21
  186. package/src/views/dsc-component/Sidebar/index.vue +24 -12
  187. package/src/views/dsc-component/tabs/tab-content.vue +18 -2
  188. package/src/views/layout/components/Breadcrumb/index.vue +1 -1
  189. package/src/views/login/index.vue +1 -1
@@ -0,0 +1,595 @@
1
+ /* eslint-disable no-undef */
2
+ import Sortable from 'sortablejs'
3
+ import Vue from 'vue'
4
+ import {
5
+ packageEnumAndBeanColumnValueSets
6
+ } from '../../utils/value-set'
7
+ import store from './store'
8
+ import {
9
+ isHasOptionFunction
10
+ } from './utils'
11
+ const superGridService = {
12
+ initialize() {
13
+ // const a = new Date().getTime()
14
+ return new Promise((resolve, reject) => {
15
+ const gridParams = store.get(this.code)
16
+ if (this.options.isAdministerListView) {
17
+ // 要从配置中实时获取页面的配置
18
+ // 根据this.options.showColumns设置显示的字段
19
+ this.getShowColumns(this.options.SuperGrid)
20
+ Object.assign(this, this.options.SuperGrid)
21
+ gridParams.isSql = this.isSql
22
+ gridParams.columns = this.columns
23
+ gridParams.query = this.query
24
+ gridParams.pagination = this.pagination
25
+ this.createBackgroundColorMap()
26
+ this.hasLoadedColumns = true
27
+ this.fetchData(null, null, null, null)
28
+ resolve()
29
+ } else {
30
+ const url = Vue.prototype.baseAPI + '/component/super-grids/' + this.code
31
+ const param = {}
32
+ const isSqlSetting = this.options.isSql
33
+ if (this.options && typeof (isSqlSetting) !== 'undefined') {
34
+ this.isSql = isSqlSetting
35
+ param.isSql = isSqlSetting + ''
36
+ }
37
+ param.publishVersion = this.publishVersion
38
+ if (this.options && typeof (this.options.isAdministerListView) !== 'undefined' && this.options.isAdministerListView) {
39
+ param.isAdminister = this.options.isAdministerListView + ''
40
+ }
41
+ let additionalParams
42
+ const additionalParamMap = sessionStorage.getItem('additionalParamMap')
43
+ if (additionalParamMap) {
44
+ // console.log('进入判断', additionalParamMap)
45
+ if (additionalParamMap && typeof (additionalParamMap) === 'object') {
46
+ additionalParams = JSON.stringify(additionalParamMap)
47
+ } else if (additionalParamMap && additionalParamMap !== '') {
48
+ additionalParams = additionalParamMap
49
+ }
50
+ }
51
+ if (this.options.additionalParamMap && typeof (this.options.additionalParamMap) === 'object') {
52
+ const optionParam = JSON.stringify(this.options.additionalParamMap)
53
+ if (additionalParams) {
54
+ Object.assign(additionalParams, optionParam)
55
+ } else {
56
+ additionalParams = optionParam
57
+ }
58
+ } else if (this.options.additionalParamMap && this.options.additionalParamMap !== '') {
59
+ const optionParam = this.options.additionalParamMap
60
+ if (additionalParams) {
61
+ Object.assign(additionalParams, optionParam)
62
+ } else {
63
+ additionalParams = optionParam
64
+ }
65
+ }
66
+ if (additionalParams) {
67
+ param.additionalParamMap = additionalParams
68
+ }
69
+ if (this.options.extraParam && this.options.extraParam.entityMap) {
70
+ this.parentFormData = this.options.extraParam.entityMap
71
+ }
72
+ this.isLoading = true
73
+ // 初始化组件时先获取元信息再获取数据,以后翻页、排序、查询不再去获取元数据了
74
+ this.$http.post(url, param).then(data => {
75
+ // const p1 = new Date().getTime()
76
+ // 判断是否查询组件渲染完之后查询
77
+ this.isLoadCompleteQuery(data.columns)
78
+ // 行编辑设置所有字段的默认值null时使用,优化行编辑性能
79
+ let allColumns = []
80
+ allColumns = allColumns.concat(JSON.parse(JSON.stringify(data.columns)))
81
+ // 根据this.options.showColumns设置显示的字段
82
+ this.getShowColumns(data)
83
+ // 将列表信息存入store缓存中,用来导出时获取国际化名
84
+ if (data.basicInfo) {
85
+ store.set(this.code + 'basicInfo', data.basicInfo)
86
+ }
87
+ if (this.options.pageSizes && data.pagination) {
88
+ // 组件的options属性配置中配置“可选行数”,已该配置为准
89
+ let pageSizeArr = null
90
+ const pageSizeStrs = this.options.pageSizes.split(',')
91
+ if (pageSizeStrs && pageSizeStrs.length > 0) {
92
+ pageSizeArr = []
93
+ for (var i = 0; i < pageSizeStrs.length; i++) {
94
+ pageSizeArr.push(pageSizeStrs[i] * 1)
95
+ }
96
+ data.pagination.pageSize = pageSizeArr[0]
97
+ }
98
+ data.pagination.layout = 'total, sizes, prev, pager, next, jumper'
99
+ data.pagination.pageSizes = pageSizeArr
100
+ }
101
+ if (typeof (this.options.initSortInfo) !== 'undefined') {
102
+ // 组件的options属性配置中配置“排序信息”,以该配置为准
103
+ if (Array.isArray(this.options.initSortInfo)) {
104
+ data.sortInfo = this.options.initSortInfo
105
+ } else {
106
+ data.sortInfo = []
107
+ data.sortInfo.push(this.options.initSortInfo)
108
+ }
109
+ }
110
+
111
+ // 需要多个组件共享的数据放到store中,避免组件定义一堆props来接收这些共享数据
112
+ packageEnumAndBeanColumnValueSets(data.columns, this.code).then(() => {
113
+ return this.getDynamicColumnByBean(additionalParams, data.dynamicColumnInfo, data.columns, gridParams)
114
+ }).then((dynamicColumns) => {
115
+ // const b = new Date().getTime()
116
+ let showColumns = []
117
+ if (typeof (this.options.showColumns) !== 'undefined') {
118
+ showColumns = this.options.showColumns.split(',')
119
+ }
120
+ let customDynamicColumns = dynamicColumns
121
+ if (!customDynamicColumns || customDynamicColumns.length === 0) {
122
+ if (this.options.dynamicColumns && this.options.dynamicColumns.length > 0) {
123
+ customDynamicColumns = this.options.dynamicColumns
124
+ }
125
+ }
126
+ if (customDynamicColumns && customDynamicColumns.length > 0) {
127
+ allColumns = allColumns.concat(JSON.parse(JSON.stringify(customDynamicColumns)))
128
+ if (showColumns && showColumns.length > 0) {
129
+ for (let i = 0; i < customDynamicColumns.length; i++) {
130
+ const prop = customDynamicColumns[i].prop
131
+ customDynamicColumns[i].dynamic = true
132
+ if (showColumns.indexOf(prop) >= 0) {
133
+ customDynamicColumns[i].show = true
134
+ } else {
135
+ customDynamicColumns[i].show = false
136
+ }
137
+ }
138
+ }
139
+ data.columns = data.columns.concat(customDynamicColumns)
140
+ // 按照排序字段的值升序排列字段
141
+ data.columns = data.columns.sort((col1, col2) => col1.displayOrder - col2.displayOrder)
142
+ }
143
+ Object.assign(this, data)
144
+ if (this.options && typeof (isSqlSetting) === 'undefined') {
145
+ // 如果options中没有配置,则以后台传过来的为准,在有动态列配置时,该值会赋值为true
146
+ this.isSql = this.basicInfo.sql
147
+ }
148
+ gridParams.isSql = this.isSql
149
+ // 行编辑时使用
150
+ gridParams.allColumns = allColumns
151
+ gridParams.columns = this.columns
152
+ // 存放map,prop-columnOption。方便直接通过prop 获取对应的配置
153
+ this.packageColumnOptionMap(gridParams)
154
+ // const columnOptionMap = {}
155
+ // if (gridParams.columns && gridParams.columns.length > 0) {
156
+ // gridParams.columns.forEach(item => {
157
+ // if (item && item.prop) {
158
+ // columnOptionMap[item.prop] = item
159
+ // }
160
+ // })
161
+ // }
162
+ // gridParams.columnOptionMap = columnOptionMap
163
+ this.judgeIsFormSubTable()
164
+ gridParams.colSetting = this.colSetting
165
+ gridParams.lineEdit = this.lineEdit
166
+ gridParams.basicInfo = this.basicInfo
167
+ gridParams.pagination = this.pagination
168
+ if (this.pagination) {
169
+ // 监控每行显示多少条变量使用
170
+ this.pageSize = this.pagination.pageSize
171
+ }
172
+ gridParams.query = this.query
173
+ gridParams.dynamicColumnInfo = this.dynamicColumnInfo
174
+ gridParams.mainDefaultValueColumns = this.mainDefaultValueColumns
175
+ gridParams.contextParameter = this.contextParameter
176
+ // 是否显示分页区域
177
+ this.isShowPage = this.isShowPageArea()
178
+ // 子表是否分页
179
+ this.isSubTableShowPage = this.isFormSubTable ? this.isShowPage : false
180
+ gridParams.isSubTableShowPage = this.isSubTableShowPage
181
+ this.hasLoadedColumns = true
182
+ let canFetchData = true
183
+ if (isHasOptionFunction('loadBeforeSend', this.code)) {
184
+ canFetchData = gridParams.options.loadBeforeSend.call(this, {
185
+ columns: this.columns,
186
+ gridParams,
187
+ additionalParamMap: gridParams.additionalParamMap
188
+ })
189
+ }
190
+ if (canFetchData === undefined || canFetchData === true) {
191
+ // 表示初始化时查询记录
192
+ if (this.options.isPageInfo) {
193
+ // 表示是页面展示模式
194
+ } else if (typeof (this.options.initSearch) === 'undefined') {
195
+ if (typeof (gridParams.basicInfo.initializationQuery) === 'undefined' || gridParams.basicInfo.initializationQuery) {
196
+ // 判断是否初始化完查询条件后再查询数据
197
+ if (this.loadCompleteQuery) {
198
+ this.isLoading = false
199
+ } else {
200
+ this.fetchData()
201
+ }
202
+ }
203
+ } else if (this.options.initSearch !== false) {
204
+ // 判断是否初始化完查询条件后再查询数据
205
+ if (this.loadCompleteQuery) {
206
+ this.isLoading = false
207
+ } else {
208
+ this.fetchData()
209
+ }
210
+ }
211
+ }
212
+ this.createBackgroundColorMap()
213
+ // const p2 = new Date().getTime()
214
+ // console.log('拿到共享数据并存储p2-p1=', p2 - p1)
215
+ // console.log('拿到共享数据并存储p2-b=', p2 - b)
216
+ resolve()
217
+ }).catch(error => {
218
+ reject(error)
219
+ })
220
+ }).catch(error => {
221
+ reject(error)
222
+ })
223
+ }
224
+ // const a1 = new Date().getTime()
225
+ // console.log('初始化所耗时间', a1 - a)
226
+ })
227
+ },
228
+ isLoadCompleteQuery(columns) {
229
+ if (columns !== null) {
230
+ let queryParameterSize = 0
231
+ columns.forEach(column => {
232
+ if (column.hasOwnProperty('queryType') && column.hasOwnProperty('prop')) {
233
+ if (column.prop !== '$index' && column.prop !== '$selection') {
234
+ if (column.queryType && column.queryType !== 'no') {
235
+ // 配置了默认值
236
+ if (column.controlConfig) {
237
+ queryParameterSize++
238
+ }
239
+ }
240
+ }
241
+ }
242
+ })
243
+ if (queryParameterSize > 0) {
244
+ this.loadCompleteQuery = true
245
+ }
246
+ }
247
+ },
248
+ packageColumnOptionMap(gridParams) {
249
+ const columnOptionMap = {}
250
+ if (gridParams.columns && gridParams.columns.length > 0) {
251
+ this.packageColumnOptionMapItems(gridParams.columns, columnOptionMap)
252
+ }
253
+ gridParams.columnOptionMap = columnOptionMap
254
+ },
255
+ packageColumnOptionMapItems(columns, columnOptionMap) {
256
+ columns.forEach(item => {
257
+ if (item.children && item.children.length > 0) {
258
+ this.packageColumnOptionMapItems(item.children, columnOptionMap)
259
+ }
260
+ if (item && item.prop) {
261
+ columnOptionMap[item.prop] = item
262
+ }
263
+ })
264
+ },
265
+ getDynamicColumnByBean(additionalParams, dynamicColumnInfos, columns, gridParams) {
266
+ return new Promise((resolve, reject) => {
267
+ if (gridParams.options.extraParam && gridParams.options.extraParam.entityMap) {
268
+ this.parentFormData = gridParams.options.extraParam.entityMap
269
+ }
270
+ if (!this.options.isPageInfo && dynamicColumnInfos && dynamicColumnInfos.length > 0) {
271
+ const totalDynamicColumns = []
272
+ this.getDynamicColumnByBeanWithOneSet(additionalParams, dynamicColumnInfos[0], columns, 0, dynamicColumnInfos, totalDynamicColumns, gridParams).then(totalDynamicColumns => {
273
+ resolve(totalDynamicColumns)
274
+ }).catch(error => {
275
+ reject(error)
276
+ })
277
+ } else {
278
+ resolve([])
279
+ }
280
+ })
281
+ },
282
+ getDynamicColumnByBeanWithOneSet(additionalParams, dynamicColumnInfo, columns, index, dynamicColumnInfos, totalDynamicColumns, gridParams) {
283
+ return new Promise((resolve, reject) => {
284
+ if (dynamicColumnInfo && dynamicColumnInfo.beanName) {
285
+ const url = Vue.prototype.baseURL + '/common/dynamic-columns'
286
+ const param = {
287
+ additionalParams, // 附加参数对象
288
+ listCode: this.code,
289
+ columns,
290
+ beanName: dynamicColumnInfo.beanName
291
+ }
292
+ if (this.parentFormData) {
293
+ // 初始化表单时,加载动态列需要
294
+ if (gridParams.dynamicTemp) {
295
+ param.parent = gridParams.dynamicTemp.parent
296
+ param.watchParentAttrValues = gridParams.dynamicTemp.watchParentAttrValues
297
+ } else {
298
+ param.parent = this.parentFormData
299
+ }
300
+ // 监听主表字段的值
301
+ if (dynamicColumnInfo.watchParentAttr) {
302
+ const watchParentAttrs = dynamicColumnInfo.watchParentAttr.split(',')
303
+ watchParentAttrs.forEach(watchParentAttr => {
304
+ if (watchParentAttr) {
305
+ // 存储属性对应的值
306
+ if (!param.watchParentAttrValues) {
307
+ param.watchParentAttrValues = {}
308
+ }
309
+ param.watchParentAttrValues[watchParentAttr] = this.parentFormData[watchParentAttr]
310
+ const unWatch = this.$watch('parentFormData.' + watchParentAttr, function (newValue, oldValue) {
311
+ // 重新加载表格及表格数据
312
+ if (!gridParams.dynamicTemp) {
313
+ gridParams.dynamicTemp = {}
314
+ }
315
+ gridParams.dynamicTemp.parent = this.parentFormData
316
+ if (!gridParams.dynamicTemp.watchParentAttrValues) {
317
+ gridParams.dynamicTemp.watchParentAttrValues = {}
318
+ }
319
+ gridParams.dynamicTemp.watchParentAttrValues[watchParentAttr] = newValue
320
+ if (this.$refs && this.$refs.superGrid) {
321
+ // 手动注销watch,否则会调用多次watch
322
+ unWatch()
323
+ // 重新加载表格及表格数据
324
+ this.$emit('reload-grid')
325
+ }
326
+ })
327
+ }
328
+ })
329
+ }
330
+ }
331
+ this.$http.post(url, param).then(dynamicColumns => {
332
+ // 给动态列分组。如果是后台接口返回的动态列,保存时要自己实现动态列的保存
333
+ dynamicColumnInfo.dynamicColumns = dynamicColumns
334
+ totalDynamicColumns = totalDynamicColumns.concat(dynamicColumns)
335
+ if (index + 1 < dynamicColumnInfos.length) {
336
+ this.getDynamicColumnByBeanWithOneSet(additionalParams, dynamicColumnInfos[index + 1], columns, index + 1, dynamicColumnInfos, totalDynamicColumns)
337
+ } else {
338
+ resolve(totalDynamicColumns)
339
+ }
340
+ }).catch(() => {
341
+ resolve([])
342
+ })
343
+ } else {
344
+ resolve([])
345
+ }
346
+ })
347
+ },
348
+ // 列拖拽
349
+ columnDrop() {
350
+ const vm = this
351
+ // 作用于实际展示列表数据时拖拽列
352
+ let isDragColumnFlag = false
353
+ if (typeof (this.options.isDragColumnFlag) !== 'undefined' && this.options.isDragColumn != null &&
354
+ this.options.isDragColumn === true) {
355
+ isDragColumnFlag = true
356
+ const wrapperTr = document.querySelector('.el-table__header-wrapper tr')
357
+ if (wrapperTr != null) {
358
+ this.sortable = Sortable.create(wrapperTr, {
359
+ animation: 180,
360
+ delay: 0,
361
+ onEnd: evt => {
362
+ let oldIndex = evt.oldIndex
363
+ let newIndex = evt.newIndex
364
+ // 判断冻结列,获取真实index
365
+ const frozenArr = []
366
+ // const columns = this.listColumnList.filter(listColumn => {
367
+ // return listColumn.listColumnFixed === 'left' || listColumn.listColumnFixed === 'right'
368
+ // })
369
+ for (var r = 0; r < vm.columns.length; r++) {
370
+ if (vm.columns[r].fixed === 'left' || vm.columns[r].fixed === 'right') {
371
+ frozenArr.push(r)
372
+ }
373
+ }
374
+ if (frozenArr && frozenArr.length > 0) {
375
+ for (var m = 0; m < frozenArr.length; m++) {
376
+ if (frozenArr[m] >= newIndex) {
377
+ newIndex--
378
+ }
379
+ if (frozenArr[m] >= oldIndex) {
380
+ oldIndex--
381
+ }
382
+ }
383
+ }
384
+ if (oldIndex !== null && oldIndex !== undefined && oldIndex !== -1 && newIndex !== null && newIndex !== undefined && newIndex !== -1) {
385
+ if (oldIndex > newIndex) {
386
+ // 从后往前
387
+ if (vm.columns && vm.columns.length > 0) {
388
+ const item = vm.columns[oldIndex]
389
+ for (var i = oldIndex - 1; i >= newIndex; i--) {
390
+ const col = vm.columns[i]
391
+ col.displayOrderType = 'custom'
392
+ vm.columns[i + 1] = col
393
+ }
394
+ vm.columns[newIndex] = item
395
+ }
396
+ } else {
397
+ // 从前往后
398
+ if (vm.columns && vm.columns.length > 0) {
399
+ const item = vm.columns[oldIndex]
400
+ for (var k = oldIndex + 1; k <= newIndex; k++) {
401
+ const col = vm.columns[k]
402
+ col.displayOrderType = 'custom'
403
+ vm.columns[k - 1] = col
404
+ }
405
+ vm.columns[newIndex] = item
406
+ }
407
+ }
408
+ }
409
+ vm.indexAfterTheChangeUpdateDisplayOrder(vm.columns, oldIndex, newIndex, 'displayOrder')
410
+ let splitArr = []
411
+ if (oldIndex > newIndex) {
412
+ // 从后往前
413
+ splitArr = vm.columns.slice(newIndex, oldIndex + 1)
414
+ } else {
415
+ // 从前往后
416
+ splitArr = vm.columns.slice(oldIndex, newIndex + 1)
417
+ }
418
+ const params = {
419
+ listCode: vm.code,
420
+ columns: splitArr
421
+ }
422
+ vm.$http.post(Vue.prototype.baseAPI + '/component/super-grids/drag-columns', params).then(data => {
423
+ // console.log('移动成功')
424
+ })
425
+ // const oldIndex = evt.oldIndex
426
+ // const newIndex = evt.newIndex
427
+ // const currentItem = vm.columns[evt.oldIndex]
428
+ // const targetItem = vm.columns[evt.newIndex]
429
+ // const currentDisplayOrder = vm.getDisplayOrder(currentItem, oldIndex + 1)
430
+ // const targetDisplayOrder = vm.getDisplayOrder(targetItem, newIndex + 1)
431
+ // const params = {
432
+ // 'listCode': vm.code,
433
+ // 'oldIndex': currentDisplayOrder,
434
+ // 'newIndex': targetDisplayOrder,
435
+ // 'currentProp': currentItem.prop, // 当前拖动的列的属性名
436
+ // 'targetProp': targetItem.prop // 拖动的列的原属性名
437
+ // }
438
+ // vm.$http.post(Vue.prototype.baseAPI + '/component/super-grids/drag-columns', params).then(data => {
439
+ // vm.columns.splice(oldIndex, 1)
440
+ // vm.columns.splice(newIndex, 0, currentItem)
441
+ // vm.$set(currentItem, 'displayOrder', targetDisplayOrder)
442
+ // vm.$set(currentItem, 'displayOrderType', 'custom')
443
+ // vm.$set(targetItem, 'displayOrder', currentDisplayOrder)
444
+ // vm.$set(targetItem, 'displayOrderType', 'custom')
445
+ // })
446
+ }
447
+ })
448
+ }
449
+ }
450
+ // 作用于列表管理编辑模式
451
+ // 作用于列表管理编辑模式
452
+ if (typeof (this.options.isAdministerListView) !== 'undefined' && this.options.isAdministerListView != null &&
453
+ this.options.isAdministerListView === true && !isDragColumnFlag) {
454
+ const wrapperTr = document.querySelector('.el-table__header-wrapper tr')
455
+ if (wrapperTr != null) {
456
+ this.sortable = Sortable.create(wrapperTr, {
457
+ animation: 180,
458
+ delay: 0,
459
+ onEnd: evt => {
460
+ const oldIndex = evt.oldIndex
461
+ const newIndex = evt.newIndex
462
+ const oldItem = this.columns[evt.oldIndex]
463
+ const that = this
464
+ that.columns.splice(oldIndex, 1)
465
+ that.columns.splice(newIndex, 0, oldItem)
466
+ this.$emit('columnDrop', oldIndex, newIndex)
467
+ }
468
+ })
469
+ }
470
+ }
471
+ },
472
+ // 移动完成后的displayOrder设置
473
+ indexAfterTheChangeUpdateDisplayOrder(dataList, oldIndex, newIndex, prop) {
474
+ if (dataList && dataList.length > 0) {
475
+ if (oldIndex != null && oldIndex !== undefined && oldIndex !== -1) {
476
+ if (newIndex !== null && newIndex !== undefined && newIndex !== -1) {
477
+ if (prop && prop !== '') {
478
+ const selectCol = dataList[newIndex]
479
+ if (newIndex > oldIndex) {
480
+ // 表示向后移动
481
+ // 位置已经移动,所以参数要赋值给原始位置的下一个
482
+ const afProp = dataList[newIndex - 1][prop]
483
+ const arr = dataList.slice(oldIndex, newIndex)
484
+ if (arr && arr.length > 0) {
485
+ for (let i = arr.length - 1; i > -1; i--) {
486
+ const col = arr[i]
487
+ if (i === 0) {
488
+ // 紧靠原始位置的上一个
489
+ col[prop] = selectCol[prop]
490
+ } else {
491
+ col[prop] = arr[i - 1][prop]
492
+ }
493
+ }
494
+ }
495
+ selectCol[prop] = afProp
496
+ } else {
497
+ const befProp = dataList[newIndex + 1][prop]
498
+ // 表示向前移动
499
+ // 位置已经移动,所以参数要赋值给原始位置的上一个
500
+ const arr = dataList.slice(newIndex + 1, oldIndex + 1)
501
+ if (arr && arr.length > 0) {
502
+ for (let i = 0; i < arr.length; i++) {
503
+ const col = arr[i]
504
+ if (i === arr.length - 1) {
505
+ // 紧靠原始位置的上一个
506
+ col[prop] = selectCol[prop]
507
+ } else {
508
+ col[prop] = arr[i + 1][prop]
509
+ }
510
+ }
511
+ }
512
+ selectCol[prop] = befProp
513
+ }
514
+ }
515
+ }
516
+ }
517
+ }
518
+ },
519
+ getDisplayOrder(column, dragIndex) {
520
+ if (column && column.displayOrder !== undefined && column.displayOrder !== null) {
521
+ return column.displayOrder
522
+ } else {
523
+ return dragIndex + 1
524
+ }
525
+ },
526
+ getShowColumns(data) {
527
+ let showColumns = []
528
+ if (typeof (this.options.showColumns) !== 'undefined') {
529
+ showColumns = this.options.showColumns.split(',')
530
+ }
531
+ if (showColumns.length > 0) {
532
+ const columns = []
533
+ for (let i = 0; i < data.columns.length; i++) {
534
+ const column = data.columns[i]
535
+ const prop = column.prop
536
+ if (prop === '$index' || prop === '$selection') {
537
+ columns.push(column)
538
+ continue
539
+ }
540
+ if (column.hasOwnProperty('children')) {
541
+ // 表示是组合表头,需要判断子表头是否显示
542
+ const children = this.getChildrenColumns(column.children, showColumns)
543
+ column.children = children
544
+ if (children.length > 0) {
545
+ columns.push(column)
546
+ }
547
+ } else {
548
+ if (showColumns.indexOf(prop) >= 0) {
549
+ columns.push(column)
550
+ }
551
+ }
552
+ }
553
+ data.columns = columns
554
+ }
555
+ },
556
+ getChildrenColumns(children, showColumns) {
557
+ const columns = []
558
+ for (let i = 0; i < children.length; i++) {
559
+ const column = children[i]
560
+ const prop = column.prop
561
+ if (column.hasOwnProperty('children')) {
562
+ // 表示是组合表头,需要判断子表头是否显示
563
+ const children = this.getChildrenColumns(column.children, showColumns)
564
+ column.children = children
565
+ if (children.length > 0) {
566
+ columns.push(column)
567
+ }
568
+ } else {
569
+ if (showColumns.indexOf(prop) >= 0) {
570
+ columns.push(column)
571
+ }
572
+ }
573
+ }
574
+ return columns
575
+ },
576
+ // 保存拖动列宽
577
+ saveColumnWidth(prop, width) {
578
+ return new Promise((resolve, reject) => {
579
+ if (width !== undefined) {
580
+ const params = {
581
+ 'prop': prop,
582
+ 'width': width + ''
583
+ }
584
+ this.$http.post(Vue.prototype.baseAPI + '/component/super-grids/setting-column-widths/' + this.code, params).then(data => {
585
+ resolve(width)
586
+ }).catch(error => {
587
+ reject(error)
588
+ })
589
+ } else {
590
+ resolve()
591
+ }
592
+ })
593
+ }
594
+ }
595
+ export default superGridService