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.
284 lines
10 KiB
284 lines
10 KiB
const app = getApp();
|
|
Component({
|
|
properties: {
|
|
id: String
|
|
},
|
|
data: {
|
|
//form
|
|
sTimeType: 34,
|
|
sStartTime: '',
|
|
sEndTime: '',
|
|
iTimeType: 0,
|
|
iPageIndex: 1,
|
|
iPageSize: 10,
|
|
//API
|
|
affList: [],
|
|
qgList: [
|
|
{key: 1, value: "正面", isSelect: false},
|
|
{key: 2, value: "负面", isSelect: false},
|
|
{key: 3, value: "中性", isSelect: false}
|
|
],
|
|
wjList: [
|
|
{key: 1,value: '低级危机', isSelect: false},{key: 2,value: '中级危机', isSelect: false},{key: 3,value: '高级危机', isSelect: false}
|
|
],
|
|
//列表
|
|
dataList: [],
|
|
total: 0,
|
|
isSelectAll: false,
|
|
result: [],
|
|
fileName: '',
|
|
reportShow: false,
|
|
reportOption: []
|
|
},
|
|
methods: {
|
|
getApi() {
|
|
app.globalData.request({
|
|
action: 'getQuDao', //获取所有渠道
|
|
token: 't%2BrswgjvzGM=',
|
|
}).then(res => {
|
|
res.forEach(ele => {
|
|
ele.isSelect = false
|
|
})
|
|
this.setData({affList: res})
|
|
});
|
|
},
|
|
getData() {
|
|
let qdList = [];
|
|
this.data.affList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qdList.push(ele.key)
|
|
}
|
|
});
|
|
let qgList = [];
|
|
this.data.qgList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qgList.push(ele.key)
|
|
}
|
|
});
|
|
let wjList = [];
|
|
this.data.wjList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
wjList.push(ele.key)
|
|
}
|
|
});
|
|
app.globalData.request({
|
|
action: 'getList', //数据列表
|
|
token: 't%2BrswgjvzGM=',
|
|
sTimeType: this.data.sTimeType,
|
|
sStartTime: this.data.sStartTime,
|
|
sEndTime: this.data.sEndTime,
|
|
sQuDao: qdList.join(',') || '',
|
|
sQingGan: qgList.join(',') || '',
|
|
iPageIndex: this.data.iPageIndex,
|
|
iPageSize: this.data.iPageSize,
|
|
sType: 'BrandDataHot',
|
|
isSourcetype: 0, //1返回渠道 0不返回
|
|
iTimeType: this.data.iTimeType, //0发布时间 1入库时间
|
|
sCrisis: wjList.join(',') || '',
|
|
sRele: wx.getStorageSync('sRele') || '',
|
|
},(res) => {
|
|
this.setData({total: res.totalNum})
|
|
}).then(res => {
|
|
this.setData({dataList: res})
|
|
});
|
|
},
|
|
changeTime(event) {
|
|
this.setData({sTimeType: event.detail.sTimeType})
|
|
if(event.detail.sStartTime) {
|
|
this.setData({sStartTime: event.detail.sStartTime})
|
|
};
|
|
if(event.detail.sEndTime) {
|
|
this.setData({sEndTime: event.detail.sEndTime})
|
|
};
|
|
this.getData();
|
|
},
|
|
changeSource(event) {
|
|
let that = this;
|
|
let val = event.currentTarget.dataset.value;
|
|
if(val.key == -1 && val.isSelect == false) {
|
|
that.data.affList.forEach(ele => {
|
|
ele.isSelect = true;
|
|
})
|
|
} else if(val.key == -1 && val.isSelect == true) {
|
|
that.data.affList.forEach(ele => {
|
|
ele.isSelect = false;
|
|
})
|
|
} else {
|
|
that.data.affList[0].isSelect = false;
|
|
}
|
|
if(val.key == -1) {
|
|
this.setData({affList: that.data.affList});
|
|
} else {
|
|
that.data.affList[val.key].isSelect = !that.data.affList[val.key].isSelect;
|
|
this.setData({affList: that.data.affList});
|
|
};
|
|
this.getData();
|
|
},
|
|
changeQingGan(event) {
|
|
let that = this;
|
|
let val = event.currentTarget.dataset.value;
|
|
that.data.qgList[val.key-1].isSelect = !that.data.qgList[val.key-1].isSelect;
|
|
this.setData({qgList: that.data.qgList});
|
|
this.getData();
|
|
},
|
|
changeWeiJi(event) {
|
|
let that = this;
|
|
let val = event.currentTarget.dataset.value;
|
|
that.data.wjList[val.key-1].isSelect = !that.data.wjList[val.key-1].isSelect;
|
|
this.setData({wjList: that.data.wjList});
|
|
this.getData();
|
|
},
|
|
iTimeTypeChange(event) {
|
|
this.setData({
|
|
iTimeType: this.data.iTimeType == 1?0:1,
|
|
});
|
|
this.getData()
|
|
},
|
|
toEventDetail(e) {
|
|
let id = e.currentTarget.dataset.id._id;
|
|
wx.navigateTo({
|
|
url: '/subPackages/pages/detail/index?id=' + id
|
|
})
|
|
},
|
|
loadMore() {
|
|
let qdList = [];
|
|
this.data.affList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qdList.push(ele.key)
|
|
}
|
|
});
|
|
let qgList = [];
|
|
this.data.qgList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qgList.push(ele.key)
|
|
}
|
|
});
|
|
let wjList = [];
|
|
this.data.wjList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
wjList.push(ele.key)
|
|
}
|
|
});
|
|
let pageIndex = this.data.iPageIndex + 1;
|
|
this.setData({iPageIndex: pageIndex});
|
|
app.globalData.request({
|
|
action: 'getList', //数据列表
|
|
token: 't%2BrswgjvzGM=',
|
|
sTimeType: this.data.sTimeType,
|
|
sStartTime: this.data.sStartTime,
|
|
sEndTime: this.data.sEndTime,
|
|
sQuDao: qdList.join(',') || '',
|
|
sQingGan: qgList.join(',') || '',
|
|
iPageIndex: this.data.iPageIndex,
|
|
iPageSize: this.data.iPageSize,
|
|
sType: 'BrandDataHot',
|
|
isSourcetype: 0, //1返回渠道 0不返回
|
|
iTimeType: this.data.iTimeType, //0发布时间 1入库时间
|
|
sCrisis: wjList.join(',') || '',
|
|
sRele: wx.getStorageSync('sRele') || '',
|
|
}).then(res => {
|
|
let arr = [...this.data.dataList, ...res]
|
|
this.setData({dataList: arr})
|
|
});
|
|
},
|
|
//单选
|
|
onChange(event) {
|
|
this.setData({
|
|
result: event.detail,
|
|
})
|
|
},
|
|
changeSelectAll(event) {
|
|
let listId = [];
|
|
let isSelectAllList = [];
|
|
if (event.detail.length != 0) {
|
|
this.data.dataList.forEach((e) => {
|
|
listId.push(e._id);
|
|
})
|
|
isSelectAllList.push(event.detail)
|
|
} else {
|
|
listId.splice();
|
|
}
|
|
this.setData({
|
|
result: listId,
|
|
isSelectAll: event.detail,
|
|
});
|
|
},
|
|
openReport() {
|
|
let d = new Date();
|
|
let date = d.toISOString().replace(/\D/g, '');
|
|
this.setData({fileName: wx.getStorageSync('sBrand') + date})
|
|
this.setData({
|
|
reportShow: true
|
|
})
|
|
},
|
|
fieldChange(event) {
|
|
let index = event.currentTarget.dataset.index;
|
|
var that = this;
|
|
that.data.reportOption[index].checked = that.data.reportOption[index].checked==0?1:0
|
|
this.setData({
|
|
reportOption: that.data.reportOption
|
|
})
|
|
},
|
|
report() {
|
|
let d = new Date();
|
|
let date = d.toISOString().replace(/\D/g, '');
|
|
let qdList = [];
|
|
this.data.affList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qdList.push(ele.key)
|
|
}
|
|
});
|
|
let qgList = [];
|
|
this.data.qgList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
qgList.push(ele.key)
|
|
}
|
|
});
|
|
let wjList = [];
|
|
this.data.wjList.forEach(ele => {
|
|
if(ele.isSelect && ele.key != -1) {
|
|
wjList.push(ele.key)
|
|
}
|
|
});
|
|
let sField = {};
|
|
this.data.reportOption.forEach(ele => {
|
|
if(ele.checked == 1 || ele.checked == "1") {
|
|
sField[ele.field] = 1;
|
|
}
|
|
})
|
|
app.globalData.request({
|
|
action: 'toExcel', //导出
|
|
token: 't%2BrswgjvzGM=',
|
|
sTimeType: this.data.sTimeType,
|
|
sStartTime: this.data.sStartTime,
|
|
sEndTime: this.data.sEndTime,
|
|
sRele: wx.getStorageSync('sRele') || '',
|
|
sQuDao: qdList.join(',') || '',
|
|
sQingGan: qgList.join(',') || '',
|
|
sCrisis: wjList.join(',') || '',
|
|
sType: 'BrandDataHot',
|
|
sField: JSON.stringify(sField), //导出字段
|
|
sFileName: "事件数据" + date, //文件名称
|
|
sCheckedIds: this.data.result.join(',') || '', //数据id
|
|
iNum: this.data.result.length == 0 ? this.data.total : this.data.result.length, //导出条数
|
|
iTimeType: this.data.iTimeType, //0发布时间 1入库时间
|
|
}, (res) => {
|
|
if (res.Code == 1) {
|
|
this.setData({
|
|
reportShow: false
|
|
})
|
|
wx.showModal({
|
|
title: '数据生成中,请前往”我的“查看生成进度',
|
|
showCancel: false
|
|
})
|
|
}
|
|
}).then(() => {});
|
|
}
|
|
},
|
|
lifetimes: {
|
|
attached() {
|
|
this.getApi();
|
|
this.getData();
|
|
},
|
|
}
|
|
}) |