<template>
|
<div class="page_activity">
|
<v-header
|
title="活动管理"
|
search
|
:bar="bar"
|
@on-search="onSearch"
|
></v-header>
|
<div class="add">
|
<el-button
|
type="primary"
|
size="small"
|
@click.stop="$router.push('/jh_activity_add')"
|
>新增</el-button
|
>
|
</div>
|
<div class="tab">
|
<v-tool-table :trs="trs" :tds="tds">
|
<template v-slot:btn="item">
|
<div class="table_flex">
|
<!-- {{item.scope.id}} -->
|
|
<span
|
class="col_primary"
|
v-for="(i, j) in is_level(+item.scope.activityType)"
|
:key="j + '-btn'"
|
@click="onEvent(i, item.scope)"
|
>{{ i.t }}</span
|
>
|
</div>
|
</template>
|
<template v-slot:activityType="item">
|
<b>{{ isactivityType(+item.scope.activityType - 1) }}</b>
|
</template>
|
<template v-slot:time="item">
|
<b
|
>{{ item.scope.activityStartTime }}~{{
|
item.scope.activityEndTime
|
}}</b
|
>
|
</template>
|
<template v-slot:rewardWay="{ scope }">
|
<b>{{ scope.rewardWay == 1 ? "按次奖励" : "" }}</b>
|
</template>
|
<template v-slot:times="item">
|
<b>{{ item.scope.applyStartTime }}~{{ item.scope.applyEndTime }}</b>
|
</template>
|
<template v-slot:num="item">
|
<b
|
>{{ item.scope.number }}/{{
|
item.scope.peopleNumber < 0 ? "无限" : item.scope.peopleNumber
|
}}</b
|
>
|
</template>
|
</v-tool-table>
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
</div>
|
<!-- 二维码 -->
|
</div>
|
</template>
|
|
<script>
|
import { mapState } from "vuex";
|
export default {
|
props: {},
|
components: {},
|
data() {
|
return {
|
dialogVisible: false,
|
bar: [
|
{ title: "活动名称", name: "title" },
|
{ title: "状态", name: "activityType", type: "select", list: [] },
|
{ title: "活动时间", name: "time", type: "times" }
|
],
|
trs: [
|
{ text: "序号", val: "index", width: "50px" },
|
{ text: "活动名称", val: "title" },
|
{ text: "活动地点", val: "address" },
|
{ text: "参与人数", val: "btn", slot: "num", width: "90px" },
|
{ text: "奖励金汇币", val: "award" },
|
// { text: "志愿者人数", val: "btn", slot: "num2", width: "90px" },
|
{ text: "活动状态", val: "btn", slot: "activityType" },
|
{ text: "发布时间", val: "creationTime" },
|
{ text: "活动时间", val: "btn", slot: "time" },
|
{ text: "报名时间", val: "btn", slot: "times" },
|
{ text: "操作", val: "btn" }
|
],
|
tds: [],
|
paged: { page: 0, total: 0, r: 0, limit: 10 },
|
os: {},
|
search: {},
|
item_id: "",
|
row_data: {},
|
codeImg: "",
|
actObj: {}
|
};
|
},
|
computed: {
|
...mapState({ vuex_page: "pageReset" })
|
},
|
watch: {
|
vuex_page: {
|
handler(n) {
|
if (n.page === this.$route.path) {
|
this.paged.page = 1;
|
this.init();
|
}
|
},
|
deep: true
|
}
|
},
|
methods: {
|
handleCommand2(data) {
|
this.item_id = data.id;
|
this.row_data = data;
|
},
|
handleCommand(val, item) {
|
switch (val) {
|
case "sign": {
|
this.$router.push(this.$nav.url("/checkRecord/" + this.item_id));
|
break;
|
}
|
case "comment": {
|
this.$router.push(this.$nav.url("/evaluateRecord/" + this.item_id));
|
break;
|
}
|
case "up": {
|
this.$router.push(this.$nav.url("/act_act_list/" + this.item_id));
|
break;
|
}
|
case "close": {
|
console.log(item);
|
this.$store.dispatch("setFixed", {
|
event: "add",
|
data: {
|
type: "act-cancel",
|
data: {
|
id: this.item_id,
|
name: this.row_data.title,
|
people: this.row_data.contactName
|
}
|
},
|
time: Date.now()
|
});
|
break;
|
}
|
default: {
|
break;
|
}
|
}
|
},
|
// 按钮权限
|
is_level(id) {
|
/**
|
状态:待发布、未开始、报名中、进行中、已结束、已取消
|
①待发布:存草稿的状态;可发布、查看、编辑、删除
|
②未开始:未到报名时间;可查看、编辑、删除
|
④进行中:包括报名到活动结束之前的时间;可报名名单、查看、取消
|
⑤已结束:已到活动结束时间;可报名名单、查看
|
⑥已取消:到活动开始时,未达到需报名人数则自动取消
|
*/
|
let v = [
|
{ t: "体验反馈", v: "feedback", by: [1, 2, 3, 4, 5, 6] },
|
{ t: "查看", v: "sel", by: [1, 2, 3, 4, 5, 6] }
|
// { t: "编辑", v: "upd", by: [1, 2, 6] },
|
// { t: "删除", v: "del", by: [1, 2, 6] }
|
// { t: "取消", v: "close", by: [3, 4] },
|
];
|
let o = v.filter(k => {
|
return k.by.indexOf(+id) >= 0;
|
});
|
return demo.copy(o);
|
},
|
// 点击操作按钮
|
onEvent(i, item) {
|
let t = this;
|
// console.log(item);
|
switch (i.v) {
|
case "feedback": // 报名名单
|
this.$router.push(this.$nav.url("/jh_activity_feedback/" + item.id));
|
break;
|
case "add": // 发布
|
this.$api.post(
|
"communityactivity/releaseactivity",
|
{ id: item.id },
|
() => {
|
demo.toast("发布成功");
|
t.init();
|
}
|
);
|
break;
|
case "sel": // 查看
|
this.$router.push(this.$nav.url("/jh_activity_detail/" + item.id));
|
break;
|
case "upd": // 编辑
|
this.$router.push(this.$nav.url("/jh_activity_edit/" + item.id));
|
break;
|
case "del": // 删除
|
this.$js.model("删除", "是否删除[" + item.title + "]", res => {
|
if (res) {
|
this.$api.del(
|
"Jinhui/experienceExpurgateData",
|
{ id: item.id },
|
() => {
|
demo.toast("删除成功");
|
t.init();
|
}
|
);
|
}
|
});
|
break;
|
case "close": // 取消 cancelReason id
|
this.$store.dispatch("setFixed", {
|
event: "add",
|
data: {
|
type: "act-cancel",
|
data: {
|
id: item.id,
|
name: item.title,
|
people: item.contactName
|
}
|
},
|
time: Date.now()
|
});
|
break;
|
default:
|
}
|
},
|
// 状态
|
isactivityType(v) {
|
return (
|
["未开始", "报名中", "进行中", "已结束", "已取消"][v] || ""
|
// 1待开始 2报名中 3已开始 4已结束 5已取消
|
);
|
},
|
onSearch(v) {
|
if (v.time && v.time.length && v.time[1]) {
|
v.activityStartTime = v.time[0];
|
v.activityEndTime = v.time[1];
|
} else {
|
v.activityStartTime = "";
|
v.activityEndTime = "";
|
}
|
this.search = demo.copy(v);
|
delete this.search.time;
|
this.paged.page = 1;
|
this.init();
|
},
|
// 分页点击
|
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();
|
},
|
handleClose() {
|
this.dialogVisible = false;
|
},
|
|
// 保存图片
|
saveImgHandle() {
|
let a = document.createElement("a");
|
a.href = this.codeImg;
|
a.setAttribute("download", "chart-download");
|
a.click();
|
},
|
// 获取数据
|
init() {
|
let v = demo.copy(
|
Object.assign(this.os, this.search, {
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit
|
})
|
);
|
this.$api.get("Jinhui/experienceGetList", v, e => {
|
this.paged.total = e.total;
|
this.paged.r++;
|
this.tds = e.records || [];
|
e.records.map((item, index) => {
|
item.index = (this.paged.page - 1) * this.paged.limit + index + 1;
|
item.activityStartTime = this.$$moment(item.activityStartTime).format(
|
"YYYY-MM-DD HH:MM:SS"
|
);
|
item.activityEndTime = this.$$moment(item.activityEndTime).format(
|
"YYYY-MM-DD HH:MM:SS"
|
);
|
item.applyStartTime = this.$$moment(item.applyStartTime).format(
|
"YYYY-MM-DD HH:MM:SS"
|
);
|
item.applyEndTime = this.$$moment(item.applyEndTime).format(
|
"YYYY-MM-DD HH:MM:SS"
|
);
|
});
|
});
|
}
|
},
|
mounted() {
|
this.bar[1].list = this.$api.static.party_activityType();
|
}
|
};
|
</script>
|
<style lang="less" scoped>
|
.page_activity {
|
overflow-y: auto;
|
.tab,
|
.add {
|
margin-bottom: 10px;
|
}
|
.code-img {
|
width: 200px;
|
height: 200px;
|
border: 1px red solid;
|
margin: auto;
|
overflow: hidden;
|
img {
|
width: 100%;
|
}
|
}
|
.text-f {
|
font-size: 13px;
|
padding-top: 15px;
|
line-height: 20px;
|
}
|
}
|
</style>
|