Tab.vue
3.26 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
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
<script>
import * as api from '@/api/drainageCode/welcome'
export default {
name: 'Tab',
components: {},
props: {
type: {
type: Number | String,
default: '1',
},
},
data() {
return {
// 查询参数
query: {
pageNum: 1,
pageSize: 10,
welcomeMsg: undefined,
welcomeMsgTplType: 1,
},
loading: false,
total: 0,
list: [],
wel: {
1: '活码',
2: '员工',
3: '入群',
},
}
},
watch: {},
computed: {},
created() {
this.query.welcomeMsgTplType = +this.type
this.getList()
},
mounted() {},
methods: {
/** 查询 */
getList(page) {
page && (this.query.pageNum = page)
this.loading = true
api
.getList(this.query)
.then(({ rows, total }) => {
this.list = rows
this.total = +total
this.loading = false
this.$emit('total', [this.type, this.total])
})
.catch(() => {
this.loading = false
})
},
/** 删除按钮操作 */
remove(id) {
// const operIds = id || this.ids + "";
this.$confirm('是否确认删除吗?', '警告', {
type: 'warning',
})
.then(function() {
return api.remove(id)
})
.then(() => {
this.getList()
this.msgSuccess('删除成功')
})
},
goRoute(data) {
let query = {}
if (data) {
let { id, welcomeMsgTplType, welcomeMsg, materialUrl } = data
query = { id, welcomeMsgTplType, welcomeMsg, materialUrl }
} else {
query.welcomeMsgTplType = this.type
}
this.$router.push({ path: 'welcomeAdd', query: query })
},
},
}
</script>
<template>
<div>
<div class="mid-action">
<div></div>
<div>
<el-button
v-hasPermi="['wecom:tlp:add']"
type="primary"
size="mini"
@click="goRoute()"
>新建{{ wel[type] }}欢迎语</el-button
>
<el-input
placeholder="请输入内容"
prefix-icon="el-icon-search"
v-model="query.welcomeMsg"
style="width: 240px; margin-left: 10px;"
@change="getList(0)"
></el-input>
</div>
</div>
<el-table v-loading="loading" :data="list">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="欢迎语" align="center" prop="welcomeMsg" />
<el-table-column label="创建人" align="center" prop="createBy" />
<el-table-column label="创建时间" align="center" prop="createTime" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="goRoute(scope.row)"
v-hasPermi="['wecom:tlp:edit']"
>编辑</el-button
>
<el-button
size="mini"
type="text"
@click="remove(scope.row.id)"
v-hasPermi="['wecom:tlp:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</div>
</template>
<style lang="scss" scoped></style>