You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
9.8 KiB

/*
* @Author: your name
* @Date: 2021-10-27 15:29:37
* @LastEditTime: 2021-12-03 18:31:19
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/views/IndustryDataExport/tableEvent.js
*/
import moment from "moment";
export function rowSelection() {
let a = null;
if (!this.form.token) {
a = null
} else {
a = {
onChange: (selectedRowKeys, selectedRows) => {
this.sk = selectedRowKeys;
this.selectedRowKeys = selectedRowKeys.toString();
this.selectedRows = selectedRows;
this.secIds = selectedRowKeys;
},
onSelect:(record, selected) => {
if(!selected) {
this.tableAll = false;
}
},
selectedRowKeys: this.sk,
onSelectAll: () => {
this.tableAll = !this.tableAll;
},
}
}
return a
}
import { getExcel } from "@/api/comm"
export default {
// 初始化页面
initDoc() {
this.title = this.$route.query.title || '行业数据'
if (this.title === '品牌-行业数据') {
this.btnUrl = 'btn_brand_c_toppt'
} else if (this.title === '车型-行业数据') {
this.btnUrl = 'btn_model_toexcel'
} else if (this.title === '事件-行业数据') {
this.btnUrl = 'btn_event_toexcel'
}
Promise.all([
this.getQuDao(),
this.getQingGan(),
this.getCrisis(),
this.getTime(),
]).then(() => {
let series = this.$route.query.series || [];
let qudao = this.$route.query.qudao || [];
this.form.token = this.$route.query.token || "";
this.form.sRele = this.$route.query.events_id || "";
this.form.action = this.$route.query.action || "";
this.form.sType = this.$route.query.sType || "";
this.form.sBrand = this.$route.query.brand || "";
this.form.sSeriesName = this.$route.query.seriesName || "";
this.doFormQudao(qudao);
this.plainOptions3 = this.doQingGanAndCrisis();
this.qingGan = series;
this.doFormQS(series);
this.form.sTimeType = this.$route.query.sTimeType || 34;
this.form.sStartTime = this.$route.query.startTime || "";
this.form.sEndTime = this.$route.query.endTime || "";
if (this.form.sStartTime && this.form.sEndTime) {
this.selTime = [this.form.sStartTime, this.form.sEndTime];
}
let x = this.timesSel.findIndex(ele => {
return ele.key == this.form.sTimeType;
})
if(x === -1) {
this.gValue = 0;
} else {
this.gValue = x;
}
this.getList();
this.getTable();
});
},
// 选择情感和渠道的情况
onChange(val, type) {
this.noClick = true;
if (type === "quDao") {
this.qdIndeterminate = !!this.quDao.length && this.quDao.length < this.plainOptions.length;
this.qdCheckAll = this.quDao.length === this.plainOptions.length;
this.form.sQuDao = this.quDao.toString();
} else if (type === "qingGan") {
this.qgIndeterminate = !!this.qingGan.length && this.qingGan.length < this.plainOptions3.length;
this.qgCheckAll = this.qingGan.length === this.plainOptions3.length;
this.doFormQS(this.qingGan);
}
this.form.iPageIndex = 1;
this.pagination.current = 1;
Promise.all([this.getList(), this.getTable()]).then(() => {
this.noClick = false;
});
},
// 选择导出接口
fileTypeChange(val = []) {
let obj = {};
this.plainOptions4.forEach(ele => {
if (val.includes(ele.value)) {
obj[ele.value] = 1;
} else {
obj[ele.value] = 0;
}
});
this.execlForm.sField = JSON.stringify(obj);
},
// 导出弹框
handlerExport() {
this.getToExcelField(this.form.sType, this.form.token).then(() => {
if(!this.form.sBrand && !this.form.sSeriesName) {
this.execlForm.sFileName = "事件数据" + this.getDatetimeSs();
} else {
this.execlForm.sFileName = this.form.sBrand + this.form.sSeriesName + this.getDatetimeSs();
}
this.execlForm.sCheckedIds = this.tableAll ? '' : this.secIds.toString();
this.execlForm.iNum = this.tableAll ? this.totalNum : this.secIds.length;
this.modalObj.visible = true;
})
},
// 给后台传渠道
doFormQudao(val = []) {
let arr = [];
val.forEach((ele) => {
let n = this.plainOptions.findIndex((e) => {
return e.label === ele;
});
if (n != -1) {
arr.push(this.plainOptions[n].value);
}
});
this.quDao = arr;
this.form.sQuDao = arr.toString();
},
// 给后台传情感和负面等级
doFormQS(val = []) {
let qingGan = [];
let crisis = [];
val.forEach((ele) => {
let n1 = this.plainOptions1.findIndex((e) => {
return e.label === ele;
});
let n2 = this.plainOptions2.findIndex((e) => {
return e.label === ele;
});
if (n1 != -1) {
qingGan.push(this.plainOptions1[n1].value);
}
if (n2 != -1) {
crisis.push(this.plainOptions2[n2].value);
}
});
this.form.sQingGan = qingGan.toString();
this.form.sCrisis = crisis.toString();
},
// 处理情感和负面等级
doQingGanAndCrisis() {
let arr = [];
let tes = [...this.plainOptions1, ...this.plainOptions2];
tes.forEach((ele) => {
let obj = {
label: ele.label,
value: ele.label,
};
arr.push(obj);
});
return arr;
},
// 返回
handlerBack() {
this.$router.go(-1);
},
// 改变时间的选项
handlerTime(n) {
let ele = this.timesSel[n];
this.form.sTimeType = ele.key;
if (ele.key != this.selVal) {
this.getTable();
this.getList();
}
},
// 选择时间的效果
handlerChangeTime(val) {
this.form.sStartTime = val[0];
this.form.sEndTime = val[1];
this.selectPriceDate = "";
this.getTable();
this.getList();
},
// 改变页面的数据
handlerPage(p) {
let iPageIndex = p.current;
this.form.iPageIndex = iPageIndex;
this.pagination.current = iPageIndex;
this.getTable();
},
// 导出时将对象合并
mergeForm() {
let wKey = ['action', 'iPageIndex', 'iPageSize'];
for (let key in this.form) {
if (!wKey.includes(key)) {
this.execlForm[key] = this.form[key]
}
}
},
// 导出数据
exportExcel() {
if(this.execlForm.iNum === 0) {
this.$message.warning('请选择下载数据');
return;
}
if(this.checkedIds.length === 0) {
this.$message.warning('请选择下载字段');
return;
}
if (this.execlForm.iNum && this.checkedIds.length > 0) {
this.mergeForm();
getExcel(this.execlForm).then(() => {
this.$notification.open({
message: `数据生成中`,
description: '请前往个人中心查看下载进度',
placement: 'bottomRight',
});
this.modalObj.visible = false;
})
}
},
// 点击渠道全部的效果
onCheckAllChangeQd(e) {
let arr = [];
this.plainOptions.forEach(ele => {
let value = ele.value;
arr.push(value)
})
Object.assign(this, {
quDao: e.target.checked ? arr : [],
qdIndeterminate: false,
qdCheckAll: e.target.checked,
});
this.form.sQuDao = this.quDao.toString();
this.form.iPageIndex = 1;
this.pagination.current = 1;
Promise.all([this.getList(), this.getTable()]).then(() => {
this.noClick = false;
});
},
// 点击调性全部的方法
onCheckAllChangeQg(e) {
let arr = [];
this.plainOptions3.forEach(ele => {
let value = ele.value;
arr.push(value)
})
Object.assign(this, {
qingGan: e.target.checked ? arr : [],
qgIndeterminate: false,
qgCheckAll: e.target.checked,
});
this.doFormQS(this.qingGan);
this.form.iPageIndex = 1;
this.pagination.current = 1;
Promise.all([this.getList(), this.getTable()]).then(() => {
this.noClick = false;
});
},
//选择开始时间/结束时间
calendarPriceRangeChange(date) {
this.selectPriceDate = date[0];
},
//根据选择的开始时间/结束时间,动态渲染要禁用的日期
disabledDate(current) {
return current > moment();
// if (this.selectPriceDate) {
// let selectV = moment(
// this.selectPriceDate,
// "YYYY-MM-DD"
// ).valueOf();
// return (
// current >
// moment() ||
// current <
// moment(
// new Date(selectV - this.offsetDays),
// "YYYY-MM-DD"
// )
// );
// } else {
// return false;
// }
},
}