add.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 于继渤 2024-1-23 1.00 客户档案新增
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const util = require('@/utils/util.js')
  11. const mixins = require('@/mixins/index.js')
  12. const app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. routeObjName: 'customer',
  20. cardList: ['main', 'center', 'remarks'],
  21. buttonSaveList: [{ code: 'add', title: mixins.$t('save'), width: '120rpx' }],
  22. contentObj: {
  23. main: [
  24. { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') },
  25. { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true },
  26. { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: true },
  27. { code: 'addressNo', type: 'str', required: true, title: mixins.$t('addressNo') },
  28. { code: 'cusFrom', name: 'cusFromName', required: true, title: mixins.$t('customerSource'), type: 'choose', urlKey: 'choosecusFrom' },
  29. { code: 'contactName', type: 'str', required: false, title: mixins.$t('contactName') },
  30. { code: 'contactPhone', type: 'str', title: mixins.$t('cpPhone'), required: false },
  31. ],
  32. center: [
  33. { code: 'channelId', name: 'channelName', required: true, title: mixins.$t('saleChannel'), type: 'choose', urlKey: 'chooseChannel' },
  34. { code: 'staffId', name: 'staffName', type: 'choose', required: true, title: mixins.$t('saleStaff'), urlKey: 'chooseStaff' },
  35. { code: 'orgId', name: 'orgName', type: 'choose', required: true, title: mixins.$t('saleOrg'), urlKey: 'chooseOrg' },
  36. { code: 'initialDebt', type: 'number', required: false, title:'初始欠款' },
  37. ],
  38. remarks: [
  39. { code: 'remarks', type: 'textarea', title: mixins.$t('remarks') }
  40. ]
  41. },
  42. },
  43. /**
  44. * @desc : 选择数据源
  45. * @date : 2024/2/1 15:49
  46. * @author : 于继渤
  47. */
  48. chooseData(e) {
  49. let formData = JSON.parse(this.data.formData)
  50. let code = e.detail.code
  51. let data = e.detail.data.data
  52. if (code == "staffId") { //员工
  53. formData.staffId = data.id
  54. formData.staffName = data.name
  55. }
  56. if (code == "orgId") { //部门
  57. formData.orgId = data.id
  58. formData.orgName = data.name
  59. }
  60. //销售渠道
  61. if (code == 'channelId') {
  62. formData.channelId = data.id
  63. formData.channelCode = data.code
  64. formData.channelName = data.name
  65. }
  66. //客户来源
  67. if (code == 'cusFrom') {
  68. formData.cusFrom = data.id
  69. formData.cusFromCode = data.code
  70. formData.cusFromName = data.name
  71. }
  72. this.setData({
  73. formData: JSON.stringify(formData)
  74. })
  75. },
  76. /**
  77. * @desc : 保存数据服务
  78. * @date : 2024/2/1 15:49
  79. * @author : 于继渤
  80. */
  81. saveData() {
  82. if (this.data.formMode == Constants.formMode.edit) {
  83. return this.excute(this.data.service, this.data.service.update, this.data.params);
  84. } else {
  85. return this.excute(this.data.service, this.data.service.insert, this.data.params);
  86. }
  87. },
  88. /**
  89. * @desc : 给表单赋值
  90. * @date : 2024/2/1 15:49
  91. * @author : 于继渤
  92. */
  93. setValuesByEdit(data) {
  94. //处理地址
  95. data.address = {
  96. address: data.addressFull,
  97. addressFull: data.addressFull,
  98. addressArea: data.addressArea,
  99. addressGcj02: data.addressGcj02,
  100. addressName: data.addressName,
  101. }
  102. this.setData({
  103. formData: JSON.stringify(data)
  104. })
  105. },
  106. /**
  107. * 生命周期函数--监听页面加载
  108. */
  109. loadInit(options) {
  110. //TODO 销售渠道默认 零售 ,销售部门销售员工默认当前登录人的
  111. if (this.data.formMode == Constants.formMode.edit) {
  112. wx.setNavigationBarTitle({
  113. title: mixins.$t('editCus'),
  114. })
  115. }
  116. },
  117. })