imatrix-ui 2.9.15-dw-tmp2 → 2.9.16-boe2

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