1
0

resourcepool.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. const app=getApp(),utils=require("../../../utils/http");
  2. let page=1;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. type:0,//0是已分配信息,1是手动分配
  9. cid:'',//
  10. resourceobj:{},
  11. customerlist:[],
  12. result: [],
  13. rlist:[],
  14. pooltype:1,//
  15. radio:'',
  16. weburl:''
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.setData({
  23. cid:options.rid,
  24. type:options.type
  25. })
  26. if(options.type==0){
  27. this.poolmsg();
  28. }else{
  29. this.customerfun();
  30. }
  31. this.setData({
  32. weburl:app.globalData.webUrl + 'applet.html#/resourcepool?orgid='+app.globalData.personMsg.binded.org_id+'&type='+this.data.type+'&cid='+this.data.cid+'&token=' + app.globalData.token + '&client_type=' + app.globalData.clientype,
  33. })
  34. },
  35. poolmsg:function(){
  36. const that=this;
  37. utils.$post({
  38. url: app.globalData.webUrl + 'api/crm_customer/cil_detail',
  39. header: {
  40. 'Authorization':'bearer '+app.globalData.token
  41. },
  42. data:{
  43. cilid:that.data.cid
  44. },
  45. success: function (res) {
  46. if(res.data.code=='0'){
  47. that.setData({
  48. resourceobj:res.data.data,
  49. })
  50. }
  51. }
  52. })
  53. },
  54. customerfun:function(){
  55. const that=this;
  56. page=1;
  57. utils.$post({
  58. url: app.globalData.webUrl + 'api/crm_customer/resourcepool',
  59. header: {
  60. 'Authorization':'bearer '+app.globalData.token
  61. },
  62. data:{
  63. cilid:that.data.cid,
  64. page:page,
  65. limit:15,
  66. },
  67. success: function (res) {
  68. if(res.data.code=='0'){
  69. that.setData({
  70. customerlist:res.data.data,
  71. })
  72. }
  73. }
  74. })
  75. },
  76. resoucredata:function(){
  77. const that=this;
  78. utils.$post({
  79. url: app.globalData.webUrl + "api/crm_customer/employee4resource",
  80. header: {
  81. 'Authorization':'bearer '+app.globalData.token
  82. },
  83. data:{
  84. org:app.globalData.personMsg.binded.org_id
  85. },
  86. success: function (res) {
  87. if(res.data.code=='0'){
  88. that.setData({
  89. customerlist:res.data.data
  90. })
  91. }
  92. }
  93. })
  94. },
  95. onChange(event) {
  96. this.setData({
  97. result: event.detail,
  98. });
  99. },
  100. onChanget(event) {
  101. this.setData({
  102. radio: event.detail,
  103. });
  104. },
  105. onClick(event) {
  106. const { name } = event.currentTarget.dataset;
  107. this.setData({
  108. radio: name,
  109. });
  110. },
  111. toggle(event) {
  112. const { index } = event.currentTarget.dataset;
  113. const checkbox = this.selectComponent(`.checkboxes-${index}`);
  114. checkbox.toggle();
  115. },
  116. selectap:function(e){
  117. this.setData({
  118. pooltype:e.currentTarget.dataset.type
  119. })
  120. if(e.currentTarget.dataset.type==2){
  121. this.resoucredata();
  122. }else{
  123. this.customerfun();
  124. }
  125. },
  126. noop() {},
  127. surebatchtap:function(){
  128. const that=this;
  129. wx.showModal({
  130. title: '分配提示',
  131. content: '您确定分配吗?',
  132. success (res) {
  133. if (res.confirm) {
  134. wx.showLoading({
  135. title: '分配中...',
  136. })
  137. utils.$post({
  138. url: app.globalData.webUrl + "api/crm_customer/resdistributing",
  139. header: {
  140. 'Authorization':'bearer '+app.globalData.token
  141. },
  142. data:{
  143. org_pool:'',
  144. emp_id:that.data.radio,
  145. cilid:that.data.cid,
  146. type:'toemp',
  147. targets:that.data.result.join(',')
  148. },
  149. success: function (res) {
  150. wx.hideLoading()
  151. if(res.data.code=='0'){
  152. wx.showToast({
  153. title: res.data.msg,
  154. icon: "none",
  155. duration: 2000
  156. });
  157. setTimeout(function(){
  158. wx.navigateBack()
  159. },2000)
  160. }else{
  161. wx.showToast({
  162. title: res.data.msg,
  163. icon: "none",
  164. duration: 2000
  165. });
  166. }
  167. }
  168. })
  169. }else{
  170. that.setData({
  171. batchflag:false,
  172. nowresourceid:'',
  173. result: [],
  174. })
  175. }
  176. }
  177. })
  178. },
  179. /**
  180. * 生命周期函数--监听页面初次渲染完成
  181. */
  182. onReady: function () {
  183. },
  184. /**
  185. * 生命周期函数--监听页面显示
  186. */
  187. onShow: function () {
  188. },
  189. /**
  190. * 生命周期函数--监听页面隐藏
  191. */
  192. onHide: function () {
  193. },
  194. /**
  195. * 生命周期函数--监听页面卸载
  196. */
  197. onUnload: function () {
  198. },
  199. /**
  200. * 页面相关事件处理函数--监听用户下拉动作
  201. */
  202. onPullDownRefresh: function () {
  203. },
  204. /**
  205. * 页面上拉触底事件的处理函数
  206. */
  207. onReachBottom: function () {
  208. },
  209. /**
  210. * 用户点击右上角分享
  211. */
  212. })