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.

430 lines
12 KiB

import moment from "moment"
const app = getApp();
Page({
data: {
steps: [{
text: '名称设置',
inactiveIcon: 'more-o',
activeIcon: 'more',
},
{
text: '分析词设置',
inactiveIcon: 'more-o',
activeIcon: 'more',
},
{
text: '定向监测',
inactiveIcon: 'more-o',
activeIcon: 'more',
}
],
Guid: '',
//表单
Name: '',
StartTime: '',
EndTime: '',
startShow: new Date().getTime(),
endShow: new Date().getTime(),
DetailsData: [],
AnalyzeWord: '', // 和 或 的主体词
HuoWord: '', // 和 或 的可选词
PaiChu: '', // 排除词
highAnalizeWord: '', // 高级模式分析词
Source: '', // 定向监测媒体
UserAuthor: '', // 定向监测作者
//
active: 0,
activeNames: [],
show1: false,
show2: false,
dt: '',
dt2: '',
// 总体模式
totalMode: 0, // 0便捷 1高级
/* 分析词设置 */
currWordType: '必选词和的关系',
wtShow: false,
wtColumns: ['必选词和的关系', '主题词或的关系'],
// 是否推送信息
Statu: 0,
// 预警选项
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
}
],
},
onLoad: function (options) {
this.setData({
Guid: options.Guid
});
},
onShow() {
this.getApi();
app.globalData.request({
action: 'getSchemeDataByGuid',
token: 't%2BrswgjvzGM=',
Guids: this.data.Guid,
}).then(res => {
// todo: 回显预警信息
console.log(res)
if (res.DetailsData) {
if (res.DetailsData[0].IsAdvancedQuery == 1) {
this.setData({
totalMode: 1,
highAnalizeWord: res.DetailsData[0].AnalyzeWord,
})
} else if (res.DetailsData[0].IsAdvancedQuery == 0) {
this.setData({
totalMode: 0,
currWordType: '必选词和的关系'
})
} else {
this.setData({
totalMode: 0,
currWordType: '主题词或的关系'
})
}
this.setData({
AnalyzeWord: res.DetailsData[0].AnalyzeWord,
HuoWord: res.DetailsData[0].HuoWord,
PaiChu: res.DetailsData[0].PaiChu,
UserAuthor: res.DetailsData[0].UserAuthor,
Source: res.DetailsData[0].Source,
})
}
this.setData({
Name: res.Name,
StartTime: res.StartTime,
start: res.StartTime,
EndTime: res.EndTime,
end: res.EndTime,
startShow: new Date(res.StartTime).valueOf(),
endShow: new Date(res.EndTime).valueOf(),
})
});
},
getApi() {
app.globalData.request({
action: 'getQuDao', //获取所有渠道
token: 't%2BrswgjvzGM=',
}).then(res => {
res.forEach(ele => {
ele.isSelect = false;
})
this.setData({
affList: res
})
});
},
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
});
};
},
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
});
},
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
});
},
getApi() {
app.globalData.request({
action: 'getQuDao', //获取所有渠道
token: 't%2BrswgjvzGM=',
}).then(res => {
res.forEach(ele => {
ele.isSelect = false;
})
this.setData({
affList: res
})
});
},
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
});
};
},
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
});
},
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
});
},
//表单
themeNameInput(event) {
this.setData({
Name: event.detail.value
})
},
//
changeTips(value) {
this.setData({
activeNames: value.detail,
});
},
onConfirm(event) {
var time = moment(event.detail).format("YYYY-MM-DD HH:mm:ss")
this.setData({
show1: false,
StartTime: time,
start: time
});
},
onConfirm2(event) {
var time = moment(event.detail).format("YYYY-MM-DD HH:mm:ss")
this.setData({
show2: false,
EndTime: time,
end: time
});
},
onDisplay() {
this.setData({
show1: true
});
},
onDisplay2() {
this.setData({
show2: true
});
},
onCancel() {
this.setData({
show1: false,
});
},
onCancel2() {
this.setData({
show2: false,
});
},
changeTotalMode(event) {
this.setData({
totalMode: event.detail.index
});
},
wordType() {
this.setData({
wtShow: true
});
},
wtConfirm(event) {
this.setData({
wtShow: false,
currWordType: event.detail.value
});
},
wtCancel() {
this.setData({
wtShow: false
});
},
infoPushChange(event) {
if (event.detail == 0) {
this.setData({
show: true,
Statu: event.detail
})
} else {
this.setData({
show: false,
Statu: event.detail
});
}
},
goBeforeStep() {
this.setData({
active: this.data.active - 1
})
},
goNextStep() {
this.setData({
active: this.data.active + 1
})
},
// 分析词设置
bindAnalyzeWord(event) {
this.setData({
AnalyzeWord: event.detail.value
})
},
bindHuoWord(event) {
this.setData({
HuoWord: event.detail.value
})
},
bindPaiChu(event) {
this.setData({
PaiChu: event.detail.value
})
},
bindHighAnalizeWord(event) {
this.setData({
highAnalizeWord: event.detail.value
})
},
// 定向监测
bindSource(event) {
this.setData({
Source: event.detail.value
})
},
bindUserAuthor(event) {
this.setData({
UserAuthor: event.detail.value
})
},
themeSave() {
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 dtData = {
"AnalyzeWord": this.data.AnalyzeWord,
"HuoWord": this.data.HuoWord,
"PaiChu": this.data.PaiChu,
"IsAdvancedQuery": this.data.totalMode == 0 && this.data.currWordType == '必选词和的关系' ? 0 : this.data.totalMode == 1 ? 1 : 2,
"Source": this.data.Source,
"UserAuthor": this.data.UserAuthor
};
let jsonObj = {
"Guids": this.data.Guid,
"Name": this.data.Name,
"Classify": 0,
"StartTime": this.data.StartTime,
"EndTime": this.data.EndTime,
"Types": "theme",
"DetailsData": [dtData],
"Warning": {
"Statu": this.data.Statu,
"Es": {
"QuDao": qdList.join(',') || '',
"QingGan": qgList.join(',') || '',
"Crisis": wjList.join(',') || '',
}
}
}
var dtJson = JSON.stringify(jsonObj)
app.globalData.request({
action: 'setSchemeData', //数据列表
token: 't%2BrswgjvzGM=',
DataJson: dtJson,
}).then(res => {
wx.showModal({
title: '编辑成功!',
showCancel: false,
success: function (result) {
if (result.cancel == false) {
wx.navigateBack({
delta: 1,
})
}
}
});
});
}
})