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.

243 lines
7.8 KiB

4 years ago
/*
* @Author: your name
* @Date: 2021-10-27 15:29:37
4 years ago
* @LastEditTime: 2021-10-28 10:36:57
4 years ago
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /data-show/src/views/IndustryDataExport/tableEvent.js
*/
function rowSelection(that) {
return {
onChange: (selectedRowKeys, selectedRows) => {
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
that.selectedRowKeys = selectedRowKeys.toString();
that.selectedRows = selectedRows;
that.secIds = selectedRowKeys;
4 years ago
4 years ago
},
// onSelect: (record, selected, selectedRows) => {
// console.log(record, selected, selectedRows);
// },
// onSelectAll: (selected, selectedRows, changeRows) => {
// console.log(selected, selectedRows, changeRows);
// },
}
}
4 years ago
import { getExcel } from "@/api/comm"
4 years ago
export default {
// 初始化页面
initDoc() {
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.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.gValue = 0;
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];
}
if (this.form.sTimeType === 4) {
this.gValue = 4;
}
if (this.form.token) {
this.rowSelection = rowSelection(this);
}
this.getList();
this.getTable();
});
},
// 选择情感和渠道的情况
onChange(val, type) {
this.noClick = true;
if (type === "quDao") {
4 years ago
this.qdIndeterminate = !!this.quDao.length && this.quDao.length < this.plainOptions.length;
this.qdCheckAll = this.quDao.length === this.plainOptions.length;
4 years ago
this.form.sQuDao = this.quDao.toString();
} else if (type === "qingGan") {
4 years ago
this.qgIndeterminate = !!this.qingGan.length && this.qingGan.length < this.plainOptions3.length;
this.qgCheckAll = this.qingGan.length === this.plainOptions3.length;
4 years ago
this.doFormQS(this.qingGan);
}
this.form.iPageIndex = 1;
this.pagination.current = 1;
Promise.all([this.getList(), this.getTable()]).then(() => {
this.noClick = false;
});
},
4 years ago
// 选择导出接口
fileTypeChange(val = []) {
let obj = {};
this.plainOptions4.forEach(ele => {
4 years ago
if (val.includes(ele.value)) {
obj[ele.value] = 1;
} else {
obj[ele.value] = 0;
}
4 years ago
});
this.execlForm.sField = JSON.stringify(obj);
},
4 years ago
// 导出弹框
handlerExport() {
this.getToExcelField(this.form.sType, this.form.token).then(() => {
4 years ago
this.execlForm.sFileName = this.form.sBrand + '洞察-' + this.getDatetimeSs();
4 years ago
this.execlForm.sCheckedIds = this.secIds.toString();
this.execlForm.iNum = this.secIds.length;
4 years ago
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.getTable();
this.getList();
},
// 改变页面的数据
handlerPage(p) {
let iPageIndex = p.current;
this.form.iPageIndex = iPageIndex;
this.pagination.current = iPageIndex;
this.getTable();
},
4 years ago
// 导出时将对象合并
mergeForm() {
let wKey = ['action', 'iPageIndex', 'iPageSize'];
4 years ago
for (let key in this.form) {
if (!wKey.includes(key)) {
4 years ago
this.execlForm[key] = this.form[key]
}
}
},
4 years ago
// 导出数据
4 years ago
exportExcel() {
4 years ago
if (this.execlForm.iNum) {
4 years ago
this.mergeForm();
getExcel(this.execlForm).then(() => {
this.$notification.open({
message: `数据生成中`,
description: '请前往个人中心查看下载进度',
4 years ago
placement: 'bottomRight',
});
4 years ago
})
}
4 years ago
},
// 点击渠道全部的效果
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;
});
4 years ago
}
4 years ago
}