imatrix-ui 2.8.21-dw → 2.8.21

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 +4 -2
  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 +402 -0
  10. package/packages/department-tree-inline/src/department-single-tree-inline.vue +284 -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 +245 -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 +626 -0
  20. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +269 -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 +230 -0
  23. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +122 -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 +70 -0
  28. package/packages/dynamic-source-select/src/dynamic-source-select.vue +440 -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 +453 -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 +763 -0
  73. package/packages/super-grid/src/columns-config.vue +335 -0
  74. package/packages/super-grid/src/custom-formatter.js +250 -0
  75. package/packages/super-grid/src/dynamic-input.vue +1279 -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 +769 -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 +653 -0
  90. package/packages/super-grid/src/search-form-dialog.vue +79 -0
  91. package/packages/super-grid/src/search-form-item.vue +386 -0
  92. package/packages/super-grid/src/search-form-number.vue +38 -0
  93. package/packages/super-grid/src/search-form-open.vue +162 -0
  94. package/packages/super-grid/src/search-form-ordinarySearch.vue +188 -0
  95. package/packages/super-grid/src/search-form.vue +634 -0
  96. package/packages/super-grid/src/search-methods.js +387 -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 +561 -0
  100. package/packages/super-grid/src/super-grid.vue +2793 -0
  101. package/packages/super-grid/src/utils.js +763 -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 +132 -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 +91 -0
  112. package/packages/super-nine-grid/src/super-nine-grid.vue +872 -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/utils.js +152 -0
  117. package/packages/utils/value-set.js +86 -0
  118. package/packages/valid-code/index.js +7 -0
  119. package/packages/valid-code/src/valid-code.vue +95 -0
  120. package/packages/workflow-button/index.js +6 -0
  121. package/packages/workflow-button/src/workflow-button.vue +325 -0
  122. package/packages/workflow-history-list/index.js +6 -0
  123. package/packages/workflow-history-list/src/api.js +7 -0
  124. package/packages/workflow-history-list/src/workflow-history-list.vue +185 -0
  125. package/packages/workgroup-tree/index.js +6 -0
  126. package/packages/workgroup-tree/src/workgroup-tree.vue +76 -0
  127. package/packages/workgroup-tree-inline/index.js +6 -0
  128. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +317 -0
  129. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +43 -0
  130. package/packages/workgroup-user-tree/index.js +6 -0
  131. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +100 -0
  132. package/packages/workgroup-user-tree-inline/index.js +6 -0
  133. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +163 -0
  134. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +436 -0
  135. package/packages/year-range-picker/index.js +6 -0
  136. package/packages/year-range-picker/src/year-range-picker.vue +51 -0
  137. package/src/i18n/i18n.js +1 -1
  138. package/src/i18n/langs/cn.js +4 -2
  139. package/src/i18n/langs/en.js +4 -2
  140. package/src/index.js +93 -0
  141. package/src/permission.js +7 -3
  142. package/src/plugins.js +3 -3
  143. package/src/router/index.js +24 -0
  144. package/src/store/getters.js +2 -1
  145. package/src/store/modules/app.js +10 -1
  146. package/src/styles/display-layout.scss +34 -0
  147. package/src/styles/index.scss +32 -4
  148. package/src/styles/theme/dark-blue/button.scss +9 -0
  149. package/src/styles/theme/dark-blue/card.scss +64 -0
  150. package/src/styles/theme/dark-blue/checkbox.scss +10 -0
  151. package/src/styles/theme/dark-blue/dark-blue-var.scss +8 -0
  152. package/src/styles/theme/dark-blue/dialog.scss +21 -0
  153. package/src/styles/theme/dark-blue/element-variables.scss +7 -0
  154. package/src/styles/theme/dark-blue/font.scss +71 -0
  155. package/src/styles/theme/dark-blue/form.scss +51 -0
  156. package/src/styles/theme/dark-blue/index.scss +247 -0
  157. package/src/styles/theme/dark-blue/input.scss +15 -0
  158. package/src/styles/theme/dark-blue/pagination.scss +14 -0
  159. package/src/styles/theme/dark-blue/scrollbar-style.scss +32 -0
  160. package/src/styles/theme/dark-blue/sidebar.scss +296 -0
  161. package/src/styles/theme/dark-blue/tab.scss +83 -0
  162. package/src/styles/theme/dark-blue/table.scss +60 -0
  163. package/src/styles/theme/dark-blue/tree.scss +31 -0
  164. package/src/styles/theme/dark-blue/var.scss +1028 -0
  165. package/src/styles/theme/gray/form-style.scss +2 -2
  166. package/src/styles/theme/gray/input-style.scss +8 -0
  167. package/src/utils/auth-api.js +115 -0
  168. package/src/utils/auth.js +34 -42
  169. package/src/utils/calculator/calculator-factory.js +2 -2
  170. package/src/utils/common-util.js +34 -0
  171. package/src/utils/jump-page-utils.js +29 -5
  172. package/src/utils/menu.js +19 -0
  173. package/src/utils/permission.js +4 -0
  174. package/src/utils/request.js +18 -2
  175. package/src/utils/util.js +7 -3
  176. package/src/views/dsc-component/Sidebar/Item.vue +4 -4
  177. package/src/views/dsc-component/Sidebar/Link.vue +11 -2
  178. package/src/views/dsc-component/Sidebar/SidebarItem.vue +36 -20
  179. package/src/views/dsc-component/Sidebar/index.vue +24 -12
  180. package/src/views/dsc-component/tabs/tab-content.vue +16 -1
  181. package/src/views/login/index.vue +1 -1
