imatrix-ui 2.8.39-dw → 2.8.39-pvtmp

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