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.

107 lines
2.5 KiB

const app = getApp();
import {throttle} from "../../../../js/utils";
const risk_message = "检测到内容含有敏感词汇";
function msgSecCheck({name="", remarks=""}){
let content = name+","+ remarks;
console.log("msgsecCheck", content);
if(this.tmp_promise&&this.tmp_content==content)
return this.tmp_promise;
this.tmp_promise = app.openapi("security.msgSecCheck")({content});
this.tmp_content = content;
this.tmp_promise.then(res=>{
if(res.errCode==87014){
wx.showToast({
title: risk_message,icon:"none",duration:2600
})
}
})
return this.tmp_promise;
}
Component({
properties: {
show:{
type:Boolean,
value:false
},
school_name:String,
school_id:Number
},
data: {
buttons:[
{text:"取消"},
{text:"提交"}
],
name: "",
remarks:""
},
methods: {
cancel(){
this.setData({show:false});
},
updateName({detail:{value}}){
this.setData({name:value});
this.throttledMsgSecCheck(this.data);
},
updateRemarks({detail:{value}}){
this.setData({remarks:value});
this.throttledMsgSecCheck(this.data);
},
checkInput(){
if(!this.data.name)
return wx.showToast({
title: '请输入子单位名称',icon:"none"
})&&false;
return true;
},
throttledMsgSecCheck:throttle(msgSecCheck, 1000, {}),
msgSecCheck,
submit(){
if(!this.checkInput())
return;
let {remarks, name, school_id} = this.data;
wx.showLoading({
title: '检查内容中...'
})
this.msgSecCheck({name, remarks}).then(res=>{
if(res.errCode==0){
wx.showLoading({
title: '正在添加'
})
app.api("add_department_applies")({school_id, name, remarks})
.then(res=>{
this.triggerEvent("success",res);
wx.hideLoading();
wx.showToast({
title: '添加成功'
})
this.setData({show:false});
}).catch(e=>{
app.showError(e);
})
5 years ago
}else{
wx.hideLoading();
wx.showModal({
content:risk_message,
showCancel:false
})
}
}).catch(e=>{
//app.showError(e);
wx.showToast({
title: '出错了\n>_<',icon:"none"
})
throw e;
})
},
onTapButton({detail}){
if(detail.index==0)
this.cancel()
else if(detail.index==1)
this.submit()
}
}
})