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.

78 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const app = getApp();
Component({
properties: {
show:{
type:Boolean,
value:false
},
school_name:String,
school_id:Number
},
data: {
buttons:[
{text:"取消"},
{text:"提交"}
]
},
methods: {
cancel(){
this.setData({show:false});
},
updateName({detail:{value}}){
this.setData({name:value});
},
updateRemarks({detail:{value}}){
this.setData({remarks:value});
},
checkInput(){
if(!this.data.name)
return wx.showToast({
title: '请输入子单位名称',icon:"none"
})&&false;
return true;
},
submit(){
if(!this.checkInput())
return;
let {remarks, name, school_id} = this.data;
let content = name + remarks?""+remarks:'';
wx.showLoading({
title: '检查内容中...'
})
console.log("onSubmit");
app.openapi({name:"security.msgSecCheck",data:{content},success:res=>{
if(res.errCode==0){
wx.showLoading({
title: '正在添加'
})
app.api("add_department_applies")({school_id, name, remarks})
.then(res=>{
//console.log(res);
this.triggerEvent("success",res);
wx.hideLoading();
wx.showToast({
title: '添加成功'
})
this.setData({show:false});
}).catch(e=>{
app.showError(e);
})
//console.log("内容合法")
}else{
wx.hideLoading();
wx.showToast({
title: '内容含有敏感词汇',icon:"none"
});
}
}});
console.log(remarks, name, school_id);
},
onTapButton({detail}){
if(detail.index==0)
this.cancel()
else if(detail.index==1)
this.submit()
}
}
})