myCustomerList.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import request from '../../../util/http'
  2. import apiUrl from '../../../util/apiUrl'
  3. var app = getApp();
  4. Page({
  5. data: {
  6. listShow:false,//是否有多个客户
  7. noCustomerList:false,
  8. unSetModal:false,//未设置服务者提醒
  9. unSetBtn: [
  10. { text: '现在关联', extClass: 'buttonBold' },
  11. { text: '暂不' },
  12. ],
  13. editModalShow:false,//编辑弹框
  14. customerName:'',//编辑客户姓名输入
  15. buttonFooter:[
  16. { text: '取消' },
  17. { text: '确定', extClass: 'buttonBold' },
  18. ],
  19. bindModalShow:false,//关联雇主弹框
  20. bindCode:'',
  21. bindName:'',
  22. customerList:[
  23. ],
  24. emReNo:''//编辑信息的雇佣关系编号
  25. },
  26. onLoad() {
  27. // this.initCustomerList();
  28. },
  29. onShow(){
  30. this.initCustomerList();
  31. },
  32. initCustomerList(){
  33. let params={
  34. "servantId":app.globalData.userInfo.id,
  35. "pageNo": 1,
  36. "pageSize": 100,
  37. }
  38. request.httpServicePost(apiUrl.findByServantIdListPath,params).then(data=>{
  39. console.log(data);
  40. if(data.dataList.length==0){
  41. this.setData({
  42. listShow:false,
  43. noCustomerList:true,
  44. unSetModal:true,
  45. });
  46. }else{
  47. this.setData({
  48. listShow:true,
  49. noCustomerList:false,
  50. unSetModal:false,
  51. customerList:data.dataList
  52. });
  53. // my.alert({
  54. // content:JSON.stringify(data.dataList)
  55. // });
  56. }
  57. }).catch(e=>{
  58. console.log(e);
  59. })
  60. },
  61. editCustomer(e){
  62. console.log(e);
  63. this.setData({
  64. editModalShow:true,
  65. // customerName:e.target.dataset.emName,
  66. emReNo:e.target.dataset.emReNo,
  67. });
  68. },
  69. onModalClose(e){
  70. console.log(e.target);
  71. if(e.target.dataset.index==0){
  72. this.setData({
  73. editModalShow: false,
  74. });
  75. }else{
  76. // 保存客户姓名
  77. this.editEmployerSubmit();
  78. }
  79. },
  80. // 编辑雇主提交
  81. editEmployerSubmit(){
  82. let params={
  83. "employerName":this.data.customerName,
  84. "employRelationNo": this.data.emReNo,
  85. }
  86. request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{
  87. console.log(data);
  88. this.setData({
  89. editModalShow: false,
  90. });
  91. my.showToast({
  92. content: '修改成功',
  93. });
  94. // 修改成功后刷新页面
  95. this.initCustomerList();
  96. }).catch(e=>{
  97. console.log(e);
  98. })
  99. },
  100. bindKeyInput(e) {
  101. this.setData({
  102. customerName: e.detail.value,
  103. });
  104. console.log(this.data.customerName);
  105. },
  106. bindCodeInput(e) {
  107. this.setData({
  108. bindCode: e.detail.value,
  109. });
  110. console.log(this.data.bindCode);
  111. },
  112. bindNameInput(e) {
  113. this.setData({
  114. bindName: e.detail.value,
  115. });
  116. },
  117. // 添加新客户
  118. bindNewCustomer(){
  119. this.setData({
  120. bindModalShow: true,
  121. bindCode:'',
  122. bindName:''
  123. });
  124. },
  125. onBindModalClose(e){
  126. console.log(e.target);
  127. if(e.target.dataset.index==0){
  128. this.setData({
  129. bindModalShow: false,
  130. });
  131. }else{
  132. // 关联雇主
  133. if(this.data.bindCode==''){
  134. my.alert({
  135. content:'请输入关联码'
  136. });
  137. }else if(this.data.bindName==''){
  138. my.alert({
  139. content:'请输入雇主称呼'
  140. });
  141. }else{
  142. this.bindNow();
  143. }
  144. }
  145. },
  146. // 进入工作台
  147. enterServantCenter(e){
  148. let emReNo=e.target.dataset.emReNo;
  149. my.navigateTo({
  150. url: '../servantCenter/servantCenter?emReNo='+emReNo
  151. });
  152. },
  153. bindNow(){
  154. let params={
  155. "servantId":app.globalData.userInfo.id,
  156. "employerName":this.data.bindName,
  157. "employIdentifier": this.data.bindCode,
  158. }
  159. request.httpServicePost(apiUrl.relationEmployerPath,params).then(data=>{
  160. console.log(data);
  161. this.setData({
  162. bindModalShow: false,
  163. });
  164. my.showToast({
  165. content: '关联成功',
  166. });
  167. // 关联成功后刷新页面
  168. this.initCustomerList();
  169. }).catch(e=>{
  170. console.log(e);
  171. })
  172. },
  173. enterServantCenter(e){
  174. let emReNo=e.target.dataset.emReNo;
  175. my.navigateTo({ url: '../servantCenter/servantCenter?emReNo='+emReNo });
  176. },
  177. // 点击设置按钮
  178. onSetButtonClick(e){
  179. console.log(e.target);
  180. if(e.target.dataset.index==0){
  181. this.setData({
  182. unSetModal: false,
  183. bindModalShow:true,
  184. bindCode:'',
  185. bindName:''
  186. });
  187. }else{
  188. this.setData({
  189. unSetModal: false
  190. });
  191. }
  192. },
  193. // 切换角色
  194. switchRole(){
  195. my.navigateTo({ url: '../../common/selectRole/selectRole' });
  196. }
  197. });