@leevan/jtui 1.2.7 → 2.0.1

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 (34) hide show
  1. package/examples/App.vue +640 -24
  2. package/examples/scss/cover.scss +139 -0
  3. package/examples/scss/global.scss +457 -0
  4. package/examples/scss/main-style/_handle.scss +217 -0
  5. package/examples/scss/main-style/_themes.scss +95 -0
  6. package/examples/scss/main-style/style1.scss +0 -0
  7. package/examples/scss/main-style/style2.scss +12 -0
  8. package/examples/scss/main-style/style3.scss +16 -0
  9. package/examples/scss/pub.scss +142 -0
  10. package/examples/tableTest/table-dsj.vue +209 -0
  11. package/examples/tableTest/table-fzbg.vue +163 -0
  12. package/examples/tableTest/table-ptbg.vue +222 -0
  13. package/examples/tableTest/table-tree.vue +45 -0
  14. package/examples/tableTest/tree-table.vue +45 -0
  15. package/lib/jtui.common.js +114134 -84420
  16. package/lib/jtui.css +1 -1
  17. package/lib/jtui.umd.js +114134 -84420
  18. package/lib/jtui.umd.min.js +176 -133
  19. package/package.json +6 -5
  20. package/packages/index.js +6 -3
  21. package/packages/jt-echarts-pc/JtEchartsPc.vue +6 -2
  22. package/packages/jt-form-pc/JtFormPc.vue +1 -1
  23. package/packages/jt-table/comp.js +17 -0
  24. package/packages/jt-table/components/tabsBtn.vue +53 -0
  25. package/packages/jt-table/examples/FilterComplex.vue +78 -0
  26. package/packages/jt-table/examples/FilterContent.vue +159 -0
  27. package/packages/jt-table/examples/FilterExcel.vue +161 -0
  28. package/packages/jt-table/examples/FilterInput.vue +92 -0
  29. package/packages/jt-table/filter.js +162 -0
  30. package/packages/jt-table/index.js +10 -0
  31. package/packages/jt-table/index.vue +1441 -0
  32. package/packages/jt-table-pc/data2.js +33 -14
  33. package/packages/jtaxios.js +31 -0
  34. package/vue.config.js +1 -1
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <div class="jt-table-filter-input">
3
+ <vxe-input
4
+ v-for="(item,index) in column.filters"
5
+ :key="index"
6
+ type="text"
7
+ style="margin-top:6px"
8
+ v-model="item.data"
9
+ placeholder="请输入筛选值"
10
+ @input="changeOptionEvent"></vxe-input>
11
+ <div class="jt-table-fc-footer">
12
+ <vxe-button status="primary" @click="confirmEvent">确认</vxe-button>
13
+ <vxe-button @click="resetEvent">重置</vxe-button>
14
+ <vxe-button @click="addInput">+</vxe-button>
15
+ <vxe-button @click="decInput">-</vxe-button>
16
+ </div>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ export default {
22
+ name: 'FilterInput',
23
+ props: {
24
+ params: Object
25
+ },
26
+ data () {
27
+ return {
28
+ size: 'mini',
29
+ column: null,
30
+ option: null
31
+ }
32
+ },
33
+ watch: {
34
+ params () {
35
+ this.load()
36
+ }
37
+ },
38
+ created () {
39
+ this.load()
40
+ },
41
+ methods: {
42
+ load () {
43
+ // filters 可以配置多个,实际只用一个就可以满足需求了
44
+ const { column } = this.params
45
+ const option = column.filters[0]
46
+ this.column = column
47
+ this.option = option
48
+ },
49
+ changeOptionEvent () {
50
+ const { params, option } = this
51
+ const { $panel } = params
52
+ const checked = !!option.data
53
+ $panel.changeOption(null, checked, option)
54
+ },
55
+ //确认
56
+ confirmEvent () {
57
+ const { $panel } = this.params
58
+ $panel.confirmFilter()
59
+ },
60
+ //重置
61
+ resetEvent () {
62
+ const { $panel } = this.params
63
+ this.column.filters.length = 1;
64
+ $panel.resetFilter()
65
+ },
66
+ //增加
67
+ addInput(){
68
+ this.column.filters.push({checked: true,
69
+ data: "",
70
+ label: undefined,
71
+ resetValue: undefined,
72
+ value: undefined})
73
+ },
74
+ decInput(){
75
+ if(this.column.filters.length > 1){
76
+ this.column.filters.pop();
77
+ }
78
+ }
79
+ }
80
+ }
81
+ </script>
82
+
83
+ <style scoped>
84
+ .jt-table-filter-input {
85
+ padding: 10px;
86
+
87
+ }
88
+ .jt-table-filter-input .jt-table-fc-footer {
89
+ padding-top:12px;
90
+ text-align: center;
91
+ }
92
+ </style>
@@ -0,0 +1,162 @@
1
+ import Vue from 'vue';
2
+ import VXETable from 'vxe-table';
3
+ import XEUtils from 'xe-utils'
4
+
5
+ import FilterInput from './examples/FilterInput.vue'
6
+ import FilterContent from './examples/FilterContent.vue'
7
+ import FilterComplex from './examples/FilterComplex.vue'
8
+ import FilterExcel from './examples/FilterExcel.vue'
9
+
10
+ Vue.component(FilterInput.name, FilterInput)
11
+ Vue.component(FilterContent.name, FilterContent)
12
+ Vue.component(FilterComplex.name, FilterComplex)
13
+ Vue.component(FilterExcel.name, FilterExcel)
14
+
15
+ import VXETablePluginExportXLSX from 'vxe-table-plugin-export-xlsx';
16
+ VXETable.use(VXETablePluginExportXLSX);
17
+
18
+ // 创建一个简单的输入框筛选
19
+ VXETable.renderer.add('FilterInput', {
20
+ // 不显示底部按钮,使用自定义的按钮
21
+ isFooter: false,
22
+ // 筛选模板
23
+ renderFilter (h, renderOpts, params) {
24
+ return [
25
+ <filter-input params={ params }></filter-input>
26
+ ]
27
+ },
28
+ // 筛选方法
29
+ filterMethod ({ option, row, column }) {
30
+ const { data } = option
31
+ const cellValue = XEUtils.get(row, column.property)
32
+ return XEUtils.toString(cellValue).indexOf(data) > -1
33
+ }
34
+ })
35
+
36
+ // 创建一个支持列内容的筛选
37
+ VXETable.renderer.add('FilterContent', {
38
+ // 不显示底部按钮,使用自定义的按钮
39
+ isFooter: false,
40
+ // 筛选模板
41
+ renderFilter (h, renderOpts, params) {
42
+ return [
43
+ <filter-content params={ params }></filter-content>
44
+ ]
45
+ },
46
+ // 重置数据方法
47
+ filterResetMethod ({ options }) {
48
+ options.forEach(option => {
49
+ option.data = { vals: [], sVal: '' }
50
+ })
51
+ },
52
+ // 筛选数据方法
53
+ filterMethod ({ option, row, column }) {
54
+ const { vals } = option.data
55
+ const cellValue = XEUtils.get(row, column.property)
56
+ /* eslint-disable eqeqeq */
57
+ return vals.some(val => val == cellValue)
58
+ }
59
+ })
60
+
61
+ // 创建一个条件的渲染器
62
+ VXETable.renderer.add('FilterComplex', {
63
+ // 不显示底部按钮,使用自定义的按钮
64
+ isFooter: false,
65
+ // 筛选模板
66
+ renderFilter (h, renderOpts, params) {
67
+ return [
68
+ <filter-complex params={ params }></filter-complex>
69
+ ]
70
+ },
71
+ // 重置数据方法
72
+ filterResetMethod ({ options }) {
73
+ options.forEach(option => {
74
+ option.data = { type: 'eq' , name: '' }
75
+ })
76
+ },
77
+ // 筛选数据方法
78
+ filterMethod ({ option, row, column }) {
79
+ let cellValue = XEUtils.get(row, column.property)
80
+ const { type } = option.data
81
+ let { value } = option.data
82
+ if (cellValue) {
83
+ switch (type) {
84
+ case 'eq':
85
+ return cellValue == value
86
+ case 'gt':
87
+ return Number(cellValue) > Number(value)
88
+ case 'lt':
89
+ return Number(cellValue) < Number(value)
90
+ case 'gteq':
91
+ return Number(cellValue) >= Number(value)
92
+ case 'lteq':
93
+ return Number(cellValue) <= Number(value)
94
+ }
95
+ }
96
+ return false
97
+ }
98
+ })
99
+
100
+ // 创建一个实现Excel的筛选器
101
+ VXETable.renderer.add('FilterExcel', {
102
+ // 不显示底部按钮,使用自定义的按钮
103
+ isFooter: false,
104
+ // 筛选模板
105
+ renderFilter (h, renderOpts, params) {
106
+ return [
107
+ <filter-excel params={ params }></filter-excel>
108
+ ]
109
+ },
110
+ // 重置数据方法
111
+ filterResetMethod ({ options }) {
112
+ options.forEach(option => {
113
+ option.data = {f1Type: '1', f1Val: '', fMode: 'and', f2Type: '1', f2Val: '' }
114
+ })
115
+ },
116
+ // 筛选数据方法
117
+ filterMethod ({ option, row, column }) {
118
+ const cellValue = XEUtils.get(row, column.property)
119
+ const {f1Type, f1Val, fMode, f2Type, f2Val } = option.data
120
+ if (cellValue) {
121
+ if (f1Type || f2Type) {
122
+ // 通过筛选条件
123
+ const calculate = (type, val) => {
124
+ switch (type) {
125
+ case '1':
126
+ return cellValue == val
127
+ case '2':
128
+ return cellValue != val
129
+ case '3':
130
+ return Number(cellValue) > Number(val)
131
+ case '4':
132
+ return Number(cellValue) >= Number(val)
133
+ case '5':
134
+ return Number(cellValue) < Number(val)
135
+ case '6':
136
+ return Number(cellValue) <= Number(val)
137
+ case '7':
138
+ return cellValue.indexOf(val) === 0
139
+ case '8':
140
+ return cellValue.indexOf(val) !== 0
141
+ case '9':
142
+ return cellValue.lastIndexOf(val) === cellValue.length - val.length
143
+ case '10':
144
+ return cellValue.lastIndexOf(val) !== cellValue.length - val.length
145
+ case '11':
146
+ return cellValue.indexOf(val) > -1
147
+ case '12':
148
+ return cellValue.indexOf(val) === -1
149
+ }
150
+ return true
151
+ }
152
+ const f1Rest = calculate(f1Type, f1Val)
153
+ const f2Rest = calculate(f2Type, f2Val)
154
+ if (fMode === 'and') {
155
+ return f1Rest && f2Rest
156
+ }
157
+ return f1Rest || f2Rest
158
+ }
159
+ }
160
+ return false
161
+ }
162
+ })
@@ -0,0 +1,10 @@
1
+ // 导入组件,组件必须声明 name
2
+ import JtTablePc from './index.vue';
3
+
4
+ // 为组件提供 install 安装方法,供按需引入
5
+ JtTablePc.install = function (Vue) {
6
+ Vue.component(JtTablePc.name, JtTablePc)
7
+ }
8
+
9
+ // 导出组件
10
+ export default JtTablePc
@@ -0,0 +1,1441 @@
1
+ <template>
2
+ <div class="tableStyle-2"
3
+ :class="isWrap ? 'isWrap' : ''"
4
+ style="position:absolute;top:1px;left:1px;right:1px;bottom:1px;">
5
+ <!-- 普通表格 -->
6
+ <div style="position:relative" v-if="isTool">
7
+ <vxe-toolbar class="jt-toolbar" :custom="{icon:'jtIcon iconpeizhi41 colStyle'}"></vxe-toolbar>
8
+ </div>
9
+ <vxe-table
10
+ class="jt-table-class-only"
11
+ height="auto"
12
+ size="mini"
13
+ show-overflow
14
+ show-header-overflow
15
+ auto-resize
16
+ resizable
17
+ highlight-current-row
18
+ highlight-current-column
19
+ keep-source
20
+ v-if="tableType === 'default'"
21
+ :id="id"
22
+ :ref="id"
23
+ :data="data.DataArray"
24
+ :stripe="stripe"
25
+ :border="border"
26
+ :max-height="maxHeight"
27
+ :show-footer="isFooter"
28
+ :footer-method="footerMethod"
29
+ :footer-span-method="footerColspanMethod"
30
+ :footer-cell-class-name="footerCellClassName"
31
+ :loading="loading"
32
+ :row-style="rowStyle"
33
+ :cell-style="cellStyle_m"
34
+ :span-method="spanMethod"
35
+ :scroll-y="{mode: 'wheel'}"
36
+ :sort-config="{sortMethod:sortMethod}"
37
+ :radio-config="{checkRowKey: null}"
38
+ :keyboard-config="{isArrow: true}"
39
+ :checkbox-config="{highlight:true}"
40
+ :export-config="{type: 'xlsx',types:['xlsx', 'csv', 'html', 'xml', 'txt']}"
41
+ :custom-config="{storage: true,checkMethod: checkColumnMethod}"
42
+ :edit-config="{trigger: 'dblclick', mode: 'cell', showStatus: true,activeMethod: activeCellMethod}"
43
+ :expand-config="{visibleMethod,loadMethod:expandConfig.loadMethod,toggleMethod,lazy:true,accordion: expandConfig.accordion}"
44
+ @scroll="scroll"
45
+ @checkbox-change="selectChangeEvent"
46
+ @checkbox-all="selectChangeEvent"
47
+ @radio-change="radioSelectChangeEvent"
48
+ @cell-click="cellClickEvent"
49
+ @keydown="keyEnter"
50
+ >
51
+ <!-- 复选框列 -->
52
+ <vxe-table-column v-if="checkbox"
53
+ type="checkbox"
54
+ width="38"
55
+ align="center"
56
+ fixed="left"
57
+ ></vxe-table-column>
58
+ <!-- 单选框列 -->
59
+ <vxe-table-column
60
+ v-if="radio"
61
+ type="radio"
62
+ width="38"
63
+ align="center"
64
+ fixed="left"
65
+ ></vxe-table-column>
66
+ <!-- 序号列 -->
67
+ <vxe-table-column
68
+ v-if="isSeq && data"
69
+ type="seq"
70
+ align="center"
71
+ :width="req+'px'"
72
+ title="序号"
73
+ fixed="left"
74
+ ></vxe-table-column>
75
+ <!-- 后台数据列 -->
76
+ <template v-for="(item,index) in data.retjson.header">
77
+ <vxe-table-column
78
+ :edit-render="item.edit"
79
+ :key="index"
80
+ show-overflow
81
+ :field="item.prop"
82
+ :align="item.align"
83
+ :title="item.label"
84
+ :type="item.html ? 'html': ''"
85
+ :min-width="item.width"
86
+ :sortable="item.isSort"
87
+ :visible="item.width!=0"
88
+ :fixed="item.isFixed"
89
+ :filters="filterData(item.filterRender)"
90
+ :filter-render="{name: item.filterRender}"
91
+ :formatter="formatEnum"
92
+ :cell-render="cellRenderData(item.cellRender)"
93
+ >
94
+ </vxe-table-column>
95
+ </template>
96
+ <!-- 展开行 -->
97
+ <vxe-table-column
98
+ v-if="expandConfig.isOpen"
99
+ type="expand"
100
+ fixed="right"
101
+ :width="expandConfig.width"
102
+ >
103
+ <template #default="{row}">
104
+ <span style="position:relative;top:2px;right:6px;color:#333">
105
+ {{isExpandText(row) ? expandConfig.text : ''}}</span>
106
+ </template>
107
+ <template #content="{ row }">
108
+ <slot name="expandContent" :slot-scope="row"></slot>
109
+ </template>
110
+ </vxe-table-column>
111
+ <!-- 操作列 -->
112
+ <vxe-table-column title="操作"
113
+ :visible="handlerConfig.show"
114
+ :align="handlerConfig.align"
115
+ :width="handlerConfig.width"
116
+ :fixed="handlerConfig.fixed"
117
+ show-overflow>
118
+ <template v-slot="{ row , rowIndex }">
119
+ <el-dropdown v-if="handlerConfig.btnGroup">
120
+ <el-button size="mini" type="primary">
121
+ 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
122
+ </el-button>
123
+ <el-dropdown-menu slot="dropdown">
124
+ <el-dropdown-item
125
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
126
+ v-for="(item,index) in data.retjson.inBottons"
127
+ :key="'s' + index"
128
+ >{{item.name}}</el-dropdown-item>
129
+ <el-dropdown-item
130
+ v-for="(item,index) in row.inBottons"
131
+ :key="index"
132
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
133
+ >{{item.name}}</el-dropdown-item>
134
+ </el-dropdown-menu>
135
+ </el-dropdown>
136
+ <template v-if="!handlerConfig.btnGroup">
137
+ <el-button
138
+ type="text"
139
+ v-for="(item,index) in data.retjson.inBottons"
140
+ :key="index"
141
+ size="mini"
142
+ @click="handlerColClick(item.funcode,row,rowIndex)"
143
+ >
144
+ <i class="jtIcon ht-icon"
145
+ :style="{color:item.color ? item.color : '#666',
146
+ fontSize:item.size ? item.size + 'px' : '16px'}"
147
+ :class="item.icon?item.icon:'iconcaidan'"></i>
148
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
149
+ </el-button>
150
+ <el-button
151
+ type="text"
152
+ v-for="(item,index) in row.inBottons"
153
+ :key="index"
154
+ size="mini"
155
+ @click="handlerColClick(item.funcode,row,rowIndex)"
156
+ >
157
+ <i class="jtIcon ht-icon"
158
+ :style="{color:item.color ? item.color : '#666',
159
+ fontSize:item.size ? item.size + 'px' : '16px'}"
160
+ :class="item.icon?item.icon:'iconcaidan'"></i>
161
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
162
+ </el-button>
163
+ </template>
164
+ </template>
165
+ </vxe-table-column>
166
+ </vxe-table>
167
+ <!-- 大数据 -->
168
+ <vxe-table
169
+ class="jt-table-class-only"
170
+ height="auto"
171
+ size="mini"
172
+ show-overflow
173
+ show-header-overflow
174
+ auto-resize
175
+ resizable
176
+ highlight-current-row
177
+ highlight-current-column
178
+ keep-source
179
+ v-if="tableType === 'bigData'"
180
+ :id="id"
181
+ :ref="id"
182
+ :data="data.DataArray"
183
+ :stripe="stripe"
184
+ :border="border"
185
+ :max-height="maxHeight"
186
+ :loading="loading"
187
+ :row-style="rowStyle"
188
+ :cell-style="cellStyle_m"
189
+ :span-method="spanMethod"
190
+ :scroll-x="{gt: 20}"
191
+ :scroll-y="{gt: 40,mode: 'wheel'}"
192
+ :sort-config="{sortMethod:sortMethod}"
193
+ :radio-config="{checkRowKey: null}"
194
+ :keyboard-config="{isArrow: true}"
195
+ :checkbox-config="{highlight:true}"
196
+ :export-config="{type: 'xlsx',types:['xlsx', 'csv', 'html', 'xml', 'txt']}"
197
+ :custom-config="{storage: true,checkMethod: checkColumnMethod}"
198
+ :edit-config="{trigger: 'dblclick', mode: 'cell', showStatus: true,activeMethod: activeCellMethod}"
199
+ @scroll="scroll"
200
+ @checkbox-change="selectChangeEvent"
201
+ @checkbox-all="selectChangeEvent"
202
+ @radio-change="radioSelectChangeEvent"
203
+ @cell-click="cellClickEvent"
204
+ @keydown="keyEnter"
205
+ >
206
+ <!-- 复选框列 -->
207
+ <vxe-table-column v-if="checkbox"
208
+ type="checkbox"
209
+ width="38"
210
+ align="center"
211
+ fixed="left"
212
+ ></vxe-table-column>
213
+ <!-- 单选框列 -->
214
+ <vxe-table-column
215
+ v-if="radio"
216
+ type="radio"
217
+ width="38"
218
+ align="center"
219
+ fixed="left"
220
+ ></vxe-table-column>
221
+ <!-- 序号列 -->
222
+ <vxe-table-column
223
+ v-if="isSeq && data"
224
+ type="seq"
225
+ align="center"
226
+ :width="req+'px'"
227
+ title="序号"
228
+ fixed="left"
229
+ ></vxe-table-column>
230
+ <!-- 后台数据列 -->
231
+ <template v-for="(item,index) in data.retjson.header">
232
+ <vxe-table-column
233
+ :edit-render="item.edit"
234
+ :key="index"
235
+ show-overflow
236
+ :field="item.prop"
237
+ :align="item.align"
238
+ :title="item.label"
239
+ :type="item.html ? 'html': ''"
240
+ :min-width="item.width"
241
+ :sortable="item.isSort"
242
+ :visible="item.width!=0"
243
+ :fixed="item.isFixed"
244
+ :filters="filterData(item.filterRender)"
245
+ :filter-render="{name: item.filterRender}"
246
+ :formatter="formatEnum"
247
+ :cell-render="cellRenderData(item.cellRender)"
248
+ >
249
+ </vxe-table-column>
250
+ </template>
251
+ <!-- 展开行 -->
252
+ <vxe-table-column
253
+ v-if="expandConfig.isOpen"
254
+ type="expand"
255
+ fixed="right"
256
+ :width="expandConfig.width"
257
+ >
258
+ <template #default="{row}">
259
+ <span style="position:relative;top:2px;right:6px;color:#333">
260
+ {{isExpandText(row) ? expandConfig.text : ''}}</span>
261
+ </template>
262
+ <template #content="{ row }">
263
+ <slot name="expandContent" :slot-scope="row"></slot>
264
+ </template>
265
+ </vxe-table-column>
266
+ <!-- 操作列 -->
267
+ <vxe-table-column title="操作"
268
+ :visible="handlerConfig.show"
269
+ :align="handlerConfig.align"
270
+ :width="handlerConfig.width"
271
+ :fixed="handlerConfig.fixed"
272
+ show-overflow>
273
+ <template v-slot="{ row , rowIndex }">
274
+ <el-dropdown v-if="handlerConfig.btnGroup">
275
+ <el-button size="mini" type="primary">
276
+ 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
277
+ </el-button>
278
+ <el-dropdown-menu slot="dropdown">
279
+ <el-dropdown-item
280
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
281
+ v-for="(item,index) in data.retjson.inBottons"
282
+ :key="'s' + index"
283
+ >{{item.name}}</el-dropdown-item>
284
+ <el-dropdown-item
285
+ v-for="(item,index) in row.inBottons"
286
+ :key="index"
287
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
288
+ >{{item.name}}</el-dropdown-item>
289
+ </el-dropdown-menu>
290
+ </el-dropdown>
291
+ <template v-if="!handlerConfig.btnGroup">
292
+ <el-button
293
+ type="text"
294
+ v-for="(item,index) in data.retjson.inBottons"
295
+ :key="index"
296
+ size="mini"
297
+ @click="handlerColClick(item.funcode,row,rowIndex)"
298
+ >
299
+ <i class="jtIcon ht-icon"
300
+ :style="{color:item.color ? item.color : '#666',
301
+ fontSize:item.size ? item.size + 'px' : '16px'}"
302
+ :class="item.icon?item.icon:'iconcaidan'"></i>
303
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
304
+ </el-button>
305
+ <el-button
306
+ type="text"
307
+ v-for="(item,index) in row.inBottons"
308
+ :key="index"
309
+ size="mini"
310
+ @click="handlerColClick(item.funcode,row,rowIndex)"
311
+ >
312
+ <i class="jtIcon ht-icon"
313
+ :style="{color:item.color ? item.color : '#666',
314
+ fontSize:item.size ? item.size + 'px' : '16px'}"
315
+ :class="item.icon?item.icon:'iconcaidan'"></i>
316
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
317
+ </el-button>
318
+ </template>
319
+ </template>
320
+ </vxe-table-column>
321
+ </vxe-table>
322
+ <!-- 分组表格 -->
323
+ <vxe-table
324
+ size="mini"
325
+ class="jt-table-class-only"
326
+ :id="id"
327
+ :ref="id"
328
+ v-if="tableType === 'group'"
329
+ :custom-config="{storage: true,checkMethod: checkColumnMethod}"
330
+ :border="border"
331
+ show-overflow
332
+ show-header-overflow
333
+ height="auto"
334
+ :max-height="maxHeight"
335
+ auto-resize
336
+ resizable
337
+ highlight-current-row
338
+ :tree-config="groupConfig"
339
+ :row-class-name="rowClassName"
340
+ :cell-class-name="gcellClassName"
341
+ :keyboard-config="{isArrow: true}"
342
+ highlight-current-column
343
+ @checkbox-change="treeSelectChangeEvent"
344
+ :checkbox-config="{
345
+ highlight:true
346
+ }"
347
+ @checkbox-all="treeSelectChangeEvent"
348
+ @cell-click="cellClickEvent"
349
+ :row-style="rowStyle"
350
+ :cell-style="cellStyle_m"
351
+ :loading="loading"
352
+ :data="data.DataArray">
353
+ <vxe-table-column v-if="checkbox"
354
+ type="checkbox"
355
+ width="38"
356
+ fixed="left"
357
+ align="center"></vxe-table-column>
358
+ <vxe-table-column
359
+ v-if="isSeq && data"
360
+ type="seq"
361
+ align="center"
362
+ :width="req+'px'"
363
+ title="序号"
364
+ fixed="left"
365
+ ></vxe-table-column>
366
+ <template v-for="(item,index) in data.retjson.header">
367
+ <vxe-table-column
368
+ :key="index"
369
+ show-overflow
370
+ :tree-node="item.prop == treeField"
371
+ :field="item.prop"
372
+ :align="item.align"
373
+ :type="item.html ? 'html': ''"
374
+ :title="item.label"
375
+ :min-width="item.width"
376
+ :visible="item.width!=0"
377
+ :formatter="formatEnum"
378
+ >
379
+ </vxe-table-column>
380
+ </template>
381
+ <!-- 操作列 -->
382
+ <vxe-table-column title="操作"
383
+ v-if="handlerConfig.show"
384
+ :align="handlerConfig.align"
385
+ :width="handlerConfig.width"
386
+ :fixed="handlerConfig.fixed"
387
+ show-overflow>
388
+ <template v-slot="{ row , rowIndex }">
389
+ <el-dropdown v-if="handlerConfig.btnGroup">
390
+ <el-button size="mini" type="primary">
391
+ 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
392
+ </el-button>
393
+ <el-dropdown-menu slot="dropdown">
394
+ <template v-for="(item,index) in data.retjson.inBottons">
395
+ <el-dropdown-item
396
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
397
+ v-if="isShowAddButton(row.path,item.name)"
398
+ :key="'s' + index"
399
+ >{{item.name}}</el-dropdown-item>
400
+ </template>
401
+ <template v-for="(item,index) in row.inBottons">
402
+ <el-dropdown-item
403
+ v-if="isShowAddButton(row.path,item.name)"
404
+ :key="index"
405
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
406
+ >{{item.name}}</el-dropdown-item>
407
+ </template>
408
+ </el-dropdown-menu>
409
+ </el-dropdown>
410
+ <template v-if="!handlerConfig.btnGroup">
411
+ <template v-for="(item,index) in data.retjson.inBottons">
412
+ <el-button
413
+ type="text"
414
+ v-if="isShowAddButton(row.path,item.name)"
415
+ :key="'s' + index"
416
+ size="mini"
417
+ @click="handlerColClick(item.funcode,row,rowIndex)"
418
+ >
419
+ <i class="jtIcon ht-icon"
420
+ :style="{color:item.color ? item.color : '#666',
421
+ fontSize:item.size ? item.size + 'px' : '16px'}"
422
+ :class="item.icon?item.icon:'iconcaidan'"></i>
423
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
424
+ </el-button>
425
+ </template>
426
+ <template v-for="(item,index) in row.inBottons">
427
+ <el-button
428
+ type="text"
429
+ v-if="isShowAddButton(row.path,item.name)"
430
+ :key="index"
431
+ size="mini"
432
+ @click="handlerColClick(item.funcode,row,rowIndex)"
433
+ >
434
+ <i class="jtIcon ht-icon"
435
+ :style="{color:item.color ? item.color : '#666',
436
+ fontSize:item.size ? item.size + 'px' : '16px'}"
437
+ :class="item.icon?item.icon:'iconcaidan'"></i>
438
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
439
+ </el-button>
440
+ </template>
441
+ </template>
442
+ </template>
443
+ </vxe-table-column>
444
+ </vxe-table>
445
+ <!-- 树形表格 and 树 -->
446
+ <vxe-table
447
+ size="mini"
448
+ class="jt-table-class-only"
449
+ :id="id"
450
+ :ref="id"
451
+ :stripe="stripe"
452
+ :show-header="treeTypeConfig.type == 'treeTable'"
453
+ v-if="tableType === 'tree'"
454
+ :max-height="maxHeight"
455
+ :border="border"
456
+ show-overflow
457
+ show-header-overflow
458
+ height="auto"
459
+ auto-resize
460
+ :cell-style="cellStyle_m"
461
+ :row-style="rowStyle"
462
+ :span-method="spanMethod"
463
+ resizable
464
+ highlight-current-row
465
+ :tree-config="treeConfig"
466
+ :row-key="true"
467
+ row-id="pkid"
468
+ :radio-config="{labelField:treeTypeConfig.type !== 'treeTable' ? 'name' : '',
469
+ checkMethod:treeRadioMethod}"
470
+ :checkbox-config="{labelField:treeTypeConfig.type !== 'treeTable' ? 'name' : '',
471
+ checkRowKeys: this.treeTypeConfig.checkRowKeys,
472
+ highlight:true,
473
+ checkMethod:checCheckboxkMethod2}"
474
+ @checkbox-change="treeCheckChange"
475
+ @checkbox-all="treeCheckChange"
476
+ @radio-change="radioSelectChangeEvent"
477
+ @cell-click="cellClickEvent"
478
+ :edit-config="{trigger: 'dblclick', mode: 'cell', showStatus: true,activeMethod: activeCellMethod}"
479
+ keep-source
480
+ :loading="loading"
481
+ @keydown="keyEnter"
482
+ @scroll="scroll1"
483
+ :expand-config="{visibleMethod,loadMethod:expandConfig.loadMethod,
484
+ toggleMethod,
485
+ lazy:true,accordion: expandConfig.accordion}"
486
+ :data="data.DataArray">
487
+ <!-- 复选框列 -->
488
+ <vxe-table-column v-if="treeTypeConfig.type === 'treeTable' && treeTypeConfig.checkbox"
489
+ type="checkbox"
490
+ width="38"
491
+ align="center"
492
+ fixed="left"
493
+ >
494
+ </vxe-table-column>
495
+ <!-- 单选框列 -->
496
+ <vxe-table-column
497
+ v-if="treeTypeConfig.type === 'treeTable' && treeTypeConfig.radio"
498
+ type="radio"
499
+ width="38"
500
+ align="center"
501
+ fixed="left"
502
+ ></vxe-table-column>
503
+ <!-- 序号列 -->
504
+ <vxe-table-column
505
+ v-if="isSeq && treeTypeConfig.type === 'treeTable'"
506
+ type="seq"
507
+ align="center"
508
+ :width="req+'px'"
509
+ title="序号"
510
+ fixed="left"
511
+ ></vxe-table-column>
512
+ <template v-for="(item,index) in data.retjson.header">
513
+ <vxe-table-column
514
+ v-if="treeTypeConfig.type !== 'treeTable'"
515
+ :edit-render="item.edit"
516
+ :type="treeTypeConfig.colType"
517
+ :tree-node="index == 0"
518
+ :key="index"
519
+ show-overflow
520
+ :field="item.prop"
521
+ align="left"
522
+ :title="item.label"
523
+ :min-width="item.width"
524
+ :cell-render="cellRenderData(item.cellRender)"
525
+ :visible="index === 0"
526
+ >
527
+ <template v-slot="{ row }">
528
+ <span @click="treeTxtClick(row)" style="position:relative;top:2px;">
529
+ <template v-if="row.path && row.path !== undefined">
530
+ <i class="jtIcon" :class="row.icon ? row.icon : 'jt-iconClose2 iconwenjianjia'"></i>
531
+ </template>
532
+ <template v-else>
533
+ <i class="jtIcon jt-iconFile" :class="row.icon ? row.icon : 'icon21file'"></i>
534
+ </template>
535
+ <span>{{ row.name }}</span>
536
+ </span>
537
+ </template>
538
+ </vxe-table-column>
539
+ <vxe-table-column
540
+ v-if="treeTypeConfig.type === 'treeTable'"
541
+ :edit-render="item.edit"
542
+ :tree-node="index == 0"
543
+ :key="index"
544
+ show-overflow
545
+ :field="item.prop"
546
+ :align="item.align"
547
+ :title="item.label"
548
+ :min-width="item.width"
549
+ :visible="item.width !== 0"
550
+ :type="item.html ? 'html': ''"
551
+ :cell-render="cellRenderData(item.cellRender)"
552
+ :formatter="formatEnum"
553
+ >
554
+ <template v-slot="{ row }" v-if="index === 0">
555
+ <span @click="treeTxtClick(row)" style="position:relative;top:2px;">
556
+ <template v-if="row.path && row.path !== undefined">
557
+ <i class="jtIcon" :class="row.icon ? row.icon : 'jt-iconClose2 iconwenjianjia'"></i>
558
+ </template>
559
+ <template v-else>
560
+ <i class="jtIcon jt-iconFile" :class="row.icon ? row.icon : 'icon21file'"></i>
561
+ </template>
562
+ <span>{{ row[item.prop] }}</span>
563
+ </span>
564
+ </template>
565
+ </vxe-table-column>
566
+ </template>
567
+ <!-- 展开行 -->
568
+ <vxe-table-column
569
+ v-if="expandConfig.isOpen"
570
+ type="expand"
571
+ :width="expandConfig.width"
572
+ >
573
+ <template #default="{row}">
574
+ <span style="position:relative;top:2px;right:6px;color:#333">
575
+ {{isExpandText(row) ? expandConfig.text : ''}}</span>
576
+ </template>
577
+ <template #content="{ row }">
578
+ <slot name="expandContent" :slot-scope="row"></slot>
579
+ </template>
580
+ </vxe-table-column>
581
+ <!-- 操作列 -->
582
+ <vxe-table-column title="操作"
583
+ v-if="handlerConfig.show"
584
+ :align="handlerConfig.align"
585
+ :width="handlerConfig.width"
586
+ :fixed="handlerConfig.fixed"
587
+ show-overflow>
588
+ <template v-slot="{ row , rowIndex }">
589
+ <el-dropdown v-if="handlerConfig.btnGroup">
590
+ <el-button size="mini" type="primary">
591
+ 更多操作<i class="el-icon-arrow-down el-icon--right"></i>
592
+ </el-button>
593
+ <el-dropdown-menu slot="dropdown">
594
+ <template v-for="(item,index) in data.retjson.inBottons">
595
+ <el-dropdown-item
596
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
597
+ v-if="isShowAddButton(row.path,item.name)"
598
+ :key="'s' + index"
599
+ >{{item.name}}</el-dropdown-item>
600
+ </template>
601
+ <template v-for="(item,index) in row.inBottons">
602
+ <el-dropdown-item
603
+ v-if="isShowAddButton(row.path,item.name)"
604
+ :key="index"
605
+ @click.native="handlerColClick(item.funcode,row,rowIndex)"
606
+ >{{item.name}}</el-dropdown-item>
607
+ </template>
608
+ </el-dropdown-menu>
609
+ </el-dropdown>
610
+ <template v-if="!handlerConfig.btnGroup">
611
+ <template v-for="(item,index) in data.retjson.inBottons">
612
+ <el-button
613
+ type="text"
614
+ v-if="isShowAddButton(row.path,item.name)"
615
+ :key="'s' + index"
616
+ size="mini"
617
+ @click="handlerColClick(item.funcode,row,rowIndex)"
618
+ >
619
+ <i class="jtIcon ht-icon"
620
+ :style="{color:item.color ? item.color : '#666',
621
+ fontSize:item.size ? item.size + 'px' : '16px'}"
622
+ :class="item.icon?item.icon:'iconcaidan'"></i>
623
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
624
+ </el-button>
625
+ </template>
626
+ <template v-for="(item,index) in row.inBottons">
627
+ <el-button
628
+ type="text"
629
+ v-if="isShowAddButton(row.path,item.name)"
630
+ :key="index"
631
+ size="mini"
632
+ @click="handlerColClick(item.funcode,row,rowIndex)"
633
+ >
634
+ <i class="jtIcon ht-icon"
635
+ :style="{color:item.color ? item.color : '#666',
636
+ fontSize:item.size ? item.size + 'px' : '16px'}"
637
+ :class="item.icon?item.icon:'iconcaidan'"></i>
638
+ <span class="ht-text" style="color:#666;">{{item.name}}</span>
639
+ </el-button>
640
+ </template>
641
+ </template>
642
+ </template>
643
+ </vxe-table-column>
644
+ </vxe-table>
645
+ </div>
646
+ </template>
647
+
648
+ <script>
649
+ import XEUtils from 'xe-utils';
650
+ export default {
651
+ name: 'jt-table-pc',
652
+ created(){
653
+ if(this.isPage){
654
+ this.tDataCopy = JSON.parse(JSON.stringify(this.data.DataArray));
655
+ this.dataTotal = this.tableData.length;
656
+ this.pageTotal = Math.ceil(this.dataTotal / 50);
657
+ for(let i = 1; i <= this.pageTotal; i++){
658
+ this.dataTreeObj[i] = this.tDataCopy.slice((i-1) * 50, i * 50);
659
+ }
660
+ this.data.DataArray = [...this.dataTreeObj[this.pageIndex],...this.dataTreeObj[this.pageIndex+1]] ;
661
+ }
662
+ if('header' in this.data.retjson){
663
+ this.treeField = this.data.retjson.header[0].prop;
664
+ }
665
+ },
666
+ props:{
667
+ //表格ID
668
+ id:{
669
+ type:String,
670
+ required:true
671
+ },
672
+ //表格数据源
673
+ data:{
674
+ type:Object,
675
+ required:true
676
+ },
677
+ //序号width
678
+ req:{
679
+ type:[Number,String],
680
+ default:60
681
+ },
682
+ //表格类型,默认default为普通表格、tree为树表
683
+ tableType:{
684
+ type:String,
685
+ default:'default'
686
+ },
687
+ //是否显示单选框
688
+ radio:{
689
+ type:Boolean,
690
+ default:false
691
+ },
692
+ //是否显示复选框
693
+ checkbox:{
694
+ type:Boolean,
695
+ default:false
696
+ },
697
+ //操作列配置
698
+ handlerConfig:{
699
+ type:Object,
700
+ default:() => {
701
+ return {
702
+ show:false,
703
+ width:250,
704
+ align:'center',
705
+ fixed:'right',
706
+ btnGroup:true
707
+ }
708
+ }
709
+ },
710
+ //是否显示表尾
711
+ isFooter:{
712
+ type:Boolean,
713
+ default:false
714
+ },
715
+ //表尾显示项控制
716
+ footConfig:{
717
+ type:Object,
718
+ default:() => {
719
+ return {
720
+ filed:[]
721
+ }
722
+ }
723
+ },
724
+ //树 or 树表控制项
725
+ treeTypeConfig:{
726
+ type:Object,
727
+ default:() => {
728
+ return {
729
+ colType:'checkbox',
730
+ type:'tree',
731
+ checkbox:true,
732
+ line:true,
733
+ expandAll:false,
734
+ checkRowKeys:[]
735
+ }
736
+ }
737
+ },
738
+ treeLazy:{
739
+ type:Boolean,
740
+ default:true
741
+ },
742
+ //加载动画
743
+ loading:{
744
+ type:Boolean,
745
+ default:false
746
+ },
747
+ //显示、隐藏列开关
748
+ isTool:{
749
+ type:Boolean,
750
+ default:false
751
+ },
752
+ //行样式控制函数
753
+ rowStyle:{
754
+ type:Function
755
+ },
756
+ //单元格样式控制函数
757
+ cellStyle:{
758
+ type:Function
759
+ },
760
+ //分组表格是否开启连线模式
761
+ groupLine:{
762
+ type:Boolean,
763
+ default:false
764
+ },
765
+ //合并行和列函数
766
+ spanMethod:{
767
+ type:Function
768
+ },
769
+ //斑马线开关
770
+ stripe:{
771
+ type:Boolean,
772
+ default:false
773
+ },
774
+ //表格最大高度
775
+ maxHeight:{
776
+ type:[String,Number],
777
+ default:0
778
+ },
779
+ //分组表格是否默认展开所有
780
+ groupExpandAll:{
781
+ type:Boolean,
782
+ default:false
783
+ },
784
+ //表格边线
785
+ border:{
786
+ type:String,
787
+ default:'full'
788
+ },
789
+ //树、树表是否禁用非最后一级
790
+ isParent:{
791
+ type:Boolean,
792
+ default:true
793
+ },
794
+ //是否开启序号
795
+ isSeq:{
796
+ type:Boolean,
797
+ default:true
798
+ },
799
+ //分组表格默认展开所有
800
+ isExpand:{
801
+ type:Boolean,
802
+ default:true
803
+ },
804
+ //前端滚动分页加载
805
+ isPage:{
806
+ type:Boolean,
807
+ default:false
808
+ },
809
+ //表头是否换行
810
+ isWrap:{
811
+ type:Boolean,
812
+ default:false
813
+ },
814
+ //单元格自定义组件events
815
+ cellRenderMethods:{
816
+ type:Object,
817
+ default:()=>({
818
+ parentRow:Object,
819
+ radioChange:()=>{}
820
+ })
821
+ },
822
+ //展开行配置
823
+ expandConfig:{
824
+ type:Object,
825
+ default:()=>({
826
+ isOpen:false,
827
+ width:120,
828
+ text:'',
829
+ accordion:true, //手风琴模式
830
+ loadMethod:()=>{}
831
+ })
832
+ },
833
+ //树手风琴开关
834
+ treeAccordion:{
835
+ type:Boolean,
836
+ default:false
837
+ }
838
+ },
839
+ data(){
840
+ return {
841
+ tableData:this.data.DataArray, //表格数据
842
+ colNum:0,//当前列的数量
843
+ leftCol:0,//从左起计算合并列的基数
844
+ //分组表格的配置
845
+ groupConfig:{
846
+ children: 'children',
847
+ iconOpen: 'jtIcon iconwenjianjia1 jt-iconOpen1',
848
+ iconClose: 'jtIcon iconwenjianjia jt-iconClose1',
849
+ expandAll: this.groupExpandAll,
850
+ line:this.groupLine
851
+ },
852
+ //树 or 树表 配置
853
+ treeConfig:{
854
+ lazy: this.treeLazy,
855
+ children: 'children',
856
+ expandAll: this.treeTypeConfig.expandAll,
857
+ hasChild: 'path',
858
+ iconOpen: 'jtIcon iconjianshao jt-iconOpen',
859
+ iconClose: 'jtIcon iconjia1 jt-iconClose',
860
+ loadMethod: this.loadChildrenMethod,
861
+ line:this.treeTypeConfig.line,
862
+ accordion:this.treeAccordion
863
+ },
864
+ treeField:'', //分组列的字段
865
+ timeOut:null,//滚动翻页定时器Id
866
+ pageIndex:1,
867
+ sp:0,//当前滚动的位置
868
+ tPageIndex:1, //树表分页当前页数
869
+ tDataCopy:[], //树表分页数据拷贝
870
+ pageTotal:0,
871
+ dataTotal:0,
872
+ dataTreeObj:{}
873
+ }
874
+ },
875
+ methods:{
876
+ //加载数据
877
+ loadData(data){
878
+ return this.$refs[this.id].loadData(data);
879
+ },
880
+ //根据类型返回筛选框源数据
881
+ filterData(type){
882
+ switch(type){
883
+ case 'FilterInput' : return [{ data: ''}];
884
+ case 'FilterContent' : return [{data: {vals: [], sVal: ''}}];
885
+ case 'FilterExcel' : return [{data: {f1Type:'1', f1Val: '', fMode: 'and', f2Type: '1', f2Val: ''}}];
886
+ case 'FilterComplex' : return [{data: {type: 'eq', value: ''}},{data: {type: 'eq', value: ''}}];
887
+ }
888
+ },
889
+ //单元格自定义渲染根据类型返回配置
890
+ cellRenderData(type){
891
+ switch(type){
892
+ case 'TabsBtn' : return {
893
+ name:'TabsBtn',
894
+ events:{radioChange:this.cellRenderMethods.radioChange},
895
+ parentRow:this.cellRenderMethods?.parentRow
896
+ }
897
+ }
898
+ },
899
+ //枚举转换
900
+ formatEnum({column,cellValue}){
901
+ try {
902
+ let data = this.data.retjson.header.find(item => item.prop == column.property);
903
+ if(data && "html" in data && 'htmlType' in data){
904
+ if(data.htmlType == 'icon'){
905
+ if(Array.isArray(cellValue)){
906
+ let str = '';
907
+ cellValue.forEach(i => {
908
+ let item = data.html.find(im => {
909
+ return im.value == i});
910
+ if(item){
911
+ str += `<span
912
+ class="jtIcon ${item.icon}" style="
913
+ color:${item.color};
914
+ font-size:${item.size}px;
915
+ margin-right:${item.margin || '8'}px"
916
+ onclick="iconItem(${i})"
917
+ ></span>`
918
+ }
919
+ })
920
+ return str ? str : cellValue
921
+ }else{
922
+ let item = data.html.find(item => item.value == cellValue);
923
+ return item ? `<span class="jtIcon ${item.icon}" style="color:${item.color};font-size:${item.size}px"></span>` : cellValue
924
+ }
925
+
926
+ }else if(data.htmlType == 'a'){
927
+ let item = data.html.find(item => item.value == cellValue);
928
+ return item ?`<a href="javascript:">${cellValue}</a>` : cellValue
929
+ }
930
+ }else if(data && "enum" in data){
931
+ let item = data.enum.find(item => item.value == cellValue)
932
+ return item ? item.label : cellValue
933
+ }else{
934
+ return cellValue;
935
+ }
936
+ } catch (error) {
937
+ console.log(error)
938
+ return cellValue;
939
+ }
940
+ },
941
+ //全局排序自定义排序方法
942
+ sortMethod({ data, column, property, order }){
943
+ let data1 = data.filter(item => {
944
+ return property in item;
945
+ })
946
+ let data2 = data.filter(item => {
947
+ return !(property in item);
948
+ })
949
+ let list = [];
950
+ if (order === 'asc' || order === 'desc') {
951
+ list = data1.sort((a,b)=>{
952
+ return a[property]-b[property];
953
+ });
954
+ }
955
+ if (order === 'desc') {
956
+ list.reverse()
957
+ }
958
+ return list.concat(data2);
959
+ },
960
+ //筛选列默认禁用处理
961
+ checkColumnMethod({column}){
962
+ if(column.width == 0 || column.title == '序号'){
963
+ return false
964
+ }
965
+ return true
966
+ },
967
+ //表尾统计,(计算平均值和求和)
968
+ footerMethod({ columns, data }){
969
+ const means = []
970
+ const sums = []
971
+ columns.forEach((column, columnIndex) => {
972
+ if (columnIndex === 0) {
973
+ means.push('平均')
974
+ sums.push('求和')
975
+ } else {
976
+ let meanCell = null
977
+ let sumCell = null
978
+ this.footConfig.filed.forEach(i => {
979
+ switch (column.property) {
980
+ case i:
981
+ meanCell = parseInt(XEUtils.mean(data, column.property))
982
+ sumCell = XEUtils.sum(data, column.property)
983
+ break
984
+ }
985
+ })
986
+
987
+ means.push(meanCell)
988
+ sums.push(sumCell)
989
+ }
990
+ })
991
+ return [ means, sums ]
992
+ },
993
+ //表尾单元格合并
994
+ footerColspanMethod({ rowIndex, columnIndex }){
995
+ if(columnIndex === 0 && this.checkbox){
996
+ return {
997
+ rowspan: 1,
998
+ colspan: 2
999
+ }
1000
+ }
1001
+ if(columnIndex === 1 && this.checkbox){
1002
+ return {
1003
+ rowspan: 1,
1004
+ colspan: 0
1005
+ }
1006
+ }
1007
+ },
1008
+ //表尾单元格样式控制
1009
+ footerCellClassName ({ $rowIndex, column, columnIndex }) {
1010
+ if (columnIndex === 0) {
1011
+ if ($rowIndex === 0) {
1012
+ return 'jt-table-col-green'
1013
+ } else {
1014
+ return 'jt-table-col-red'
1015
+ }
1016
+ }
1017
+ },
1018
+ //树编辑禁用回调
1019
+ activeCellMethod({column}){
1020
+ let data = this.data.retjson.header.find(item => item.prop === column.property)
1021
+ if(data.edit.name){
1022
+ return true;
1023
+ }
1024
+ return false;
1025
+ },
1026
+ //展开行权限控制
1027
+ visibleMethod({column,row}){
1028
+ if(row.isExpand === '1'){
1029
+ return true
1030
+ }else{
1031
+ return false
1032
+ }
1033
+ },
1034
+ //展开行展开收起
1035
+ toggleMethod({ expanded,row }){
1036
+ if(expanded){
1037
+ return true
1038
+ }else{
1039
+ this.$refs[this.id].clearRowExpandLoaded(row);
1040
+ return false
1041
+ }
1042
+ },
1043
+ //扩展单元格样式
1044
+ cellStyle_m(param){
1045
+ let cssObj = {}
1046
+ if(param.row._rowcss == 'css0'){
1047
+ cssObj = {color:'#000'}
1048
+ }else if(param.row._rowcss == 'css1'){
1049
+ cssObj = {color:'#1E90FF'}
1050
+ }else if(param.row._rowcss == 'css2'){
1051
+ cssObj = {color:'#FF8C00'}
1052
+ }else if(param.row._rowcss == 'css3'){
1053
+ cssObj = {color:' #FF0000'}
1054
+ }
1055
+ if(this.cellStyle){
1056
+ return Object.assign(cssObj,this.cellStyle(param));
1057
+ }else{
1058
+ return cssObj;
1059
+ }
1060
+ },
1061
+ //滚动到底事件派发
1062
+ scroll(param){
1063
+ let {scrollTop,$event} = param;
1064
+ clearTimeout(this.timeOut);
1065
+ this.timeOut = setTimeout(()=>{
1066
+ let ch = $event.target.clientHeight;
1067
+ let sh = $event.target.scrollHeight;
1068
+ if(scrollTop + ch >= sh){
1069
+ this.$emit('scrollBottom',++this.pageIndex);
1070
+ }
1071
+ },200)
1072
+ },
1073
+ //checkbox改变事件派发
1074
+ selectChangeEvent({records}){
1075
+ this.$emit('checkbox',records);
1076
+ },
1077
+ //单选改变事件派发
1078
+ radioSelectChangeEvent({row}){
1079
+ this.$emit('radio',row);
1080
+ },
1081
+ //单元格点击事件派发,返回当前行的数据
1082
+ cellClickEvent({row , column}){
1083
+ let treePath = [];
1084
+ if(this.tableType === 'tree'){
1085
+ const result = XEUtils.findTree(this.data.DataArray,
1086
+ item=>{
1087
+ return item.pkid === row.pkid
1088
+ },
1089
+ {children: 'children'});
1090
+ if(result){
1091
+ treePath = result.nodes.map(item => item.name);
1092
+ }
1093
+ this.$emit('cellClick',row,treePath,column);
1094
+ }else{
1095
+ this.$emit('cellClick',row,column);
1096
+ }
1097
+ },
1098
+ //回车事件派发
1099
+ keyEnter({$event}){
1100
+ if($event.keyCode === 13){
1101
+ this.$emit('enter',this.getEditData());
1102
+ };
1103
+ },
1104
+ //获取编辑过的数据
1105
+ getEditData(){
1106
+ const {updateRecords} = this.$refs[this.id].getRecordset();
1107
+ return updateRecords;
1108
+ },
1109
+ //展开行说明文字显示控制
1110
+ isExpandText(row){
1111
+ if(row.isExpand === '1'){
1112
+ return true
1113
+ }else{
1114
+ return false
1115
+ }
1116
+ },
1117
+ //导出数据
1118
+ exportTableData(){
1119
+ this.$refs[this.id].openExport({ isPrint: false });
1120
+ },
1121
+ //导入数据
1122
+ importTableData(){
1123
+ this.$refs[this.id].importData()
1124
+ },
1125
+ //操作列点击事件派发
1126
+ handlerColClick(value,row,rowIndex){
1127
+ this.$emit('handlerClick',value,row,rowIndex);
1128
+ },
1129
+ //普通表格转树表(仅支持一层)
1130
+ default2tree(data,field){
1131
+ const result = []
1132
+ this.treeField = this.data.retjson.header[0].prop;
1133
+ XEUtils.each(XEUtils.groupBy(data, field), (childs, key) => {
1134
+ result.push({
1135
+ [this.treeField]: key + `( ${childs.length} )`,
1136
+ children: childs
1137
+ })
1138
+ })
1139
+ this.data.DataArray = result;
1140
+ if(this.isExpand){
1141
+ this.$nextTick(()=>{
1142
+ this.setAllTreeExpand();
1143
+ });
1144
+ }
1145
+ },
1146
+ //树展开所有节点
1147
+ setAllTreeExpand(){
1148
+ this.$refs[this.id].setAllTreeExpand(true);
1149
+ },
1150
+ //树、树表判断不是文件夹的不能有新增按钮
1151
+ isShowAddButton(p1,p2){
1152
+ if(p1){
1153
+ return true
1154
+ }else{
1155
+ if(p2 === '新增'){
1156
+ return false
1157
+ }else{
1158
+ return true
1159
+ }
1160
+ }
1161
+ },
1162
+ rowClassName({ row, rowIndex }){
1163
+ if('children' in row){
1164
+ return 'f-col'
1165
+ }
1166
+ },
1167
+ gcellClassName({row, column}){
1168
+ if('children' in row && column.title == '操作'){
1169
+ return 'h-col'
1170
+ }
1171
+ },
1172
+ //树表checkbox改变事件派发,过滤有子集的数据
1173
+ treeSelectChangeEvent({records,indeterminates}){
1174
+ const temp = records.filter(item => !item.children)
1175
+ this.$emit('treeCheckbox',temp);
1176
+ this.$emit('treeCheckboxAll',[...records,...indeterminates]);
1177
+ },
1178
+ //树 非最后一级禁用
1179
+ treeRadioMethod({row}){
1180
+ if(this.isParent){
1181
+ return true;
1182
+ }else{
1183
+ return !row.path
1184
+ }
1185
+ },
1186
+ checCheckboxkMethod2({ row }){
1187
+ if(this.isParent){
1188
+ return true
1189
+ }else{
1190
+ return row.children.length === 0
1191
+ }
1192
+ },
1193
+ //树 checkbox改变事件派发,过滤有子集的数据
1194
+ treeCheckChange({records,indeterminates}){
1195
+ const temp = records.filter(item => !item.path);
1196
+ this.$emit('treeCheckbox',temp);
1197
+ this.$emit('treeCheckboxAll',[...records,...indeterminates]);
1198
+ },
1199
+ //树表滚动分页+性能优化
1200
+ scroll1(param){
1201
+ let {scrollTop,$event} = param;
1202
+ clearTimeout(this.timeOut);
1203
+ this.timeOut = setTimeout(()=>{
1204
+ let ch = $event.target.clientHeight;
1205
+ let sh = $event.target.scrollHeight;
1206
+ let temp = scrollTop - this.sp;
1207
+ this.sp = scrollTop;
1208
+ if(temp < 0 && scrollTop <= 0){
1209
+ if(this.tPageIndex > 1){
1210
+ this.tPageIndex--;
1211
+ this.dataSliceUp(this.tPageIndex);
1212
+ this.$refs[this.id].scrollTo(null,(sh-ch) / 2);
1213
+ }
1214
+ }else if(temp >= 0 && scrollTop + ch >= sh){
1215
+ if(this.tPageIndex < this.pageTotal){
1216
+ this.tPageIndex++;
1217
+ this.dataSliceDown(this.tPageIndex);
1218
+ this.$refs[this.id].scrollTo(null,(sh-ch) / 2);
1219
+ }
1220
+ }
1221
+ },200)
1222
+ },
1223
+ dataSliceUp(idx){
1224
+ this.data.DataArray = this.dataTreeObj[idx-1].concat(this.dataTreeObj[idx]);
1225
+ },
1226
+ dataSliceDown(idx){
1227
+ this.data.DataArray = this.dataTreeObj[idx].concat(this.dataTreeObj[idx+1]);
1228
+ },
1229
+ //树 懒加载方法
1230
+ async loadChildrenMethod({ row }){
1231
+ const { data } = await this.$axios.post(this.treeTypeConfig.path + row.path);
1232
+ return new Promise((resolve) => {
1233
+ if(data[0].Result>0){
1234
+ resolve(data[0].DataArray)
1235
+ }else{
1236
+ const tempObj = {};
1237
+ data[0].retjson.header.forEach((item,index)=>{
1238
+ if(index === 0){
1239
+ tempObj[item.prop] = '无数据'
1240
+ }else{
1241
+ tempObj[item.prop] = ''
1242
+ }
1243
+ })
1244
+ resolve([tempObj]);
1245
+ }
1246
+ })
1247
+ },
1248
+ //表格组件实例
1249
+ jtTable(){
1250
+ return this.$refs[this.id];
1251
+ },
1252
+ //树更新字节点,懒加载
1253
+ reloadTreeChilds(row){
1254
+ this.$refs[this.id].reloadTreeChilds(row);
1255
+ },
1256
+ //重载行数据
1257
+ reloadRow(row){
1258
+ this.$refs[this.id].reloadRow(row);
1259
+ },
1260
+ //树点击图标和文字事件
1261
+ treeTxtClick(row){
1262
+ let treePath = [];
1263
+ const result = XEUtils.findTree(this.data.DataArray,
1264
+ item=>{
1265
+ return item.pkid === row.pkid
1266
+ },
1267
+ {children: 'children'});
1268
+ if(result){
1269
+ treePath = result.nodes.map(item => item.name);
1270
+ }
1271
+ this.$emit('treeTxtClick',row,treePath);
1272
+ },
1273
+ //初始化隐藏列
1274
+ hideColumn(arr){
1275
+ this.$nextTick(()=>{
1276
+ arr.forEach(item=>{
1277
+ let col = this.$refs[this.id].getColumnByField(item);
1278
+ this.$refs[this.id].hideColumn(col);
1279
+ })
1280
+ })
1281
+ },
1282
+ //树判断行是否展开
1283
+ isTreeExpandByRow(row){
1284
+ return this.$refs[this.id].isTreeExpandByRow(row);
1285
+ },
1286
+ //树清空所有节点
1287
+ clearTreeExpand(){
1288
+ this.$refs[this.id].clearTreeExpand();
1289
+ },
1290
+ //设置表格选中
1291
+ setCheckboxRow(ary,status=true){
1292
+ this.$refs[this.id].setCheckboxRow(ary,status);
1293
+ },
1294
+ //清空所有选中
1295
+ clearCheckboxRow(){
1296
+ this.$refs[this.id].clearCheckboxRow();
1297
+ },
1298
+ //切换选中状态
1299
+ toggleCheckboxRow(row){
1300
+ this.$refs[this.id].toggleCheckboxRow(row);
1301
+ },
1302
+ //树删除数据方法
1303
+ treeDelete(id){
1304
+ let matchObj = XEUtils.findTree(this.data.DataArray, item => {
1305
+ return item.pkid === id}, {
1306
+ children: 'children'
1307
+ })
1308
+ if (matchObj) {
1309
+ let { items, index } = matchObj
1310
+ items.splice(index, 1);
1311
+ }
1312
+ this.$refs[this.id].syncData();
1313
+ },
1314
+ //获取树的信息
1315
+ getTreeData(id){
1316
+ let matchObj = XEUtils.findTree(this.data.DataArray, item => {
1317
+ return item.pkid == id}, {
1318
+ children: 'children'
1319
+ })
1320
+ if(matchObj){
1321
+ return {key:'ok',data:matchObj.item};
1322
+ }else{
1323
+ return {key:'notFind'};
1324
+ }
1325
+ },
1326
+ //树添加数据方法
1327
+ treeAdd(id,obj){
1328
+ let xTree = this.$refs[this.id];
1329
+ xTree.createRow(obj).then(newRow => {
1330
+ let matchObj = XEUtils.findTree(this.data.DataArray, item => {
1331
+ return item.pkid === id}, {
1332
+ children: 'children'
1333
+ })
1334
+ if (matchObj) {
1335
+ matchObj.item.children.splice(matchObj.index, 0, newRow);
1336
+ xTree.syncData()
1337
+ }
1338
+ })
1339
+ },
1340
+ syncData(){
1341
+ this.$refs[this.id].syncData();
1342
+ },
1343
+ }
1344
+ }
1345
+ </script>
1346
+
1347
+ <style>
1348
+ .vxe-table{
1349
+ font-size: 12px;
1350
+ }
1351
+ .jt-iconOpen{
1352
+ position: relative;
1353
+ bottom:4px;
1354
+ right:2px;
1355
+ }
1356
+ .jt-iconClose{
1357
+ position: relative;
1358
+ bottom:4px;
1359
+ right:2px;
1360
+ }
1361
+ .jt-iconOpen1{
1362
+ color:rgb(238, 197, 85) !important;
1363
+ position: relative;
1364
+ bottom:7px;
1365
+ right:5px;
1366
+ }
1367
+ .jt-iconClose1{
1368
+ color:rgb(238, 197, 85) !important;
1369
+ position: relative;
1370
+ bottom:7px;
1371
+ right:5px;
1372
+ }
1373
+ .jt-iconOpen2{
1374
+ color:rgb(238, 197, 85) !important;
1375
+ margin:0 3px;
1376
+ display: inline-block;
1377
+ }
1378
+ .jt-iconClose2{
1379
+ color:rgb(238, 197, 85) !important;
1380
+ margin:0 3px;
1381
+ display: inline-block;
1382
+ }
1383
+ .jt-iconFile{
1384
+ color:rgb(195, 189, 201) !important;
1385
+ position: relative;
1386
+ font-size: 18px;
1387
+ top:1px;
1388
+ margin-left:5px;
1389
+ margin-right:2px;
1390
+ display: inline-block;
1391
+ }
1392
+ .jt-table-col-green{
1393
+ background-color: rgb(125, 240, 177);
1394
+ }
1395
+ .jt-table-col-red{
1396
+ background-color: rgb(240, 125, 125);
1397
+ }
1398
+ .ht-icon{
1399
+ position:relative;
1400
+ right:2px;
1401
+ top:1px;
1402
+ }
1403
+ .jt-table-class-only .el-button:hover span,
1404
+ .jt-table-class-only .el-button:hover i{
1405
+ color:rgb(55, 66, 214) !important;
1406
+ }
1407
+ .jt-table-class-only .vxe-cell--tree-node{
1408
+ cursor: pointer;
1409
+ }
1410
+ .jt-toolbar{
1411
+ position:absolute !important;
1412
+ top:-12px;
1413
+ right:-6px;
1414
+ z-index:9;
1415
+ background:transparent !important;
1416
+ }
1417
+ .jt-toolbar .vxe-custom--wrapper .vxe-button.is--circle,
1418
+ .jt-toolbar .is--active .vxe-button.is--circle{
1419
+ border-radius: 0 !important;
1420
+ border:none !important;
1421
+ background:transparent !important;
1422
+ }
1423
+ .jt-toolbar .vxe-button.type--button:not(.is--disabled):focus{
1424
+ box-shadow: none;
1425
+ border-color:#dcdfe6;
1426
+ background: transparent;
1427
+ }
1428
+ .jt-toolbar .colStyle{
1429
+ font-size: 24px;
1430
+ position: relative;
1431
+ top:0px;
1432
+ color:rgb(64, 111, 212);
1433
+ opacity: .4;
1434
+ }
1435
+ .jt-toolbar .colStyle:hover{
1436
+ color:rgb(125, 143, 224)
1437
+ }
1438
+ .isWrap .vxe-header--row .vxe-cell{
1439
+ flex-wrap: wrap;
1440
+ }
1441
+ </style>