olp-table 5.3.1 → 5.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/.env.build +1 -0
  2. package/README.md +26 -0
  3. package/babel.config.js +5 -0
  4. package/jsconfig.json +22 -0
  5. package/{olp-table.common.js → olp-table/olp-table.common.js} +5 -5
  6. package/{olp-table.umd.js → olp-table/olp-table.umd.js} +5 -5
  7. package/{olp-table.umd.min.js → olp-table/olp-table.umd.min.js} +3 -3
  8. package/package.json +92 -12
  9. package/public/favicon.ico +0 -0
  10. package/public/index.html +17 -0
  11. package/rmMode.bat +1 -0
  12. package/src/App.vue +199 -0
  13. package/src/api/crud.js +22 -0
  14. package/src/api/dist.js +6 -0
  15. package/src/assets/iconfont/iconfont.css +20 -0
  16. package/src/assets/iconfont/iconfont.json +16 -0
  17. package/src/assets/iconfont/iconfont.ttf +0 -0
  18. package/src/assets/iconfont/iconfont.woff +0 -0
  19. package/src/assets/iconfont/iconfont.woff2 +0 -0
  20. package/src/assets/logo.png +0 -0
  21. package/src/components/auto-height/index.vue +75 -0
  22. package/src/components/codemirror-tag.vue +100 -0
  23. package/src/components/lazy-load-select.vue +107 -0
  24. package/src/components/ol-dialog-excel.vue +112 -0
  25. package/src/components/ol-dialog-import.vue +304 -0
  26. package/src/components/ol-dialog-json.vue +82 -0
  27. package/src/components/ol-dialog-table.vue +81 -0
  28. package/src/components/ol-dialog-upload-file.vue +208 -0
  29. package/src/components/ol-dict-tag.vue +271 -0
  30. package/src/components/ol-select-dom.vue +71 -0
  31. package/src/components/ol-table-filter.vue +28 -0
  32. package/src/components/ol-table-render.vue +44 -0
  33. package/src/components/ol-table-select.vue +150 -0
  34. package/src/components/pinia-init.vue +18 -0
  35. package/src/components/table/model/ModelMixins.js +43 -0
  36. package/src/components/table/model/model-index.vue +121 -0
  37. package/src/components/table/model/ot-left-right.vue +18 -0
  38. package/src/components/table/model/ot-left-tree-right-table.scss +14 -0
  39. package/src/components/table/model/ot-left-tree-right-table.vue +41 -0
  40. package/src/components/table/model/ot-top-1-bottom-2.vue +39 -0
  41. package/src/components/table/model/ot-top-2-bottom-1.vue +38 -0
  42. package/src/components/table/model/ot-top-2-bottom-2.vue +38 -0
  43. package/src/components/table/model/ot-top-bottom.vue +18 -0
  44. package/src/components/table/model/splitpanesModel.css +22 -0
  45. package/src/components/table/model/splitpanesModel.vue +54 -0
  46. package/src/components/table/ol-form/index.vue +537 -0
  47. package/src/components/table/ol-form-v3/index.vue +455 -0
  48. package/src/components/table/ol-main-form-sub-table/index.vue +601 -0
  49. package/src/components/table/ol-pager/index.vue +46 -0
  50. package/src/components/table/ol-table/components/ol-table-column-config/columnIndex.vue +233 -0
  51. package/src/components/table/ol-table/components/ol-table-column-config/index.vue +145 -0
  52. package/src/components/table/ol-table/components/ol-table-column-dict-color/index.vue +88 -0
  53. package/src/components/table/ol-table/index.vue +232 -0
  54. package/src/components/table/ol-table-operate/index.vue +61 -0
  55. package/src/components/table/ol-table-search/index.vue +17 -0
  56. package/src/components/table/ol-table-tool-btn/index.vue +60 -0
  57. package/src/components/tree/components/o-tree.vue +289 -0
  58. package/src/components/tree/index.vue +46 -0
  59. package/src/components/v-component/index.vue +43 -0
  60. package/src/config/dev-config.js +5 -0
  61. package/src/config/prod-config.js +5 -0
  62. package/src/config/shared-config.js +20 -0
  63. package/src/data.js +9378 -0
  64. package/src/directives/permission/hasPermi.js +63 -0
  65. package/src/directives/permission/hasRole.js +30 -0
  66. package/src/main.js +55 -0
  67. package/src/mixins/VTMixin/DefaultMethods.js +749 -0
  68. package/src/mixins/VTMixin/OTMixinBody.js +105 -0
  69. package/src/mixins/VTMixin/OTMixinBodyFooter.js +93 -0
  70. package/src/mixins/VTMixin/OTMixinBodyMethods.js +420 -0
  71. package/src/mixins/VTMixin/OTMixinColumnMethod.js +450 -0
  72. package/src/mixins/VTMixin/OTMixinInitMethod.js +130 -0
  73. package/src/mixins/VTMixin/OTMixinPager.js +38 -0
  74. package/src/mixins/VTMixin/OTMixinSortable.js +43 -0
  75. package/src/mixins/VTMixin/index.js +18 -0
  76. package/src/package/index.js +20 -0
  77. package/src/plugins/axios.js +61 -0
  78. package/src/store/dict.js +76 -0
  79. package/src/store/dictType.js +52 -0
  80. package/src/store/permi.js +45 -0
  81. package/src/styles/common.scss +37 -0
  82. package/src/styles/index.scss +48 -0
  83. package/src/styles/theme.scss +32 -0
  84. package/src/utils/AESCRUDUtils.js +87 -0
  85. package/src/utils/DateUtils.js +35 -0
  86. package/src/utils/ExcelUtil.js +159 -0
  87. package/src/utils/TableSortUtil.js +91 -0
  88. package/src/utils/columnProp.js +3 -0
  89. package/src/utils/groupCompute.js +68 -0
  90. package/src/utils/http/httpFactory.js +92 -0
  91. package/src/utils/http/httpFactory2.js +79 -0
  92. package/src/utils/http/httpUtil.js +123 -0
  93. package/src/utils/http/httpUtils.js +38 -0
  94. package/src/utils/loadStyle.js +14 -0
  95. package/src/utils/message.js +56 -0
  96. package/src/utils/object.js +80 -0
  97. package/src/utils/security/TokenUtil.js +19 -0
  98. package/src/utils/tree.js +54 -0
  99. package/src/utils/util.js +127 -0
  100. package/src/views/Test/index.vue +77 -0
  101. package/src/views/Test/index2.vue +33 -0
  102. package/src/views/components/btn-config/index.vue +202 -0
  103. package/src/views/components/option-config/index.vue +192 -0
  104. package/src/views/db/chineseToEnglish.vue +127 -0
  105. package/src/views/db/filed.vue +395 -0
  106. package/src/views/db/index.vue +192 -0
  107. package/src/views/db/preview/index.vue +139 -0
  108. package/src/views/db/preview/left.vue +204 -0
  109. package/src/views/db/preview/right.vue +466 -0
  110. package/src/views/groupTable/index.vue +137 -0
  111. package/src/views/groupTable/ol-table-column-config/columnIndex.vue +194 -0
  112. package/src/views/groupTable/ol-table-column-config/index.vue +92 -0
  113. package/src/views/table/add-or-edit/config/base-config/index.vue +539 -0
  114. package/src/views/table/add-or-edit/config/base-config/table-form.vue +333 -0
  115. package/src/views/table/add-or-edit/config/column-config/header-config.vue +475 -0
  116. package/src/views/table/add-or-edit/config/column-config/index.vue +790 -0
  117. package/src/views/table/add-or-edit/config/data/column.js +218 -0
  118. package/src/views/table/add-or-edit/config/data/crud.js +122 -0
  119. package/src/views/table/add-or-edit/config/data/events.js +109 -0
  120. package/src/views/table/add-or-edit/config/data/method.js +127 -0
  121. package/src/views/table/add-or-edit/config/data/option.js +725 -0
  122. package/src/views/table/add-or-edit/config/data/page.js +79 -0
  123. package/src/views/table/add-or-edit/config/field-config/filed-config-table.vue +42 -0
  124. package/src/views/table/add-or-edit/config/field-config/index.vue +91 -0
  125. package/src/views/table/add-or-edit/config/form-config/index.vue +1179 -0
  126. package/src/views/table/add-or-edit/config/index.vue +376 -0
  127. package/src/views/table/add-or-edit/config/initFormObject.js +25 -0
  128. package/src/views/table/add-or-edit/config/script-config/LeftMeun.vue +71 -0
  129. package/src/views/table/add-or-edit/config/script-config/index.vue +70 -0
  130. package/src/views/table/add-or-edit/config/table-config/btn-config.vue +340 -0
  131. package/src/views/table/add-or-edit/config/table-config/btn-sort.vue +132 -0
  132. package/src/views/table/add-or-edit/config/table-config/index.vue +446 -0
  133. package/src/views/table/add-or-edit/configOld/dataTags/filed-config-table-model.vue +41 -0
  134. package/src/views/table/add-or-edit/configOld/dataTags/filed-config.vue +74 -0
  135. package/src/views/table/add-or-edit/configOld/dataTags/index.vue +439 -0
  136. package/src/views/table/add-or-edit/configOld/dataTags/set-table-sql.vue +79 -0
  137. package/src/views/table/add-or-edit/configOld/dataTags/table-on-config.vue +74 -0
  138. package/src/views/table/add-or-edit/configOld/index.vue +127 -0
  139. package/src/views/table/add-or-edit/configOld/tableTags/columnConfig.js +5 -0
  140. package/src/views/table/add-or-edit/configOld/tableTags/index.vue +353 -0
  141. package/src/views/table/add-or-edit/configOld/tableTags/operation-but-config.vue +75 -0
  142. package/src/views/table/add-or-edit/configOld/tableTags/tool-but-config.vue +92 -0
  143. package/src/views/table/add-or-edit/index.vue +201 -0
  144. package/src/views/table/add-or-edit/themeModel/index.vue +53 -0
  145. package/src/views/table/add-or-edit/themeModel/init-model-table.vue +48 -0
  146. package/src/views/table/add-or-edit/themeModel/init-model.vue +81 -0
  147. package/src/views/table/add-or-edit/themeModel/left-right.vue +24 -0
  148. package/src/views/table/add-or-edit/themeModel/left-tree-right-table.vue +75 -0
  149. package/src/views/table/add-or-edit/themeModel/olTableSearchModelMixins.js +42 -0
  150. package/src/views/table/add-or-edit/themeModel/splitpanesThemeModel.vue +49 -0
  151. package/src/views/table/add-or-edit/themeModel/top-1-bottom-2.vue +29 -0
  152. package/src/views/table/add-or-edit/themeModel/top-2-bottom-1.vue +32 -0
  153. package/src/views/table/add-or-edit/themeModel/top-2-bottom-2.vue +32 -0
  154. package/src/views/table/add-or-edit/themeModel/top-bottom.vue +14 -0
  155. package/src/views/table/index.vue +43 -0
  156. package/src/views/table/index2.vue +199 -0
  157. package/src/views/table/preview/index.vue +29 -0
  158. package/src/views/tree/components/config-core-data.vue +85 -0
  159. package/src/views/tree/components/config-core-table.vue +362 -0
  160. package/src/views/tree/components/config-core-tree/data/events.js +95 -0
  161. package/src/views/tree/components/config-core-tree/data/option.js +88 -0
  162. package/src/views/tree/components/config-core-tree/data/prop.js +28 -0
  163. package/src/views/tree/components/config-core-tree/index.vue +181 -0
  164. package/src/views/tree/components/config-core.vue +42 -0
  165. package/src/views/tree/components/form-config/index.vue +967 -0
  166. package/src/views/tree/index.vue +424 -0
  167. package/vue.config.js +44 -0
  168. /package/{demo.html → olp-table/demo.html} +0 -0
  169. /package/{fonts → olp-table/fonts}/iconfont.1720006583309.7e4906d9.woff +0 -0
  170. /package/{fonts → olp-table/fonts}/iconfont.1720006583309.947a27f0.ttf +0 -0
  171. /package/{olp-table.css → olp-table/olp-table.css} +0 -0
