imatrix-ui 2.8.21 → 2.8.22-boe10

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 (177) hide show
  1. package/lib/super-ui.css +1 -1
  2. package/lib/super-ui.umd.min.js +5 -5
  3. package/package.json +2 -2
  4. package/src/api/sso-service.js +19 -1
  5. package/src/i18n/langs/cn.js +13 -3
  6. package/src/i18n/langs/en.js +15 -4
  7. package/src/router/index.js +10 -0
  8. package/src/store/modules/tab-content.js +6 -0
  9. package/src/store/modules/user.js +19 -0
  10. package/src/styles/index.scss +72 -2
  11. package/src/styles/theme/black/font-style.scss +70 -0
  12. package/src/styles/theme/black/index.scss +6 -30
  13. package/src/styles/theme/blue/font-style.scss +37 -0
  14. package/src/styles/theme/blue/index.scss +2 -18
  15. package/src/styles/theme/blue2/font-style.scss +70 -0
  16. package/src/styles/theme/blue2/index.scss +3 -13
  17. package/src/styles/theme/dark-blue/index.scss +27 -5
  18. package/src/styles/theme/dark-blue/message.scss +8 -0
  19. package/src/styles/theme/dark-blue/sidebar.scss +7 -37
  20. package/src/styles/theme/dark-blue/table.scss +1 -1
  21. package/src/styles/theme/gray/card-style.scss +13 -1
  22. package/src/styles/theme/gray/font-style.scss +38 -0
  23. package/src/styles/theme/gray/index.scss +13 -25
  24. package/src/styles/theme/gray/scrollbar-style.scss +32 -0
  25. package/src/styles/theme/gray/sidebar.scss +5 -0
  26. package/src/utils/auth-api.js +45 -1
  27. package/src/utils/common-util.js +28 -0
  28. package/src/utils/range-selector.js +185 -0
  29. package/src/utils/request.js +5 -2
  30. package/src/utils/util.js +7 -5
  31. package/src/views/dsc-component/Sidebar/Item.vue +4 -2
  32. package/src/views/dsc-component/Sidebar/SidebarItem.vue +1 -2
  33. package/src/views/dsc-component/Sidebar/index.vue +12 -20
  34. package/src/views/dsc-component/tabs/tab-content.vue +1 -5
  35. package/src/views/layout/NewLayout.vue +6 -65
  36. package/src/views/layout/components/Menubar/Item.vue +23 -7
  37. package/src/views/layout/components/Menubar/Link.vue +11 -2
  38. package/src/views/layout/components/Menubar/SidebarItem.vue +50 -7
  39. package/src/views/layout/components/Menubar/index.vue +51 -16
  40. package/src/views/layout/components/tabs/tab-content.vue +160 -0
  41. package/src/views/layout/tab-content-iframe-index.vue +31 -0
  42. package/src/views/layout/tab-content-index.vue +85 -0
  43. package/packages/breadcrumb/index.js +0 -6
  44. package/packages/breadcrumb/src/breadcrumb.vue +0 -71
  45. package/packages/department-tree/index.js +0 -6
  46. package/packages/department-tree/src/department-tree.vue +0 -108
  47. package/packages/department-tree-inline/index.js +0 -6
  48. package/packages/department-tree-inline/src/department-multi-tree-inline.vue +0 -402
  49. package/packages/department-tree-inline/src/department-single-tree-inline.vue +0 -284
  50. package/packages/department-tree-inline/src/department-tree-inline.vue +0 -86
  51. package/packages/department-tree-inline/src/department-tree-service.js +0 -245
  52. package/packages/department-tree-inline/src/search-result.vue +0 -176
  53. package/packages/department-user-tree/index.js +0 -6
  54. package/packages/department-user-tree/src/department-user-multiple-tree.vue +0 -116
  55. package/packages/department-user-tree/src/department-user-single-tree.vue +0 -76
  56. package/packages/department-user-tree/src/department-user-tree.vue +0 -101
  57. package/packages/department-user-tree-inline/index.js +0 -6
  58. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +0 -626
  59. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +0 -269
  60. package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +0 -79
  61. package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +0 -230
  62. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +0 -122
  63. package/packages/department-user-tree-inline/src/search-result.vue +0 -197
  64. package/packages/directives/prevent-reclick.js +0 -19
  65. package/packages/dynamic-source-select/index.js +0 -6
  66. package/packages/dynamic-source-select/src/dynamic-source-select-service.js +0 -70
  67. package/packages/dynamic-source-select/src/dynamic-source-select.vue +0 -440
  68. package/packages/dynamic-source-select/src/events.js +0 -55
  69. package/packages/fs-preview/index.js +0 -6
  70. package/packages/fs-preview/src/fs-preview.vue +0 -226
  71. package/packages/fs-upload/index.js +0 -6
  72. package/packages/fs-upload/src/fs-upload-multi.vue +0 -420
  73. package/packages/fs-upload/src/fs-upload-single.vue +0 -312
  74. package/packages/fs-upload/src/fs-upload.vue +0 -189
  75. package/packages/fs-upload/src/see-big-picture.vue +0 -55
  76. package/packages/fs-upload-list/index.js +0 -6
  77. package/packages/fs-upload-list/src/fs-upload-list.vue +0 -287
  78. package/packages/hamburger/index.js +0 -6
  79. package/packages/hamburger/src/hamburger.vue +0 -38
  80. package/packages/index.js +0 -121
  81. package/packages/multipart-upload/index.js +0 -6
  82. package/packages/multipart-upload/src/index.vue +0 -73
  83. package/packages/multipart-upload/src/multipart-upload-form.vue +0 -297
  84. package/packages/multipart-upload/src/multipart-upload-list.vue +0 -378
  85. package/packages/organization-input/index.js +0 -6
  86. package/packages/organization-input/src/organization-input.vue +0 -542
  87. package/packages/plugins/export-data-new.js +0 -453
  88. package/packages/plugins/export-data.js +0 -361
  89. package/packages/plugins/index.js +0 -15
  90. package/packages/plugins/public-method.js +0 -43
  91. package/packages/remove-department/index.js +0 -6
  92. package/packages/remove-department/src/remove-department.vue +0 -172
  93. package/packages/remove-department/src/remove-dept-service.js +0 -20
  94. package/packages/remove-user/index.js +0 -6
  95. package/packages/remove-user/src/remove-user-service.js +0 -20
  96. package/packages/remove-user/src/remove-user.vue +0 -195
  97. package/packages/remove-workgroup/index.js +0 -6
  98. package/packages/remove-workgroup/src/remove-workgroup-service.js +0 -20
  99. package/packages/remove-workgroup/src/remove-workgroup.vue +0 -159
  100. package/packages/rich-editor/index.js +0 -7
  101. package/packages/rich-editor/index.vue +0 -278
  102. package/packages/rich-editor/langs/zh-Hans.js +0 -1
  103. package/packages/rich-editor/viewer.vue +0 -103
  104. package/packages/scan-code-input/index.js +0 -6
  105. package/packages/scan-code-input/src/events.js +0 -33
  106. package/packages/scan-code-input/src/scan-code-input-colse.vue +0 -131
  107. package/packages/scan-code-input/src/scan-code-input.vue +0 -116
  108. package/packages/secret-info/index.js +0 -7
  109. package/packages/secret-info/index.vue +0 -90
  110. package/packages/super-grid/index.js +0 -7
  111. package/packages/super-grid/src/apis.js +0 -763
  112. package/packages/super-grid/src/columns-config.vue +0 -335
  113. package/packages/super-grid/src/custom-formatter.js +0 -250
  114. package/packages/super-grid/src/dynamic-input.vue +0 -1279
  115. package/packages/super-grid/src/eventBus.js +0 -2
  116. package/packages/super-grid/src/events.js +0 -55
  117. package/packages/super-grid/src/formValidatorUtil.js +0 -226
  118. package/packages/super-grid/src/formatter.js +0 -181
  119. package/packages/super-grid/src/group-column.vue +0 -100
  120. package/packages/super-grid/src/header-context-menu.vue +0 -87
  121. package/packages/super-grid/src/index-column.vue +0 -51
  122. package/packages/super-grid/src/normal-column.vue +0 -769
  123. package/packages/super-grid/src/public-methods.js +0 -31
  124. package/packages/super-grid/src/row-operation.vue +0 -161
  125. package/packages/super-grid/src/search-button.vue +0 -66
  126. package/packages/super-grid/src/search-condition-input.vue +0 -61
  127. package/packages/super-grid/src/search-condition-list.vue +0 -59
  128. package/packages/super-grid/src/search-form-advancedQuery.vue +0 -653
  129. package/packages/super-grid/src/search-form-dialog.vue +0 -79
  130. package/packages/super-grid/src/search-form-item.vue +0 -386
  131. package/packages/super-grid/src/search-form-number.vue +0 -38
  132. package/packages/super-grid/src/search-form-open.vue +0 -162
  133. package/packages/super-grid/src/search-form-ordinarySearch.vue +0 -188
  134. package/packages/super-grid/src/search-form.vue +0 -634
  135. package/packages/super-grid/src/search-methods.js +0 -387
  136. package/packages/super-grid/src/selection-column.vue +0 -43
  137. package/packages/super-grid/src/store.js +0 -3
  138. package/packages/super-grid/src/super-grid-service.js +0 -561
  139. package/packages/super-grid/src/super-grid.vue +0 -2793
  140. package/packages/super-grid/src/utils.js +0 -763
  141. package/packages/super-grid/src/view-image-dialog.vue +0 -130
  142. package/packages/super-nine-grid/index.js +0 -7
  143. package/packages/super-nine-grid/src/apis.js +0 -103
  144. package/packages/super-nine-grid/src/custom-formatter.js +0 -66
  145. package/packages/super-nine-grid/src/formatter.js +0 -132
  146. package/packages/super-nine-grid/src/search-form-number.vue +0 -38
  147. package/packages/super-nine-grid/src/search-form.vue +0 -430
  148. package/packages/super-nine-grid/src/search-methods.js +0 -134
  149. package/packages/super-nine-grid/src/store.js +0 -3
  150. package/packages/super-nine-grid/src/super-grid-service.js +0 -91
  151. package/packages/super-nine-grid/src/super-nine-grid.vue +0 -872
  152. package/packages/super-nine-grid/src/utils.js +0 -261
  153. package/packages/svg-icon/index.js +0 -6
  154. package/packages/svg-icon/src/svg-icon.vue +0 -43
  155. package/packages/utils/utils.js +0 -152
  156. package/packages/utils/value-set.js +0 -86
  157. package/packages/valid-code/index.js +0 -7
  158. package/packages/valid-code/src/valid-code.vue +0 -95
  159. package/packages/workflow-button/index.js +0 -6
  160. package/packages/workflow-button/src/workflow-button.vue +0 -325
  161. package/packages/workflow-history-list/index.js +0 -6
  162. package/packages/workflow-history-list/src/api.js +0 -7
  163. package/packages/workflow-history-list/src/workflow-history-list.vue +0 -185
  164. package/packages/workgroup-tree/index.js +0 -6
  165. package/packages/workgroup-tree/src/workgroup-tree.vue +0 -76
  166. package/packages/workgroup-tree-inline/index.js +0 -6
  167. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +0 -317
  168. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +0 -43
  169. package/packages/workgroup-user-tree/index.js +0 -6
  170. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +0 -100
  171. package/packages/workgroup-user-tree-inline/index.js +0 -6
  172. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +0 -163
  173. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +0 -436
  174. package/packages/year-range-picker/index.js +0 -6
  175. package/packages/year-range-picker/src/year-range-picker.vue +0 -51
  176. package/src/index.js +0 -93
  177. package/src/styles/theme/gray/form-style.scss +0 -41
