add.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.客户资料列表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * yjb 2022-0-12 1.00
  9. *******************************************************************************/
  10. const Constants = require('@/utils/Constants.js');
  11. const util = require('@/utils/util.js')
  12. const mixins = require('@/mixins/index.js')
  13. const app = getApp()
  14. Page({
  15. mixins: [mixins],
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. radioFollowUp: '1',
  21. routeObjName: 'cusFollow',
  22. cardList: ['main'],
  23. buttonSaveList: [{ code: 'add', title: mixins.$t('save'), width: '120rpx' }],
  24. contentObj: {
  25. main: [
  26. { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') },
  27. { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true },
  28. { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: false },
  29. { code: 'addressNo', type: 'str', required: false, title: mixins.$t('addressNo') },
  30. { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') },
  31. { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') },
  32. { code: 'nextFollowTime', type: 'dateTime', required: true, title: mixins.$t('nextFollowTime') },
  33. { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', },
  34. { code: 'file', type: 'uploader', title: mixins.$t("uploader") }
  35. ]
  36. },
  37. table: Constants.tables.cusFollow,
  38. customerService: app.globalData['customerService'],
  39. followStatus: mixins.$t('followStatusReporting')
  40. },
  41. /**
  42. * @desc : 设置保存参数
  43. * @date : 2024/2/1 15:49
  44. * @author : 于继渤
  45. */
  46. setParams(params) {
  47. params.followStatus = this.data.followStatus
  48. params.followOrg = app.globalData.user.orgId
  49. return params
  50. },
  51. /**
  52. * @desc : 保存数据服务
  53. * @date : 2024/2/1 15:49
  54. * @author : 于继渤
  55. */
  56. saveData() {
  57. return this.excute(this.data.service, this.data.service.insert, this.data.params);
  58. },
  59. /**
  60. * @desc : 手机号离开焦点事件
  61. * @date : 2024/4/8 15:49
  62. * @author : 于继渤
  63. */
  64. changePhoneblur(e) {
  65. let phone = e.detail.detail.detail.value
  66. if (phone) {
  67. //查询客户信息
  68. this.getCustomerData({ cusPhone: phone })
  69. }
  70. },
  71. /**
  72. * @desc : 查询客户信息
  73. * @author : 于继渤
  74. * @date : 2024/1/23 9:16
  75. */
  76. getCustomerData(params) {
  77. return this.excute(this.data.customerService, this.data.customerService.selectByCondNoPage, params).then(res => {
  78. if (res.data.code == 200) {
  79. if (res.data.data.length > 0) {
  80. let formData = JSON.parse(this.data.formData)
  81. let item = res.data.data[0]
  82. formData.cusCode = item.cusCode
  83. formData.cusId = item.cusId
  84. formData.cusName = item.cusName
  85. formData.cusFromName = item.cusFromName
  86. //处理地址
  87. formData.address = {
  88. address: item.addressFull,
  89. addressFull: item.addressFull,
  90. addressArea: item.addressArea,
  91. addressGcj02: item.addressGcj02,
  92. addressName: item.addressName,
  93. }
  94. formData.addressArea = item.addressArea
  95. formData.addressFull = item.addressFull
  96. formData.addressGcj02 = item.addressGcj02
  97. formData.addressName = item.addressName
  98. formData.addressNo = item.addressNo
  99. this.setData({
  100. formData: JSON.stringify(formData)
  101. })
  102. }
  103. }
  104. });
  105. },
  106. /**
  107. * @desc : 顶部切换
  108. * @date : 2024/4/8 15:49
  109. * @author : 于继渤
  110. */
  111. onRadioFollowUp(e) {
  112. let detail = e.detail
  113. this.setFormContent(detail)
  114. this.setData({
  115. radioFollowUp: detail,
  116. formData: null
  117. })
  118. console.log('onRadioFollowUp', e.detail)
  119. },
  120. /**
  121. * @desc : 跳转购物车
  122. * @date : 2024/2/1 15:49
  123. * @author : 于继渤
  124. */
  125. toShopping(){
  126. },
  127. /**
  128. * @desc : 设置跟进form 字段
  129. * @date : 2024/2/1 15:49
  130. * @author : 于继渤
  131. */
  132. setFormContent(radioFollowUp) {
  133. let radioFollowUpOnelist = [
  134. { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') },
  135. { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true },
  136. { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: false },
  137. { code: 'addressNo', type: 'str', required: false, title: mixins.$t('addressNo') },
  138. { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') },
  139. { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') },
  140. { code: 'nextFollowTime', type: 'dateTime', required: true, title: mixins.$t('nextFollowTime') },
  141. { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', },
  142. { code: 'file', type: 'uploader', title: mixins.$t("uploader") }
  143. ]
  144. let radioFollowUpTwolist = [
  145. { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') },
  146. { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') },
  147. { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', },
  148. { code: 'file', type: 'uploader', title: mixins.$t("uploader") }
  149. ]
  150. let contentObj = this.data.contentObj
  151. let followStatus = this.data.followStatus
  152. if (radioFollowUp == '1') {
  153. followStatus = mixins.$t('followStatusReporting')
  154. contentObj.main = radioFollowUpOnelist
  155. }
  156. if (radioFollowUp == '2') {
  157. followStatus = mixins.$t('followStatusReception')
  158. contentObj.main = radioFollowUpTwolist
  159. }
  160. this.setData({
  161. followStatus, followStatus,
  162. contentObj: contentObj
  163. })
  164. }
  165. })