<template>
|
<div class="">
|
<div class="but">
|
<el-button v-if="newVal.status===3||newVal.status===4" @click="add()" size="small" type="primary">新增宣传</el-button>
|
<el-button @click="Change = !Change" size="small">批量操作</el-button>
|
</div>
|
<div class="Tips" v-show="Change">
|
<i style="color: #409eff" class="el-icon-info"></i>
|
<div class="Tips-cont">
|
已选择<span>{{ ids.length }}</span
|
>项
|
</div>
|
<el-button type="text" @click="clearAll()">批量删除</el-button>
|
<el-button type="text" @click="cancel">取消</el-button>
|
</div>
|
<div class="tab">
|
<v-tool-table :trs="trs" :tds="tds" first firstWidth="50px">
|
<template v-slot:first-th>
|
<div>
|
<el-checkbox @change="cheAll" v-model="alls"></el-checkbox>
|
</div>
|
</template>
|
<template v-slot:first-td="item">
|
<div>
|
<el-checkbox
|
@change="change"
|
v-model="item.scope.che"
|
></el-checkbox>
|
</div>
|
</template>
|
<template v-slot:time="item">
|
<b>{{ reTime(item.scope.createTime) }}</b>
|
</template>
|
<template v-slot:type="item">
|
<span>{{ item.scope.item }}</span>
|
</template>
|
<template v-slot:status="item">
|
<span>{{ item.scope.item }}</span>
|
</template>
|
<template v-slot:btn="{ scope }">
|
<el-button @click="clickHandle('edit', scope)" type="text"
|
>编辑</el-button
|
>
|
<el-button
|
v-if="scope.isTop == 1"
|
@click="clickHandle('close', scope)"
|
type="text"
|
>取消置顶</el-button
|
>
|
<el-button v-else @click="clickHandle('top', scope)" type="text"
|
>置顶</el-button
|
>
|
<el-button @click="clear(scope.id)" type="text">删除</el-button>
|
</template>
|
</v-tool-table>
|
</div>
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
</div>
|
</template>
|
|
<script>
|
import { dateTime } from "../../../../utils/common";
|
export default {
|
props: {
|
item: { type: Object },
|
level: { type: Number },
|
},
|
data() {
|
return {
|
trs: [
|
{ text: "序号", val: "index", width: "50px" },
|
{ text: "宣传标题", val: "title" },
|
{ text: "项目名称", val: "name" },
|
{ text: "责任方", val: "responsibility", slot: "type" },
|
{ text: "发布时间", val: "btn", slot: "time" },
|
{ text: "操作", val: "btn", slot: "btn" },
|
],
|
tds: [],
|
paged: { page: 0, total: 0, r: 0, limit: 10 },
|
Change: false,
|
ids: [],
|
alls: false,
|
newVal: {},
|
};
|
},
|
watch: {
|
item(val) {
|
this.newVal = val;
|
this.init();
|
},
|
},
|
methods: {
|
reTime(t) {
|
return dateTime(t);
|
},
|
// 分页点击
|
onPage(v) {
|
if (v.page === this.paged.page && v.page && !v.reset) {
|
return 0;
|
}
|
this.paged.page = v.page;
|
this.paged.limit = v.limit;
|
this.init();
|
},
|
add() {
|
this.$router.push(`/addPropagate?id=${this.item.id}`);
|
},
|
|
// 页面操作
|
clickHandle(type, row) {
|
switch (type) {
|
case "edit": {
|
this.$router.push(
|
`/addPropagate?level=${this.level + 1}&id=${row.id}&isedit=1`
|
);
|
break;
|
}
|
case "top": {
|
this.$api.post(
|
"/comActSocialProjectPublicity/update",
|
{ id: row.id, isTop: 1 },
|
(e) => {
|
demo.toast("置顶成功");
|
this.init();
|
}
|
);
|
break;
|
}
|
case "close": {
|
this.$api.post(
|
"/comActSocialProjectPublicity/update",
|
{ id: row.id, isTop: 0 },
|
(e) => {
|
demo.toast("取消成功");
|
this.init();
|
}
|
);
|
break;
|
}
|
default: {
|
break;
|
}
|
}
|
},
|
|
// 获取数据
|
init() {
|
let v = {
|
page: this.paged.page,
|
size: this.paged.limit,
|
paramId: this.newVal.id,
|
level: this.newVal.level + 1, //创建子项目的等级
|
};
|
this.$api.post("comActSocialProjectPublicity/queryAll", v, (e) => {
|
e.records.map((item, index) => {
|
item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
|
});
|
this.paged.total = e.total;
|
this.tds = e.records || [];
|
|
});
|
},
|
|
cancel() {
|
//取消
|
this.Change = false;
|
this.alls = false;
|
this.ids = [];
|
this.tds.map((item) => {
|
item.che = false;
|
});
|
},
|
cheAll() {
|
//全选
|
this.tds.map((item) => {
|
item.che = this.alls;
|
});
|
this.change();
|
},
|
change() {
|
//单个选择
|
this.ids = [];
|
this.tds.map((item) => {
|
if (item.che) {
|
this.ids.push(item.id);
|
} else {
|
this.alls = false;
|
}
|
});
|
},
|
//删除
|
clear(id) {
|
//删除
|
let t = this;
|
if (id) {
|
t.$js.model("提示", "是否删除此条数据?", (res) => {
|
if (res) {
|
t.$api.get("comActSocialProjectPublicity/del", { id: id }, (e) => {
|
if (!e) {
|
demo.toast(e.msg);
|
return;
|
}
|
demo.toast("删除成功");
|
t.init();
|
});
|
}
|
});
|
}
|
},
|
|
//批量删除
|
clearAll() {
|
let t = this;
|
if (this.ids.length === 0) {
|
demo.toast("请勾选需要删除的内容");
|
return;
|
} else {
|
t.$js.model("提示", "是否删除此条数据?", (res) => {
|
if (res) {
|
t.$api.post("comActSocialProjectPublicity/delBatch", t.ids, (e) => {
|
if (!e) {
|
demo.toast(e.msg);
|
return;
|
}
|
demo.toast("删除成功");
|
t.ids = [];
|
t.init();
|
});
|
}
|
});
|
}
|
},
|
},
|
};
|
</script>
|
|
<style lang="less" scoped>
|
.tab {
|
padding-top: 20px;
|
}
|
.Tips {
|
margin: 10px 0;
|
box-sizing: border-box;
|
width: 100%;
|
display: flex;
|
align-items: center;
|
background: #e6f7ff;
|
border: #bae7ff 1px solid;
|
border-radius: 6px;
|
height: 40px;
|
padding: 0 20px;
|
}
|
.Tips-cont {
|
padding: 0 10px;
|
font-size: 16px;
|
color: #606266;
|
}
|
.Tips-cont > span {
|
padding: 0 4px;
|
color: #409eff;
|
font-weight: 600;
|
}
|
</style>
|