@@ -0,0 +1,453 @@
1
+ import Vue from 'vue'
2
+ import store from '../super-grid/src/store'
3
+ import {
4
+ getExtraParam
5
+ } from '../super-grid/src/utils'
6
+ import nineGridStore from '../super-nine-grid/src/store'
7
+ import {
8
+ Message
9
+ } from 'element-ui'
10
+ import {
11
+ packageEnumAndBeanColumnValueSets
12
+ } from '../utils/value-set'
13
+ import {
14
+ getI18n
15
+ } from '../../src/utils/util'
16
+ /**
17
+ *
18
+ * @param {*} dataParam
19
+ * @param {*} excelName
20
+ * @param {*} listCode 如果是九宫格组件导出时,如果页面中有多个九宫格时,该属性需要传“listCode~gridId”,例如:
21
+ * @param {*} exportOptions
22
+ */
23
+ function exportData(dataParam, excelName, listCode, functionCode, uuid, exportOptions) {
24
+ return new Promise((resolve, reject) => {
25
+ exportResultData(dataParam, excelName, listCode, exportOptions, functionCode, uuid).then(result => {
26
+ // 表示导出成功,需要执行导出成功回调方法
27
+ if (isHasTheOption('afterExport', exportOptions) && typeof (exportOptions.afterExport) === 'function') {
28
+ exportOptions.afterExport.call(this)
29
+ }
30
+ resolve(result)
31
+ }).catch(error => {
32
+ if (isHasTheOption('exportError', exportOptions) && typeof (exportOptions.exportError) === 'function') {
33
+ exportOptions.exportError.call(this)
34
+ }
35
+ reject(error)
36
+ })
37
+ })
38
+ }
39
+ /**
40
+ * 导出数据
41
+ */
42
+ function exportResultData(dataParam, excelName, listCode, exportOptions, functionCode, uuid) {
43
+ return new Promise((resolve, reject) => {
44
+ // 从store缓存中取出列表信息
45
+ if (store.get(listCode + 'basicInfo')) {
46
+ const basicInfo = store.get(listCode + 'basicInfo')
47
+ if (basicInfo && basicInfo.i18nLable) {
48
+ excelName = basicInfo.i18nLable
49
+ }
50
+ }
51
+ let isCanExport = true
52
+ if (isHasTheOption('beforeExport', exportOptions) && typeof (exportOptions.beforeExport) === 'function') {
53
+ isCanExport = exportOptions.beforeExport.call(this)
54
+ }
55
+ if (!isCanExport) {
56
+ resolve(false)
57
+ } else {
58
+ if (dataParam && dataParam.hasOwnProperty('url')) {
59
+ // 导出url对应的数据
60
+ exportUrlData(dataParam, excelName, listCode).then((result) => {
61
+ resolve(result)
62
+ }).catch(error => {
63
+ reject(error)
64
+ })
65
+ } else {
66
+ // const dataIds = []
67
+ if (dataParam && dataParam.hasOwnProperty('data')) {
68
+ // 导出选中行
69
+ console.log('data', dataParam.data)
70
+ // dataParam.data.forEach(item => {
71
+ // if (item.id) {
72
+ // dataIds.push(item.id)
73
+ // } else if (item.ID) {
74
+ // dataIds.push(item.ID)
75
+ // }
76
+ // })
77
+ }
78
+ // 导出台账数据,有查询条件则导出查询条件对应的数据,没有查询条件则导出所有记录
79
+ exportListData(excelName, listCode, dataParam.data, functionCode, uuid).then((result) => {
80
+ resolve(result)
81
+ }).catch(error => {
82
+ reject(error)
83
+ })
84
+ }
85
+ }
86
+ })
87
+ }
88
+ // 导出的后台单独重写
89
+ function exportUrlData(dataParam, excelName, listCode) {
90
+ return new Promise((resolve, reject) => {
91
+ const listCodeStore = getListCode(listCode)
92
+ let param = getExportParamByGridParam(listCode)
93
+ const url = dataParam.url
94
+ if (dataParam.hasOwnProperty('param')) {
95
+ param = Object.assign(param, dataParam.param)
96
+ }
97
+ Vue.prototype.$http.post(url, param).then(data => {
98
+ let exportSheetData
99
+ // console.log('data===', data)
100
+ if (data instanceof Array) {
101
+ // 是数组,表示返回的是list记录集合
102
+ const result = {}
103
+ // console.log('_data', data)
104
+ result['_data'] = data
105
+ exportSheetData = JSON.stringify(result)
106
+ } else {
107
+ // 表示返回的是{_data:{},_styles:{}}
108
+ exportSheetData = JSON.stringify(data)
109
+ }
110
+ return exportMyData(exportSheetData, excelName, listCodeStore)
111
+ }).then((result) => {
112
+ resolve(result)
113
+ }).catch(error => {
114
+ reject(error)
115
+ })
116
+ })
117
+ }
118
+
119
+ function getListCode(listCode) {
120
+ if (listCode !== null && listCode !== undefined && listCode !== '') {
121
+ return listCode
122
+ }
123
+ let listCodeStore = listCode
124
+ if (!listCode || listCode === null || listCode === '') {
125
+ listCodeStore = store.get('_list_code')
126
+ }
127
+ if (listCodeStore === undefined || listCodeStore === null || listCodeStore === '') {
128
+ listCodeStore = nineGridStore.get('_nine_list_code')
129
+ if (listCodeStore && listCodeStore.indexOf('~') < 0) {
130
+ // 拼接默认的九宫格gridId
131
+ listCodeStore = listCodeStore + '~' + '_nineGrid'
132
+ }
133
+ }
134
+ if (listCodeStore && listCodeStore.indexOf('~') > 0) {
135
+ listCodeStore = listCodeStore.substring(0, listCodeStore.indexOf('~'))
136
+ }
137
+ return listCodeStore
138
+ }
139
+
140
+ function getGridParams(listCode) {
141
+ let gridParams = null
142
+ let listCodeStore = listCode
143
+ if (!listCode || listCode === null || listCode === '') {
144
+ listCodeStore = store.get('_list_code')
145
+ }
146
+ gridParams = store.get(listCodeStore)
147
+ if (gridParams === undefined || gridParams === null) {
148
+ if (!listCode || listCode === null || listCode === '') {
149
+ listCodeStore = nineGridStore.get('_nine_list_code')
150
+ }
151
+ if (listCodeStore && listCodeStore.indexOf('~') < 0) {
152
+ // 拼接默认的九宫格gridId
153
+ listCodeStore = listCodeStore + '~' + '_nineGrid'
154
+ }
155
+ gridParams = nineGridStore.get(listCodeStore)
156
+ }
157
+ return gridParams
158
+ }
159
+
160
+ function getExportParamByGridParam(listCode) {
161
+ let param = {}
162
+ const gridParams = getGridParams(listCode)
163
+ if (gridParams !== undefined && gridParams !== null) {
164
+ const searchParam = Object.assign({}, gridParams.searchParam)
165
+ const pagination = {
166
+ 'currentPage': 1,
167
+ 'pageSize': 99999999,
168
+ 'showTotal': false
169
+ }
170
+ param = searchParam
171
+ searchParam.pagination = pagination
172
+ if (gridParams.options.extraParam) {
173
+ // 当前有附加参数时,处理附加参数
174
+ param = getExtraParam(searchParam, gridParams)
175
+ let parentProp
176
+ const parentPropSetting = gridParams.options.parentProp
177
+ if (
178
+ typeof parentPropSetting !== 'undefined' &&
179
+ parentPropSetting !== '' &&
180
+ parentPropSetting !== null
181
+ ) {
182
+ parentProp = parentPropSetting
183
+ }
184
+ if (parentProp && searchParam && searchParam.searchForm && searchParam.searchForm.length > 0) {
185
+ // 表示有查询条件时,不支持树形结构显示数据
186
+ param.listViewTreeSetting = null
187
+ }
188
+ }
189
+ }
190
+ return param
191
+ }
192
+ // 导出当前台账数据
193
+ function exportListData(excelName, listCode, data, functionCode, uuid) {
194
+ return new Promise((resolve, reject) => {
195
+ const gridParams = getGridParams(listCode)
196
+ if (gridParams === undefined || gridParams === null) {
197
+ reject('导出失败')
198
+ } else {
199
+ const param = getExportParamByGridParam(listCode)
200
+ param.data = data
201
+ if (gridParams.columns) {
202
+ param.exportColumns = getExportColumnsByStore(gridParams.columns)
203
+ }
204
+ param.exportData = {
205
+ excelName: excelName
206
+ }
207
+ if (!excelName || excelName === null || excelName === '') {
208
+ excelName = 'default.xlsx'
209
+ } else {
210
+ excelName = excelName + '.xlsx'
211
+ }
212
+ if (functionCode) {
213
+ param.functionCode = functionCode
214
+ } else {
215
+ Message({
216
+ message: getI18n().t('imatrixUIMessage.theButtonIsNotBoundToAResource'),
217
+ type: 'error',
218
+ showClose: true
219
+ })
220
+ return
221
+ }
222
+
223
+ if (uuid) {
224
+ param.uuid = uuid
225
+ }
226
+ // 用来控制按钮禁止编辑的
227
+ localStorage.setItem(uuid, 'start')
228
+ Vue.prototype.$http.post(Vue.prototype.baseURL + '/dsc/commons/export-list-data', param).then(data => {
229
+ if (data.indexOf('~~') >= 0) {
230
+ localStorage.setItem(uuid, 'ok')
231
+ return download(Vue.prototype.baseAPI + '/component/super-grids/downloads?fileName=' + encodeURI(data) + '&_t=' + new Date().getTime(), excelName)
232
+ } else {
233
+ getFileUuid(data, param, excelName)
234
+ }
235
+ // return download(Vue.prototype.baseAPI + '/component/super-grids/downloads?fileName=' + encodeURI(fileName) + '&_t=' + new Date().getTime(), excelName)
236
+ }).then((result) => {
237
+ resolve(result)
238
+ }).catch(error => {
239
+ // 用来控制按钮禁止编辑的
240
+ localStorage.setItem(uuid, 'error')
241
+ reject(error)
242
+ })
243
+ }
244
+ })
245
+ }
246
+ /**
247
+ * 根据uuid获取导出情况
248
+ * @param {*} uuid
249
+ * @param {*} param
250
+ * @param {*} excelName
251
+ */
252
+ function getFileUuid(uuid, param, excelName) {
253
+ setTimeout(() => {
254
+ Vue.prototype.$http.post(Vue.prototype.baseURL + '/dsc/commons/get-file-uuid/' + uuid, param).then(data => {
255
+ if (data) {
256
+ if (data.code && (data.code === 'ok' || data.code === 'error')) {
257
+ if (data.code === 'ok') {
258
+ // 用来控制按钮禁止编辑的
259
+ localStorage.setItem(uuid, 'ok')
260
+ return download(Vue.prototype.baseAPI + '/component/super-grids/downloads?fileName=' + encodeURI(data.fileName) + '&uuid=' + uuid + '&_t=' + new Date().getTime(), excelName)
261
+ } else {
262
+ localStorage.setItem(uuid, 'error')
263
+ Message({
264
+ message: data.message,
265
+ type: 'error',
266
+ showClose: true
267
+ })
268
+ }
269
+ } else {
270
+ getFileUuid(uuid, param, excelName)
271
+ }
272
+ } else {
273
+ localStorage.setItem(uuid, 'ok')
274
+ }
275
+ }).catch(() => {
276
+ // 用来控制按钮禁止编辑的
277
+ localStorage.setItem(uuid, 'error')
278
+ })
279
+ }, 5000)
280
+ }
281
+ function exportMyData(data, excelName, listCode) {
282
+ return new Promise((resolve, reject) => {
283
+ const gridParams = getGridParams(listCode)
284
+ if (gridParams !== undefined) {
285
+ if (gridParams.columns) {
286
+ // console.log('exportMyData--grid--gridParams.columns.length=', gridParams.columns)
287
+ const columnInfoArr = getExportColumnsByStore(gridParams.columns)
288
+ // console.log('exportMyData--grid--columnInfoArr.length=', columnInfoArr.length)
289
+ if (columnInfoArr.length === 0) {
290
+ Message({
291
+ message: getI18n().t('imatrixUIMessage.noExportColumnsConfigured'),
292
+ type: 'warning',
293
+ showClose: true
294
+ })
295
+ resolve(false)
296
+ } else {
297
+ exportColumns(getExportInfo(data, excelName, listCode, columnInfoArr)).then((result) => {
298
+ resolve(result)
299
+ }).catch(error => {
300
+ reject(error)
301
+ })
302
+ }
303
+ } else {
304
+ Message({
305
+ message: getI18n().t('imatrixUIMessage.noExportColumnsConfigured'),
306
+ type: 'warning',
307
+ showClose: true
308
+ })
309
+ resolve(false)
310
+ }
311
+ } else {
312
+ exportOtherListData(data, excelName, listCode).then(result => {
313
+ resolve(result)
314
+ }).catch(error => {
315
+ reject(error)
316
+ })
317
+ }
318
+ })
319
+ }
320
+
321
+ /**
322
+ * 导出非台账列表数据
323
+ * @param {*}} data
324
+ * @param {*} excelName
325
+ * @param {*} listCode
326
+ */
327
+ function exportOtherListData(data, excelName, listCode, additionalParameterStr) {
328
+ return new Promise((resolve, reject) => {
329
+ const params = {}
330
+ if (additionalParameterStr && additionalParameterStr !== '') {
331
+ params.additionalParamMap = additionalParameterStr
332
+ }
333
+ Vue.prototype.$http.post(Vue.prototype.baseAPI + '/component/super-grids/' + listCode + '/export-columns', params).then(columnInfoArr => {
334
+ packageEnumAndBeanColumnValueSets(columnInfoArr, listCode).then(() => {
335
+ if (columnInfoArr.length === 0) {
336
+ Message({
337
+ message: getI18n().t('imatrixUIMessage.noExportColumnsConfigured'),
338
+ type: 'warning',
339
+ showClose: true
340
+ })
341
+ resolve(false)
342
+ } else {
343
+ exportColumns(getExportInfo(data, excelName, listCode, columnInfoArr)).then((result) => {
344
+ resolve(result)
345
+ }).catch(error => {
346
+ reject(error)
347
+ })
348
+ }
349
+ }).catch(error => {
350
+ reject(error)
351
+ })
352
+ }).catch(error => {
353
+ reject(error)
354
+ })
355
+ })
356
+ }
357
+
358
+ /**
359
+ * @param {exportInfo} Object 导出的字段配置集合及导出的数据信息
360
+ */
361
+ function exportColumns(exportInfo) {
362
+ return new Promise((resolve, reject) => {
363
+ let excelName = exportInfo.exportData.excelName
364
+ if (!excelName || excelName === null || excelName === '') {
365
+ excelName = 'default.xlsx'
366
+ } else {
367
+ excelName = excelName + '.xlsx'
368
+ }
369
+ Vue.prototype.$http.post(Vue.prototype.baseAPI + '/component/super-grids/exports', exportInfo).then(fileName => {
370
+ // window.location.href = Vue.prototype.baseAPI + '/component/super-grids/downloads?fileName=' + encodeURI(fileName)
371
+ return download(Vue.prototype.baseAPI + '/component/super-grids/downloads?fileName=' + encodeURI(fileName) + '&_t=' + new Date().getTime(), excelName)
372
+ }).then((result) => {
373
+ resolve(result)
374
+ }).catch(error => {
375
+ reject(error)
376
+ })
377
+ })
378
+ }
379
+
380
+ function getExportColumnsByStore(columns) {
381
+ let exportColumns = []
382
+ columns.forEach(column => {
383
+ if (column.children && column.children.length > 0) {
384
+ // 解决组合表头时没有导出的问题
385
+ exportColumns = exportColumns.concat(getExportColumnsByStore(column.children))
386
+ } else {
387
+ if (column.exportable && column.exportable === true) {
388
+ exportColumns.push(column)
389
+ }
390
+ }
391
+ })
392
+ return exportColumns
393
+ }
394
+
395
+ function getExportInfo(data, excelName, listCode, columnInfoArr) {
396
+ if (!excelName || excelName === null || excelName === '') {
397
+ excelName = listCode
398
+ }
399
+ return {
400
+ exportColumns: columnInfoArr,
401
+ exportData: getExportData(data, excelName)
402
+ }
403
+ }
404
+
405
+ function getExportData(data, excelName) {
406
+ return {
407
+ excelName: excelName,
408
+ exportSheetData: [{
409
+ data: data,
410
+ sheetName: excelName
411
+ }]
412
+ }
413
+ }
414
+
415
+ function isHasTheOption(event, exportOptions) {
416
+ if (typeof (exportOptions) !== 'undefined' && typeof (exportOptions[event]) !== 'undefined') {
417
+ return true
418
+ }
419
+ return false
420
+ }
421
+
422
+ function download(url, fileName) {
423
+ return new Promise((resolve, reject) => {
424
+ Vue.prototype.$http({
425
+ method: 'GET',
426
+ url: url,
427
+ responseType: 'blob'
428
+ }).then(res => {
429
+ const blob = new Blob([res])
430
+ if (window.navigator.msSaveOrOpenBlob) {
431
+ navigator.msSaveBlob(blob, fileName)
432
+ } else {
433
+ const link = document.createElement('a')
434
+ const evt = document.createEvent('HTMLEvents')
435
+ evt.initEvent('click', false, false)
436
+ link.href = URL.createObjectURL(blob)
437
+ link.download = fileName
438
+ link.style.display = 'none'
439
+ document.body.appendChild(link)
440
+ link.click()
441
+ window.URL.revokeObjectURL(link.href)
442
+ }
443
+ resolve(true)
444
+ }).catch(error => {
445
+ reject(error)
446
+ })
447
+ })
448
+ }
449
+
450
+ export default {
451
+ exportData,
452
+ download
453
+ }