index.vue
5.37 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
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
<template>
<div class="classification-page">
<div class="toolbar">
<el-button type="success" @click="addCustom">添加页面</el-button>
</div>
<el-table
:data="tableData"
style="width: 100%"
border
row-key="id"
:header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
:tree-props="{ children: 'childs' }"
>
<el-table-column prop="name" label="页面名称" />
<el-table-column prop="updateTime" label="更新时间" />
<el-table-column prop="status" label="操作">
<template slot-scope="scope">
<el-button type="text" @click.native.prevent="fitupRow(scope.row)">装修</el-button>
<el-button type="text" @click.native.prevent="checkRow(scope.row)">查看</el-button>
<el-button type="text" @click.native.prevent="updateRow(scope.row)">编辑</el-button>
<el-button type="text" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="fenye">
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="10"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
<el-dialog :title="dialog.type === 'add'?'添加页面':'编辑页面'" :visible.sync="dialog.isVisible" width="30%">
<el-form :model="form">
<el-form-item label="页面名称">
<el-input v-model="form.name" autocomplete="off" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialog.isVisible = false">取 消</el-button>
<el-button type="primary" @click="submitForm">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
selectCanvasCustomList,
saveCanvasCustom,
delCanvasCustom
} from '@/api/renovation'
export default {
data() {
return {
formParams: {
page: 1,
pageSize: 10,
type: 2
},
form: {
name: '',
type: 2
},
total: 1,
tableData: [],
currentPage: 1,
dialog: {
type: 'add',
isVisible: false
}
}
},
created() {
this.getCanvasList()
this.getAll(this.formParams)
},
methods: {
handleSizeChange(val) {
this.formParams.pageSize = val
this.getAll(this.formParams)
},
handleCurrentChange(val) {
this.formParams.page = val
this.getAll(this.formParams)
},
fetch(config) {
const { limit, page } = config
this.formParams.pageIndex = page || 1
this.formParams.pageSize = limit || 10
this.getCanvasList()
},
// 新增自定义页面
addCustom() {
this.dialog.isVisible = true
this.form.name = ''
delete this.form.id
this.dialog = {
type: 'add',
isVisible: true
}
},
// 窗口确定
submitForm() {
if (!this.form.name) {
this.$message.error('页面名称不能为空!')
return
}
if (this.dialog.type === 'add') {
saveCanvasCustom(this.form).then((res) => {
if (res && res.data) {
this.$message({
message: '新增成功',
type: 'success'
})
}
this.dialog.isVisible = false
this.getCanvasList()
}, (error) => {
console.log(error)
})
} else if (this.dialog.type === 'edit') {
saveCanvasCustom(this.form).then((res) => {
if (res && res.data) {
this.$message({
message: '编辑成功',
type: 'success'
})
}
this.dialog.isVisible = false
this.getCanvasList()
}, (error) => {
console.log(error)
})
}
},
// 编辑
updateRow(row) {
this.form.id = row.id
this.form.name = row.name
this.dialog = {
type: 'edit',
isVisible: true
}
},
// 查看
checkRow(row) {
const id = row.classifyId
this.dialog = {
type: 'check',
isVisible: true
}
this.$refs.edit.setParams({
id
})
},
// 装修
fitupRow() {
},
// 删除
async deleteRow(row) {
this.$confirm('此操作将永久删除该自定义页面, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
delCanvasCustom({ id: row.id }).then(res => {
if (res.code === '') {
this.$message({
type: 'success',
message: '删除成功!'
})
}
this.getCanvasList()
})
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
async getCanvasList() {
this.getAll(this.formParams)
},
async getAll(formParams) {
const res = await selectCanvasCustomList(formParams)
this.tableData = res.data.list
this.total = res.data.total
}
}
}
</script>
<style lang="scss" scoped>
.classification-page {
padding: 15px 20px;
.toolbar {
margin-bottom: 15px;
text-align: right;
}
}
</style>