| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- /*******************************************************************************
- * Copyright(c) 2022 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 于继渤 2024-1-23 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: {
- routeObjName: 'customer',
- gradeCode: app.globalData.company.gradeCode,
- saleChannelService: app.globalData['saleChannelService'],
- cardList: ['main', 'center', 'remarks'],
- buttonSaveList: [{ code: 'add', title: mixins.$t('save'), width: '120rpx' }],
- 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: true },
- { code: 'addressNo', type: 'str', required: true, title: mixins.$t('addressNo') },
- { code: 'cusFrom', name: 'cusFromName', required: true, title: mixins.$t('customerSource'), type: 'choose', urlKey: 'choosecusFrom' },
- { code: 'contactName', type: 'str', required: false, title: mixins.$t('contactName') },
- { code: 'contactPhone', type: 'str', title: mixins.$t('cpPhone'), required: false },
- ],
- center: [
- { code: 'channelId', name: 'channelName', required: true, title: mixins.$t('saleChannel'), type: 'choose', urlKey: 'chooseChannel' },
- { code: 'staffId', name: 'staffName', type: 'choose', required: true, title: mixins.$t('saleStaff'), urlKey: 'chooseStaff' },
- { code: 'orgId', name: 'orgName', type: 'choose', required: true, title: mixins.$t('saleOrg'), urlKey: 'chooseOrg' },
- { code: 'initialDebt', type: 'number', required: false, title: '初始欠款' },
- ],
- remarks: [
- { code: 'remarks', type: 'textarea', title: mixins.$t('remarks') }
- ]
- },
- },
- /**
- * @desc : 选择数据源
- * @date : 2024/2/1 15:49
- * @author : 于继渤
- */
- chooseData(e) {
- let formData = JSON.parse(this.data.formData)
- let code = e.detail.code
- let data = e.detail.data.data
- if (code == "staffId") { //员工
- formData.staffId = data.id
- formData.staffName = data.name
- }
- if (code == "orgId") { //部门
- formData.orgId = data.id
- formData.orgName = data.name
- }
- //销售渠道
- if (code == 'channelId') {
- formData.channelId = data.id
- formData.channelCode = data.code
- formData.channelName = data.name
- }
- //客户来源
- if (code == 'cusFrom') {
- formData.cusFrom = data.id
- formData.cusFromCode = data.code
- formData.cusFromName = data.name
- }
- this.setData({
- formData: JSON.stringify(formData)
- })
- },
- /**
- * @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 : 给表单赋值
- * @date : 2024/2/1 15:49
- * @author : 于继渤
- */
- setValuesByEdit(data) {
- //处理地址
- data.address = {
- address: data.addressFull,
- addressFull: data.addressFull,
- addressArea: data.addressArea,
- addressGcj02: data.addressGcj02,
- addressName: data.addressName,
- }
- this.setData({
- formData: JSON.stringify(data)
- })
- },
- /**
- * @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
- }
- formData.staffId = app.globalData.user.staffId
- formData.staffName = app.globalData.user.staffName
- formData.orgId = app.globalData.user.orgId
- formData.orgName = app.globalData.user.orgName
- //设置默认值
- this.setData({
- formData: JSON.stringify(formData)
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- loadInit(options) {
- //TODO 销售渠道默认 零售 ,销售部门销售员工默认当前登录人的
- let contentObj = this.data.contentObj
- if (this.data.gradeCode == Constants.gradeCode.STD) {
- 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: true },
- { code: 'addressNo', type: 'str', required: true, title: mixins.$t('addressNo') },
- // { code: 'cusFrom', name: 'cusFromName', required: true, title: mixins.$t('customerSource'), type: 'choose', urlKey: 'choosecusFrom' },
- { code: 'contactName', type: 'str', required: false, title: mixins.$t('contactName') },
- { code: 'contactPhone', type: 'str', title: mixins.$t('cpPhone'), required: false },
- ]
- } else if (this.data.gradeCode == Constants.gradeCode.PRO) {
- 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: true },
- { code: 'addressNo', type: 'str', required: true, title: mixins.$t('addressNo') },
- { code: 'cusFrom', name: 'cusFromName', required: false, title: mixins.$t('customerSource'), type: 'choose', urlKey: 'choosecusFrom' },
- { code: 'contactName', type: 'str', required: false, title: mixins.$t('contactName') },
- { code: 'contactPhone', type: 'str', title: mixins.$t('cpPhone'), required: false },
- ]
- }
- this.setData({
- contentObj: contentObj
- })
- if (this.data.formMode == Constants.formMode.edit) {
- wx.setNavigationBarTitle({
- title: mixins.$t('editCus'),
- })
- } else {
- //设置默认值
- this.getDefChannel()
- }
- },
- })
|