You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bsdgy-front/src/pages/activity/ActivityPlan.vue

469 lines
13 KiB
Vue

<template>
5 years ago
<div>
5 years ago
<Spin v-if="saving" fix>加载中...</Spin>
<Form ref="formValidate" :model="formValidate" :label-width="80">
5 years ago
<Row :gutter="10">
<i-col span="4">
<FormItem label="开始日期" prop>
5 years ago
<Date-picker
v-model="formValidate.startDate"
:options='startDateOptions'
type="date"
5 years ago
placement="bottom-end"
placeholder="选择日期区间"
format="yyyy-MM-dd"
@on-change="startDateChange"
5 years ago
></Date-picker>
5 years ago
</FormItem>
</i-col>
<i-col span="4">
<FormItem label="结束日期" prop>
<Date-picker
v-model="formValidate.endDate"
:options='endDateOptions'
type="date"
placement="bottom-end"
placeholder="选择结束日期"
format="yyyy-MM-dd"
@on-change="endDateChange"
></Date-picker>
</FormItem>
</i-col>
<i-col span="4">
5 years ago
<FormItem label="零售公司" prop>
<Select
v-model="formValidate.organizationId"
filterable
@on-change="selectCompany"
placeholder="全部"
clearable
>
<Option
v-for="(item, index) in companyList"
:key="index"
:value="item.value"
>{{ item.label }}</Option>
5 years ago
</Select>
</FormItem>
</i-col>
<i-col span="6">
5 years ago
<FormItem label="店铺" prop>
<Select v-model="formValidate.storeId" filterable placeholder="全部" clearable>
<Option
v-for="(item, index) in shopList"
:key="index"
:value="item.value"
>{{ item.label }}</Option>
5 years ago
</Select>
</FormItem>
</i-col>
5 years ago
<i-col span="3">
<FormItem label="活动状态" prop>
5 years ago
<Select v-model="formValidate.status">
5 years ago
<Option
v-for="(item, index) in activityStatusList"
:key="index"
:value="item.value"
>{{ item.label }}</Option>
5 years ago
</Select>
</FormItem>
</i-col>
5 years ago
<i-col span="3">
<Button type="primary" @click="() => {pageNum = 1;searchTable()}">查询</Button>
5 years ago
</i-col>
</Row>
<Row style="margin-top:50px">
5 years ago
<Table
:loading="loading"
border
@on-row-dblclick="showDetail"
:columns="columns1"
:data="data"
></Table>
<Page
:total="totalSize"
:current="pageNum"
:page-size="pageSize"
show-elevator
show-total
placement="top"
@on-change="handlePage"
class-name="ks-page"
></Page>
5 years ago
</Row>
</Form>
5 years ago
<useTable
ref="useTable"
@doShow="doShow"
:show="showUse"
:isModify="true"
:schedule="activityInstance.scheduleVO"
></useTable>
<Modal v-model="isShowDetail" title="活动计划详情" width="70%" :footer-hide="true">
<planDetail v-if="isShowDetail" :detail="detail"></planDetail>
5 years ago
</Modal>
5 years ago
</div>
</template>
<script>
5 years ago
import ActivityManager from "../../services/ActivityManager/ActivityManager";
import useTable from "./useTable";
import http from "../../services/CommonHttp";
import { formatDate } from "../../utils/Common";
5 years ago
import store from "../../store";
5 years ago
import planDetail from "./PlanDetail";
5 years ago
export default {
name: "ActivityPlan",
inject: ["setMenuName"],
components: {
5 years ago
useTable,
5 years ago
planDetail
5 years ago
},
5 years ago
data() {
5 years ago
const _this = this;
5 years ago
return {
5 years ago
loading: false,
5 years ago
isShowDetail: false,
5 years ago
totalSize: 0,
pageNum: 1,
5 years ago
detail: {},
5 years ago
pageSize: 10,
5 years ago
saving: false,
5 years ago
data: [],
companyList: [],
5 years ago
customerId: null,
5 years ago
shopList: [],
5 years ago
showUse: false,
activityInstance: {},
5 years ago
formValidate: {
date: null,
organizationId: null,
storeId: null,
status: 2,
startDate:null,
endDate:null,
5 years ago
},
startDateOptions:{},
endDateOptions:{},
5 years ago
activityData: [
{
5 years ago
activityStatus: "进行中"
5 years ago
},
{
5 years ago
activityStatus: "已结束"
}
5 years ago
],
activityStatusList: [
{
label: "全部",
5 years ago
value: 0
5 years ago
},
{
label: "进行中",
5 years ago
value: 2
5 years ago
},
{
label: "未开始",
5 years ago
value: 1
5 years ago
},
{
label: "已结束",
5 years ago
value: 3
}
5 years ago
],
columns1: [
{
width: 60,
align: "center",
5 years ago
title: "序号",
5 years ago
render(h, params) {
let num = parseInt(params.index) + 1;
console.log(_this.pageSize);
if (_this.pageSize > 1) {
num += (_this.pageNum - 1) * _this.pageSize;
}
return h("span", num);
}
5 years ago
},
{
title: "活动名称",
5 years ago
key: "name"
5 years ago
},
{
title: "活动类型",
key: "scheduleVO.name",
5 years ago
render(h, params) {
return h("span", params.row["params"][0]["name"]);
}
5 years ago
},
{
5 years ago
title: "活动时间",
5 years ago
key: "beginTime",
5 years ago
width: 230,
5 years ago
render(h, params) {
5 years ago
return h("span", params.row.beginTime + " - " + params.row.endTime);
5 years ago
}
5 years ago
},
5 years ago
{
title: "零售公司",
key: "shop",
5 years ago
render(h, params) {
5 years ago
return h(
"span",
params.row.companyName +
5 years ago
"等" +
(params.row.companyCount || 0) +
"家公司"
5 years ago
);
5 years ago
}
5 years ago
},
5 years ago
{
title: "店铺",
key: "shop",
5 years ago
render(h, params) {
5 years ago
return h(
"span",
params.row.storeName +
5 years ago
"等" +
(params.row.storeCount || 0) +
"家店铺"
5 years ago
);
5 years ago
}
5 years ago
},
{
title: "添加好友数",
key: "addFriendNum",
5 years ago
render(h, params) {
5 years ago
return h("span", (params.row.friends || 0) + "人");
5 years ago
}
5 years ago
},
{
title: "参与活动客户数",
key: "joinActivityClientNum",
5 years ago
render(h, params) {
5 years ago
return h("span", (params.row.friends || 0) + "人");
5 years ago
}
5 years ago
},
{
title: "活动码",
key: "activityCode",
5 years ago
render(h, p) {
5 years ago
return h(
"Button",
5 years ago
{
props: { type: "primary", size: "small" },
5 years ago
on: { click: () => _this.navigateCode(p.row) }
5 years ago
},
5 years ago
"查看详情"
);
5 years ago
}
5 years ago
},
{
title: "活动状态",
key: "status",
5 years ago
render(h, p) {
5 years ago
const status = p.row.status;
if (status === 1) return h("span", "未开始");
if (status === 2) return h("span", "进行中");
if (status === 3) return h("span", "已结束");
if (status === 4) return h("span", "取消");
5 years ago
}
5 years ago
},
{
title: "操作",
key: "action",
width: 200,
5 years ago
render(h, p) {
let r = [
5 years ago
h(
"Button",
{
props: { type: "primary", size: "small" },
style: { marginRight: "8px" },
5 years ago
on: {
5 years ago
click: () => _this.stop(p.row)
}
5 years ago
},
5 years ago
"终止"
),
h(
"Button",
{
props: { type: "primary", size: "small" },
5 years ago
on: { click: () => _this.modify(p.row) }
},
5 years ago
"修改"
5 years ago
)
];
if (p.row.status > 2) {
delete r[0];
}
return h("div", r);
}
}
]
5 years ago
};
},
5 years ago
mounted() {
5 years ago
this.setMenuName("活动管理", "活动计划");
this.getCompanyInfo();
this.getShopInfo();
this.searchTable();
},
methods: {
5 years ago
doShow(show) {
5 years ago
this.showUse = show;
5 years ago
this.searchTable();
5 years ago
},
5 years ago
showDetail(detail) {
5 years ago
let _this = this;
5 years ago
this.getDetail(detail.id).then(res => {
5 years ago
_this.detail = res;
_this.isShowDetail = true;
5 years ago
});
5 years ago
},
5 years ago
getCompanyInfo() {
5 years ago
let that = this;
let data = {
5 years ago
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId
5 years ago
};
5 years ago
ActivityManager.getCompany(data, function(data) {
5 years ago
that.companyList = [];
5 years ago
data.data.results.forEach(element => {
5 years ago
that.companyList.push({
label: element.name,
5 years ago
value: element.id
5 years ago
});
});
});
},
5 years ago
selectCompany(value) {
5 years ago
this.customerId = value;
this.getShopInfo();
},
5 years ago
getShopInfo() {
5 years ago
let that = this;
let data = {
userId: JSON.parse(sessionStorage.getItem("loginInfo")).userId,
5 years ago
customerIds: this.customerId,
5 years ago
scheduleId: null
5 years ago
};
5 years ago
ActivityManager.getShop(data, function(data) {
5 years ago
that.shopList = [];
5 years ago
data.data.results.forEach(element => {
5 years ago
that.shopList.push({
label: element.name,
5 years ago
value: element.id
5 years ago
});
});
});
},
5 years ago
handlePage: function(value) {
5 years ago
this.pageNum = value;
this.searchTable();
},
5 years ago
stop(instance) {
5 years ago
let _this = this;
5 years ago
this.$Modal.confirm({
5 years ago
title: "您确认要终止?",
content: "终止之后不可恢复",
5 years ago
onOk: () => {
this.saving = true;
5 years ago
ActivityManager.instanceTerminate(
{ instanceId: instance.id },
5 years ago
res => {
5 years ago
_this.saving = false;
if (res.data.success == undefined || !res.data.success) {
_this.$Message.error("终止失败!");
} else {
_this.searchTable();
}
5 years ago
}
5 years ago
);
5 years ago
},
5 years ago
onCancel: () => {}
5 years ago
});
},
5 years ago
getDetail(instanceId) {
5 years ago
return new Promise((resolve, reject) => {
5 years ago
ActivityManager.instanceDetail(
{
5 years ago
instanceId
5 years ago
},
5 years ago
res => {
5 years ago
resolve(res.data.results);
}
);
});
5 years ago
},
5 years ago
modify(instance) {
5 years ago
let _this = this;
5 years ago
this.getDetail(instance.id).then(res => {
5 years ago
store.commit("SET_useData", res);
_this.activityInstance = res;
_this.showUse = true;
5 years ago
});
5 years ago
},
5 years ago
navigateCode(instance) {
5 years ago
this.$router.push({
path: "/activity/plan/code",
5 years ago
query: { instanceId: instance.id }
5 years ago
});
},
5 years ago
searchTable(params = {}) {
debugger
5 years ago
this.loading = true;
if (this.formValidate.startDate !== "") {
this.formValidate.startDate = formatDate(this.formValidate.startDate);
} else {
this.formValidate.startDate = undefined;
}
if (!!this.formValidate.endDate) {
this.formValidate.endDate = formatDate(this.formValidate.endDate);
} else {
this.formValidate.endDate = undefined;
5 years ago
}
params.pageNum = this.pageNum;
params.pageSize = this.pageSize;
params = { ...params, ...this.formValidate };
5 years ago
params.userId = JSON.parse(sessionStorage.getItem("loginInfo")).userId;
5 years ago
if (params.status == 0) {
params.status = undefined;
}
params.date = undefined;
5 years ago
http.get("/activity/instance/list", params).then(res => {
5 years ago
const data = res.data.results.this || {};
this.data = data.list || [];
this.totalSize = data.total || 0;
5 years ago
this.loading = false;
5 years ago
});
},
startDateChange:function(e){
//设置开始时间
this.endDateOptions = {
disabledDate:date =>{
let startTime = this.formValidate.startDate ? new Date(this.formValidate.startDate).valueOf() : '';
return date && (date.valueOf() < startTime)
}
}
},
endDateChange:function(e){
//设置结束时间
let endTime = this.formValidate.endDate ? new Date( this.formValidate.endDate ).valueOf()-1*24*60*60*1000 :'';
this.startDateOptions = {
disabledDate:date =>{
return date && (date.valueOf() >endTime);
}
}
}
5 years ago
}
5 years ago
};
</script>
5 years ago
<style>
.ivu-date-picker .ivu-select-dropdown {
5 years ago
left: 0 !important;
5 years ago
}
</style>