takeOrder.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp();
  4. const util = require('../../../utils/jmsUtil.js');
  5. const api = require('../../../api/jms.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. serviceId:'',
  10. keywords:'',
  11. wholeList:[],
  12. workerList:[],
  13. workerId:'',
  14. scrollShow:false,
  15. orderInfo:{
  16. changeReason:{
  17. label: '请选择(必填)',
  18. value:''
  19. },
  20. },
  21. selectValue:'',
  22. selectVisible:false,
  23. selectKey:'',
  24. },
  25. // 事件处理函数
  26. onLoad(options) {
  27. if(options.serviceid){
  28. this.setData({
  29. serviceId:options.serviceid
  30. });
  31. }
  32. this.getWorkerList();
  33. },
  34. getWorkerList(){
  35. util.request(api.ServiceOrderPerson, {
  36. pageNo: 1, pageSize: 1000
  37. }, 'POST').then(res=>{
  38. if (res.errno == 0) {
  39. this.setData({
  40. wholeList:res.data.list,
  41. workerList:res.data.list,
  42. });
  43. }else{
  44. wx.showToast({
  45. title: res.errmsg,
  46. icon:'none'
  47. })
  48. }
  49. });
  50. },
  51. inputClue(e){
  52. let obj=e.currentTarget.dataset.obj;
  53. let item=`clueInfo.${obj}`;
  54. this.setData({
  55. [item]:e.detail.value
  56. });
  57. // console.log(this.data.clueInfo);
  58. },
  59. selectClue(e){
  60. let obj=e.currentTarget.dataset.obj;
  61. this.setData({
  62. selectKey:obj,
  63. selectVisible:true
  64. });
  65. console.log(this.data.selectKey);
  66. },
  67. onPickerConfirm(e){
  68. console.log(e);
  69. let obj={
  70. label:e.detail.value.text,
  71. value:e.detail.value.value
  72. }
  73. this.setData({
  74. 'orderInfo.changeReason':obj,
  75. selectVisible:false
  76. });
  77. },
  78. onPickerCancel(){
  79. this.setData({
  80. selectVisible:true
  81. });
  82. },
  83. inputWorker(e){
  84. // console.log(e);
  85. let keyworks=e.detail.value;
  86. let list=this.data.wholeList;
  87. let newList=[];
  88. if(keyworks==''){
  89. newList=this.data.wholeList;
  90. this.setData({
  91. workerId:''
  92. });
  93. }else{
  94. list.forEach(item=>{
  95. if(item.name.indexOf(keyworks)>-1){
  96. newList.push(item);
  97. }
  98. });
  99. }
  100. this.setData({
  101. workerList:newList
  102. });
  103. },
  104. selectWorker(){
  105. this.setData({
  106. scrollShow:true
  107. });
  108. },
  109. workerTap(e){
  110. let id=e.currentTarget.dataset.id;
  111. let name=e.currentTarget.dataset.name;
  112. this.setData({
  113. workerId:id,
  114. keywords:name,
  115. scrollShow:false,
  116. })
  117. },
  118. confTap(){
  119. if(this.data.workerId==''){
  120. wx.showToast({
  121. title: '请选择服务者',
  122. icon:'none'
  123. });
  124. }else{
  125. wx.showLoading({
  126. title: '加载中',
  127. })
  128. let params={
  129. serviceId: this.data.serviceId,
  130. tempWorkerId: this.data.workerId,
  131. }
  132. util.request(api.SelectServiceOrderPerson,
  133. params
  134. , 'POST').then(res=>{
  135. wx.hideLoading();
  136. if (res.errno == 0) {
  137. wx.showModal({
  138. title: '提示',
  139. content: '操作成功',
  140. showCancel:false,
  141. complete: (res) => {
  142. if (res.cancel) {
  143. }
  144. if (res.confirm) {
  145. wx.navigateBack({
  146. delta:1
  147. });
  148. }
  149. }
  150. })
  151. }else{
  152. wx.showToast({
  153. title: res.errmsg,
  154. icon:'none'
  155. })
  156. }
  157. }).catch(err=>{
  158. wx.hideLoading();
  159. });
  160. }
  161. },
  162. })