parent
fbfcc4abb7
commit
eac02edfd4
After Width: | Height: | Size: 5.2 KiB |
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2021-10-27 15:26:21
|
||||
* @LastEditTime: 2021-10-27 15:53:06
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @Description: In User Settings Edit
|
||||
* @FilePath: /data-show/src/views/IndustryDataExport/getApiData.js
|
||||
*/
|
||||
import { getQuDao, getQingGan, getCrisis, getTwoTime, getToExcelField } from "@/api/comm";
|
||||
import { getListHome } from "@/api/home";
|
||||
export default {
|
||||
// 获取表格数据
|
||||
getTable() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.tableLoading = true;
|
||||
this.tbData = [];
|
||||
this.getData(0)
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
this.totalNum = res.totalNum;
|
||||
this.pagination.total = res.totalNum;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let _source = ele._source;
|
||||
arr.push(_source);
|
||||
});
|
||||
this.tbData = arr;
|
||||
this.tableLoading = false;
|
||||
resolve(res);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取渠道数据
|
||||
getList() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.getData(1)
|
||||
.then((res) => {
|
||||
let data = res.data1;
|
||||
let arr = [...this.plainOptions];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let label = arr[i].label || "";
|
||||
let str = label.replace(/\(.*?\)/g, "");
|
||||
arr[i].label = str + "(" + data[i] + ")";
|
||||
}
|
||||
this.plainOptions = arr;
|
||||
resolve(res);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取后台数据
|
||||
getData(isSourcetype) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let obj = Object.assign({}, this.form);
|
||||
obj.isSourcetype = isSourcetype;
|
||||
getListHome(obj)
|
||||
.then((res) => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取时间选项
|
||||
getTime() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getTwoTime()
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
this.timesSel = data;
|
||||
this.form.sTimeType = this.timesSel[0].key;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let value = ele.value;
|
||||
arr.push(value);
|
||||
});
|
||||
this.btnTimes = arr;
|
||||
resolve(data);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取渠道
|
||||
getQuDao() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getQuDao()
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let obj = {
|
||||
label: ele.value,
|
||||
value: ele.key,
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
this.plainOptions = arr;
|
||||
resolve(arr);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取情感
|
||||
getQingGan() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getQingGan()
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let obj = {
|
||||
label: ele.value,
|
||||
value: ele.key,
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
this.plainOptions1 = arr;
|
||||
resolve(arr);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取负面等级
|
||||
getCrisis() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getCrisis()
|
||||
.then((res) => {
|
||||
let data = res.data;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let obj = {
|
||||
label: ele.value,
|
||||
value: ele.key,
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
this.plainOptions2 = arr;
|
||||
resolve(arr);
|
||||
})
|
||||
.catch(() => {
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取导出字段
|
||||
getToExcelField(sType, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getToExcelField({sType: sType, token: token}).then(res => {
|
||||
let data = res.data;
|
||||
let arr = [];
|
||||
data.forEach((ele) => {
|
||||
let obj = {
|
||||
label: ele.name,
|
||||
value: ele.field,
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
this.plainOptions4 = arr;
|
||||
resolve(arr);
|
||||
}).catch(() => {
|
||||
reject(false);
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2021-10-27 15:29:37
|
||||
* @LastEditTime: 2021-10-27 16:53:08
|
||||
* @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);
|
||||
// },
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
},
|
||||
// 导出弹框
|
||||
handlerExport() {
|
||||
this.getToExcelField(this.form.sType, this.form.token).then(() => {
|
||||
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();
|
||||
},
|
||||
}
|
Loading…
Reference in new issue