imatrix-ui 2.8.97-dw-tmp39 → 2.8.97-dw-tmp41

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