servantsettings.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. import request from '../../../util/http'
  2. import apiUrl from '../../../util/apiUrl1'
  3. import util from '../../../util/util'
  4. import moment from 'moment'
  5. var app = getApp();
  6. Page({
  7. data: {
  8. servantlist:[],
  9. },
  10. onLoad() {
  11. this.getservantlist("SN000002");
  12. },
  13. ///加载绑定数据
  14. getservantlist(subjectType){
  15. request.httpServiceGet(apiUrl.servantappletservicePath,{subjectType:subjectType}).then(data=>{
  16. //console.log(data);
  17. let servantlist = data;
  18. var that = this;
  19. for(let i=0;i<servantlist.length;i++){
  20. if(i==0){
  21. servantlist[i].show=true;
  22. }
  23. else{
  24. servantlist[i].show=false;
  25. }
  26. if(i==(servantlist.length-1)) {
  27. servantlist[i].button="完成";
  28. }else{
  29. servantlist[i].button="下一步";
  30. }
  31. servantlist[i].index=i+1;
  32. }
  33. this.setData({
  34. servantlist: servantlist
  35. });
  36. });
  37. },
  38. //提交数据
  39. dailytasksdeit(){
  40. let employRelationNo = app.globalData.employRelationNo;
  41. let servantselectedlist=[];
  42. for(let i=0;i<this.data.servantlist.length;i++){
  43. for(let j=0;j<this.data.servantlist[i].subjectList.length;j++){
  44. let answerstr='';
  45. for(let t=0;t<this.data.servantlist[i].subjectList[j].answer.length;t++){
  46. if(this.data.servantlist[i].subjectList[j].answer[t].isChoose){
  47. answerstr += this.data.servantlist[i].subjectList[j].answer[t].answer+',';
  48. }
  49. }
  50. //console.log(answerstr);
  51. servantselectedlist.push({answer: [answerstr],customAnswer: this.data.servantlist[i].subjectList[j].subject,subjectId: this.data.servantlist[i].subjectList[j].subjectId});
  52. }
  53. }
  54. //console.log(servantselectedlist);
  55. request.httpServicePost(apiUrl.employerServiceStandard,{employRelationNo:employRelationNo,subjectList:servantselectedlist,subjectType:"SN000001"}).then(data=>{
  56. my.alert({
  57. title: data,
  58. });
  59. });
  60. },
  61. //选择问题 多选
  62. answerselected(e){
  63. let checkedlist=e.detail.value;
  64. let servantlist=this.data.servantlist;
  65. //先做清除
  66. for(let i=0;i<servantlist.length;i++){
  67. for(let j=0;j<servantlist[i].subjectList.length;j++){
  68. if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
  69. for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
  70. servantlist[i].subjectList[j].answer[t].isChoose=0;
  71. }
  72. }
  73. }
  74. }
  75. //添加选中
  76. for(let i=0;i<servantlist.length;i++){
  77. for(let j=0;j<servantlist[i].subjectList.length;j++){
  78. if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
  79. for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
  80. for(let u=0;u<checkedlist.length;u++){
  81. if(checkedlist[u]==servantlist[i].subjectList[j].answer[t].answer){
  82. servantlist[i].subjectList[j].answer[t].isChoose=1;
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. this.setData({
  90. servantlist: servantlist
  91. })
  92. },
  93. //问题选择单选
  94. answerselectedSingle(e){
  95. let checkedlist=e.detail.value;
  96. let servantlist=this.data.servantlist;
  97. //先做清除
  98. for(let i=0;i<servantlist.length;i++){
  99. for(let j=0;j<servantlist[i].subjectList.length;j++){
  100. if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
  101. for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
  102. servantlist[i].subjectList[j].answer[t].isChoose=0;
  103. }
  104. }
  105. }
  106. }
  107. //添加选中
  108. for(let i=0;i<servantlist.length;i++){
  109. for(let j=0;j<servantlist[i].subjectList.length;j++){
  110. if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
  111. for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
  112. for(let u=0;u<checkedlist.length;u++){
  113. if(checkedlist[u]==servantlist[i].subjectList[j].answer[t].answer){
  114. servantlist[i].subjectList[j].answer[t].isChoose=1;
  115. }
  116. else {
  117. servantlist[i].subjectList[j].answer[t].isChoose=0;
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. this.setData({
  125. servantlist: servantlist
  126. })
  127. },
  128. //自定义问题
  129. customanswer(e){
  130. console.log(e.target.dataset.id);
  131. let servantlist=this.data.servantlist;
  132. for(let i=0;i<servantlist.length;i++){
  133. for(let j=0;j<servantlist[i].subjectList.length;j++){
  134. if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
  135. servantlist[i].subjectList[j].customAnswer = e.detail.value;
  136. break;
  137. }
  138. }
  139. }
  140. this.setData({
  141. servantlist: servantlist
  142. })
  143. },
  144. //切换tab
  145. loadclasslistadd(e){
  146. let nowsubtypeNo=e.target.dataset.id;
  147. let servantlist=this.data.servantlist;
  148. //1.先清除
  149. let t=0;
  150. for(let i=0;i<servantlist.length;i++){
  151. servantlist[i].show=false;
  152. if(servantlist[i].subtypeNo==nowsubtypeNo){
  153. t=i;
  154. }
  155. }
  156. servantlist[t+1].show=true;
  157. this.setData({
  158. servantlist: servantlist
  159. })
  160. },
  161. //切换tab
  162. loadclasslist(e){
  163. let nowsubtypeNo=e.target.dataset.id;
  164. let servantlist=this.data.servantlist;
  165. //1.先清除
  166. let t=0;
  167. for(let i=0;i<servantlist.length;i++){
  168. servantlist[i].show=false;
  169. if(servantlist[i].subtypeNo==nowsubtypeNo){
  170. t=i;
  171. }
  172. }
  173. servantlist[t-1].show=true;
  174. this.setData({
  175. servantlist: servantlist
  176. })
  177. },
  178. });