@@ -0,0 +1,466 @@
1
+ <template>
2
+ <vxe-grid v-bind="table" :columns="$attrs.columns" ref="vexGridRef" @sortChange="sortChange" @keydown="keydown">
3
+ <template #checkedBox_header="{ column }">
4
+ <div style="display: flex;align-items: center;">
5
+ <el-tooltip class="box-item"
6
+ effect="dark"
7
+ :content="column.title"
8
+ placement="left-start"
9
+ >
10
+ <span style="margin-left: 5px;">{{
11
+ column.title != undefined ? column.title.toString().substring(0, 4) : ''
12
+ }} </span>
13
+ </el-tooltip>
14
+ <el-checkbox v-model="column.children[0].params.time" style="margin-left: 5px;margin-right: 5px"
15
+ @change="column.children[0].params.range = false;query();">时间
16
+ </el-checkbox>
17
+ <el-checkbox v-model="column.children[0].params.range"
18
+ @change="column.children[0].params.time = false;query();">范围
19
+ </el-checkbox>
20
+ </div>
21
+ </template>
22
+ <template #operate="{ row }">
23
+ <el-tooltip class="box-item"
24
+ effect="dark"
25
+ content="保存"
26
+ placement="top-start"
27
+ >
28
+ <vxe-button @click="saveUpdateEvent(row)" mode="text" icon="vxe-icon-save"
29
+ :status="hasUpdateStatus(row) ? 'warning' : 'info'" size="mini"
30
+ :disabled="!hasUpdateStatus(row)"
31
+ :loading="row.loading"/>
32
+ </el-tooltip>
33
+ <el-tooltip class="box-item"
34
+ effect="dark"
35
+ content="复制数据"
36
+ placement="top-start"
37
+ >
38
+ <vxe-button @click="add(row)" mode="text" icon="vxe-icon-add"
39
+ status="primary" size="mini"/>
40
+ </el-tooltip>
41
+ <el-tooltip class="box-item"
42
+ effect="dark"
43
+ content="删除数据"
44
+ placement="top-start"
45
+ >
46
+ <el-popconfirm title="是否删除数据" @confirm="remove(row)">
47
+ <template #reference>
48
+ <vxe-button mode="text" icon="vxe-icon-delete"
49
+ status="danger" size="mini"/>
50
+ </template>
51
+ </el-popconfirm>
52
+
53
+ </el-tooltip>
54
+ </template>
55
+ <template #header_name_auto_filter="{ column }">
56
+ <div v-if="column.params.time">
57
+ <el-date-picker
58
+ v-model="column.params.start"
59
+ style="width: 100%;"
60
+ type="datetime"
61
+ placeholder="开始时间"
62
+ format="YYYY-MM-DD HH:mm:ss"
63
+ @change="query"
64
+ />
65
+ <el-date-picker
66
+ v-model="column.params.end"
67
+ style="width: 100%;"
68
+ type="datetime"
69
+ placeholder="结束"
70
+ format="YYYY-MM-DD HH:mm:ss"
71
+ @change="query"
72
+ />
73
+ </div>
74
+ <div v-else-if="column.params.range">
75
+ <el-input
76
+ v-model="column.params.start"
77
+ style="width: 100%;"
78
+ placeholder="开始"
79
+ @change="query"
80
+ />
81
+ <el-input
82
+ v-model="column.params.end"
83
+ style="width: 100%;"
84
+ placeholder="结束"
85
+ @change="query"
86
+ />
87
+ </div>
88
+ <el-input v-else v-model="column.params.value" style="width: 100%;"
89
+ placeholder="关键字搜索" clearable
90
+ @change="query">
91
+ </el-input>
92
+
93
+ </template>
94
+ <template #pager>
95
+ <olPager v-bind="pagination" :showDetails="false" @page-change="handlePageChange"
96
+ @clearSelected="clearSelected"/>
97
+ <el-input
98
+ v-model="sql"
99
+ style="width: 100%"
100
+ type="textarea"
101
+ placeholder="sql"
102
+ />
103
+ <el-button @click="addNew()" type="primary">新增列</el-button>
104
+ </template>
105
+ </vxe-grid>
106
+ </template>
107
+
108
+ <script>
109
+ import olPager from "@/components/table/ol-pager/index.vue";
110
+ import {get, post} from "@/utils/http/httpUtils";
111
+ import Sortable from "sortablejs";
112
+ import {OTMixinPager} from "@/mixins/VTMixin/OTMixinPager";
113
+ import {dateFormat} from "@/utils/DateUtils";
114
+
115
+ export default {
116
+ name: "previewRight",
117
+ components: {olPager},
118
+ inject: ['http', 'column'],
119
+ mixins: [OTMixinPager],
120
+ data() {
121
+ return {
122
+ form: {},
123
+ sql: '',
124
+ table: {
125
+ showOverflow: true,
126
+ resizable: true,
127
+ resizableConfig: {},
128
+ columnConfig: {
129
+ resizable: true, isHover: true, isCurrent: true,
130
+ useKey: true,
131
+ },
132
+ keepSource: true,
133
+ mouseConfig: {selected: true},
134
+ rowConfig: {isHover: true, isCurrent: true, useKey: true},
135
+ editConfig: {
136
+ mode: 'cell',
137
+ showIcon: false,
138
+ trigger: 'click',
139
+ showStatus: true,
140
+ showUpdateStatus: true,
141
+ beforeEditMethod: ({column, row}) => {
142
+ let resp = column.params.is_pk != 1 || !row.resp_Data_UUID
143
+ return resp
144
+ }
145
+ },
146
+ align: 'center',
147
+ filterConfig: {
148
+ showIcon: false
149
+ },
150
+ sortConfig: {
151
+ remote: true,
152
+ },
153
+ scrollX: {enabled: true, gt: 15},
154
+ scrollY: {enabled: true, gt: 15},
155
+ loading: false,
156
+ size: 'mini',
157
+ border: true,
158
+ height: '100%',
159
+ columns: [],
160
+ data: []
161
+ }
162
+ }
163
+ },
164
+ methods: {
165
+ async addNew(row) {
166
+ console.log("add")
167
+ const $table = this.$refs.vexGridRef
168
+ const record = {}
169
+ const {row: newRow} = await $table.insertAt(record, row)
170
+ console.log(row,newRow)
171
+ await $table.setEditCell(newRow, this.columns[2].COLUMN_NAME)
172
+ },
173
+ remove(row) {
174
+ let params = {
175
+ "_DbName_": this.form.datasource,
176
+ "_TableName_": this.form.tableName
177
+ };
178
+ for (let column of this.$attrs.columns) {
179
+ if (column.is_pk == 1) {
180
+ params[column.COLUMN_NAME] = row[column.COLUMN_NAME];
181
+ }
182
+ }
183
+ if (Object.keys(params).length == 0) {
184
+ this.$message.error("保存失败,数据表没有唯一键!");
185
+ return false;
186
+ }
187
+
188
+ post(this.http, '/online/asyncDb/data/remove/', params).then(res => {
189
+ if (res) {
190
+ this.query();
191
+ }
192
+ }).finally(() => {
193
+ row.loading = false;
194
+ })
195
+ },
196
+ add(row) {
197
+ let is_pk = this.$attrs.columns.filter(o => o.is_pk == 1).map(o => o.COLUMN_NAME);
198
+ var parse = JSON.parse(JSON.stringify(row));
199
+ delete parse._X_ROW_KEY;
200
+ delete parse.resp_Data_UUID;
201
+ for (let key of is_pk) {
202
+ if (key.toLowerCase() == 'id') {
203
+ parse[key] = new Date().getTime()
204
+ }
205
+ }
206
+ this.$table.insertAt(parse, row).then((e) => {
207
+ this.$table.setEditCell(e.row, is_pk.length != 0 ? is_pk[0] : this.$attrs.columns[0].COLUMN_NAME)
208
+ })
209
+
210
+ },
211
+ keydown({$event}) {
212
+ if ($event.key == "Enter") {
213
+ this.query();
214
+ }
215
+ },
216
+ hasUpdateStatus(row) {
217
+ if (this.$table) {
218
+ return this.$table.isUpdateByRow(row) || this.$table.isInsertByRow(row)
219
+ }
220
+ },
221
+ doSaveUpdate(row, type, params) {
222
+ row.loading = true;
223
+ post(this.http, '/online/asyncDb/data/' + type, params).then(res => {
224
+ if (res) {
225
+ this.query();
226
+ }
227
+ }).finally(() => {
228
+ row.loading = false;
229
+ })
230
+ },
231
+ setUpdateParams(row, params) {
232
+ let whereMap = {};
233
+ for (let column of this.$attrs.columns) {
234
+ if (column.is_pk == 1) {
235
+ whereMap[column.COLUMN_NAME] = row[column.COLUMN_NAME];
236
+ }
237
+ }
238
+ if (Object.keys(whereMap).length == 0) {
239
+ this.$message.error("保存失败,数据表没有唯一键!");
240
+ return false;
241
+ }
242
+ let columnAndValueMap = {};
243
+ for (let key of Object.keys(row)) {
244
+ let updateByRow = this.$table.isUpdateByRow(row, key);
245
+ if (updateByRow) {
246
+ columnAndValueMap[key] = row[key];
247
+ }
248
+ }
249
+ params.columnAndValueMap = columnAndValueMap;
250
+ params.whereMap = whereMap;
251
+ return true;
252
+ },
253
+ saveUpdateEvent(row) {
254
+ let insertByRow = this.$table.isInsertByRow(row);
255
+ var parse = JSON.parse(JSON.stringify(row));
256
+ delete parse._X_ROW_KEY;
257
+ delete parse.resp_Data_UUID;
258
+ let params = {
259
+ tableName: this.form.tableName,
260
+ dbName: this.form.datasource
261
+ }
262
+ if (insertByRow) {
263
+ let columnAndValueMap = {};
264
+ for (let key of Object.keys(parse)) {
265
+ let rowElement = parse[key];
266
+ if (rowElement != undefined && rowElement != '') {
267
+ columnAndValueMap[key] = parse[key];
268
+ }
269
+ }
270
+ params.columnAndValueMap = columnAndValueMap;
271
+ } else {
272
+ let bool = this.setUpdateParams(row, params)
273
+ if (!bool) {
274
+ return;
275
+ }
276
+ }
277
+ this.doSaveUpdate(insertByRow ? parse : row, insertByRow ? 'save' : 'modify', params);
278
+
279
+ },
280
+ query() {
281
+ let orderByStr = '';
282
+ let queryParameterListAnd = [];
283
+ for (let column of this.$attrs.columns) {
284
+ if (!column.children) {
285
+ continue
286
+ }
287
+ let fvo = column.children[0].children[0];
288
+ fvo.search = false;
289
+ fvo.searchContent = '';
290
+ if (!fvo.visible) {
291
+ continue;
292
+ }
293
+ if (column.params.asc) {
294
+ orderByStr = this.getNext(orderByStr, column.COLUMN_NAME + " ASC ")
295
+ } else if (column.params.desc) {
296
+ orderByStr = this.getNext(orderByStr, column.COLUMN_NAME + " DESC ")
297
+ }
298
+ if (fvo.params.time || fvo.params.range) {
299
+ if (fvo.params.start.toString().trim()) {
300
+
301
+ queryParameterListAnd.push({
302
+ key: column.COLUMN_NAME,
303
+ value: fvo.params.start,
304
+ type: 5,
305
+ })
306
+ fvo.search = true;
307
+ fvo.searchContent += column.COLUMN_NAME + " >= " + (fvo.params.time ? dateFormat(fvo.params.start) : fvo.params.start) + " ";
308
+ }
309
+ if (fvo.params.end.toString().trim()) {
310
+ queryParameterListAnd.push({
311
+ key: column.COLUMN_NAME,
312
+ value: fvo.params.end,
313
+ type: 6,
314
+ })
315
+ fvo.search = true;
316
+ fvo.searchContent += column.COLUMN_NAME + " <= " + (fvo.params.time ? dateFormat(fvo.params.end) : fvo.params.end) + " ";
317
+ }
318
+ } else {
319
+ if (fvo.params.value.toString().trim()) {
320
+ queryParameterListAnd.push({
321
+ key: column.COLUMN_NAME,
322
+ value: fvo.params.value,
323
+ type: 8,
324
+ })
325
+ fvo.search = true;
326
+ fvo.searchContent = column.COLUMN_NAME + " like %" + fvo.params.value + "%" + " ";
327
+ }
328
+ }
329
+ }
330
+ let params = {
331
+ dbName: this.form.datasource,
332
+ tableName: this.form.tableName,
333
+ queryParameterListAnd: queryParameterListAnd,
334
+ orderByStr: orderByStr,
335
+ pageNumber: this.pagination.currentPage,
336
+ pageSize: this.pagination.pageSize
337
+ }
338
+ this.table.loading = true;
339
+ post(this.http, "/online/asyncDb/getData", params, false, false).then(({data, msg}) => {
340
+ let field = '';
341
+ for (let column of this.$attrs.columns) {
342
+ if (!column.children) {
343
+ continue;
344
+ }
345
+ if (column.children[0].children[0].visible) {
346
+ if (field.length > 0) {
347
+ field += ",";
348
+ }
349
+ field += column.COLUMN_NAME;
350
+ }
351
+ }
352
+ let indexOf = msg.toString().toLowerCase().indexOf(" from ");
353
+ this.sql = "SELECT " + field + msg.substring(indexOf);
354
+ let respData = (data instanceof Array) ? data : data.listData;
355
+ let COLUMN_NAME = this.$attrs.columns.map(o => o.COLUMN_NAME).filter(item => item !== "" && item !== null && item !== undefined);
356
+
357
+ for (let respDatum of respData) {
358
+ respDatum.resp_Data_UUID = true;
359
+ for (let i = COLUMN_NAME.length - 1; i >= 0; i--) {
360
+ let k = COLUMN_NAME[i];
361
+ if (respDatum[k] != undefined) {
362
+ COLUMN_NAME.splice(i, 1); // 从后向前删除偶数
363
+ }
364
+ }
365
+ }
366
+ for (let column of this.$attrs.columns) {
367
+ if (COLUMN_NAME.indexOf(column.COLUMN_NAME) != -1) {
368
+ column.children[0].children[0].isNull = true;
369
+ } else if (column.children) {
370
+ column.children[0].children[0].isNull = false;
371
+ }
372
+ }
373
+ if (COLUMN_NAME.length > 0) {
374
+ this.$table.reloadColumn(this.$attrs.columns)
375
+ }
376
+ this.table.data = respData
377
+ this.pagination.total = data.count;
378
+ }).finally(() => {
379
+ this.table.loading = false;
380
+ })
381
+
382
+ },
383
+ getNext(str, str2) {
384
+ if (str.trim().length != 0) {
385
+ str += ",";
386
+ }
387
+ return str + str2;
388
+ },
389
+ clearSortEvent(field) {
390
+ if (this.$table) {
391
+ this.$table.clearSort(field)
392
+ }
393
+ },
394
+ sortChange({field, order}) {
395
+ for (const col of this.$attrs.columns) {
396
+ if (col.field == field) {
397
+ if (col.params.desc == true || col.params.asc == true) {
398
+ this.clearSortEvent(field)
399
+ col.params.desc = false
400
+ col.params.asc = false
401
+ break
402
+ }
403
+ col.params.desc = order == 'desc'
404
+ col.params.asc = order == 'asc'
405
+ break
406
+ }
407
+ }
408
+ this.query()
409
+ },
410
+ init(o) {
411
+ this.form = o;
412
+ /*this.updateSort()
413
+ this.$nextTick(() => {
414
+ this.query()
415
+ })*/
416
+ },
417
+ updateSort() {
418
+ this.$nextTick(() => {
419
+ //el绑定元素需要找到vxe的DOM下的tbody元素
420
+ Sortable.create(this.$table.$el.querySelector('.body--wrapper>.vxe-table--header .vxe-header--row'),
421
+ {
422
+ filter: '.col--fixed',
423
+ handle: '.vxe-header--column',
424
+ onEnd: ({newIndex, oldIndex}) => {
425
+ let tableColumn = JSON.parse(JSON.stringify(this.$table.getColumns()));
426
+ let newColumn = tableColumn[newIndex];
427
+ let oldColumn = tableColumn[oldIndex];
428
+ for (let i = 0; i < this.$attrs.columns.length; i++) {
429
+ let column = this.$attrs.columns[i];
430
+ if (oldColumn.field == column.field) {
431
+ oldIndex = i;
432
+ } else if (newColumn.field == column.field) {
433
+ newIndex = i;
434
+ }
435
+ }
436
+ let columns = this.$attrs.columns;
437
+
438
+ this.$table.loadColumn([]);
439
+ let spliceElement = columns.splice(oldIndex, 1)[0];
440
+ columns.splice(newIndex, 0, spliceElement);
441
+ this.$attrs.columns = columns;
442
+ this.$nextTick(() => {
443
+ this.$table.loadColumn(this.$attrs.columns);
444
+ this.$emit('updateColumn')
445
+ })
446
+
447
+ }
448
+ })
449
+ })
450
+ },
451
+ },
452
+ created() {
453
+ this.pagination.pageSizes = [50, 100, 500, 1000, 2000, 5000];
454
+ },
455
+ computed: {
456
+ $table() {
457
+ return this.$refs['vexGridRef']
458
+ }
459
+ },
460
+ }
461
+ </script>
462
+ <style scoped>
463
+ .vxe-body--column {
464
+ height: 25px !important;
465
+ }
466
+ </style>
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <div style="height: 90vh">
3
+ <vxe-grid v-bind="gridOptions1" ref="table" show-footer :footer-method="footerMethod">
4
+ <template #header_right>
5
+ <vxe-button @click="zoomEvent" circle>
6
+ <i class="vxe-icon-fullscreen" v-if="!isMaximized" title="全屏"/>
7
+ <i class=" vxe-icon-minimize" title="取消全屏" v-else/>
8
+ </vxe-button>
9
+ <vxe-button icon="vxe-icon-refresh" @click="query" title="刷新" circle></vxe-button>
10
+ <vxe-button icon="vxe-icon-setting-fill" @click="$refs.tableColumnConfig.open(gridOptions1.columns)"
11
+ title="设置" circle></vxe-button>
12
+ </template>
13
+ </vxe-grid>
14
+ <table-column-config ref="tableColumnConfig"></table-column-config>
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import data from "@/data";
20
+ import {groupAndCompute} from "@/utils/groupCompute";
21
+ import TableColumnConfig from "@/views/groupTable/ol-table-column-config/index.vue";
22
+ import http from "@/utils/http/httpUtil";
23
+
24
+ export default {
25
+ name: 'groupTable',
26
+ components: {TableColumnConfig},
27
+ data() {
28
+ return {
29
+ gridOptions1: data(),
30
+ isMaximized: false,
31
+ dataSource: [],
32
+ }
33
+ }, provide() {
34
+ return {
35
+ gridOptions1: this.gridOptions1
36
+ }
37
+ },
38
+ methods: {
39
+ refresh() {
40
+ this.$refs.table.reloadColumn(this.gridOptions1.columns);
41
+ let groupKey = [];
42
+ let comValue = [];
43
+ for (let column of this.gridOptions1.columns) {
44
+ if (column.visible && column.group) {
45
+ groupKey.push(column.field)
46
+ }
47
+ if (column.computes) {
48
+ comValue.push(column.field + ":" + column.computes)
49
+ }
50
+ }
51
+ let datas = groupAndCompute(groupKey, comValue, this.dataSource)
52
+ console.log(datas)
53
+ this.gridOptions1.data = datas;
54
+ },
55
+ sumNum(list, field) {
56
+ let count = 0
57
+ list.forEach(item => {
58
+ count += Number(item[field])
59
+ })
60
+ return count
61
+ },
62
+ maxOrMin(list, field, max) {
63
+ let count = max ? -9999999 : 9999999;
64
+ data.forEach(item => {
65
+ let n = Number(item[field]);
66
+ if (max) {
67
+ if (count < n) {
68
+ count = n;
69
+ }
70
+ } else {
71
+ if (count > n) {
72
+ count = n;
73
+ }
74
+ }
75
+ })
76
+ return count;
77
+ },
78
+ footerMethod() {
79
+ const footerData = [
80
+ this.gridOptions1.columns.map((column, _columnIndex) => {
81
+ if (_columnIndex === 0) {
82
+ return '合计'
83
+ }
84
+ console.log(column.footer)
85
+ if (column.footer) {
86
+ let operation = column.footer;
87
+ console.log(column)
88
+ if (operation.toLowerCase() == 'avg') {
89
+ return this.sumNum(this.gridOptions1.data, column.field) / this.gridOptions1.data.length
90
+ } else if (operation.toLowerCase() == 'sum') {
91
+ return this.sumNum(this.gridOptions1.data, column.field)
92
+ } else if (operation.toLowerCase() == 'max') {
93
+ return this.maxOrMin(this.gridOptions1.data, column.field, true)
94
+ } else if (operation.toLowerCase() == 'min') {
95
+ return this.maxOrMin(this.gridOptions1.data, column.field, false)
96
+ }
97
+ }
98
+ return null
99
+ })
100
+ ]
101
+ return footerData
102
+ },
103
+ query() {
104
+ this.dataSource = JSON.parse(JSON.stringify(this.gridOptions1.data))
105
+ },
106
+ zoomEvent() {
107
+
108
+ }
109
+ },
110
+ created() {
111
+ this.$nextTick(() => {
112
+ this.gridOptions1.refresh = this.refresh;
113
+ })
114
+ this.query();
115
+ }
116
+ }
117
+ </script>
118
+ <style lang="less" scoped>
119
+ .table-right {
120
+ position: relative;
121
+ float: left;
122
+ width: calc(100% - 315px);
123
+ height: 100%;
124
+ }
125
+
126
+ .tree-left {
127
+ height: 100%;
128
+ position: relative;
129
+ float: left;
130
+ margin-right: 10px;
131
+ z-index: 100;
132
+
133
+ /deep/ .el-card__body {
134
+ height: 100%;
135
+ }
136
+ }
137
+ </style>