FlowRangeDialog.vue
2.87 KB
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
<template>
<el-dialog
title="已选择流程"
:visible.sync="dialogVisible"
append-to-body
:close-on-click-modal="false"
width="900px"
>
<el-table :data="filterTableData" border stripe style="width: 100%" height="570px">
<el-table-column label="序号" type="index" width="60"></el-table-column>
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="defKey" label="流程key">
</el-table-column>
<el-table-column prop="typeName" label="流程分类"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="text" @click="deleteRow(scope.row.defKey)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div style="margin-top:15px;text-align:right;">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pageBean.page"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageBean.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="pageBean.total"
>
</el-pagination>
</div>
<div slot="footer" style="margin-top:20px;text-align: right;">
<el-button @click="onCancel()">取 消</el-button>
<el-button type="primary" @click="onConfirm()">确定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'FlowRangeDialog',
props: {},
data() {
return {
dialogVisible: false,
tableData: [],
pageBean: {
page: 1,
pageSize: 10,
total: 0
}
}
},
computed: {
filterTableData() {
if (this.pageBean.total === 0) {
return []
}
return this.tableData.filter((item, i) => {
let index = i + 1
return (
index <= this.pageBean.page * this.pageBean.pageSize &&
index > (this.pageBean.page - 1) * this.pageBean.pageSize
)
})
}
},
methods: {
deleteRow(defKey) {
let index = this.tableData.findIndex(item=>{
return item.defKey === defKey
})
if (index > -1) {
this.tableData.splice(index, 1)
this.pageBean.total = this.tableData.length
}
},
handleSizeChange(pageSize) {
this.pageBean.page = 1
this.pageBean.pageSize = pageSize
},
handleCurrentChange(page) {
this.pageBean.page = page
},
showDialog(data) {
this.tableData = JSON.parse(JSON.stringify(data))
this.pageBean.page = 1
this.pageBean.pageSize = 10
this.pageBean.total = this.tableData.length || 0
this.dialogVisible = true
},
onConfirm() {
this.$emit('confirmSelect', this.tableData)
this.dialogVisible = false
},
onCancel() {
this.dialogVisible = false
}
}
}
</script>
<style lang="scss" scoped></style>