@@ -1,2793 +0,0 @@
1
- <template>
2
- <div>
3
- <search-form
4
- v-if="!isFormSubTable && hasLoadedColumns && query && query.showType === 'embedded'"
5
- ref="sf"
6
- :columns="columns"
7
- :code="code"
8
- :url="url"
9
- :pagination="pagination"
10
- :query="query"
11
- :search-form-info="searchFormInfo"
12
- :search-param="searchFormContent"
13
- :init-search-props="initSearchProps"
14
- @search="doSearch"
15
- @reset="resetSearch"
16
- @open-fold="openFold"
17
- />
18
- <search-form-dialog
19
- v-if="
20
- hasLoadedColumns && query && query.showType === 'popup'
21
- "
22
- ref="sfDialog"
23
- :columns="columns"
24
- :code="code"
25
- :url="url"
26
- :pagination="pagination"
27
- :query="query"
28
- :search-param="searchFormContent"
29
- :init-search-props="initSearchProps"
30
- @search="doSearchDialog"
31
- @reset="resetSearch"
32
- @close="closeSearchFormDialog"
33
- />
34
- <div :class="'grid-area ' + code">
35
- <el-table
36
- v-if="refreshGrid && hasLoadedColumns"
37
- ref="superGrid"
38
- :data="gridData"
39
- :row-key="getRowKeyProp"
40
- :show-summary="showSummary"
41
- :summary-method="getSummaries"
42
- style="width: 100%"
43
- :stripe="stripe"
44
- :border="true"
45
- :default-expand-all="defaultExpandAll"
46
- :lazy="isLazy"
47
- :load="loadChildren"
48
- :row-style="changeRowStyle"
49
- :cell-style="changeCellStyle"
50
- :header-cell-style="changeHeaderStyle"
51
- :highlight-current-row="true"
52
- :span-method="rowSpan"
53
- :max-height="maxHeight"
54
- :height="height"
55
- class="elTable"
56
- :tree-props="treeProps"
57
- @sort-change="handleSortChange"
58
- @select="select"
59
- @select-all="selectAll"
60
- @row-click="rowClickEvent"
61
- @row-dblclick="rowDblclickEvent"
62
- @expand-change="expandChange"
63
- @header-click="headerClick"
64
- @header-dragend="changeHederWidth"
65
- @header-contextmenu="headerContextmenu"
66
- @cell-click="selectCell"
67
- >
68
- <template v-if="myCustomFormatter">
69
- <component
70
- :is="column._defaultComponentType"
71
- v-for="(column, index) in visibleColumns"
72
- :ref="column.prop"
73
- :key="column.label + index"
74
- :column="column"
75
- :is-sql="isSql"
76
- :list-code="code"
77
- :custom-format="
78
- column._defaultComponentType === 'GroupColumn'
79
- ? myCustomFormatter
80
- : myCustomFormatter[column.prop]
81
- "
82
- :new-width="newWidth"
83
- :drag-column-prop="dragColumnProp"
84
- :right-click-menu-arr="options.rightClickMenuArr"
85
- :table-name="tableName"
86
- :page-code="pageCode"
87
- :list-name="listName"
88
- :current-page="currentPage"
89
- :grid-data="isSubTableShowPage ? subTableData : gridData"
90
- :page-grid-data="isSubTableShowPage ? pageGridData : gridData"
91
- @open-page="openPageDialog"
92
- @refresPortData="refresPortData"
93
- @refresPortsData="refresPortsData"
94
- @refresMainTableFields="refresMainTableFields"
95
- @prohibitToEdit="prohibitToEdit"
96
- />
97
- </template>
98
- <template v-else>
99
- <component
100
- :is="column._defaultComponentType"
101
- v-for="(column, index) in visibleColumns"
102
- :ref="column.prop"
103
- :key="column.label + index"
104
- :is-sql="isSql"
105
- :column="column"
106
- :list-code="code"
107
- :is-line-edit="lineEdit !== null && lineEdit.editable"
108
- :new-width="newWidth"
109
- :drag-column-prop="dragColumnProp"
110
- :right-click-menu-arr="options.rightClickMenuArr"
111
- :table-name="tableName"
112
- :page-code="pageCode"
113
- :list-name="listName"
114
- :current-page="currentPage"
115
- :grid-data="isSubTableShowPage ? subTableData : gridData"
116
- :page-grid-data="isSubTableShowPage ? pageGridData : gridData"
117
- @open-page="openPageDialog"
118
- @refresData="refresData"
119
- @refresPortData="refresPortData"
120
- @refresPortsData="refresPortsData"
121
- @refresMainTableFields="refresMainTableFields"
122
- @prohibitToEdit="prohibitToEdit"
123
- />
124
- </template>
125
- </el-table>
126
- <div style="position:relative;margin-top:5px;">
127
- <el-row>
128
- <el-col
129
- v-if="
130
- !(
131
- typeof options.isAdministerListView !== 'undefined' &&
132
- options.isAdministerListView != null &&
133
- options.isAdministerListView === true
134
- )
135
- "
136
- :span="2"
137
- >
138
- <i
139
- v-if="basicInfo.customConfig && !isFormSubTable"
140
- class="el-icon-setting"
141
- :title="$t('superGrid.columnConfig')"
142
- style="float:left;padding: 10px 0px;color:#777"
143
- @click="configColumns"
144
- />
145
- <i
146
-
147
- v-if="!isFormSubTable"
148
- class="el-icon-refresh"
149
- :title="$t('superGrid.refresh')"
150
- style="float:left;padding: 10px 0px;color:#777"
151
- @click="refreshGridData"
152
- />
153
- </el-col>
154
- <el-col
155
- :span="
156
- !(
157
- typeof options.isAdministerListView !== 'undefined' &&
158
- options.isAdministerListView != null &&
159
- options.isAdministerListView === true
160
- )
161
- ? 22
162
- : 24
163
- "
164
- >
165
- <el-pagination
166
- v-if="pagination && isShowPage"
167
- background
168
- :current-page.sync="currentPage"
169
- :page-sizes="pagination.pageSizes"
170
- :page-size="pagination.pageSize"
171
- :layout="pagination.layout"
172
- :total="pagination.total"
173
- @size-change="handleSizeChange"
174
- @current-change="handleCurrentChange"
175
- />
176
- </el-col>
177
- </el-row>
178
- </div>
179
- </div>
180
-
181
- <columns-config
182
- v-if="showColumnConfig"
183
- :columns="columns"
184
- :list-code="code"
185
- :is-sql="isSql"
186
- @close="closeCustomConfig($event)"
187
- @reset="resetCustomConfig($event)"
188
- />
189
- <header-context-menu
190
- v-if="showHeaderContextmenu"
191
- ref="headerMenu"
192
- :buttom-arr="options.rightClickMenuArr"
193
- :column="rightClickColumn"
194
- @clearHeaderContextmenu="clearHeaderContextmenu"
195
- />
196
- <super-page-dialog
197
- v-if="isShowPageDialog"
198
- :dev-mode="pageDevMode"
199
- :jump-page-setting="Object.freeze(jumpPageSetting)"
200
- :source-page-code="pageCode"
201
- @close="closePageDialog"
202
- @update-value="updateValues"
203
- />
204
- </div>
205
- </template>
206
- <style rel="stylesheet/scss" lang="scss" scoped>
207
- .grid-area {
208
- .elTable th {
209
- padding: 2px 0 !important;
210
- }
211
- .elTable td {
212
- padding: 2px 0 !important;
213
- }
214
- }
215
- </style>
216
-
217
- <script>
218
- import IndexColumn from './index-column'
219
- import SelectionColumn from './selection-column'
220
- import NormalColumn from './normal-column'
221
- import GroupColumn from './group-column'
222
- import ColumnsConfig from './columns-config'
223
- import SearchForm from './search-form'
224
- import searchFormDialog from './search-form-dialog'
225
- import {
226
- setEntityFieldValue
227
- } from '../../../src/utils/util'
228
- import {
229
- getSpanValuesForColumn,
230
- getFirstEditableColumn,
231
- getGridParams,
232
- getTableHeight,
233
- isObjectValueEqual,
234
- isHasEditOption,
235
- isHasOptionFunction,
236
- isCanRefreshGrid,
237
- isEditOptionFunction,
238
- getExtraParam,
239
- getLastPageNum
240
- } from './utils'
241
- import Sortable from 'sortablejs'
242
- import store from './store'
243
- import events from './events'
244
- import publicMethods from './public-methods'
245
- import superGridService from './super-grid-service'
246
- import formValidatorService from './formValidatorUtil'
247
- import { getSystemCode } from '../../../src/utils/permissionAuth'
248
- import apis from './apis'
249
- import headerContextMenu from './header-context-menu'
250
- import { addDynamicProp } from './utils'
251
- import { updateWithPageValue } from '../../../src/utils/jump-page-utils'
252
- import { getEntityFieldValueWithOutCase } from '../../../src/utils/util'
253
- import { checkPermission } from '../../../src/utils/permission'
254
- import Vue from 'vue'
255
- export default {
256
- name: 'SuperGrid',
257
- components: {
258
- IndexColumn,
259
- SelectionColumn,
260
- NormalColumn,
261
- GroupColumn,
262
- ColumnsConfig,
263
- SearchForm,
264
- headerContextMenu,
265
- searchFormDialog
266
- },
267
- props: {
268
- code: {
269
- type: String,
270
- default: ''
271
- },
272
- url: {
273
- type: String,
274
- default: ''
275
- },
276
- options: {
277
- type: Object,
278
- default: function() {
279
- return {}
280
- }
281
- },
282
- // 为了兼容平台的旧写法,暂不删除以下属性
283
- // 操作列、占位符列内容显示的函数,格式为:{'属性名':方法},例如:{'name':viewUser,'operation':showOperation}
284
- customFormatter: {
285
- type: Object,
286
- default: null
287
- },
288
- searchFormInfo: {
289
- type: Object,
290
- default: () => {
291
- return {}
292
- }
293
- }
294
- },
295
- data() {
296
- let parentProp
297
- const parentPropSetting = this.options.parentProp
298
- if (
299
- typeof parentPropSetting !== 'undefined' &&
300
- parentPropSetting !== '' &&
301
- parentPropSetting !== null
302
- ) {
303
- parentProp = parentPropSetting
304
- }
305
- let mergeFields = []
306
- if (
307
- this.options &&
308
- this.options.mergeFields &&
309
- this.options.mergeFields !== ''
310
- ) {
311
- mergeFields = this.options.mergeFields.split(',')
312
- }
313
- let optionTableHeight
314
- if (
315
- this.options &&
316
- this.options.optionTableHeight &&
317
- this.options.optionTableHeight !== ''
318
- ) {
319
- optionTableHeight = this.options.optionTableHeight
320
- }
321
- let pageCode
322
- if (this.options && this.options.pageCode) {
323
- pageCode = this.options.pageCode
324
- }
325
- let pageHeight
326
- if (this.options && this.options.pageHeight) {
327
- pageHeight = this.options.pageHeight
328
- }
329
- let isLazy = true
330
- if (this.options && this.options.lazy !== undefined) {
331
- isLazy = this.options.lazy
332
- }
333
- let defaultExpandAll = true
334
- if (this.options && this.options.defaultExpandAll !== undefined) {
335
- defaultExpandAll = this.options.defaultExpandAll
336
- }
337
- // 数据库类型,值为mysql、oracle、sqlserver,默认是mysql,树形表格时需要使用
338
- let dataSourceType = 'mysql'
339
- if (Vue.prototype.dataSourceType) {
340
- dataSourceType = Vue.prototype.dataSourceType.toLowerCase()
341
- }
342
- let pageDevMode = this.options.pageDevMode
343
- if (pageDevMode === undefined) {
344
- pageDevMode = false
345
- }
346
- return {
347
- isLoading: false,
348
- currentPage: 1,
349
- showColumnConfig: false,
350
- basicInfo: {
351
- summary: 'no'
352
- },
353
- columns: [],
354
- pagination: null,
355
- query: null,
356
- lineEdit: null,
357
- gridData: [],
358
- summaries: null,
359
- sortInfo: null,
360
- pageSize: null,
361
- showSearch: false,
362
- myCustomFormatter: null,
363
- height: null,
364
- timer: null,
365
- timer2: null,
366
- isSql: false, // 是否是sql查询
367
- parentProp, // 树状结构数据时,父字段名,默认是id
368
- hasLoadData: false,
369
- mergeFields,
370
- newWidth: null,
371
- dragColumnProp: null,
372
- hasLoadedColumns: false, // 是否已经加载了列配置
373
- backgroundColorMap: {},
374
- showHeaderContextmenu: false,
375
- rightClickColumn: null,
376
- externalClickFlag: false, // 是否是外部点击
377
- dataTableCode: null,
378
- dynamicColumnInfo: null, // 列表管理/字段配置/动态列配置中解析的动态列集合,在获得列表数据和行编辑保存动态列时使用
379
- mainDefaultValueColumns: null, // 当前列表对应的数据表的字段配置有默认值的字段集合,动态列insert插入主表记录时使用
380
- dynamicServiceName: null, // 动态列展示及行编辑时数据保存的service处理类,可以不填,使用平台默认的处理类
381
- searchFormContent: null,
382
- initSearchProps: [], // 初始查询的字段属性名集合
383
- refreshGrid: true, // 字段配置刷新列表时用于重新渲染列表的状态位
384
- optionTableHeight, // option传递的table高度
385
- isFormSubTable: false,
386
- isShowPageDialog: false, // 是否显示弹框
387
- jumpPageSetting: null,
388
- pageCode,
389
- maxHeight: null,
390
- pageHeight, // 页面高度
391
- currentSelectCell: null,
392
- isLazy, // 树形结构时是否懒加载,默认是懒加载的
393
- defaultExpandAll, // 树形结构是否默认展开所有节点
394
- parentFormData: null, // 父表单实体信息
395
- stripe: true,
396
- dataSourceType,
397
- pageDevMode,
398
- toolbarFieldParam: [],
399
- tableName: null,
400
- listName: null,
401
- subTableData: [],
402
- isShowPage: false, // 子表或普通列表是否显示分页
403
- isSubTableShowPage: false // 子表是否显示分页
404
- }
405
- },
406
- computed: {
407
- treeProps() {
408
- return this.getTreeProps(this.parentProp, this.isSql, this.isLazy, this.dataSourceType)
409
- },
410
- pageGridData() {
411
- return this.getSubTableGridData(this.subTableData)
412
- },
413
- visibleColumns() {
414
- const gridParams = store.get(this.code)
415
- const operations = this.getOptionOperations()
416
- gridParams.canntEdit = false
417
- if (operations && operations.operation && operations.operation.length > 0) {
418
- operations.operation.forEach(buttonInfo => {
419
- if (buttonInfo.props.code === 'lineEditUpdate') {
420
- if (checkPermission(buttonInfo.props.functionCode)) {
421
- gridParams.canntEdit = true
422
- }
423
- }
424
- })
425
- }
426
- if (
427
- typeof this.options.isAdministerListView !== 'undefined' &&
428
- this.options.isAdministerListView != null &&
429
- this.options.isAdministerListView === true
430
- ) {
431
- return this.columns
432
- } else {
433
- const filterColumns = this.columns.filter(column => {
434
- if (
435
- typeof this.options.multiple !== 'undefined' &&
436
- this.options.multiple === false &&
437
- column.prop === '$selection'
438
- ) {
439
- // 表示不显示“多选”列
440
- return false
441
- }
442
- if (
443
- typeof this.options.showIndex !== 'undefined' &&
444
- this.options.showIndex === false &&
445
- column.prop === '$index'
446
- ) {
447
- // 表示不显示“序号”列
448
- return false
449
- }
450
- let isVisible
451
- if (column.show === undefined || column.show) {
452
- isVisible = true
453
- const hiddenColumns = this.options.hiddenColumns
454
- if (
455
- hiddenColumns &&
456
- hiddenColumns.length > 0 &&
457
- hiddenColumns.indexOf(column.prop) !== -1
458
- ) {
459
- // 如果当前字段包含在隐藏字段集合中,则不显示该字段
460
- isVisible = false
461
- return isVisible
462
- }
463
- // 给列配置操作属性
464
- this.initColumnOperation(column, operations)
465
- if (!gridParams.$dataTypeMap) {
466
- gridParams.$dataTypeMap = {}
467
- }
468
- // sql时行编辑保存后台代码需要
469
- gridParams.$dataTypeMap[column.prop] = column.dataType
470
- } else {
471
- isVisible = false
472
- }
473
- // 存储有默认值的字段集合
474
- this.storeHasDefaultValueColumns(column, gridParams)
475
- // 字段的控件类型
476
- column._defaultComponentType = this.getComponentType(column.prop)
477
- return isVisible
478
- })
479
- return filterColumns
480
- }
481
- },
482
- spanArr() {
483
- const spanArr = []
484
- for (const column of this.columns) {
485
- if (
486
- column.span ||
487
- (this.mergeFields && this.mergeFields.indexOf(column.prop) !== -1)
488
- ) {
489
- spanArr[column.prop] = getSpanValuesForColumn(
490
- this.gridData,
491
- column.prop,
492
- column.mergerCellBasis
493
- )
494
- }
495
- }
496
- return spanArr
497
- },
498
- showSummary() {
499
- return (
500
- this.basicInfo.summary !== undefined && this.basicInfo.summary !== 'no'
501
- )
502
- },
503
- // 返回table用来确定唯一的字段。必须配置,否则树形结构时无法显示子集合。
504
- getRowKeyProp() {
505
- const gridParams = store.get(this.code)
506
- if (gridParams && gridParams.options && gridParams.options.rowKeyProp) {
507
- return gridParams.options.rowKeyProp
508
- } else {
509
- if (this.dataSourceType === 'oracle') {
510
- return 'ID'
511
- } else {
512
- return 'id'
513
- }
514
- }
515
- }
516
- // ,
517
- // hasLoadMainTable() {
518
- // const hasLoadMainTable = store.get('hasLoadMainTable')
519
- // if (typeof (hasLoadMainTable) === 'undefined') {
520
- // return false
521
- // }
522
- // return hasLoadMainTable
523
- // }
524
- },
525
- watch: {
526
- 'options.SuperGrid': {
527
- deep: true,
528
- handler: function() {
529
- this.externalClickFlag = true
530
- console.log('监听到数据改变')
531
- this.initSetting()
532
- this.initialize()
533
- }
534
- },
535
- // 监控列表数据修改,列表作为表单编辑器中子表时使用
536
- gridData: {
537
- deep: true,
538
- immediate: true,
539
- handler: function() {
540
- if (!this.isSubTableShowPage) {
541
- // 列表子表不分页时使用
542
- this.$emit('change-grid-data', this.gridData)
543
- }
544
- }
545
- },
546
- // 监控列表数据修改,列表作为表单编辑器中子表时使用
547
- subTableData: {
548
- deep: true,
549
- immediate: true,
550
- handler: function() {
551
- if (this.isSubTableShowPage) {
552
- // 列表子表分页时使用
553
- const gridParams = store.get(this.code)
554
- this.$emit('change-grid-data', this.subTableData)
555
- if (gridParams.isChangePage !== undefined && gridParams.isChangePage) {
556
- // 表示新建记录时
557
- // 新建记录时跳转到最后一页
558
- const lastPageNum = getLastPageNum(this.subTableData.length, this.pageSize)
559
- // 表示最后一页页码和当前页不同时需要切换页码
560
- if (lastPageNum !== this.currentPage) {
561
- // 切换当前页码为最后一页
562
- this.currentPage = lastPageNum
563
- // 切换当前页码到最后一页的数据
564
- this.changePage()
565
- } else {
566
- // 表示不需要切换页码
567
- this.gridData = this.getSubTableGridData(this.subTableData)
568
- gridParams.gridData = this.gridData// 完成深拷贝,复制一份对象,行编辑时使用
569
- gridParams.orgGridData = [].concat(
570
- JSON.parse(JSON.stringify(this.gridData))
571
- )
572
- }
573
- if (gridParams.lineEdit.editingCell) {
574
- gridParams.lineEdit.editingCell.row = this.gridData.length
575
- }
576
- // 使用完状态还原
577
- gridParams.isChangePage = false
578
- } else {
579
- // 表示不是子表新建记录
580
- this.gridData = this.getSubTableGridData(this.subTableData)
581
- gridParams.gridData = this.gridData
582
- // 完成深拷贝,复制一份对象,行编辑时使用
583
- gridParams.orgGridData = [].concat(
584
- JSON.parse(JSON.stringify(this.gridData))
585
- )
586
- }
587
- }
588
- }
589
- },
590
- currentSelectCell: {
591
- deep: true,
592
- handler: function(newVal, oldVal) {
593
- this.$nextTick(() => {
594
- if (newVal) {
595
- // 手动触发新单元格的点击事件
596
- newVal.click()
597
- }
598
- if (oldVal) {
599
- // 清空上一个单元格的选中样式
600
- oldVal.style.border = ''
601
- }
602
- })
603
- }
604
- },
605
- 'options.validateRules': {
606
- deep: true,
607
- handler: function() {
608
- this.externalClickFlag = true
609
- console.log('监听到数据改变================', this.options.validateRules)
610
- const gridParams = store.get(this.code)
611
- if (gridParams && gridParams.options) {
612
- gridParams.options.validateRules = this.options.validateRules
613
- store.set(this.code, gridParams)
614
- }
615
- // this.initSetting()
616
- // this.initialize()
617
- }
618
- },
619
- 'options.subTableCanAdd': {
620
- deep: true,
621
- handler: function() {
622
- const gridParams = store.get(this.code)
623
- if (gridParams && gridParams.options) {
624
- gridParams.options.subTableCanAdd = this.options.subTableCanAdd
625
- store.set(this.code, gridParams)
626
- }
627
- }
628
- },
629
- // pageSize每页显示多少条,改变时抛出事件,配置出来的流程表单子表验证提示信息时使用,例如:“第x页第x条记录,xxx必填”,获得页数时需要使用
630
- pageSize: {
631
- handler(newValue, oldValue) {
632
- this.$emit('change-rows-per-page', this.pageSize)
633
- }
634
- }
635
- },
636
- provide() {
637
- return {}
638
- },
639
- created() {
640
- store.set(this.code, getGridParams())
641
- store.set('_list_code', this.code)
642
- this.initSetting()
643
- this.judgeIsFormSubTable()
644
- let stripe = true
645
- if (isHasOptionFunction('rowStyleRender', this.code)) {
646
- // 当行需要自定义样式时,斑马线样式会影响效果,所以需要去掉斑马线配置
647
- stripe = false
648
- }
649
- this.stripe = stripe
650
-
651
- // if (this.parentProp) {
652
- // // 表示配置了树形配置
653
- // this.treeProps = this.getTreeProps()
654
- // }
655
- // this.showDemo()
656
- },
657
- mounted() {
658
- this.initialize().then(() => {
659
- const gridParams = store.get(this.code)
660
- if (
661
- gridParams &&
662
- gridParams.basicInfo &&
663
- gridParams.basicInfo.tableName
664
- ) {
665
- this.tableName = gridParams.basicInfo.tableName
666
- }
667
- if (
668
- gridParams &&
669
- gridParams.basicInfo &&
670
- gridParams.basicInfo.name
671
- ) {
672
- this.listName = gridParams.basicInfo.name
673
- }
674
- this.$nextTick(() => {
675
- const a = new Date().getTime()
676
- // 将子表选项组值传递super-pages中,解决到处报告时子表选项组赋值问题
677
- this.columns.forEach(column => {
678
- if (column.valueSet) {
679
- this.$emit('set-select-options', { 'prop': this.code + '.' + column.prop, 'valueSet': column.valueSet })
680
- }
681
- })
682
- this.rowDrop()
683
- this.columnDrop()
684
- store.get(this.code).superGrid = this.$refs.superGrid
685
- if (this.query && this.query.showType === 'embedded') {
686
- // 嵌入查询时,刚进台账要计算一次列表高度
687
- this.resizeTableHeight()
688
- } else {
689
- this.$watch(
690
- 'showSearch',
691
- function(newVal, oldVal) {
692
- this.resizeTableHeight()
693
- },
694
- {
695
- immediate: true,
696
- deep: true
697
- }
698
- )
699
- }
700
-
701
- this.$watch(
702
- 'hasLoadData',
703
- function(newVal, oldVal) {
704
- if (newVal === true) {
705
- this.$nextTick(() => {
706
- const gridParams = store.get(this.code)
707
- if (isHasOptionFunction('gridComplete', this.code)) {
708
- gridParams.options.gridComplete.call(this, {
709
- gridData: this.isSubTableShowPage ? this.subTableData : this.gridData,
710
- columns: gridParams.columns,
711
- superGrid: this.$refs.superGrid,
712
- pageGridData: this.isSubTableShowPage ? this.gridData : null
713
- })
714
- }
715
- })
716
- }
717
- },
718
- {
719
- immediate: true,
720
- deep: true
721
- }
722
- )
723
-
724
- const that = this
725
- const isShowUserTreeDialog =
726
- document.querySelector('.user-tree') !== null
727
- // 当前页面监视键盘输入
728
- document.querySelector('.' + this.code).onkeydown = function(e) {
729
- if (!that.isShowPageDialog && !isShowUserTreeDialog) {
730
- // 当前列表页面没有弹框或选人弹框,才走键盘监视事件
731
- // 事件对象兼容
732
- // eslint-disable-next-line no-caller
733
- const e1 = e || event || window.event || arguments.callee.caller.arguments[0]
734
- // 处于行编辑状态时,左右上下箭头事件不需要生效
735
- const isEdit = that.isEditRow(that)
736
- // 键盘按键判断:左箭头-37;上箭头-38;右箭头-39;下箭头-40
737
- // 左
738
- if (e1 && e1.keyCode === 37) {
739
- // 左箭头
740
- if (!isEdit) {
741
- that.selectLeftCell(that)
742
- }
743
- } else if (e1 && e1.keyCode === 38) {
744
- // 上箭头
745
- if (!isEdit) {
746
- that.selectUpCell(that)
747
- }
748
- } else if (e1 && e1.keyCode === 39) {
749
- // 右箭头
750
- if (!isEdit) {
751
- that.selectRightCell(that)
752
- }
753
- } else if (e1 && e1.keyCode === 40) {
754
- // 下箭头
755
- if (!isEdit) {
756
- that.selectDownCell(that)
757
- }
758
- } else if (e1 && e1.keyCode === 13) {
759
- // 回车
760
- that.enterOperation(that)
761
- } else if (e1 && e1.keyCode === 27) {
762
- // ESC
763
- that.escOperation(that)
764
- }
765
- }
766
- }
767
-
768
- const b = new Date().getTime()
769
- console.log('super-page--created--执行时间=', (b - a))
770
- })
771
- if (this.query && this.query.showType === 'popup') {
772
- this.$emit('setSearchType', true)
773
- }
774
- this.$watch(
775
- 'options.extraParam',
776
- function(newValue, oldVal) {
777
- this.$set(this.options, 'extraParam', newValue)
778
- const gridParams = store.get(this.code)
779
- gridParams.options.extraParam = newValue
780
- },
781
- {
782
- deep: true
783
- }
784
- )
785
- })
786
- },
787
- methods: {
788
- ...events,
789
- ...publicMethods,
790
- ...superGridService,
791
- ...apis,
792
- isShowPageArea() {
793
- if (this.isFormSubTable) {
794
- return this.options.showPageArea !== undefined && this.options.showPageArea === true
795
- } else {
796
- return true
797
- }
798
- },
799
- resizeTableHeight() {
800
- this.$nextTick(() => {
801
- let tableHeight = getTableHeight(
802
- this.$refs.superGrid,
803
- this.code,
804
- this.pageHeight
805
- )
806
- const gridParams = store.get(this.code)
807
- if (isHasOptionFunction('resizeHeight', this.code)) {
808
- let searchHeight = 0
809
- if (this.$refs.sf) {
810
- // 获得查询区高度
811
- searchHeight = this.$refs.sf.$el.offsetHeight
812
- }
813
- const newHeight = gridParams.options.resizeHeight.call(this, {
814
- code: this.code,
815
- height: tableHeight,
816
- searchHeight: searchHeight
817
- })
818
- if (newHeight) {
819
- tableHeight = newHeight
820
- }
821
- }
822
- this.height = tableHeight
823
- if (this.optionTableHeight) {
824
- this.height = this.optionTableHeight
825
- } else if (
826
- gridParams.options &&
827
- gridParams.options.isFormSubTable &&
828
- gridParams.options.isPdfEditor
829
- ) {
830
- this.height = null
831
- } else if (
832
- gridParams.options &&
833
- gridParams.options.isFormSubTable &&
834
- gridParams.options.formSetHeight
835
- ) {
836
- this.height = gridParams.options.formSetHeight
837
- } else if (
838
- !this.basicInfo.displayEffect ||
839
- this.basicInfo.displayEffect === '' ||
840
- this.basicInfo.displayEffect === 'default'
841
- ) {
842
- this.height = null
843
- }
844
- this.maxHeight = tableHeight
845
- if (
846
- gridParams.options &&
847
- gridParams.options.isFormSubTable &&
848
- gridParams.options.isPdfEditor
849
- ) {
850
- this.maxHeight = null
851
- } else if (
852
- gridParams.options &&
853
- gridParams.options.isFormSubTable &&
854
- gridParams.options.formSetMaxHeight
855
- ) {
856
- this.maxHeight = gridParams.options.formSetMaxHeight
857
- }
858
- })
859
- },
860
- // 回车键
861
- enterOperation(that) {
862
- const gridParams = store.get(that.code)
863
- if (gridParams.options && gridParams.options.isFormSubTable) {
864
- // 如果是子表,只是取消行编辑状态
865
- const editRow = gridParams.$editRow
866
- if (editRow) {
867
- setEntityFieldValue(editRow, '$editing', false)
868
- gridParams.$editRow = null
869
- }
870
- } else {
871
- // 不是子表
872
- if (gridParams.options && !gridParams.options.isFormSubTable) {
873
- const currentSelectCell = that.currentSelectCell
874
- if (currentSelectCell) {
875
- const textAreaCell = currentSelectCell.querySelector('.el-textarea')
876
- if (textAreaCell) {
877
- return
878
- }
879
- }
880
- // 表示不是表单子表时,才需要回车保存
881
- const rowIndex = gridParams.$rowIndex
882
- if (rowIndex !== undefined && rowIndex !== null) {
883
- const row = gridParams.gridData[rowIndex]
884
- if (isEditOptionFunction('enter', that.listCode)) {
885
- gridParams.options.lineEditOptions.enter.call(
886
- that,
887
- rowIndex,
888
- that.column,
889
- row,
890
- gridParams.orgGridData[rowIndex]
891
- )
892
- } else {
893
- that.saveRow(rowIndex, that.code)
894
- }
895
- }
896
- }
897
- }
898
- },
899
- // ESC键取消行编辑
900
- escOperation(that) {
901
- const gridParams = store.get(that.code)
902
- if (gridParams.options && !gridParams.options.isFormSubTable) {
903
- // 表示不是表单子表时,才需要处理ESC取消操作
904
- const rowIndex = gridParams.$rowIndex
905
- if (rowIndex !== undefined && rowIndex !== null) {
906
- that.restoreRow(rowIndex, that.code)
907
- const row = gridParams.gridData[rowIndex]
908
- if (isEditOptionFunction('esc', that.listCode)) {
909
- gridParams.options.lineEditOptions.esc.call(
910
- that,
911
- rowIndex,
912
- that.column,
913
- row,
914
- gridParams.orgGridData[rowIndex]
915
- )
916
- } else {
917
- that.restoreRow(rowIndex, that.code)
918
- }
919
- }
920
- }
921
- },
922
- // 是否正在编辑行,如果正在编辑左右上下箭头事件不需要生效
923
- isEditRow(that) {
924
- const currentSelectCell = that.currentSelectCell
925
- if (currentSelectCell) {
926
- const inputInner = currentSelectCell.querySelector('.el-input__inner')
927
- if (inputInner) {
928
- return true
929
- }
930
- }
931
- return false
932
- },
933
- // 选中上方单元格
934
- selectUpCell(that) {
935
- const currentSelectCell = that.currentSelectCell
936
- if (currentSelectCell) {
937
- const trDom = currentSelectCell.parentNode
938
- if (trDom) {
939
- let tdClass = null
940
- let classes = null
941
- const classObj = currentSelectCell.attributes['class']
942
- if (classObj) {
943
- classes = classObj['nodeValue']
944
- }
945
- if (classes && classes.indexOf(' ') > 0) {
946
- const classArr = classes.split(' ')
947
- tdClass = classArr[0]
948
- }
949
- const preTr = trDom['previousSibling']
950
- if (preTr) {
951
- const targetCell = preTr.querySelector('.' + tdClass)
952
- that.currentSelectCell = targetCell
953
- }
954
- }
955
- }
956
- },
957
- // 选中下方单元格
958
- selectDownCell(that) {
959
- const currentSelectCell = that.currentSelectCell
960
- if (currentSelectCell) {
961
- const trDom = currentSelectCell.parentNode
962
- if (trDom) {
963
- let tdClass = null
964
- let classes = null
965
- const classObj = currentSelectCell.attributes['class']
966
- if (classObj) {
967
- classes = classObj['nodeValue']
968
- }
969
- if (classes && classes.indexOf(' ') > 0) {
970
- const classArr = classes.split(' ')
971
- tdClass = classArr[0]
972
- }
973
- const preTr = trDom['nextSibling']
974
- if (preTr) {
975
- const targetCell = preTr.querySelector('.' + tdClass)
976
- that.currentSelectCell = targetCell
977
- }
978
- }
979
- }
980
- },
981
- // 选中右侧单元格
982
- selectRightCell(that) {
983
- if (that.currentSelectCell) {
984
- const nextCell = that.currentSelectCell['nextSibling']
985
- if (nextCell) {
986
- let classes
987
- const classObj = nextCell.attributes['class']
988
- if (classObj) {
989
- classes = classObj['nodeValue']
990
- }
991
- if (classes && classes.indexOf(' is-hidden') > 0) {
992
- // 表示需要处理冻结列情况
993
- that.getTargetCellWithFixTable(that, classes, nextCell)
994
- } else {
995
- that.currentSelectCell = nextCell
996
- }
997
- }
998
- }
999
- },
1000
- // 选中左侧单元格
1001
- selectLeftCell(that) {
1002
- if (that.currentSelectCell) {
1003
- const preCell = that.currentSelectCell['previousSibling']
1004
- if (preCell) {
1005
- let classes
1006
- const classObj = preCell.attributes['class']
1007
- if (classObj) {
1008
- classes = classObj['nodeValue']
1009
- }
1010
- if (classes && classes.indexOf(' is-hidden') > 0) {
1011
- // 表示需要处理冻结列情况
1012
- that.getTargetCellWithFixTable(that, classes, preCell)
1013
- } else {
1014
- that.currentSelectCell = preCell
1015
- }
1016
- }
1017
- }
1018
- },
1019
- // 左右箭头时,有冻结列时,获得目的单元格
1020
- getTargetCellWithFixTable(that, classes, currentCell) {
1021
- const tr = currentCell.parentNode
1022
- if (tr) {
1023
- const tbody = tr.parentNode
1024
- if (tbody) {
1025
- const table = tbody.parentNode
1026
- if (table) {
1027
- const tableDiv = table.parentNode
1028
- if (tableDiv) {
1029
- const classObj = tableDiv.attributes['class']
1030
- if (classObj) {
1031
- const tableDivClasses = classObj['nodeValue']
1032
- if (
1033
- tableDivClasses &&
1034
- tableDivClasses.indexOf('el-table__fixed-body-wrapper') >= 0
1035
- ) {
1036
- // 表示当前单元格是冻结列中的,需要在非冻结列中获得该单元格
1037
- let tdClass = null
1038
- if (classes && classes.indexOf(' ') > 0) {
1039
- const classArr = classes.split(' ')
1040
- tdClass = classArr[0]
1041
- }
1042
- if (tdClass) {
1043
- const targetCell = document.querySelector(
1044
- '.' +
1045
- this.code +
1046
- ' .el-table__body-wrapper .current-row .' +
1047
- tdClass
1048
- )
1049
- that.currentSelectCell = targetCell
1050
- }
1051
- } else if (
1052
- tableDivClasses &&
1053
- tableDivClasses.indexOf('el-table__body-wrapper') >= 0
1054
- ) {
1055
- // 表示当前单元格是非冻结列中的,需要在冻结列中获得该单元格
1056
- let tdClass = null
1057
- if (classes && classes.indexOf(' ') > 0) {
1058
- const classArr = classes.split(' ')
1059
- tdClass = classArr[0]
1060
- }
1061
- if (tdClass) {
1062
- const targetCell = document.querySelector(
1063
- '.' +
1064
- this.code +
1065
- ' .el-table__fixed-body-wrapper .current-row .' +
1066
- tdClass
1067
- )
1068
- that.currentSelectCell = targetCell
1069
- }
1070
- }
1071
- }
1072
- }
1073
- }
1074
- }
1075
- }
1076
- },
1077
- // 存储有默认值的字段集合
1078
- storeHasDefaultValueColumns(column, gridParams) {
1079
- if (
1080
- column.defaultValue !== undefined &&
1081
- column.defaultValue !== null &&
1082
- column.defaultValue !== ''
1083
- ) {
1084
- if (
1085
- gridParams.defaultValueColumns === undefined ||
1086
- gridParams.defaultValueColumns === null
1087
- ) {
1088
- gridParams.defaultValueColumns = []
1089
- }
1090
- gridParams.defaultValueColumns.push(column)
1091
- }
1092
- },
1093
- // 判断是不是表单子表的使用
1094
- judgeIsFormSubTable() {
1095
- // 没有分页
1096
- // 没有排序
1097
- const gridParams = store.get(this.code)
1098
- if (
1099
- gridParams &&
1100
- gridParams.options &&
1101
- gridParams.options.isFormSubTable !== undefined &&
1102
- gridParams.options.isFormSubTable === true
1103
- ) {
1104
- this.isFormSubTable = true
1105
- }
1106
- },
1107
- /**
1108
- * 给列设置操作信息
1109
- * @param operationSetting 操作列设置,{prop:[{按钮组件},{按钮组件},{link组件}],prop:[{},{}]}
1110
- */
1111
- initColumnOperation(column, operationSetting) {
1112
- if (operationSetting && operationSetting[column.prop]) {
1113
- const prop = column.prop
1114
- column.operations = operationSetting[prop]
1115
- }
1116
- },
1117
- // 获得属性列操作信息
1118
- getOptionOperations() {
1119
- if (
1120
- typeof this.options['operations'] !== 'undefined' &&
1121
- this.options['operations'] !== null
1122
- ) {
1123
- return this.options['operations']
1124
- }
1125
- },
1126
- initSetting() {
1127
- const gridParams = store.get(this.code)
1128
- if (typeof this.options !== 'undefined') {
1129
- Object.assign(gridParams.options, this.options)
1130
- if (!gridParams.options.lineEditOptions) {
1131
- gridParams.options.lineEditOptions = gridParams.defaultLineEditOptions
1132
- }
1133
- if (
1134
- typeof this.options['customFormatter'] !== 'undefined' &&
1135
- this.options['customFormatter'] !== null
1136
- ) {
1137
- this.myCustomFormatter = this.options['customFormatter']
1138
- }
1139
- } else {
1140
- gridParams.options = {}
1141
- gridParams.options.lineEditOptions = gridParams.defaultLineEditOptions
1142
- }
1143
- if (!isHasEditOption('input', this.code)) {
1144
- gridParams.options.lineEditOptions.input =
1145
- gridParams.defaultLineEditOptions.input
1146
- }
1147
- if (
1148
- !this.myCustomFormatter &&
1149
- typeof this.customFormatter !== 'undefined' &&
1150
- this.customFormatter !== null
1151
- ) {
1152
- this.myCustomFormatter = this.customFormatter
1153
- }
1154
- if (
1155
- this.options &&
1156
- this.options.dynamicServiceName &&
1157
- this.options.dynamicServiceName !== undefined
1158
- ) {
1159
- this.dynamicServiceName = this.options.dynamicServiceName
1160
- gridParams.dynamicServiceName = this.dynamicServiceName
1161
- }
1162
- if (
1163
- this.options &&
1164
- this.options.system &&
1165
- this.options.system !== undefined
1166
- ) {
1167
- gridParams.system = this.options.system
1168
- }
1169
- if (
1170
- this.options &&
1171
- this.options.additionalParamMap &&
1172
- this.options.additionalParamMap !== undefined
1173
- ) {
1174
- gridParams.additionalParamMap = this.options.additionalParamMap
1175
- }
1176
- },
1177
- changeRowStyle(param) {
1178
- // param的格式:{row, rowIndex}
1179
- const gridParams = store.get(this.code)
1180
- if (this.lineEdit && this.lineEdit.editable) {
1181
- if (param.rowIndex === gridParams.$rowIndex) {
1182
- if (
1183
- !isObjectValueEqual(
1184
- param.row,
1185
- gridParams.orgGridData[gridParams.$rowIndex]
1186
- )
1187
- ) {
1188
- // return { 'background': 'rgb(245, 181, 203)' }
1189
- }
1190
- }
1191
- }
1192
- if (isHasOptionFunction('rowStyleRender', this.code)) {
1193
- return gridParams.options.rowStyleRender.call(this, param)
1194
- }
1195
- if (
1196
- this.options &&
1197
- this.options.renderRow &&
1198
- this.options.renderRow.hasOwnProperty(param.rowIndex)
1199
- ) {
1200
- return { background: this.options.renderRow[param.rowIndex] }
1201
- }
1202
- },
1203
- changeCellStyle(param) {
1204
- const gridParams = store.get(this.code)
1205
- let funName = null
1206
- let columnOptions = null
1207
- if (param && param.column && param.column.property) {
1208
- if (gridParams && gridParams.columnOptionMap) {
1209
- if (gridParams.columnOptionMap[param.column.property]) {
1210
- columnOptions = gridParams.columnOptionMap[param.column.property]
1211
- if (columnOptions.events && columnOptions.events.cellStyle) {
1212
- funName = columnOptions.events.cellStyle
1213
- }
1214
- }
1215
- }
1216
- }
1217
- // {row, column, rowIndex, columnIndex}
1218
- // 获取对应单元格配置
1219
- if (isHasOptionFunction('cellStyleRender', this.code)) {
1220
- return gridParams.options.cellStyleRender.call(this, param)
1221
- } else if (
1222
- funName !== null &&
1223
- columnOptions !== null &&
1224
- gridParams.options &&
1225
- gridParams.options['eventCallBack'] &&
1226
- gridParams.options['eventCallBack'][funName] &&
1227
- typeof gridParams.options['eventCallBack'][funName] === 'function'
1228
- ) {
1229
- const params = {
1230
- value: param.row[param.column.property],
1231
- row: param.row,
1232
- column: columnOptions,
1233
- prop: param.column.property
1234
- }
1235
- return gridParams.options['eventCallBack'][funName].call(this, params)
1236
- }
1237
- },
1238
- changeHeaderStyle(param) {
1239
- // param的格式:{row, column, rowIndex, columnIndex}
1240
- // 区分是编辑模式还是应用模式
1241
- if (
1242
- typeof this.options.isAdministerListView !== 'undefined' &&
1243
- this.options.isAdministerListView != null &&
1244
- this.options.isAdministerListView === true
1245
- ) {
1246
- // 编辑模式
1247
- const column = param.column
1248
- if (column.type === 'selection') {
1249
- if (this.backgroundColorMap['$selection']) {
1250
- return { background: this.backgroundColorMap['$selection'] }
1251
- }
1252
- } else if (
1253
- column.type &&
1254
- column.type === 'default' &&
1255
- !column.property
1256
- ) {
1257
- if (this.backgroundColorMap['$index']) {
1258
- return { background: this.backgroundColorMap['$index'] }
1259
- }
1260
- } else {
1261
- if (column.property && this.backgroundColorMap[column.property]) {
1262
- return { background: this.backgroundColorMap[column.property] }
1263
- }
1264
- }
1265
- } else {
1266
- const gridParams = store.get(this.code)
1267
- let funName = null
1268
- let columnOptions = null
1269
- if (param && param.column && param.column.property) {
1270
- if (gridParams && gridParams.columnOptionMap) {
1271
- if (gridParams.columnOptionMap[param.column.property]) {
1272
- columnOptions = gridParams.columnOptionMap[param.column.property]
1273
- if (
1274
- columnOptions.events &&
1275
- columnOptions.events.headerCellStyle
1276
- ) {
1277
- funName = columnOptions.events.headerCellStyle
1278
- }
1279
- }
1280
- }
1281
- }
1282
- // 应用模式
1283
- // 修改表头样式,当某些字段需要编辑时,某些字段不需要编辑时,为了突出显示有权限编辑的字段,可以使用该功能
1284
- if (
1285
- gridParams.options.renderHeader &&
1286
- gridParams.options.renderHeader.props
1287
- ) {
1288
- const column = param.column
1289
- const props = gridParams.options.renderHeader.props
1290
- const propsArr = props.split(',')
1291
- for (let i = 0; i < propsArr.length; i++) {
1292
- const prop = propsArr[i]
1293
- if (column.property === prop.trim()) {
1294
- let backgroundColor = '#c3f4e2'
1295
- if (
1296
- typeof gridParams.options.renderHeader.color !== 'undefined'
1297
- ) {
1298
- backgroundColor = gridParams.options.renderHeader.color
1299
- }
1300
- return { background: backgroundColor }
1301
- }
1302
- }
1303
- } else if (
1304
- funName !== null &&
1305
- columnOptions !== null &&
1306
- gridParams.options &&
1307
- gridParams.options['eventCallBack'] &&
1308
- gridParams.options['eventCallBack'][funName] &&
1309
- typeof gridParams.options['eventCallBack'][funName] === 'function'
1310
- ) {
1311
- // const param = { value: param.row[param.column.property], row: param.row, column: columnOptions, prop: param.column.property }
1312
- return gridParams.options['eventCallBack'][funName].call(this, param)
1313
- }
1314
- }
1315
- },
1316
- fetchData(searchParam, isSearch, parentRowIds, resove) {
1317
- const gridParams = store.get(this.code)
1318
- // 查询数据需要区分,如果时列表管理编辑模式,使用静态数据
1319
- if (gridParams.options && gridParams.options.isPageInfo) {
1320
- // 预览模式且从表单子表进入
1321
- } else {
1322
- if (gridParams.options && gridParams.options.isAdministerListView) {
1323
- // 根据类型生成静态数据
1324
- if (
1325
- gridParams.options.SuperGrid &&
1326
- gridParams.options.SuperGrid.simulationDate
1327
- ) {
1328
- if (isHasOptionFunction('gridDataLoaded', this.code)) {
1329
- const gridData = gridParams.options.gridDataLoaded.call(this, {
1330
- gridData: gridParams.options.SuperGrid.simulationDate,
1331
- columns: gridParams.columns
1332
- })
1333
- if (gridData) {
1334
- this.gridData = gridData
1335
- } else {
1336
- this.gridData = gridParams.options.SuperGrid.simulationDate
1337
- }
1338
- } else {
1339
- this.gridData = gridParams.options.SuperGrid.simulationDate
1340
- }
1341
- gridParams.gridData = this.gridData
1342
- }
1343
- } else if (
1344
- gridParams.options &&
1345
- gridParams.options.isFormSubTable &&
1346
- gridParams.options.subTableData &&
1347
- gridParams.options.subTableData.length > 0
1348
- ) {
1349
- this.hasLoadData = false
1350
- gridParams.loaded = true
1351
- let subTableData = []
1352
- // 如果有子表数据,则展示传递的子表数据
1353
- if (isHasOptionFunction('gridDataLoaded', this.code)) {
1354
- const gridData = gridParams.options.gridDataLoaded.call(this, {
1355
- gridData: gridParams.options.subTableData,
1356
- columns: gridParams.columns
1357
- })
1358
- if (gridData) {
1359
- subTableData = gridData
1360
- this.hasLoadData = true
1361
- } else {
1362
- subTableData = gridParams.options.subTableData
1363
- this.hasLoadData = true
1364
- }
1365
- } else {
1366
- subTableData = gridParams.options.subTableData
1367
- this.hasLoadData = true
1368
- }
1369
- if (subTableData) {
1370
- // 子表时所有记录的所有字段设置默认值null,优化子表编辑时性能
1371
- subTableData.forEach(item => {
1372
- this.setColumnsDefaultValue(gridParams.allColumns, item)
1373
- })
1374
- }
1375
- if (this.pagination && this.isSubTableShowPage === true) {
1376
- // 表示子表需要显示分页
1377
- this.subTableData = subTableData
1378
- // 更新记录总条数
1379
- this.pagination.total = this.subTableData.length
1380
- gridParams.subTableData = this.subTableData
1381
- this.gridData = this.getSubTableGridData(this.subTableData)
1382
- } else {
1383
- this.gridData = subTableData
1384
- }
1385
- gridParams.gridData = this.gridData
1386
- // 完成深拷贝,复制一份对象,行编辑时使用
1387
- gridParams.orgGridData = [].concat(
1388
- JSON.parse(JSON.stringify(this.gridData))
1389
- )
1390
- } else {
1391
- return this.fetchListData(searchParam, isSearch, parentRowIds, resove)
1392
- }
1393
- }
1394
- },
1395
- getSubTableGridData(subTableData) {
1396
- let gridData = subTableData
1397
- if (this.isSubTableShowPage === true) {
1398
- if (subTableData && subTableData.length > 0) {
1399
- // const subTableData = JSON.parse(JSON.stringify(this.subTableData))
1400
- this.pagination.total = subTableData.length
1401
- // 当前是第几页
1402
- let currentPage = this.currentPage
1403
- if (currentPage === undefined || currentPage === null) {
1404
- currentPage = 1
1405
- }
1406
- // 每页显示多少条记录
1407
- let pageSize = this.pageSize
1408
- if (pageSize === null && this.pagination) {
1409
- pageSize = this.pagination.pageSize
1410
- }
1411
- if (pageSize === undefined || pageSize === null) {
1412
- pageSize = 20
1413
- }
1414
- // 当前页的第一条记录的数组下标
1415
- const startRowIndex = (currentPage - 1) * pageSize
1416
- // 当前页的最后一条记录的数组下标
1417
- let lastRowIndex = startRowIndex + pageSize
1418
- if (subTableData.length > startRowIndex) {
1419
- // 表示当前页有记录
1420
- if (lastRowIndex > subTableData.length) {
1421
- // 表示最后一条记录超过下标了
1422
- lastRowIndex = subTableData.length
1423
- }
1424
- // 前包,后不包
1425
- gridData = subTableData.slice(startRowIndex, lastRowIndex)
1426
- }
1427
- }
1428
- }
1429
- if (gridData === undefined || gridData === null) {
1430
- gridData = []
1431
- }
1432
- return gridData
1433
- },
1434
- fetchListData(searchParam, isSearch, parentRowIds, resove) {
1435
- return new Promise((resolve, reject) => {
1436
- this.isLoading = true
1437
- this.hasLoadData = false
1438
- if (isSearch === undefined || isSearch === false) {
1439
- // 如果不是查询时才需要从缓存中获得结果
1440
- // 如果是刷新当前列表,则需要获得缓存中的sessionStorage
1441
- const isRefreshList = sessionStorage.getItem(
1442
- 'refreshList-' + this.code
1443
- )
1444
- // console.log('fetchData--isRefreshList--', isRefreshList)
1445
- if (isRefreshList !== undefined && isRefreshList === 'true') {
1446
- const searchParamJson = sessionStorage.getItem(
1447
- 'searchParam-' + this.code
1448
- )
1449
- // console.log('fetchData--searchParamJson--', searchParamJson)
1450
- // console.log('fetchData--pagination--', this.pagination)
1451
- if (
1452
- searchParamJson !== undefined &&
1453
- searchParamJson !== null &&
1454
- searchParamJson !== ''
1455
- ) {
1456
- searchParam = JSON.parse(searchParamJson)
1457
- const pagination = searchParam.pagination
1458
- if (pagination) {
1459
- this.currentPage = pagination.currentPage
1460
- this.pagination.pageSize = pagination.pageSize
1461
- this.pagination.showTotal = pagination.showTotal
1462
- }
1463
- this.getInitSearchForm(searchParam.searchForm)
1464
- // this.searchFormContent = searchParam.searchForm
1465
- }
1466
- }
1467
- }
1468
- sessionStorage.removeItem('refreshList-' + this.code)
1469
- if (searchParam === undefined) {
1470
- searchParam = this.getSearchParam()
1471
- }
1472
- const gridParams = store.get(this.code)
1473
- let param = searchParam
1474
-
1475
- if (gridParams.options.extraParam || parentRowIds !== undefined) {
1476
- param = getExtraParam(searchParam, gridParams)
1477
- }
1478
- // 导出需要这两个参数
1479
- gridParams.searchParam = searchParam
1480
- gridParams.url = this.url
1481
- let requestUrl = this.url
1482
- if (parentRowIds !== undefined && parentRowIds !== null) {
1483
- // 表示是查询子集合时
1484
- param = Object.assign({}, param)
1485
- // 清空查询子集合时,分页信息,即不需要分页查询子集合
1486
- param.searchParam.pagination = null
1487
- // 父节点id传给后台
1488
- param['parentIds'] = parentRowIds
1489
- // 父级字段名,例如:parentId 或 fk_parent_id
1490
- param['parentProp'] = this.parentProp
1491
- // 传入系统code
1492
- param.systemCode = getSystemCode()
1493
-
1494
- requestUrl = this.options.subRowUrl
1495
- }
1496
- // 解决新建后,查询,再点新建报“有未保存的行”问题,解决方案是一旦刷新列表,就还原这些状态
1497
- gridParams.isCreateRow = false
1498
- gridParams.isEditRow = false
1499
- gridParams.$lastSaveRowIndex = null
1500
- gridParams.$rowIndex = null
1501
- gridParams.canSaveRow = true
1502
- // 是否根据权限显示数据
1503
- gridParams.withDataPermission = gridParams.options.isWithDataPermission
1504
- // 对象是否是流程实体
1505
- gridParams.isWorkflowEntity = gridParams.options.isWorkflowEntity
1506
- // 缓存查询条件及当前页数
1507
- sessionStorage.setItem(
1508
- 'searchParam-' + this.code,
1509
- JSON.stringify(param)
1510
- )
1511
- if (this.parentProp && searchParam.searchForm && searchParam.searchForm.length > 0) {
1512
- // 表示是树形列表的查询时,查询结果不需要树形显示,后台处理的数据没有加has_children来实现的
1513
- param.listViewTreeSetting = null
1514
- }
1515
- this.$http
1516
- .post(requestUrl, param)
1517
- .then(data => {
1518
- if (typeof parentRowIds === 'undefined' || parentRowIds === null) {
1519
- let tableData = []
1520
- // 对数据做序列化,比如:处理xss攻击
1521
- if (isHasOptionFunction('gridDataLoaded', this.code)) {
1522
- const gridData = gridParams.options.gridDataLoaded.call(this, {
1523
- gridData: data.data,
1524
- columns: gridParams.columns
1525
- })
1526
- if (gridData) {
1527
- tableData = gridData
1528
- } else {
1529
- tableData = data.data
1530
- }
1531
- } else {
1532
- tableData = data.data
1533
- }
1534
- if (!tableData) {
1535
- tableData = []
1536
- }
1537
- if (gridParams.options.isFormSubTable) {
1538
- // 子表时默认不全部行编辑
1539
- if (tableData) {
1540
- // 子表时所有记录的所有字段设置默认值null,优化子表编辑时性能
1541
- tableData.forEach(item => {
1542
- this.setColumnsDefaultValue(gridParams.allColumns, item)
1543
- })
1544
- }
1545
- // console.log('子表数据循环', this.gridData)
1546
- // this.gridData.forEach(item => {
1547
- // item.$editing = true
1548
- // })
1549
- if (this.pagination && this.isSubTableShowPage === true) {
1550
- // 表示子表需要显示分页
1551
- this.subTableData = tableData
1552
- this.gridData = this.getSubTableGridData(this.subTableData)
1553
- gridParams.subTableData = this.subTableData
1554
- } else {
1555
- this.gridData = tableData
1556
- }
1557
- if (this.pagination !== null) {
1558
- this.pagination.total = tableData.length
1559
- }
1560
- } else {
1561
- // if (this.lineEdit.editable) {
1562
- this.gridData = tableData
1563
- // } else {
1564
- // this.gridData = Object.freeze(tableData)
1565
- // }
1566
-
1567
- if (this.pagination !== null) {
1568
- this.pagination.total = data.total
1569
- }
1570
- }
1571
- if (data.summaries && Object.keys(data.summaries).length > 0) {
1572
- this.summaries = data.summaries
1573
- }
1574
-
1575
- gridParams.gridData = this.gridData
1576
-
1577
- // 完成深拷贝,复制一份对象,行编辑时使用
1578
- gridParams.orgGridData = [].concat(
1579
- JSON.parse(JSON.stringify(this.gridData))
1580
- )
1581
-
1582
- gridParams.pagination = this.pagination
1583
- gridParams.loaded = true
1584
-
1585
- // TODO: 输入焦点默认停在第一个可编辑的单元格
1586
- if (this.lineEdit.editable) {
1587
- if (typeof isSearch === 'undefined' || isSearch === false) {
1588
- // 不是查询时,才需要创建第一行记录
1589
- if (this.gridData.length === 0) {
1590
- if (
1591
- this.options &&
1592
- this.options.isDefaultShowEdit !== null &&
1593
- this.options.isDefaultShowEdit !== undefined &&
1594
- this.options.isDefaultShowEdit === true
1595
- ) {
1596
- this.createRow(this.code, null, this.gridData)
1597
- }
1598
- }
1599
- if (this.gridData.length > 0) {
1600
- this.$set(this.lineEdit, 'editingCell', {
1601
- row: 0,
1602
- prop: getFirstEditableColumn(this.code)
1603
- })
1604
- }
1605
- }
1606
- }
1607
- this.hasLoadData = true
1608
- } else {
1609
- // 对数据做序列化,比如:处理xss攻击
1610
- if (isHasOptionFunction('gridDataLoaded', this.code)) {
1611
- gridParams.options.gridDataLoaded.call(this, { gridData: data })
1612
- }
1613
-
1614
- if (isHasOptionFunction('loadChildrenComplete', this.code)) {
1615
- gridParams.options.loadChildrenComplete.call(this, {
1616
- parentRowIds: parentRowIds,
1617
- gridData: data,
1618
- columns: gridParams.columns
1619
- })
1620
- }
1621
- if (typeof resove !== 'undefined' && resove !== null) {
1622
- // 首次加载或点击三角展开父节点时走该分支
1623
- // 刷新数据后,移除该父节点下的所有已选中的子节点记录。
1624
- // 必须调用该方法,否则在删除记录时,数据即使刷新了,已选中集合this.$refs.superGrid.store.states.selection中仍会有该已删除记录,导致再次执行删除报id不存在
1625
- this.removeGridStoreSelection(parentRowIds)
1626
- resove(data[parentRowIds[0]])
1627
- } else {
1628
- // 刷新父记录对应的子记录集合时需要,例如:删除时
1629
- parentRowIds.forEach(parentRowId => {
1630
- // 单行父记录id
1631
- this.$refs.superGrid.store.states.lazyTreeNodeMap[
1632
- parentRowId
1633
- ] = data[parentRowId]
1634
- this.$refs.superGrid.store.states.treeData[
1635
- parentRowId
1636
- ].children = data[parentRowId]
1637
- })
1638
- // 刷新数据后,移除该父节点下的所有已选中的子节点记录
1639
- // 必须调用该方法,否则在删除记录时,数据即使刷新了,已选中集合this.$refs.superGrid.store.states.selection中仍会有该已删除记录,导致再次执行删除报id不存在
1640
- this.removeGridStoreSelection(parentRowIds)
1641
- }
1642
- this.hasLoadData = true
1643
- }
1644
- resolve()
1645
- })
1646
- .catch(error => {
1647
- if (isHasOptionFunction('loadError', this.code)) {
1648
- gridParams.options.loadError.call(this, this.code, error)
1649
- }
1650
- reject(error)
1651
- })
1652
- })
1653
- },
1654
- // 获得初始查询条件对象
1655
- getInitSearchForm(searchFormArr) {
1656
- const gridParams = store.get(this.code)
1657
- if (searchFormArr && searchFormArr.length > 0) {
1658
- this.searchFormContent = {}
1659
- searchFormArr.forEach(item => {
1660
- // 获得的是"isDeleted"
1661
- let prop = item.propName
1662
- // 获得的是“deleted”
1663
- const columnProp = item.columnProp
1664
- const dataType = item.dataType
1665
- if (dataType && dataType === 'BOOLEAN') {
1666
- prop = columnProp
1667
- }
1668
- this.initSearchProps.push(prop)
1669
- const propValue = item.propValue
1670
- if (prop && prop.indexOf('.') > 0) {
1671
- // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
1672
- addDynamicProp(this.searchFormContent, prop, propValue)
1673
- } else {
1674
- this.searchFormContent[prop] = propValue
1675
- }
1676
- })
1677
- gridParams.searchForm = searchFormArr
1678
- // 调用查询api方法,该方法中调用了@showSearch方法,用于控制“查询”按钮改名为“取消查询”
1679
- this.showSearchForm()
1680
- } else {
1681
- gridParams.searchForm = null
1682
- }
1683
- },
1684
- showDemo() {
1685
- this.isLoading = true
1686
- this.$http
1687
- .get(this.url)
1688
- .then(data => {
1689
- // 根据this.options.showColumns设置显示的字段
1690
- this.getShowColumns(data)
1691
-
1692
- Object.assign(this, data)
1693
- const gridParams = store.get(this.code)
1694
- gridParams.listCode = this.code
1695
-
1696
- gridParams.columns = this.columns
1697
- if (gridParams.columns && this.options.dynamicColumns) {
1698
- for (var i = 0; i < this.options.dynamicColumns.length; i++) {
1699
- this.options.dynamicColumns[i].dynamic = true
1700
- gridParams.columns.push(this.options.dynamicColumns[i])
1701
- }
1702
- }
1703
- gridParams.lineEdit = this.lineEdit
1704
- gridParams.basicInfo = this.basicInfo
1705
- gridParams.pagination = this.pagination
1706
- gridParams.query = this.query
1707
-
1708
- this.gridData = data.gridData
1709
- // 对数据做序列化,比如:处理xss攻击
1710
- if (isHasOptionFunction('gridDataLoaded', this.code)) {
1711
- const gridData = gridParams.options.gridDataLoaded.call(
1712
- this,
1713
- data.gridData
1714
- )
1715
- if (gridData) {
1716
- this.gridData = gridData
1717
- } else {
1718
- this.gridData = data.gridData
1719
- }
1720
- } else {
1721
- this.gridData = data.gridData
1722
- }
1723
-
1724
- if (this.pagination != null) {
1725
- this.pagination.total = data.total
1726
- }
1727
- if (!this.gridData) {
1728
- this.gridData = []
1729
- }
1730
- gridParams.gridData = this.gridData
1731
- // 完成深拷贝,复制一份对象,行编辑时使用
1732
- gridParams.orgGridData = [].concat(
1733
- JSON.parse(JSON.stringify(this.gridData))
1734
- )
1735
- gridParams.pagination = this.pagination
1736
-
1737
- // TODO: 输入焦点默认停在第一个可编辑的单元格
1738
- if (this.lineEdit.editable) {
1739
- if (this.gridData.length === 0) {
1740
- this.createRow(this.code, null, this.gridData)
1741
- }
1742
- this.$set(this.lineEdit, 'editingCell', {
1743
- row: 0,
1744
- prop: getFirstEditableColumn(this.code)
1745
- })
1746
- }
1747
- if (isHasOptionFunction('gridComplete', this.code)) {
1748
- gridParams.options.gridComplete.call(
1749
- this,
1750
- this.gridData,
1751
- gridParams.columns
1752
- )
1753
- }
1754
- })
1755
- .catch(error => {
1756
- if (isHasOptionFunction('loadError', this.code)) {
1757
- const gridParams = store.get(this.code)
1758
- gridParams.options.loadError.call(this, this.code, error)
1759
- }
1760
- })
1761
- },
1762
- doSearch(searchForm) {
1763
- // 修改当前页为第1页
1764
- this.currentPage = 1
1765
- // 将toolbar 参数和查询表单参数合并
1766
- if (searchForm) {
1767
- if (searchForm.length > 0) {
1768
- if (this.toolbarFieldParam && this.toolbarFieldParam.length > 0) {
1769
- if (searchForm.length === 1) {
1770
- searchForm[0].leftBracket = '('
1771
- searchForm[0].rightBracket = ')'
1772
- }
1773
- if (searchForm[searchForm.length - 1].joinSign === 'or') {
1774
- searchForm[searchForm.length - 1].joinSign = 'and'
1775
- }
1776
- // 拼接
1777
- // param.concat(toolbarFieldParam)
1778
- Array.prototype.push.apply(searchForm, this.toolbarFieldParam)
1779
- }
1780
- } else {
1781
- if (this.toolbarFieldParam && this.toolbarFieldParam.length > 0) {
1782
- searchForm = this.toolbarFieldParam
1783
- }
1784
- }
1785
- }
1786
- this.search(searchForm, true)
1787
- },
1788
- doSearchDialog(searchForm) {
1789
- // 修改当前页为第1页
1790
- this.currentPage = 1
1791
- this.search(searchForm, true)
1792
- this.closeSearchFormDialog()
1793
- },
1794
- // cs123
1795
- search(searchForm, isSearch, parentRowIds) {
1796
- // 重新查询列表数据时,抛出refresh事件,供父组件捕获做自己的业务处理
1797
- this.$emit('refresh')
1798
- const vm = this
1799
- return new Promise((resolve, reject) => {
1800
- const gridParams = store.get(vm.code)
1801
- if (typeof searchForm !== 'undefined' && searchForm !== null) {
1802
- gridParams.searchForm = searchForm
1803
- } else {
1804
- gridParams.searchForm = null
1805
- }
1806
- if (gridParams.options && gridParams.options.isAdministerListView) {
1807
- // 根据类型生成静态数据
1808
- if (
1809
- gridParams.options.SuperGrid &&
1810
- gridParams.options.SuperGrid.simulationDate
1811
- ) {
1812
- let gridData
1813
- if (isHasOptionFunction('gridDataLoaded', vm.code)) {
1814
- gridData = gridParams.options.gridDataLoaded.call(this, {
1815
- gridData: gridParams.options.SuperGrid.simulationDate,
1816
- columns: gridParams.columns
1817
- })
1818
- if (!gridData) {
1819
- gridData = gridParams.options.SuperGrid.simulationDate
1820
- }
1821
- } else {
1822
- gridData = gridParams.options.SuperGrid.simulationDate
1823
- }
1824
- resolve(gridData)
1825
- }
1826
- } else if (
1827
- gridParams.options &&
1828
- gridParams.options.isFormSubTable &&
1829
- gridParams.options.subTableData &&
1830
- gridParams.options.subTableData.length > 0
1831
- ) {
1832
- let gridData
1833
- vm.hasLoadData = false
1834
- gridParams.loaded = true
1835
- // 如果有子表数据,则展示传递的子表数据
1836
- if (isHasOptionFunction('gridDataLoaded', vm.code)) {
1837
- gridData = gridParams.options.gridDataLoaded.call(this, {
1838
- gridData: gridParams.options.subTableData,
1839
- columns: gridParams.columns
1840
- })
1841
- if (!gridData) {
1842
- gridData = gridParams.options.subTableData
1843
- vm.hasLoadData = true
1844
- }
1845
- } else {
1846
- gridData = gridParams.options.subTableData
1847
- vm.hasLoadData = true
1848
- }
1849
- resolve(gridData)
1850
- } else {
1851
- vm.fetchData(vm.getSearchParam(), isSearch, parentRowIds)
1852
- .then(data => {
1853
- console.log('打印1====', gridParams)
1854
- if (
1855
- gridParams !== undefined &&
1856
- gridParams.options !== undefined &&
1857
- gridParams.options.isHiddenSearchForm !== undefined &&
1858
- gridParams.options.isHiddenSearchForm === true
1859
- ) {
1860
- // 查询时,是否隐藏查询区域,默认是不隐藏查询区域
1861
- console.log('打印2====', vm)
1862
- vm.showSearch = false
1863
- vm.$emit('cancel-search')
1864
- }
1865
- console.log('打印3====', vm)
1866
- console.log('打印4====', vm.$refs)
1867
- if (vm.$refs && vm.$refs.sf) {
1868
- console.log('打印5====', vm.$refs.sf)
1869
- vm.$refs.sf.loading = false
1870
- vm.$refs.sf.searchComplete()
1871
- }
1872
- console.log('打印6====', vm)
1873
- // 重新计算列表高度
1874
- this.resizeTableHeight()
1875
- resolve(data)
1876
- })
1877
- .catch(error => {
1878
- if (vm.$refs.sf) {
1879
- vm.$refs.sf.loading = false
1880
- vm.$refs.sf.searchComplete()
1881
- }
1882
- reject(error)
1883
- })
1884
- }
1885
- })
1886
- },
1887
- // addSearchParam(searchData) {
1888
- // if (searchData && searchData.length > 0) {
1889
- // const gridParams = store.get(this.code)
1890
- // if (typeof (gridParams.searchForm) !== 'undefined') {
1891
- // const searchForm = gridParams.searchForm
1892
- // searchForm.concat()
1893
- // searchParam.searchForm = gridParams.searchForm
1894
- // } else {
1895
- // searchParam.searchForm = []
1896
- // }
1897
- // }
1898
- // },
1899
- getPaginationInfo() {
1900
- const gridParams = store.get(this.code)
1901
- if (this.pagination !== null) {
1902
- const pagination = {
1903
- currentPage: this.currentPage,
1904
- pageSize: this.pagination.pageSize,
1905
- showTotal: this.pagination.showTotal
1906
- }
1907
- if (this.pageSize !== null) {
1908
- // 表示更改了每页显示的数据条数
1909
- pagination.pageSize = this.pageSize
1910
- }
1911
- if (
1912
- typeof gridParams.currentPage !== 'undefined' &&
1913
- gridParams.currentPage !== null
1914
- ) {
1915
- // 保持页数时使用
1916
- pagination.currentPage = gridParams.currentPage
1917
- // 必须清空一下,否则会导致翻页有问题
1918
- gridParams.currentPage = null
1919
- }
1920
- return pagination
1921
- }
1922
- },
1923
- getSearchParam() {
1924
- const searchParam = {
1925
- code: this.code
1926
- }
1927
- const gridParams = store.get(this.code)
1928
- const pagination = this.getPaginationInfo()
1929
- if (pagination && pagination !== null) {
1930
- searchParam.pagination = pagination
1931
- }
1932
- // 排序信息
1933
- if (this.sortInfo !== null) {
1934
- // 表示更改了排序信息
1935
- searchParam.sorts = this.sortInfo
1936
- }
1937
- if (this.mergeFields && this.mergeFields.length > 0) {
1938
- if (!searchParam.sorts) {
1939
- searchParam.sorts = []
1940
- }
1941
- const mergeFieldsArr = []
1942
- for (const mergeField of this.mergeFields) {
1943
- let flag = true
1944
- for (const so of searchParam.sorts) {
1945
- if (so.prop === mergeField) {
1946
- flag = false
1947
- break
1948
- }
1949
- }
1950
- if (flag) {
1951
- mergeFieldsArr.push({
1952
- prop: mergeField,
1953
- order: 'ascending'
1954
- })
1955
- }
1956
- }
1957
- mergeFieldsArr.push(...searchParam.sorts)
1958
- searchParam.sorts = mergeFieldsArr
1959
- }
1960
- // 是否有初始过滤条件
1961
- if (
1962
- gridParams.options &&
1963
- typeof gridParams.options.initSearchForm !== 'undefined'
1964
- ) {
1965
- searchParam.initSearchForm = gridParams.options.initSearchForm
1966
- }
1967
- if (
1968
- gridParams.query &&
1969
- typeof gridParams.query.defaultQueryCriteria !== 'undefined'
1970
- ) {
1971
- // json字符串转数组
1972
- searchParam.defaultQueryCriteria = JSON.parse(
1973
- gridParams.query.defaultQueryCriteria
1974
- )
1975
- }
1976
- if (typeof gridParams.searchForm !== 'undefined') {
1977
- searchParam.searchForm = gridParams.searchForm
1978
- } else {
1979
- searchParam.searchForm = []
1980
- }
1981
- if (this.dynamicColumnInfo) {
1982
- searchParam.dynamicColumnInfo = this.dynamicColumnInfo
1983
- }
1984
- if (this.dynamicServiceName) {
1985
- searchParam.dynamicServiceName = this.dynamicServiceName
1986
- }
1987
- const additionalParamMap = gridParams.additionalParamMap
1988
- if (additionalParamMap) {
1989
- if (additionalParamMap && typeof additionalParamMap === 'object') {
1990
- searchParam.additionalParamMap = additionalParamMap
1991
- } else if (additionalParamMap && additionalParamMap !== '') {
1992
- searchParam.additionalParamMap = JSON.parse(additionalParamMap)
1993
- }
1994
- }
1995
- return searchParam
1996
- },
1997
- getComponentType(prop) {
1998
- let type = 'NormalColumn'
1999
- if (prop === '$index') {
2000
- type = 'IndexColumn'
2001
- } else if (prop === '$selection') {
2002
- // 设置选中行时使用
2003
- store.get(this.code).isMulitiSelect = true
2004
- type = 'SelectionColumn'
2005
- } else if (prop === undefined) {
2006
- type = 'GroupColumn'
2007
- }
2008
-
2009
- return type
2010
- },
2011
- focusOnFirstEditableInput() {
2012
- if (this.basicInfo.editable) {
2013
- this.lineEdit.editingCell.row = 0
2014
- this.lineEdit.editingCell.prop = getFirstEditableColumn(this.code)
2015
- }
2016
- },
2017
- handleSizeChange(val) {
2018
- if (!this.options || !this.options.isPageShow) {
2019
- // console.log(`每页 ${val} 条`)
2020
- this.pageSize = val
2021
- this.changePage()
2022
- }
2023
- },
2024
- handleCurrentChange(val) {
2025
- if (!this.options || !this.options.isPageShow) {
2026
- // 翻页操作会导致筛选项发生变化,所以需要清空已有的
2027
- this.changePage()
2028
- }
2029
- },
2030
- changePage() {
2031
- // 翻页操作会导致筛选项发生变化,所以需要清空已有的
2032
- this.$refs.superGrid.clearFilter()
2033
- // TODO: 把当前页数、每页条数、查询条件、排序信息传回后台
2034
- if (this.isSubTableShowPage) {
2035
- this.gridData = this.getSubTableGridData(this.subTableData)
2036
- const gridParams = store.get(this.code)
2037
- gridParams.gridData = this.gridData
2038
- // 完成深拷贝,复制一份对象,行编辑时使用
2039
- gridParams.orgGridData = [].concat(
2040
- JSON.parse(JSON.stringify(this.gridData))
2041
- )
2042
- } else {
2043
- this.fetchData(this.getSearchParam())
2044
- }
2045
- },
2046
- handleSortChange({ column, prop, order }) {
2047
- if (!this.options || !this.options.isPageShow) {
2048
- let columnSetting = null
2049
- const items = this.visibleColumns.filter(item => {
2050
- return column.property === item.prop
2051
- })
2052
- if (items && items.length > 0) {
2053
- columnSetting = items[0]
2054
- }
2055
- if (!isCanRefreshGrid(this.code)) {
2056
- // 如果最后编辑行没有保存或撤销编辑,则给出提示
2057
- const gridParams = store.get(this.code)
2058
- console.log(
2059
- '请先保存或撤销编辑第' + gridParams.$rowIndex + 1 + '行记录,再排序'
2060
- )
2061
- this.$refs.superGrid.clearSort()
2062
- } else {
2063
- // TODO: 应该调用fetchData来获取信息,把当前页数、查询条件、排序信息传回后台
2064
- if (prop !== null && columnSetting && columnSetting !== null) {
2065
- // 当点击第3次时,prop会是空,表示清空排序字段,还原原顺序
2066
- let orgProp = columnSetting.orgProp
2067
- // sql查询时,会把点“.”改为两个下划线"__"
2068
- const replaceDot = '__'
2069
- if (orgProp && orgProp.indexOf(replaceDot) > 0) {
2070
- // 表示包括点“.”,需要把两个下划线"__"重新改为点“.”,否则会导致查询报500错误
2071
- orgProp = orgProp.replace(replaceDot, '.')
2072
- }
2073
- this.sortInfo = [
2074
- {
2075
- prop: orgProp,
2076
- order: order
2077
- }
2078
- ]
2079
- } else {
2080
- this.sortInfo = null
2081
- }
2082
- this.fetchData(this.getSearchParam())
2083
- this.focusOnFirstEditableInput()
2084
- this.$emit('sort-change', { columnSetting, prop, order, column })
2085
- }
2086
- }
2087
- },
2088
- isMergeable(prop) {
2089
- for (const column of this.columns) {
2090
- if (column.prop === prop) {
2091
- if (
2092
- this.mergeFields &&
2093
- this.mergeFields.indexOf(column.prop) !== -1
2094
- ) {
2095
- return true
2096
- } else {
2097
- return column.span
2098
- }
2099
- }
2100
- }
2101
- },
2102
- rowSpan({ row, column, rowIndex, columnIndex }) {
2103
- if (this.isMergeable(column.property)) {
2104
- const row = this.spanArr[column.property][rowIndex]
2105
- const col = row > 0 ? 1 : 0
2106
- return {
2107
- rowspan: row,
2108
- colspan: col
2109
- }
2110
- }
2111
- },
2112
- packageSummaryColumnProps() {
2113
- const summaryColumnProps = []
2114
- this.visibleColumns.forEach(item => {
2115
- if (item.total !== undefined && item.total === true) {
2116
- summaryColumnProps.push(item.prop)
2117
- }
2118
- })
2119
- return summaryColumnProps
2120
- },
2121
- getSummaries(param) {
2122
- // 后台返回时需要处理好序号列和多选列
2123
- if (this.basicInfo.summary !== 'no') {
2124
- const summaryMap = this.summaries
2125
- if (summaryMap) {
2126
- return this.getCustomSummaries(param, summaryMap)
2127
- } else {
2128
- return this.getDefaultSummaries(param)
2129
- }
2130
- } else {
2131
- return []
2132
- }
2133
- },
2134
- getCustomSummaries(param, summaryMap) {
2135
- // key为字段名,value为
2136
- const { columns } = param
2137
- const sums = []
2138
- columns.forEach((column, index) => {
2139
- const prop = column.property
2140
- const summaryVal = summaryMap[prop]
2141
- if (summaryVal !== undefined && summaryVal !== null) {
2142
- sums[index] = summaryVal
2143
- } else {
2144
- sums[index] = ''
2145
- }
2146
- })
2147
- return sums
2148
- },
2149
- getDefaultSummaries(param) {
2150
- const sums = []
2151
- const summaryColumnProps = this.packageSummaryColumnProps()
2152
- if (summaryColumnProps.length > 0) {
2153
- const { columns, data } = param
2154
- let totalColIndex = null
2155
- columns.forEach((column, index) => {
2156
- let colTotal = 0
2157
- const prop = column.property
2158
- if (prop && prop !== '$selection' && prop !== '$index') {
2159
- // 设置合计列
2160
- if (totalColIndex === undefined || totalColIndex === null) {
2161
- totalColIndex = index
2162
- sums[index] = '合计'
2163
- return
2164
- }
2165
- }
2166
- if (summaryColumnProps.indexOf(prop) >= 0) {
2167
- // 表示该列需要合计
2168
- if (data) {
2169
- data.forEach(row => {
2170
- let fieldValue = getEntityFieldValueWithOutCase(row, prop)
2171
- let numberValue
2172
- if (fieldValue !== undefined && fieldValue !== null) {
2173
- // 表示值存在,不需要转换
2174
- numberValue = Number(fieldValue)
2175
- } else {
2176
- // 表示值不存在,需要转小写,再获得一遍
2177
- const reg1 = /[A-Z]+/ // 大写字母
2178
- if (this.isSql && reg1.test(prop)) {
2179
- fieldValue = getEntityFieldValueWithOutCase(
2180
- row,
2181
- prop.toLowerCase()
2182
- )
2183
- if (fieldValue !== undefined && fieldValue !== null) {
2184
- numberValue = Number(fieldValue)
2185
- }
2186
- }
2187
- }
2188
- if (
2189
- numberValue !== undefined &&
2190
- numberValue !== null &&
2191
- !isNaN(numberValue)
2192
- ) {
2193
- colTotal += numberValue
2194
- }
2195
- })
2196
- }
2197
- sums[index] = colTotal
2198
- } else {
2199
- sums[index] = ''
2200
- }
2201
- })
2202
- }
2203
- return sums
2204
- },
2205
- configColumns() {
2206
- this.showColumnConfig = true
2207
- // 完成深拷贝,复制一份对象,行编辑时使用
2208
- this.orgColumnConfig = [].concat(JSON.parse(JSON.stringify(this.columns)))
2209
- },
2210
- // 行拖拽
2211
- rowDrop() {
2212
- if (this.lineEdit && this.lineEdit.urlToSaveOrder) {
2213
- const tbody = document.querySelector('.el-table__body-wrapper tbody')
2214
- if (tbody != null) {
2215
- const vm = this
2216
- Sortable.create(tbody, {
2217
- onEnd({ newIndex, oldIndex }) {
2218
- const params = {
2219
- oldIndex: oldIndex,
2220
- newIndex: newIndex
2221
- }
2222
- this.$http
2223
- .post(this.lineEdit.urlToSaveOrder, params)
2224
- .then(data => {
2225
- const currRow = vm.gridData.splice(oldIndex, 1)[0]
2226
- vm.gridData.splice(newIndex, 0, currRow)
2227
- })
2228
- }
2229
- })
2230
- }
2231
- }
2232
- },
2233
- closeCustomConfig(isRefreshGrid) {
2234
- if (isRefreshGrid !== undefined && isRefreshGrid === true) {
2235
- this.refreshGridInitialize()
2236
- }
2237
- this.showColumnConfig = false
2238
- },
2239
- resetCustomConfig() {
2240
- this.refreshGridInitialize()
2241
- },
2242
- refreshGridInitialize() {
2243
- this.initialize().then(() => {
2244
- // 添加该代码是为了解决保存字段个性化配置后,重新渲染列表问题,例如:列宽重新计算问题
2245
- this.refreshGrid = false
2246
- const vm = this
2247
- setTimeout(function() {
2248
- vm.refreshGrid = true
2249
- }, 100)
2250
- })
2251
- },
2252
- loadChildren(row, treeNode, resove) {
2253
- if (this.isLazy) {
2254
- this.loadChildrenNode(row, treeNode, resove)
2255
- }
2256
- },
2257
- loadChildrenNode(row, treeNode, resove) {
2258
- const subRowUrl = this.options.subRowUrl
2259
- if (
2260
- typeof subRowUrl !== 'undefined' &&
2261
- subRowUrl !== '' &&
2262
- subRowUrl !== null
2263
- ) {
2264
- const parentRowIds = []
2265
- parentRowIds.push(row.id ? row.id : row.ID)
2266
- this.fetchData(this.getSearchParam(), false, parentRowIds, resove)
2267
- }
2268
- },
2269
- expandChange(row, expanded) {
2270
- if (this.isLazy) {
2271
- // console.log('expandChange==row, expanded', row, expanded, this.$refs.superGrid.store.states)
2272
- if (expanded === false) {
2273
- // 折叠时清空表格缓存的已加载的标识位,使其能够动态更新子集合
2274
- // 必须添加这句,否则不会重新走load
2275
- if (this.$refs.superGrid.store.states.treeData) {
2276
- this.$refs.superGrid.store.states.treeData[
2277
- row.id ? row.id : row.ID
2278
- ].loaded = false
2279
- }
2280
- } else {
2281
- // console.log('expandChange=this.$refs.superGrid.store.states.lazyTreeNodeMap', this.$refs.superGrid.store.states.lazyTreeNodeMap)
2282
- // console.log('expandChange=this.$refs.superGrid.store.states.treeData', this.$refs.superGrid.store.states.treeData)
2283
- // console.log('expandChange=this.$refs.superGrid.store.states.selection', this.$refs.superGrid.store.states.selection)
2284
- }
2285
- }
2286
- },
2287
- removeGridStoreSelection(parentRowIds) {
2288
- let selection = []
2289
- if (this.$refs.superGrid.store.states.selection) {
2290
- selection = [].concat(
2291
- JSON.parse(
2292
- JSON.stringify(this.$refs.superGrid.store.states.selection)
2293
- )
2294
- )
2295
- }
2296
- for (let i = 0; i < selection.length; i++) {
2297
- if (
2298
- parentRowIds &&
2299
- parentRowIds.indexOf(selection[i][this.parentProp]) >= 0
2300
- ) {
2301
- // 移除第i个元素
2302
- this.$refs.superGrid.store.states.selection.splice(i, 1)
2303
- if (this.$refs.superGrid.store.states.selection.length > 0) {
2304
- this.removeGridStoreSelection(parentRowIds)
2305
- }
2306
- break
2307
- }
2308
- }
2309
- },
2310
- changeHederWidth(newWidth, oldWidth, column, event) {
2311
- const newCellWidth = newWidth - 5
2312
- let myNewWidth = newCellWidth
2313
- this.dragColumnProp = column.property
2314
- const gridParams = store.get(this.code)
2315
- if (isHasOptionFunction('resizeColumn', this.code)) {
2316
- const newWidth = gridParams.options.resizeColumn.call(this, {
2317
- code: this.code,
2318
- newWidth: newWidth,
2319
- oldWidth: oldWidth,
2320
- column: column
2321
- })
2322
- if (newWidth) {
2323
- myNewWidth = newWidth
2324
- }
2325
- }
2326
- this.newWidth = Math.ceil(myNewWidth)
2327
- if (
2328
- typeof this.options.isAdministerListView !== 'undefined' &&
2329
- this.options.isAdministerListView != null &&
2330
- this.options.isAdministerListView === true
2331
- ) {
2332
- // 表示是列表字段配置时
2333
- this.$emit('changeHederWidth', this.newWidth)
2334
- } else {
2335
- // 应用模式时
2336
- // 保存拖动后的列宽
2337
- this.saveColumnWidth(this.dragColumnProp, this.newWidth).then(() => {
2338
- const items = this.getColumnByElementColumn(column)
2339
- if (items && items.length > 0) {
2340
- items[0].widthType = 'custom'
2341
- items[0].width = this.newWidth + ''
2342
- }
2343
- })
2344
- }
2345
- },
2346
- resetSearch() {
2347
- // 修改当前页为第1页
2348
- this.currentPage = 1
2349
- this.search(null, false)
2350
- },
2351
- // 获取列信息
2352
- getColumnInformation() {
2353
- return this.visibleColumns
2354
- },
2355
- // 点击表头触发回调
2356
- headerClick(column, event) {
2357
- // 三种类型
2358
- const items = this.getColumnByElementColumn(column)
2359
- if (items && items.length > 0) {
2360
- this.$emit('header-click', items[0])
2361
- this.changeHeaderStyleTwo(items[0])
2362
- } else {
2363
- this.$emit('header-click', null)
2364
- }
2365
- this.clearHeaderContextmenu()
2366
- },
2367
- changeHeaderStyleTwo(item) {
2368
- // 改变options中的配置
2369
- // 还原所有颜色(隐藏字段判断,设置为灰色;选中字段设置为蓝色)
2370
- if (
2371
- typeof this.options.isAdministerListView !== 'undefined' &&
2372
- this.options.isAdministerListView != null &&
2373
- this.options.isAdministerListView === true
2374
- ) {
2375
- this.createBackgroundColorMap()
2376
- this.$set(this.backgroundColorMap, item.prop, '#409EFF')
2377
- if (this.$refs && this.$refs.superGrid) {
2378
- this.$refs.superGrid.doLayout()
2379
- }
2380
- }
2381
- },
2382
- // 编辑模式下创建一个对象,存储各个表头的背景色
2383
- createBackgroundColorMap() {
2384
- const biaotime = new Date().getTime()
2385
- const items = this.getColumnInformation()
2386
- const backgroundColorMap = {}
2387
- if (items && items.length > 0) {
2388
- for (var i = 0; i < items.length; i++) {
2389
- const item = items[i]
2390
- if (item.show === undefined || item.show) {
2391
- // 表示显示
2392
- } else {
2393
- backgroundColorMap[item.prop] = '#808080'
2394
- }
2395
- if (
2396
- this.backgroundColorMap &&
2397
- this.backgroundColorMap[item.prop] === '#409EFF' &&
2398
- this.externalClickFlag
2399
- ) {
2400
- backgroundColorMap[item.prop] = '#409EFF'
2401
- }
2402
- }
2403
- }
2404
- this.backgroundColorMap = backgroundColorMap
2405
- this.externalClickFlag = false
2406
- if (this.$refs && this.$refs.superGrid) {
2407
- this.$refs.superGrid.doLayout()
2408
- }
2409
- const biaotimeend = new Date().getTime()
2410
- console.log('存储表头背景色', biaotimeend - biaotime)
2411
- },
2412
- // 根据element事件传递的column来获取自定义封装的column
2413
- getColumnByElementColumn(column) {
2414
- let items = null
2415
- if (column.type && column.type === 'selection') {
2416
- // 表示为选择框
2417
- items = this.visibleColumns.filter(item => {
2418
- return item.prop === '$selection'
2419
- })
2420
- } else if (column.type && column.type === 'default' && !column.property) {
2421
- // 表示为序号
2422
- items = this.visibleColumns.filter(item => {
2423
- return item.prop === '$index'
2424
- })
2425
- } else if (column.property) {
2426
- // 表示为普通字段
2427
- items = this.visibleColumns.filter(item => {
2428
- return column.property === item.prop
2429
- })
2430
- }
2431
- return items
2432
- },
2433
- // 右键表头
2434
- headerContextmenu(column, event) {
2435
- // 阻止鼠标的默认事件
2436
- event.preventDefault()
2437
- const items = this.getColumnByElementColumn(column)
2438
- if (items && items.length > 0) {
2439
- const item = items[0]
2440
- this.$emit('header-click', items[0])
2441
- this.changeHeaderStyleTwo(items[0])
2442
- this.showHeaderContextmenu = true
2443
- this.rightClickColumn = item
2444
- this.$nextTick(() => {
2445
- const menu = this.$refs.headerMenu.$el
2446
- const scrollTop =
2447
- document.documentElement.scrollTop || document.body.scrollTop
2448
- menu.style.display = 'block'
2449
- menu.style.left = event.clientX + 'px'
2450
- // 当滑动滚动条时也能准确获取菜单位置
2451
- menu.style.top = event.clientY + scrollTop - 10 + 'px'
2452
- })
2453
- }
2454
- },
2455
- // 清除右键菜单显示
2456
- clearHeaderContextmenu() {
2457
- this.showHeaderContextmenu = false
2458
- this.rightClickColumn = null
2459
- },
2460
- // 返回表单子表模式下数据
2461
- validatorSunTableListData() {
2462
- // 返回之前需要进行规则校验
2463
- let gridData = this.gridData
2464
- if (this.isSubTableShowPage) {
2465
- gridData = this.subTableData
2466
- }
2467
- if (gridData && gridData.length > 0) {
2468
- const pageSize = this.pagination && this.pagination.pageSize
2469
- const validateRules = formValidatorService.getValidator(this.code)
2470
- for (let i = 0; i < gridData.length; i++) {
2471
- const row = gridData[i]
2472
- let needValidate = true
2473
- if (isHasEditOption('isEnableValidate', this.code)) {
2474
- // 表示配置了是否启用必填验证
2475
- needValidate = this.gridParams.options.lineEditOptions[
2476
- 'isEnableValidate'
2477
- ]
2478
- }
2479
- let validateResult = true
2480
- if (needValidate === true) {
2481
- let pageNum
2482
- // 每页的记录下标,提示时使用
2483
- let pageRowIndex
2484
- if (this.isSubTableShowPage && pageSize !== undefined && pageSize > 0) {
2485
- pageNum = Math.ceil((i + 1) / pageSize)
2486
- pageRowIndex = (i + 1) - ((pageNum - 1) * pageSize)
2487
- }
2488
- validateResult = formValidatorService.validator(
2489
- row,
2490
- this.code,
2491
- i,
2492
- validateRules,
2493
- this.isSubTableShowPage,
2494
- pageNum,
2495
- pageRowIndex
2496
- )
2497
- }
2498
- if (validateResult !== null && validateResult !== undefined) {
2499
- if (
2500
- typeof validateResult === 'string' ||
2501
- validateResult === false
2502
- ) {
2503
- return false
2504
- }
2505
- }
2506
- }
2507
- return true
2508
- }
2509
- return true
2510
- },
2511
- getSunTableListData() {
2512
- return this.isSubTableShowPage ? this.subTableData : this.gridData
2513
- },
2514
- rowDblclickEvent(row, column, event) {
2515
- const gridParams = store.get(this.code)
2516
- if (
2517
- gridParams.options &&
2518
- gridParams.options.isFormSubTable &&
2519
- gridParams.options.isPdfEditor
2520
- ) {
2521
- // 如果是子表并且是pdf模式
2522
- } else if (this.isFormSubTable) {
2523
- // 表示是表单的子表,点击时需要将当前行设为行编辑状态,并保存上一行的记录(不是保存到数据库,只是把编辑状态改为false)
2524
- if (column.property &&
2525
- column.property !== 'operation') {
2526
- // 取消上一行的编辑状态
2527
- let editRows
2528
- const gridParams = store.get(this.code)
2529
- if (this.isSubTableShowPage) {
2530
- editRows = this.subTableData.filter(
2531
- row => row.$editing !== undefined && row.$editing === true
2532
- )
2533
- } else {
2534
- editRows = this.gridData.filter(
2535
- row => row.$editing !== undefined && row.$editing === true
2536
- )
2537
- }
2538
- if (editRows && editRows.length > 0) {
2539
- editRows.forEach(editRow => {
2540
- setEntityFieldValue(editRow, '$editing', false)
2541
- // this.$set(editRow, '$editing', false)
2542
- })
2543
- }
2544
- gridParams.isEditRow = false
2545
- setEntityFieldValue(row, '$editing', true)
2546
- gridParams.$editRow = row
2547
- // this.$set(row, '$editing', true)
2548
- gridParams.isEditRow = true
2549
- }
2550
- } else {
2551
- if (row) {
2552
- if (gridParams && gridParams.lineEdit && gridParams.lineEdit.editable && gridParams.canntEdit) {
2553
- let index = this.gridData.findIndex(function(item) {
2554
- return (
2555
- (item.id && item.id === row.id) || (item.ID && item.ID === row.ID)
2556
- )
2557
- })
2558
- if (index < 0) {
2559
- index = 0
2560
- }
2561
- this.editRow(index)
2562
- }
2563
- }
2564
- }
2565
- this.rowDblClick(row, column, event)
2566
- },
2567
- rowClickEvent(row, column, event) {
2568
- // if (
2569
- // this.isFormSubTable &&
2570
- // column.property &&
2571
- // column.property !== 'operation'
2572
- // ) {
2573
- // // 表示是表单的子表,点击时需要将当前行设为行编辑状态,并保存上一行的记录(不是保存到数据库,只是把编辑状态改为false)
2574
- // // 取消上一行的编辑状态
2575
- // const gridParams = store.get(this.code)
2576
- // const editRows = this.gridData.filter(
2577
- // row => row.$editing !== undefined && row.$editing === true
2578
- // )
2579
- // if (editRows && editRows.length > 0) {
2580
- // editRows.forEach(editRow => {
2581
- // this.$set(editRow, '$editing', false)
2582
- // })
2583
- // }
2584
- // gridParams.isEditRow = false
2585
- // this.$set(row, '$editing', true)
2586
- // gridParams.isEditRow = true
2587
- // }
2588
- // this.rowClick(row, column, event)
2589
- },
2590
- openPageDialog(openPageParams) {
2591
- let jumpMode
2592
- if (openPageParams) {
2593
- jumpMode = openPageParams.jumpMode
2594
- }
2595
- const popPageSetting = openPageParams
2596
- if (jumpMode === 'popup') {
2597
- // 弹出页面
2598
- this.jumpPageSetting = popPageSetting
2599
- this.isShowPageDialog = true
2600
- } else if (jumpMode === 'refresh') {
2601
- this.$router.push({ path: '/dsc/page', query: popPageSetting })
2602
- }
2603
- },
2604
- // api方法,super-pages中有调用该方法
2605
- closePageDialog(popParams) {
2606
- // popParams格式为:{ entity, pageCode }
2607
- if (this.jumpPageSetting) {
2608
- // 调用关闭弹框事件
2609
- const gridParams = store.get(this.code)
2610
- const closeEventName = this.jumpPageSetting.closeEvent
2611
- const row = this.jumpPageSetting.row
2612
- let closeEvent
2613
- if (
2614
- gridParams.options.eventCallBack &&
2615
- closeEventName &&
2616
- closeEventName !== null &&
2617
- gridParams.options.eventCallBack[closeEventName]
2618
- ) {
2619
- // 表单页面中子表自定义事件集合
2620
- closeEvent =
2621
- gridParams.options.eventCallBack[closeEventName]
2622
- }
2623
- if (closeEvent) {
2624
- const params = {
2625
- params: gridParams.additionalParamMap,
2626
- entity: row
2627
- }
2628
- if (popParams) {
2629
- params.eventParams = {
2630
- popEntity: popParams.entity,
2631
- popPageCode: popParams.pageCode,
2632
- pageCode: this.pageCode
2633
- }
2634
- }
2635
- closeEvent.call(this, params)
2636
- }
2637
- }
2638
- this.isShowPageDialog = false
2639
- this.jumpPageSetting = null
2640
- },
2641
- updateValues(sourceModel, sourceTableName, targetRowIndex) {
2642
- // TODO 值更新
2643
- const gridParams = store.get(this.code)
2644
- const editRowIndex = targetRowIndex
2645
- if (
2646
- editRowIndex !== undefined &&
2647
- editRowIndex !== null &&
2648
- editRowIndex < this.gridData.length
2649
- ) {
2650
- // 返回true表示不需要替换字段,false表示需要替换字段
2651
- const isNotNeedReplaceFieldName =
2652
- this.isSql === false ||
2653
- (gridParams.options &&
2654
- ((gridParams.options.isAdministerListView !== undefined &&
2655
- gridParams.options.isAdministerListView === true) ||
2656
- (gridParams.options.isFormSubTable !== undefined &&
2657
- gridParams.options.isFormSubTable === true)))
2658
- const tableName = this.tableName
2659
- updateWithPageValue(
2660
- sourceModel,
2661
- sourceTableName,
2662
- this.jumpPageSetting,
2663
- this.gridData[editRowIndex],
2664
- tableName,
2665
- !isNotNeedReplaceFieldName
2666
- )
2667
- const updateValueEventName =
2668
- this.jumpPageSetting && this.jumpPageSetting.updateValueEvent
2669
- ? this.jumpPageSetting.updateValueEvent
2670
- : null
2671
- let updateValueEvent
2672
- if (
2673
- gridParams.options.eventCallBack &&
2674
- updateValueEventName &&
2675
- updateValueEventName !== null &&
2676
- gridParams.options.eventCallBack[updateValueEventName]
2677
- ) {
2678
- // 表单页面中子表自定义事件集合
2679
- updateValueEvent =
2680
- gridParams.options.eventCallBack[updateValueEventName]
2681
- }
2682
- if (updateValueEvent) {
2683
- updateValueEvent.call(this, {
2684
- sourceModel,
2685
- sourceTableName,
2686
- jumpPageSetting: this.jumpPageSetting,
2687
- entity: this.gridData[editRowIndex],
2688
- targetTableName: tableName,
2689
- isNeedReplaceFieldName: !isNotNeedReplaceFieldName
2690
- })
2691
- }
2692
- }
2693
- },
2694
- closeSearchFormDialog() {
2695
- this.showSearch = false
2696
- },
2697
- // 获取当前列表的查询方式,page项目使用
2698
- getQueryMode() {
2699
- if (this.query && this.query.showType === 'popup') {
2700
- return 'popup'
2701
- } else {
2702
- return 'embedded'
2703
- }
2704
- },
2705
- selectCell(row, column, cell, event) {
2706
- if (cell) {
2707
- this.cellClick(row, column, cell, event)
2708
- this.$nextTick(() => {
2709
- this.$set(cell.style, 'border', '2px solid #409EFF')
2710
- this.currentSelectCell = cell
2711
- })
2712
- }
2713
- },
2714
- // 刷新列表数据
2715
- refreshGridData() {
2716
- this.refresh(false, true)
2717
- },
2718
- // 刷新列表数据
2719
- refresData(data) {
2720
- this.$set(this, 'gridData', data)
2721
- },
2722
- refresPortData(port, value, index) {
2723
- if (this.gridData[index]) {
2724
- this.$set(this.gridData[index], port, value)
2725
- this.$forceUpdate()
2726
- }
2727
- },
2728
-
2729
- refresPortsData(entity, index) {
2730
- if (entity) {
2731
- for (const key in entity) {
2732
- if (this.gridData[index]) {
2733
- this.$set(this.gridData[index], key, entity[key])
2734
- this.$forceUpdate()
2735
- console.log('this.$forceUpdate()', this.$refs[key])
2736
- }
2737
- }
2738
- // entity.forEach(item => {
2739
- // if (this.gridData[index]) {
2740
- // this.$set(this.gridData[index], item.prop, item.value)
2741
- // }
2742
- // })
2743
- }
2744
- },
2745
- refresMainTableFields(map) {
2746
- this.$emit('refresMainTableFields', map)
2747
- },
2748
- openFold(isOpen) {
2749
- this.resizeTableHeight()
2750
- },
2751
- // 设置字段禁止编辑
2752
- fnProhibitToEdit(entity) {
2753
- if (entity) {
2754
- for (const key in entity) {
2755
- console.log('key', key)
2756
- console.log('this.$refs[key]', this.$refs)
2757
- if (this.$refs[key]) {
2758
- this.$refs[key][0].fnProhibitToEdit(entity[key])
2759
- }
2760
- }
2761
- }
2762
- },
2763
- // 设置字段禁止编辑
2764
- prohibitToEdit(entity) {
2765
- this.fnProhibitToEdit(entity)
2766
- },
2767
- // 树形结构时数据展示
2768
- getTreeProps(parentProp, isSql, isLazy, dataSourceType) {
2769
- let treeProps = {
2770
- children: 'children',
2771
- hasChildren: '_has_children'
2772
- }
2773
- if (parentProp) {
2774
- treeProps = {
2775
- children: 'children'
2776
- }
2777
- let hasChildren = 'hasChildren'
2778
- if (isLazy) {
2779
- if (isSql) {
2780
- if (dataSourceType === 'oracle') {
2781
- hasChildren = 'HAS_CHILDREN'
2782
- } else {
2783
- hasChildren = 'has_children'
2784
- }
2785
- }
2786
- }
2787
- treeProps.hasChildren = hasChildren
2788
- }
2789
- return treeProps
2790
- }
2791
- }
2792
- }
2793
- </script>