servantsettings.js 5.7 KB

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