1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
| <template>
| <el-container>
| <el-header class="m-header" style="height: auto">
| <el-row :gutter="10" style="margin-bottom: 5px">
| <el-col :span="7">
| <el-date-picker
| v-model="datevalue"
| type="daterange"
| unlink-panels
| range-separator="到"
| start-placeholder="开始日期"
| end-placeholder="结束日期"
| :shortcuts="shortcuts"
| :size="size"
| format="YYYY/MM/DD"
| value-format="YYYY-MM-DD"
| />
| </el-col>
|
| <el-col :span="2">
| <el-button
| id="select"
| type="primary"
| :icon="Search"
| @click="autoAddRow">查询
| </el-button>
| </el-col>
| </el-row>
|
| </el-header>
| <el-main style="padding-top: 5px">
| <vxe-grid
|
| max-height="600"
| @filter-change="filterChanged"
| class="mytable-scrollbar"
| ref="xGrid"
| v-bind="PayOptions"
| @="gridEvents"
|
| >
|
| <!-- 下拉显示所有信息插槽-->
| <template #content="{ row }">
| <ul class="expand-wrapper">
| <li v-for="(item,index) in gridOptions.columns" v-show="item.field!==undefined ">
| <span style="font-weight: bold">{{item.title+': '}}</span>
| <span>{{ row[item.field] }}</span>
| </li>
| </ul>
| </template>
|
| <!--左边固定显示的插槽-->
| <template #button_slot="{ row }">
| <el-button @click="getTableRow(row,'edit')" link type="primary" size="small">编辑</el-button>
| <!-- <el-button @click="getTableRow(row,'delete')" link type="primary" size="small">删除</el-button>-->
| <!-- <el-button @click="cellClickEvent" link type="primary" size="small">详情</el-button>-->
| </template>
|
|
| <template #num1_filter="{ column, $panel }">
| <div>
| <div v-for="(option, index) in column.filters" :key="index">
| <input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
| </div>
| </div>
| </template>
| </vxe-grid>
| </el-main>
| </el-container>
| </template>
|
|
| <script setup>
| import {ref} from 'vue'
| import {Search} from "@element-plus/icons-vue";
| import 'dayjs/locale/zh-cn'
| import {VXETable} from "vxe-table";
| import {reactive} from "vue";
| import {useRouter} from 'vue-router'
| import {ElMessage, ElMessageBox} from "element-plus";
|
| const datevalue = ref('')//时间
|
| //组件接收参数
| const PayOptions = reactive({
| border: "full",//表格加边框
| keepSource: true,//保持源数据
| align: 'center',//文字居中
| stripe: true,//斑马纹
| rowConfig: {isCurrent: true, isHover: true, height: 50},//鼠标移动或选择高亮
| id: 'CustomerList',
| showFooter: true,//显示脚
| printConfig: {},
| importConfig: {},
| exportConfig: {},
| scrollY: {enabled: true},//开启虚拟滚动
| showOverflow: true,
| columnConfig: {
| resizable: true,
| useKey: true
| },
| filterConfig: { //筛选配置项
| remote: true
| },
| customConfig: {
| storage: true
| },
| editConfig: {
| trigger: 'click',
| mode: 'row',
| showStatus: true
| },
| columns: [
| /* {title: '操作', width: '8%', slots: {default: 'button_slot'}, fixed: "left"},*/
| {type: 'expand', title: '', fixed: "left", slots: {content: 'content'}, width: '5%'},//详情
| {type: 'checkbox', fixed: "left", title: '', width: '5%'},
| {type: 'seq', fixed: "left", title: ' ', width: '5%'},
| {
| field: 'cgdh',
| width: '10%',
| title: '采购单号',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {field: 'cgzt', width: '10%', title: '月份', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
| {
| field: 'gys',
| width: '10%',
| title: '供应商',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {
| field: 'wlbh',
| width: '10%',
| title: '期初金额',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {
| field: 'wlmc',
| width: '10%',
| title: '本期应付',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {
| field: 'w',
| width: '10%',
| title: '本期已付',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {
| field: 'g',
| width: '10%',
| title: '期末余额',
| filters: [{data: ''}],
| slots: {filter: 'num1_filter'},
| sortable: true
| },
| {field: 'h', width: '9%', title: '税率', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
| {field: '6', width: '10%', title: '备注', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true}
| ],//表头参数
| toolbarConfig: {
| buttons: [{type: 'text'}, {
| 'name': '应付确认',
| status: 'primary',
| 'code': 'Sure',
| }],
| import: false,
| export: true,
| print: true,
| zoom: true,
| custom: true,
| style: 'paddling-left:10px'
| },//表头按钮
| data: [{}, {}, {}, {}],//table body实际数据
| mergeFooterItems: [
| {row: 0, col: 0, rowspan: 1, colspan: 3}
| ],//合并脚
| footerMethod({columns, data}) {//页脚函数
| return [
| columns.map((column, columnIndex) => {
| if (columnIndex === 0) {
| return '合计:'
| }
| /* if (props.tableProp.footList.includes(column.field)) {
| return sumNum(data, column.field)
| }*/
| return ''
| })
| ]
| },
|
| })
|
|
| const xGrid = ref()
| const gridEvents = {
| toolbarButtonClick({code}) {
| const $grid = xGrid.value
| if ($grid) {
| switch (code) {
| //应付确认
| case 'Sure': {
| if ($grid.getCheckboxRecords().length === 0) {
| MessageShow("请选择至少一条数据!", 'warning');
| return
| } else {
| MessageConfirmShow("确认应付", '您选择了' + $grid.getCheckboxRecords().length + '条数据!,是否确认应付?')
| }
| break
| }
| }
| }
| },
| toolbarToolClick({code}) {
| const $grid = xGrid.value
| if ($grid) {
| switch (code) {
| case 'myPrint': {
| $grid.print()
| break
| }
| }
| }
| },
| }
|
|
|
| const shortcuts = [
| {
| text: '近一周',
| value: () => {
| const end = new Date()
| const start = new Date()
| start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
| return [start, end]
| },
| },
| {
| text: '近一个月',
| value: () => {
| const end = new Date()
| const start = new Date()
| start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
| return [start, end]
| },
| },
| {
| text: '近三个月',
| value: () => {
| const end = new Date()
| const start = new Date()
| start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
| return [start, end]
| },
| },
| ]
|
|
| //页面逻辑代码执行
| function logicExecute(type){
| const $grid = xGrid.value
| switch (type) {
| case '确认应付':
| //入库逻辑代码TODO
| MessageShow('操作成功!', 'success');
| break;
|
| default:
| MessageShow('未知操作!', 'error');
| break;
|
| }
| return true;
| }
|
|
| //提示信息
| //信息内容,显示方式,显示标题,类型
| const MessageShow = (content, type = 'success') => {
| ElMessage({
| message: content,
| type: type,
| showClose: true,
| })
| }
|
| //操作确认类信息:操作类型,提示内容,提示标头,提示类型
| const MessageConfirmShow = (czType, content, title = '操作确认提示', type = 'warning') => {
| ElMessageBox.confirm(
| content,
| title,
| {
| cancelButtonText: '取消',
| confirmButtonText: '确定',
| type: type,
| center: true,
| }
| )
| //点击了确定
| .then(() => {
|
| return logicExecute(czType);
|
| })
| //点击了取消
| .catch(() => {
| return false;
| })
| }
|
| //弹窗信息
| const MessageAlertShow = (content, title, type = 'info') => {
|
| ElMessageBox.alert(content, title, {
| // 禁止自动对焦
| //autofocus: false,
| confirmButtonText: 'OK',
| /*callback: (action: Action) => {
| MessageShow(`action: ${action}`,type)
| },*/
| })
| }
|
| </script>
|
|
| <style scoped>
| .el-row {
| margin-bottom: 20px;
| }
|
| .el-row:last-child {
| margin-bottom: 0;
| }
|
| .el-col {
| border-radius: 4px;
| }
|
| .m-header {
| height: 32px;
| }
| </style>
|
|