add.js 8.5 KB

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