/******************************************************************************* * Copyright(c) 2022 dongke All rights reserved. / Confidential * 类的信息: * 1.程序名称: * 2.客户资料列表 * 编辑履历: * 作者 日期 版本 修改内容 * yjb 2022-0-12 1.00 *******************************************************************************/ const Constants = require('@/utils/Constants.js'); const util = require('@/utils/util.js') const mixins = require('@/mixins/index.js') const app = getApp() Page({ mixins: [mixins], /** * 页面的初始数据 */ data: { radioFollowUp: '1', routeObjName: 'cusFollow', cardList: ['main'], buttonSaveList: [{ code: 'add', title: mixins.$t('save'), width: '120rpx' }], saleChannelService: app.globalData['saleChannelService'], contentObj: { main: [ { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') }, { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true }, { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: false }, { code: 'addressNo', type: 'str', required: false, title: mixins.$t('addressNo') }, { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') }, { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') }, { code: 'nextFollowTime', type: 'remindDateTime', required: true, title: mixins.$t('nextFollowTime') }, { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', }, { code: 'file', type: 'uploader', title: mixins.$t("uploader") } ] }, table: Constants.tables.cusFollow, customerService: app.globalData['customerService'], followStatus: mixins.$t('followStatusReporting') }, /** * @desc : 设置保存参数 * @date : 2024/2/1 15:49 * @author : 于继渤 */ setParams(params) { params.followStatus = this.data.followStatus params.followType = '跟进方式-进店' params.followOrg = app.globalData.user.orgId return params }, /** * @desc : 保存数据服务 * @date : 2024/2/1 15:49 * @author : 于继渤 */ saveData() { if (this.data.formMode == Constants.formMode.edit) { return this.excute(this.data.service, this.data.service.update, this.data.params); } else { return this.excute(this.data.service, this.data.service.insert, this.data.params); } }, /** * @desc : 消息订阅方法 * @author : 刘尧 * @date : 2024/7/19 */ subscribeMessage(e) { const that = this const tmplIds = ['z3REuwft6NLPxVW8s5HN1UgWjFstWjD0QfCXNLTa0LA'] wx.getSetting({ withSubscriptions: true, success (res){ if(res.subscriptionsSetting && res.subscriptionsSetting.mainSwitch){ if(!(res.subscriptionsSetting['z3REuwft6NLPxVW8s5HN1UgWjFstWjD0QfCXNLTa0LA'] && res.subscriptionsSetting['z3REuwft6NLPxVW8s5HN1UgWjFstWjD0QfCXNLTa0LA'] !== "accept")){ // 以下内容需要绑定点击事件 目前方法无法调用 周一讨论 wx.requestSubscribeMessage({ tmplIds: tmplIds, success (res) { // console.log('消息订阅成功', res); that.save(e) }, fail(res) { // console.log('消息订阅取消', res); that.save(e) } }) }else { that.save(e) } } }, fail(res){ that.save(e) } }) }, /** * @desc : 编辑 * @date : 2024/2/1 15:49 * @author : 于继渤 */ toEdit(){ let item = JSON.parse(this.data.formData) let url = null if (item.followStatus == '跟进状态-报备' || item.followStatus == '跟进状态-接待') { url = this.data.route.toFollowStatus1.url } let _this = this; wx.navigateTo({ url: url, events: { // 保存成功后刷新页面 refresh: function (data) { // 刷新一览界面 _this.searchData(); } }, success: function (res) { let data = {} data.id = item.followId data.formMode = Constants.formMode.edit res.eventChannel.emit('params', data); } }) }, /** * @desc : 保存处理 * @date : 2024/2/1 15:49 * @author : 于继渤 */ handleData() { let pages = getCurrentPages(); let prevPage = pages[pages.length - 3]; //上二页 prevPage.setData({ refreshByAdd: true }) wx.navigateBack({ data: 2 }) }, /** * @desc : 手机号离开焦点事件 * @date : 2024/4/8 15:49 * @author : 于继渤 */ changePhoneblur(e) { let phone = e.detail.detail.detail.value if (phone) { //查询客户信息 this.getCustomerData({ cusPhone: phone }) } }, /** * @desc : 查询客户信息 * @author : 于继渤 * @date : 2024/1/23 9:16 */ getCustomerData(params) { return this.excute(this.data.customerService, this.data.customerService.selectByCondNoPage, params).then(res => { if (res.data.code == 200) { if (res.data.data.length > 0) { let formData = JSON.parse(this.data.formData) let item = res.data.data[0] formData.cusCode = item.cusCode formData.cusId = item.cusId formData.cusName = item.cusName formData.cusFromName = item.cusFromName //处理地址 formData.address = { address: item.addressFull, addressFull: item.addressFull, addressArea: item.addressArea, addressGcj02: item.addressGcj02, addressName: item.addressName, } formData.addressArea = item.addressArea formData.addressFull = item.addressFull formData.addressGcj02 = item.addressGcj02 formData.addressName = item.addressName formData.addressNo = item.addressNo this.setData({ formData: JSON.stringify(formData) }) } } }); }, /** * @desc : 顶部切换 * @date : 2024/4/8 15:49 * @author : 于继渤 */ onRadioFollowUp(e) { if (this.data.formMode == Constants.formMode.edit) { return } let detail = e.detail this.setFormContent(detail) this.setData({ radioFollowUp: detail, formData: null }) }, /** * @desc : 跳转购物车 * @date : 2024/2/1 15:49 * @author : 于继渤 */ toShopping() { //跳转购物车开单 let that = this wx.navigateTo({ url: this.data.route.toSelectGoods.url, success: function (res) { res.eventChannel.emit('params', { choose: true, item: 'inventory', formItem: that.data.formData, formType: 'customer-reception', route: '/package-sales/pages/order-billing/add/add' }) } }) }, /** * @desc : 给表单赋值 * @date : 2024/2/1 15:49 * @author : 于继渤 */ setValuesByEdit(data) { if (data.followStatus == '跟进状态-接待') { this.setData({ radioFollowUp: '2' }) this.setFormContent('2') } //处理地址 data.address = { address: data.addressFull, addressFull: data.addressFull, addressArea: data.addressArea, addressGcj02: data.addressGcj02, addressName: data.addressName, } this.setData({ formData: JSON.stringify(data) }) }, /** * @desc : 设置跟进form 字段 * @date : 2024/2/1 15:49 * @author : 于继渤 */ setFormContent(radioFollowUp) { let radioFollowUpOnelist = [ { code: 'cusName', type: 'str', required: true, title: mixins.$t('customerName') }, { code: 'cusPhone', type: 'phone', title: mixins.$t('cusPhone'), required: true }, { code: 'addressFull', type: 'address', title: mixins.$t('addressFull'), required: false }, { code: 'addressNo', type: 'str', required: false, title: mixins.$t('addressNo') }, { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') }, { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') }, { code: 'nextFollowTime', type: 'remindDateTime', required: true, title: mixins.$t('nextFollowTime') }, { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', }, { code: 'file', type: 'uploader', title: mixins.$t("uploader") } ] let radioFollowUpTwolist = [ // { code: 'intention', name: 'intentionName', type: 'drop', required: true, dropType: 'customerIntention', title: mixins.$t('intention') }, { code: 'remarks', type: 'textarea', rows: '5', required: true, showWordLimit: true, title: mixins.$t('followData') }, { code: 'stayTimeLen', name: 'stayTimeLenName', required: true, title: mixins.$t('stayTimeLen'), dropType: 'storeRetentionTime', type: 'drop', }, { code: 'file', type: 'uploader', title: mixins.$t("uploader") } ] let contentObj = this.data.contentObj let followStatus = this.data.followStatus if (radioFollowUp == '1') { followStatus = mixins.$t('followStatusReporting') contentObj.main = radioFollowUpOnelist } if (radioFollowUp == '2') { followStatus = mixins.$t('followStatusReception') contentObj.main = radioFollowUpTwolist } this.setData({ followStatus, followStatus, contentObj: contentObj }) }, /** * @desc : 页面初始化加载方法 * @date : 2024/2/1 15:49 * @author : 王英杰 */ loadInit() { this.getDefChannel() //获取默认渠道 }, /** * @desc : 设置销售渠道 * @date : 2024/2/1 15:49 * @author : 于继渤 */ getDefChannel() { this.excute(this.data.saleChannelService, this.data.saleChannelService.selectByCond, { flgDefault: true }).then(res => { if (res.data.code == 200) { let formData = JSON.parse(this.data.formData) if (res.data.data.list && res.data.data.list.length > 0) { formData.channelId = res.data.data.list[0].channelId formData.channelName = res.data.data.list[0].channelName formData.channelCode = res.data.data.list[0].channelCode } //设置默认值 this.setData({ formData: JSON.stringify(formData) }) } }) }, })