/* * @Author: your name * @Date: 2021-10-27 15:29:37 * @LastEditTime: 2021-10-27 19:37:22 * @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; }, // onSelect: (record, selected, selectedRows) => { // console.log(record, selected, selectedRows); // }, // onSelectAll: (selected, selectedRows, changeRows) => { // console.log(selected, selectedRows, changeRows); // }, } } import {getExcel} from "@/api/comm" 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") { this.form.sQuDao = this.quDao.toString(); } else if (type === "qingGan") { 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(() => { this.execlForm.sFileName = this.form.sBrand+'洞察-'+ this.getDatetimeSs(); this.execlForm.sCheckedIds = this.secIds.toString(); this.execlForm.iNum = 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.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) { this.mergeForm(); getExcel(this.execlForm).then(() => { this.$notification.open({ message: `数据生成中`, description: '请前往个人中心查看下载进度', placement:'bottomRight', }); }) } } }