add.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.followType = '跟进方式-进店'
  49. params.followOrg = app.globalData.user.orgId
  50. return params
  51. },
  52. /**
  53. * @desc : 保存数据服务
  54. * @date : 2024/2/1 15:49
  55. * @author : 于继渤
  56. */
  57. saveData() {
  58. if (this.data.formMode == Constants.formMode.edit) {
  59. return this.excute(this.data.service, this.data.service.update, this.data.params);
  60. } else {
  61. return this.excute(this.data.service, this.data.service.insert, this.data.params);
  62. }
  63. },
  64. /**
  65. * @desc : 编辑
  66. * @date : 2024/2/1 15:49
  67. * @author : 于继渤
  68. */
  69. toEdit(){
  70. let item = JSON.parse(this.data.formData)
  71. let url = null
  72. if (item.followStatus == '跟进状态-报备' || item.followStatus == '跟进状态-接待') {
  73. url = this.data.route.toFollowStatus1.url
  74. }
  75. let _this = this;
  76. wx.navigateTo({
  77. url: url,
  78. events: {
  79. // 保存成功后刷新页面
  80. refresh: function (data) {
  81. // 刷新一览界面
  82. _this.searchData();
  83. }
  84. },
  85. success: function (res) {
  86. let data = {}
  87. data.id = item.followId
  88. data.formMode = Constants.formMode.edit
  89. res.eventChannel.emit('params', data);
  90. }
  91. })
  92. },
  93. /**
  94. * @desc : 保存处理
  95. * @date : 2024/2/1 15:49
  96. * @author : 于继渤
  97. */
  98. handleData() {
  99. let pages = getCurrentPages();
  100. let prevPage = pages[pages.length - 3]; //上二页
  101. prevPage.setData({
  102. refreshByAdd: true
  103. })
  104. wx.navigateBack({
  105. data: 2
  106. })
  107. },
  108. /**
  109. * @desc : 手机号离开焦点事件
  110. * @date : 2024/4/8 15:49
  111. * @author : 于继渤
  112. */
  113. changePhoneblur(e) {
  114. let phone = e.detail.detail.detail.value
  115. if (phone) {
  116. //查询客户信息
  117. this.getCustomerData({ cusPhone: phone })
  118. }
  119. },
  120. /**
  121. * @desc : 查询客户信息
  122. * @author : 于继渤
  123. * @date : 2024/1/23 9:16
  124. */
  125. getCustomerData(params) {
  126. return this.excute(this.data.customerService, this.data.customerService.selectByCondNoPage, params).then(res => {
  127. if (res.data.code == 200) {
  128. if (res.data.data.length > 0) {
  129. let formData = JSON.parse(this.data.formData)
  130. let item = res.data.data[0]
  131. formData.cusCode = item.cusCode
  132. formData.cusId = item.cusId
  133. formData.cusName = item.cusName
  134. formData.cusFromName = item.cusFromName
  135. //处理地址
  136. formData.address = {
  137. address: item.addressFull,
  138. addressFull: item.addressFull,
  139. addressArea: item.addressArea,
  140. addressGcj02: item.addressGcj02,
  141. addressName: item.addressName,
  142. }
  143. formData.addressArea = item.addressArea
  144. formData.addressFull = item.addressFull
  145. formData.addressGcj02 = item.addressGcj02
  146. formData.addressName = item.addressName
  147. formData.addressNo = item.addressNo
  148. this.setData({
  149. formData: JSON.stringify(formData)
  150. })
  151. }
  152. }
  153. });
  154. },
  155. /**
  156. * @desc : 顶部切换
  157. * @date : 2024/4/8 15:49
  158. * @author : 于继渤
  159. */
  160. onRadioFollowUp(e) {
  161. if (this.data.formMode == Constants.formMode.edit) {
  162. return
  163. }
  164. let detail = e.detail
  165. this.setFormContent(detail)
  166. this.setData({
  167. radioFollowUp: detail,
  168. formData: null
  169. })
  170. console.log('onRadioFollowUp', e.detail)
  171. },
  172. /**
  173. * @desc : 跳转购物车
  174. * @date : 2024/2/1 15:49
  175. * @author : 于继渤
  176. */
  177. toShopping() {
  178. //跳转购物车开单
  179. let that = this
  180. wx.navigateTo({
  181. url: this.data.route.toSelectGoods.url,
  182. success: function (res) {
  183. res.eventChannel.emit('params', { choose: true, item: 'sale', formItem: that.data.formData, formType: 'customer-reception', route: '/package-sales/pages/order-billing/add/add' })
  184. }
  185. })
  186. },
  187. /**
  188. * @desc : 给表单赋值
  189. * @date : 2024/2/1 15:49
  190. * @author : 于继渤
  191. */
  192. setValuesByEdit(data) {
  193. console.log(data)
  194. if (data.followStatus == '跟进状态-接待') {
  195. this.setData({
  196. radioFollowUp: '2'
  197. })
  198. this.setFormContent('2')
  199. }
  200. //处理地址
  201. data.address = {
  202. address: data.addressFull,
  203. addressFull: data.addressFull,
  204. addressArea: data.addressArea,
  205. addressGcj02: data.addressGcj02,
  206. addressName: data.addressName,
  207. }
  208. this.setData({
  209. formData: JSON.stringify(data)
  210. })
  211. },
  212. /**
  213. * @desc : 设置跟进form 字段
  214. * @date : 2024/2/1 15:49
  215. * @author : 于继渤
  216. */
  217. setFormContent(radioFollowUp) {
  218. let radioFollowUpOnelist = [
  219. { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') },
  220. { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true },
  221. { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: false },
  222. { code: 'addressNo', type: 'str', required: false, title: mixins.$t('addressNo') },
  223. { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') },
  224. { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') },
  225. { code: 'nextFollowTime', type: 'dateTime', required: true, title: mixins.$t('nextFollowTime') },
  226. { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', },
  227. { code: 'file', type: 'uploader', title: mixins.$t("uploader") }
  228. ]
  229. let radioFollowUpTwolist = [
  230. // { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') },
  231. { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') },
  232. { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', },
  233. { code: 'file', type: 'uploader', title: mixins.$t("uploader") }
  234. ]
  235. let contentObj = this.data.contentObj
  236. let followStatus = this.data.followStatus
  237. if (radioFollowUp == '1') {
  238. followStatus = mixins.$t('followStatusReporting')
  239. contentObj.main = radioFollowUpOnelist
  240. }
  241. if (radioFollowUp == '2') {
  242. followStatus = mixins.$t('followStatusReception')
  243. contentObj.main = radioFollowUpTwolist
  244. }
  245. this.setData({
  246. followStatus, followStatus,
  247. contentObj: contentObj
  248. })
  249. }
  250. })