|
@@ -11,14 +11,32 @@ Page({
|
|
|
onLoad() {
|
|
|
this.getservantlist("SN000002");
|
|
|
},
|
|
|
+ ///加载绑定数据
|
|
|
getservantlist(subjectType){
|
|
|
request.httpServiceGet(apiUrl.servantappletservicePath,{subjectType:subjectType}).then(data=>{
|
|
|
//console.log(data);
|
|
|
+ let servantlist = data;
|
|
|
+ var that = this;
|
|
|
+ for(let i=0;i<servantlist.length;i++){
|
|
|
+ if(i==0){
|
|
|
+ servantlist[i].show=true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ servantlist[i].show=false;
|
|
|
+ }
|
|
|
+ if(i==(servantlist.length-1)) {
|
|
|
+ servantlist[i].button="完成";
|
|
|
+ }else{
|
|
|
+ servantlist[i].button="下一步";
|
|
|
+ }
|
|
|
+ servantlist[i].index=i+1;
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- servantlist: data
|
|
|
+ servantlist: servantlist
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
+ //提交数据
|
|
|
dailytasksdeit(){
|
|
|
let employRelationNo = app.globalData.employRelationNo;
|
|
|
let servantselectedlist=[];
|
|
@@ -27,24 +45,30 @@ Page({
|
|
|
let answerstr='';
|
|
|
for(let t=0;t<this.data.servantlist[i].subjectList[j].answer.length;t++){
|
|
|
if(this.data.servantlist[i].subjectList[j].answer[t].isChoose){
|
|
|
- answerstr += this.data.servantlist[i].subjectList[j].answer[t].answer+',';
|
|
|
+ answerstr += this.data.servantlist[i].subjectList[j].answer[t].answer +',';
|
|
|
}
|
|
|
}
|
|
|
//console.log(answerstr);
|
|
|
- servantselectedlist.push({answer: [answerstr],customAnswer: this.data.servantlist[i].subjectList[j].subject,subjectId: this.data.servantlist[i].subjectList[j].subjectId});
|
|
|
+ if(answerstr.length>0||this.data.servantlist[i].subjectList[j].customAnswer.length>0){
|
|
|
+ answerstr=answerstr.substring(0,answerstr.length - 1);
|
|
|
+ servantselectedlist.push({answer: [answerstr],customAnswer: this.data.servantlist[i].subjectList[j].customAnswer,subjectId: this.data.servantlist[i].subjectList[j].subjectId});
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//console.log(servantselectedlist);
|
|
|
request.httpServicePost(apiUrl.insertNewservantappletservicePath,{employRelationNo:employRelationNo,subjectList:servantselectedlist,subjectType:"SN000002"}).then(data=>{
|
|
|
my.alert({
|
|
|
- title: data,
|
|
|
- });
|
|
|
+ title: '提示',
|
|
|
+ content: '设置完成',
|
|
|
+ buttonText: '确定',
|
|
|
+ success: () => {
|
|
|
+ my.navigateBack();
|
|
|
+ }
|
|
|
+ } );
|
|
|
});
|
|
|
},
|
|
|
+ //选择问题 多选
|
|
|
answerselected(e){
|
|
|
- //console.log(e.target.dataset.id);
|
|
|
- //console.log(e.detail.value);
|
|
|
-
|
|
|
let checkedlist=e.detail.value;
|
|
|
let servantlist=this.data.servantlist;
|
|
|
//先做清除
|
|
@@ -75,6 +99,42 @@ Page({
|
|
|
servantlist: servantlist
|
|
|
})
|
|
|
},
|
|
|
+ //问题选择单选
|
|
|
+ answerselectedSingle(e){
|
|
|
+ let checkedlist=e.detail.value;
|
|
|
+ let servantlist=this.data.servantlist;
|
|
|
+ //先做清除
|
|
|
+ for(let i=0;i<servantlist.length;i++){
|
|
|
+ for(let j=0;j<servantlist[i].subjectList.length;j++){
|
|
|
+ if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
|
|
|
+ for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
|
|
|
+ servantlist[i].subjectList[j].answer[t].isChoose=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加选中
|
|
|
+ for(let i=0;i<servantlist.length;i++){
|
|
|
+ for(let j=0;j<servantlist[i].subjectList.length;j++){
|
|
|
+ if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
|
|
|
+ for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
|
|
|
+ for(let u=0;u<checkedlist.length;u++){
|
|
|
+ if(checkedlist[u]==servantlist[i].subjectList[j].answer[t].answer){
|
|
|
+ servantlist[i].subjectList[j].answer[t].isChoose=1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ servantlist[i].subjectList[j].answer[t].isChoose=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ servantlist: servantlist
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //自定义问题
|
|
|
customanswer(e){
|
|
|
console.log(e.target.dataset.id);
|
|
|
let servantlist=this.data.servantlist;
|
|
@@ -90,6 +150,43 @@ Page({
|
|
|
servantlist: servantlist
|
|
|
})
|
|
|
},
|
|
|
+ //切换tab
|
|
|
+ loadclasslistadd(e){
|
|
|
+ let nowsubtypeNo=e.target.dataset.id;
|
|
|
+
|
|
|
+ let servantlist=this.data.servantlist;
|
|
|
+ //1.先清除
|
|
|
+ let t=0;
|
|
|
+ for(let i=0;i<servantlist.length;i++){
|
|
|
+ servantlist[i].show=false;
|
|
|
+ if(servantlist[i].subtypeNo==nowsubtypeNo){
|
|
|
+ t=i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ servantlist[t+1].show=true;
|
|
|
+ this.setData({
|
|
|
+ servantlist: servantlist
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //切换tab
|
|
|
+ loadclasslist(e){
|
|
|
+ let nowsubtypeNo=e.target.dataset.id;
|
|
|
+
|
|
|
+ let servantlist=this.data.servantlist;
|
|
|
+ //1.先清除
|
|
|
+ let t=0;
|
|
|
+ for(let i=0;i<servantlist.length;i++){
|
|
|
+ servantlist[i].show=false;
|
|
|
+ if(servantlist[i].subtypeNo==nowsubtypeNo){
|
|
|
+ t=i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ servantlist[t-1].show=true;
|
|
|
+ this.setData({
|
|
|
+ servantlist: servantlist
|
|
|
+ })
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
|