Browse Source

专题修改

master
pzy 3 years ago
parent
commit
5597e72eff
  1. 104
      src/views/article/subject/article.vue

104
src/views/article/subject/article.vue

@ -1,33 +1,38 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-card class="box-card">
<el-form <el-form
ref="queryForm" ref="queryForm"
:model="listQuery" :model="listQuery"
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<el-form-item label="专题" prop="special_id">
<el-select
v-model="listQuery.special_id"
placeholder="专题"
</el-form>
<el-row :gutter="24">
<el-col :span="3">
<el-tree
style="width: 100%"
:data="subject"
highlight-current
:props="defaultProps"
@node-click="handleNodeClick"
></el-tree>
</el-col>
<el-col :span="21">
<el-form>
<el-form-item label="文章标题" prop="title">
<el-input
v-model="article_title"
placeholder="请输入文章标题"
clearable clearable
size="small" size="small"
style="width: 160px" style="width: 160px"
>
<el-option
v-for="dict in subject"
:key="dict.special_id"
:label="dict.title"
:value="dict.special_id"
/> />
</el-select>
</el-form-item>
<el-form-item>
<el-button <el-button
style="margin-left: 5px"
class="filter-item el-button el-button--primary el-button--mini"
type="primary" type="primary"
icon="el-icon-search"
size="mini"
@click="getList"
icon="el-icon-edit"
>搜索</el-button >搜索</el-button
> >
</el-form-item> </el-form-item>
@ -38,7 +43,7 @@
type="primary" type="primary"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleCreate" @click="handleCreate"
>添加文章</el-button
>关联文章</el-button
> >
</div> </div>
<el-table <el-table
@ -86,11 +91,13 @@
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
>删除</el-button
>解绑</el-button
> >
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-col>
</el-row>
<pagination <pagination
v-show="total > 0" v-show="total > 0"
@ -116,16 +123,9 @@
label-width="70px" label-width="70px"
style style
> >
<el-form-item label="专题">
<el-select v-model="temp.special_id" placeholder="选择专题">
<el-option
v-for="(item, index) in subject"
:key="index"
:label="item.title"
:value="item.special_id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="专题"
><div>{{ special_title }}</div></el-form-item
>
<el-form-item label="关联文章"> <el-form-item label="关联文章">
<el-select <el-select
v-model="temp.article_id" v-model="temp.article_id"
@ -153,6 +153,7 @@
</div> </div>
</div> </div>
</el-drawer> </el-drawer>
</el-card>
</div> </div>
</template> </template>
@ -183,7 +184,6 @@ export default {
special_id: undefined, special_id: undefined,
}, },
subject: [], subject: [],
uploadAction: process.env.VUE_APP_BASE_API + "/files/uploadFile",
temp: { temp: {
id: undefined, id: undefined,
special_id: undefined, special_id: undefined,
@ -195,15 +195,11 @@ export default {
update: "编辑", update: "编辑",
create: "添加", create: "添加",
}, },
rules: {
// title: [
// { required: true, message: "title is required", trigger: "blur" },
// ],
},
downloadLoading: false,
defaultProps: {},
searchArticleLoading: false, searchArticleLoading: false,
articles: [], articles: [],
validation: true,
special_title: "",
article_title: "",
}; };
}, },
created() { created() {
@ -221,10 +217,26 @@ export default {
}, },
}, },
methods: { methods: {
//
handleNodeClick(data) {
this.listQuery.special_id = data.id;
this.defaultProps = data;
this.getList();
},
//
getSubjectList() { getSubjectList() {
this.listLoading = true; this.listLoading = true;
listSubject(this.listQuery).then((response) => { listSubject(this.listQuery).then((response) => {
this.subject = response.data;
response.data.forEach((i) => {
this.subject.push({
label: i.title,
id: i.special_id,
});
});
this.subject.unshift({
label: "全部",
id: "",
});
}); });
}, },
getList() { getList() {
@ -236,7 +248,7 @@ export default {
// Just to simulate the time of the request // Just to simulate the time of the request
setTimeout(() => { setTimeout(() => {
this.listLoading = false; this.listLoading = false;
}, 1.5 * 1000);
}, 600);
}); });
}, },
handleFilter() { handleFilter() {
@ -260,12 +272,19 @@ export default {
submitForm() { submitForm() {
if (this.dialogStatus == "create") { if (this.dialogStatus == "create") {
this.createData(); this.createData();
} else if (this.dialogStatus == "update") {
this.updateData();
} }
}, },
handleCreate() { handleCreate() {
if (!this.defaultProps.id) {
this.$message({
message: "请选择专题(全部除外)",
type: "warning",
});
return;
}
this.resetTemp(); this.resetTemp();
this.temp.special_id = this.defaultProps.id;
this.special_title = this.defaultProps.label;
this.dialogStatus = "create"; this.dialogStatus = "create";
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
@ -285,7 +304,7 @@ export default {
// }) // })
}, },
async handleDelete({ article_title, article_id, special_id }) { async handleDelete({ article_title, article_id, special_id }) {
let confirm = this.$confirm(
let confirm = await this.$confirm(
'是否确认删除名称为"' + article_title + '"的数据项?', '是否确认删除名称为"' + article_title + '"的数据项?',
"警告", "警告",
{ {
@ -294,7 +313,6 @@ export default {
type: "warning", type: "warning",
} }
); );
console.log(1);
let r = await delSubjectArticle({ article_id, special_id }); let r = await delSubjectArticle({ article_id, special_id });
if (r.code === 200) { if (r.code === 200) {
this.$message({ this.$message({
@ -341,6 +359,8 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-container { .app-container {
width: 100%;
padding: 20px;
.filter-container { .filter-container {
margin-left: 5px; margin-left: 5px;
margin-bottom: 6px; margin-bottom: 6px;

Loading…
Cancel
Save