1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import request from '../../../util/http'
- import apiUrl from '../../../util/apiUrl1'
- import util from '../../../util/util'
- import moment from 'moment'
- var app = getApp();
- Page({
- data: {
- servantlist:[],
- },
- onLoad() {
- this.getservantlist("SN000002");
- },
- getservantlist(subjectType){
- request.httpServiceGet(apiUrl.servantappletservicePath,{subjectType:subjectType}).then(data=>{
- //console.log(data);
- this.setData({
- servantlist: data
- });
- });
- },
- dailytasksdeit(){
- let employRelationNo = app.globalData.employRelationNo;
- let servantselectedlist=[];
- for(let i=0;i<this.data.servantlist.length;i++){
- for(let j=0;j<this.data.servantlist[i].subjectList.length;j++){
- 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+',';
- }
- }
- //console.log(answerstr);
- servantselectedlist.push({answer: [answerstr],customAnswer: this.data.servantlist[i].subjectList[j].subject,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,
- });
- });
- },
- answerselected(e){
- //console.log(e.target.dataset.id);
- //console.log(e.detail.value);
- 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;
- }
- }
- }
- }
- }
- }
- this.setData({
- servantlist: servantlist
- })
- },
- customanswer(e){
- console.log(e.target.dataset.id);
- 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){
- servantlist[i].subjectList[j].customAnswer = e.detail.value;
- break;
- }
- }
- }
- this.setData({
- servantlist: servantlist
- })
- },
- });
|