list.vue
6.21 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
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
<template>
<div class="tablePage">
<!-- 筛选参数 -->
<el-header>
<el-form :inline="true" style="display:flex">
<el-form-item style="flex-grow: 1"></el-form-item>
<el-form-item>
<el-button @click="handleShowEdit(null)" type="primary" icon="el-icon-plus">新建</el-button>
</el-form-item>
</el-form>
</el-header>
<!-- 表格 -->
<el-container>
<el-table :data="list" :loading="loading">
<el-table-column label="关键词" prop="keyword"></el-table-column>
<el-table-column label="状态">
<template slot-scope="scope">
<el-tag
v-if="scope.row.onlineStatus==1"
type="success"
class="pointer"
:class="{'not-allowed' : scope.row.sysList}"
@click="scope.row.sysList ? '' : handleChangeStatue(scope.row, 0)"
>在线</el-tag>
<el-tag
v-else
type="info"
class="pointer"
:class="{'not-allowed' : scope.row.sysList}"
@click="scope.row.sysList ? '' : handleChangeStatue(scope.row, 1)"
>下线</el-tag>
</template>
</el-table-column>
<el-table-column label="排序" prop="orderId"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="text" @click="handleShowEdit(scope.row)">编辑</el-button>
<el-button
type="text"
@click="handleDelete(scope.row)"
:disabled="scope.row.sysList ? true : false"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</el-container>
<!-- 分页 -->
<el-footer class="fixed-bottom">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:current-page="queryForm.page"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:page-sizes="[10,20,30,50]"
:page-size="queryForm.size"
:total="total"
></el-pagination>
</el-footer>
</div>
</template>
<script>
// 列表路径
const listUrl = app.api.getArticleKeywordList;
// 提交路径
const postUrl = app.api.setArticleKeywordList;
// 唯一标识
const primaryCodeName = "primaryCode";
export default {
components: {},
data() {
return {
postUrl,
queryForm: {
page: 1,
size: 10
}, //列表默认传参
list: [], //列表数据
total: 0, //列表总数
loading: true, //表格加载状态
classifyCode: "",
relationsArticleCodes: [],
isShowRelations: false,
articlesList: [],
transferProps: {
key: "memberCode",
label: "name"
}
};
},
created() {
this.initData();
},
methods: {
// 初始化数据
initData(resize) {
if (resize && resize != undefined) {
this.queryForm.page = 1;
}
this.getList();
},
// 获取列表
getList() {
this.loading = true;
app
.get({
url: listUrl,
data: this.queryForm
})
.then(res => {
this.loading = false;
this.list = res.list;
this.total = res.total;
})
.catch(err => {
this.loading = false;
});
},
// 切换页码大小
handleSizeChange(val) {
this.queryForm.size = val;
this.queryForm.page = 1;
this.initData();
},
// 切换页码
handleCurrentChange(val) {
this.queryForm.page = val;
this.initData();
},
handleShowEdit(pojo) {
this.$router.push({
name: "keywordDetail",
query: {
pojo: JSON.stringify(pojo)
}
});
},
handleShowRelation(classifyCode) {
this.relationsArticleCodes = [];
this.classifyCode = classifyCode;
this.getArticleRelativeArticles(classifyCode);
},
handleDelete(pojo) {
this.$confirm("删除后,不可恢复 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
let data = {};
data[primaryCodeName] = pojo[primaryCodeName];
this.loading = true;
app
.delete({
url: postUrl,
data
})
.then(res => {
this.getList();
this.$notify({
title: "成功",
message: "删除成功",
type: "success"
});
});
})
.catch(() => {
this.loading = true;
});
},
handleChangeStatue(row, status) {
let msg = status == 1 ? "是否上线当前分类?" : "是否下线当前分类?";
let data = JSON.parse(JSON.stringify(row));
data.onlineStatus = status;
this.$confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.loading = true;
app.post({ url: postUrl, data }).then(res => {
this.getList();
this.$notify({
title: "成功",
message: "操作成功",
type: "success"
});
});
})
.catch(() => {
this.loading = true;
});
},
handleChangeShow(row, status) {
let msg = status == 1 ? "是否显示当前分类?" : "是否隐藏当前分类?";
let data = JSON.parse(JSON.stringify(row));
data.onShow = status;
this.$confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.loading = true;
app.post({ url: postUrl, data }).then(res => {
this.getList();
this.$notify({
title: "成功",
message: "操作成功",
type: "success"
});
});
})
.catch(() => {
this.loading = true;
});
}
}
};
</script>
<style scoped>
.transfer {
margin: 0 auto;
}
.not-allowed {
cursor: not-allowed;
}
</style>