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