You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1350 lines
46 KiB
1350 lines
46 KiB
<!--编辑客户-->
|
|
<template>
|
|
<view class="assemble">
|
|
<fui-segmented-control style="padding-top: 30rpx;" :values="optionTable" :current="(Number(optionTableId))"
|
|
type="text" activeColor="#29d3b4" color="#fff" @click="segmented">
|
|
</fui-segmented-control>
|
|
|
|
<!-- 基础信息 -->
|
|
<view v-if="optionTableId == 0" style="margin-top: 20rpx;">
|
|
<view class="form-style">
|
|
<fui-form ref="form" top="0" :model="formData" :show="false">
|
|
<view class="title" style="margin-top: 20rpx; display: flex; justify-content: space-between; align-items: center;">
|
|
<text>基础信息</text>
|
|
<view @click="viewEditLog" style="color: #29d3b4; font-size: 28rpx;">
|
|
查看修改记录
|
|
</view>
|
|
</view>
|
|
<view class="input-style">
|
|
<!-- 姓名 -->
|
|
<fui-form-item label="姓名" labelSize='26' prop="name" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-input :borderBottom="false" :padding="[0]" placeholder="点击填写" v-model="formData.name" backgroundColor="#434544" size="26" color="#fff"></fui-input>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 联系电话 -->
|
|
<fui-form-item label="联系电话" labelSize='26' prop="phone_number" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-input :borderBottom="false" :padding="[0]" placeholder="点击填写" v-model="formData.phone_number" backgroundColor="#434544" size="26" color="#fff" @blur="handlePhoneBlur"></fui-input>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 校区 -->
|
|
<fui-form-item label="校区" labelSize='26' prop="campus" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('campus')">
|
|
{{ formData.campus ? picker_config.campus.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 来源 -->
|
|
<fui-form-item label="来源" labelSize='26' prop="source" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('source')">
|
|
{{ formData.source ? picker_config.source.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 来源渠道 -->
|
|
<fui-form-item
|
|
v-if="formData.source == 1"
|
|
label="来源渠道"
|
|
labelSize='26'
|
|
prop="source_channel"
|
|
background='#434544'
|
|
labelColor='#fff'
|
|
:bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('source_channel')">
|
|
{{ formData.source_channel ? picker_config.source_channel.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 年龄 -->
|
|
<fui-form-item label="年龄" labelSize='26' prop="age" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-input :borderBottom="false" :padding="[0]" placeholder="请输入年龄" v-model="formData.age" backgroundColor="#434544" size="26" color="#fff" type="digit"></fui-input>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 客户初步意向度 -->
|
|
<fui-form-item label="客户初步意向度" labelWidth="240" labelSize='26' prop="initial_intent" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('initial_intent')">
|
|
{{ formData.initial_intent ? picker_config.initial_intent.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 性别 -->
|
|
<fui-form-item label="性别" labelSize='26' prop="gender" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-radio-group name="radio" v-model="formData.gender" @change="changeSex">
|
|
<view class="fui-list__item" style="display: flex;justify-content: flex-end;">
|
|
<fui-label>
|
|
<view class="fui-align__center">
|
|
<fui-radio value="male" checked></fui-radio>
|
|
<text class="fui-text">男</text>
|
|
</view>
|
|
</fui-label>
|
|
<fui-label :margin="['0','0','0','40rpx']">
|
|
<view class="fui-align__center">
|
|
<fui-radio value="female"></fui-radio>
|
|
<text class="fui-text">女</text>
|
|
</view>
|
|
</fui-label>
|
|
</view>
|
|
</fui-radio-group>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 资源是否有效 -->
|
|
<fui-form-item label="资源是否有效" labelSize='26' label-width="200" prop="is_valid" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-radio-group name="radio" v-model="formData.efficacious">
|
|
<view class="fui-list__item" style="display: flex;justify-content: flex-end;">
|
|
<fui-label>
|
|
<view class="fui-align__center">
|
|
<fui-radio :value="1" checked></fui-radio>
|
|
<text class="fui-text">是</text>
|
|
</view>
|
|
</fui-label>
|
|
<fui-label :margin="['0','0','0','40rpx']">
|
|
<view class="fui-align__center">
|
|
<fui-radio :value="0"></fui-radio>
|
|
<text class="fui-text">否</text>
|
|
</view>
|
|
</fui-label>
|
|
</view>
|
|
</fui-radio-group>
|
|
</view>
|
|
</fui-form-item>
|
|
</view>
|
|
<!-- 添加底部安全区 -->
|
|
<view class="safe-area-bottom"></view>
|
|
</fui-form>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 电话六要素 -->
|
|
<view v-if="optionTableId == 1" style="margin-top: 20rpx;">
|
|
<view class="form-style">
|
|
<fui-form ref="form" top="0" :model="formData" :show="false">
|
|
<view class="title" style="margin-top: 20rpx; display: flex; justify-content: space-between; align-items: center;">
|
|
<text>六要素信息</text>
|
|
<view @click="viewEditLog" style="color: #29d3b4; font-size: 28rpx;">
|
|
查看修改记录
|
|
</view>
|
|
</view>
|
|
<view class="input-style">
|
|
<!-- 需求 -->
|
|
<fui-form-item label="一、需求" labelSize='26' prop="demand" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-input :borderBottom="false" :padding="[0]" placeholder="点击填写" v-model="formData.demand" backgroundColor="#434544" size="26" color="#fff" ></fui-input>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 购买力 -->
|
|
<fui-form-item label="二、购买力" labelSize='26' prop="purchasing_power" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('purchasing_power')">
|
|
{{ formData.purchasing_power ? picker_config.purchasing_power.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 认知理念 -->
|
|
<fui-form-item label="三、认知理念" label-width="210" labelSize='26' prop="cognitive_idea" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('cognitive_idea')">
|
|
{{ formData.cognitive_idea ? picker_config.cognitive_idea.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<view style="color: #ffffff;width: 100%;text-align: left;margin: 10px;">
|
|
四、时间/距离
|
|
</view>
|
|
<!-- 可选上课时间 -->
|
|
<fui-form-item labelWidth="240" label="1、可选上课时间" labelSize='26' prop="optional_class_time" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-input :borderBottom="false" :padding="[0]" placeholder="填写可选上课时间" v-model="formData.optional_class_time" backgroundColor="#434544" size="26" color="#fff" ></fui-input>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 承诺到访时间 -->
|
|
<fui-form-item labelWidth="240" label="2、承诺到访时间" labelSize='26' prop="promised_visit_time" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openDateTime('promised_visit_time')">
|
|
{{ formData.promised_visit_time ? formData.promised_visit_time : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 距离 -->
|
|
<fui-form-item label="3、距离" label-width="210" labelSize='26' prop="distance" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('distance')">
|
|
{{ formData.distance ? picker_config.distance.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 决策人 -->
|
|
<fui-form-item label="五、决策人" labelSize='26' prop="decision_maker" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('decision_maker')">
|
|
{{ formData.decision_maker ? picker_config.decision_maker.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 情感粘度 -->
|
|
<fui-form-item label="六、情感粘度" label-width="210" labelSize='26' prop="emotional_stickiness_score" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('emotional_stickiness_score')">
|
|
{{ formData.emotional_stickiness_score ? picker_config.emotional_stickiness_score.text : '点击选择' }}
|
|
</view>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 是否加微信 -->
|
|
<fui-form-item label="是否加微信" labelSize='26' prop="call_intent" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-radio-group name="radio" v-model="formData.call_intent">
|
|
<view class="fui-list__item" style="display: flex;justify-content: flex-end;">
|
|
<fui-label>
|
|
<view class="fui-align__center">
|
|
<fui-radio value="1" checked></fui-radio>
|
|
<text class="fui-text">是</text>
|
|
</view>
|
|
</fui-label>
|
|
<fui-label :margin="['0','0','0','40rpx']">
|
|
<view class="fui-align__center">
|
|
<fui-radio value="2"></fui-radio>
|
|
<text class="fui-text">否</text>
|
|
</view>
|
|
</fui-label>
|
|
</view>
|
|
</fui-radio-group>
|
|
</view>
|
|
</fui-form-item>
|
|
|
|
<!-- 沟通备注 -->
|
|
<fui-form-item label="沟通备注" labelSize='26' prop="communication" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-textarea v-model="formData.communication" placeholder="点击填写" backgroundColor="#434544" size="26" color="#fff" :borderTop="false" :isCounter="true" :maxlength="500" :minHeight="250" :isAutoHeight="true"></fui-textarea>
|
|
</view>
|
|
</fui-form-item>
|
|
</view>
|
|
<!-- 添加底部安全区 -->
|
|
<view class="safe-area-bottom"></view>
|
|
</fui-form>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 面咨记录 -->
|
|
<view v-if="optionTableId == 2" style="margin-top: 20rpx;">
|
|
<view class="form-style">
|
|
<fui-form ref="form" top="0" :model="formData" :show="false">
|
|
<view class="title" style="margin-top: 20rpx;">跟进与面咨</view>
|
|
<view class="input-style">
|
|
<!-- 一访时间 -->
|
|
<fui-form-item label="一访时间" labelSize='26' prop="first_visit_time" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openDate('first_visit_time')">
|
|
{{ formData.first_visit_time ? formData.first_visit_time : '点击选择' }}
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 一访情况 -->
|
|
<fui-form-item label="一访情况" labelSize='26' prop="first_visit_status" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="textarea-container">
|
|
<fui-textarea v-model="formData.first_visit_status" placeholder="点击填写" backgroundColor="#434544" size="26" color="#fff" :textareaBorder="false" :isCounter="true" :maxlength="500" :minHeight="120" :isAutoHeight="true" :borderTop="false"></fui-textarea>
|
|
</view>
|
|
</fui-form-item>
|
|
|
|
<!-- 二访时间 -->
|
|
<fui-form-item label="二访时间" labelSize='26' prop="second_visit_time" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;" @click="openDate('second_visit_time')">
|
|
{{ formData.second_visit_time ? formData.second_visit_time : '点击选择' }}
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 二访情况 -->
|
|
<fui-form-item label="二访情况" labelSize='26' prop="second_visit_status" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="textarea-container">
|
|
<fui-textarea v-model="formData.second_visit_status" placeholder="点击填写" backgroundColor="#434544" size="26" color="#fff" :textareaBorder="false" :isCounter="true" :maxlength="500" :minHeight="120" :isAutoHeight="true" :borderTop="false"></fui-textarea>
|
|
</view>
|
|
</fui-form-item>
|
|
|
|
<fui-form-item label="追单标注" labelSize='26' prop="chasing_orders" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="textarea-container">
|
|
<fui-textarea v-model="formData.chasing_orders" placeholder="点击填写" backgroundColor="#434544" size="26" color="#fff" :textareaBorder="false" :isCounter="true" :maxlength="500" :minHeight="120" :isAutoHeight="true" :borderTop="false"></fui-textarea>
|
|
</view>
|
|
</fui-form-item>
|
|
|
|
<fui-form-item label="是否报名" labelSize='26' prop="is_bm" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="input-title" style="margin-right:14rpx;">
|
|
<fui-radio-group name="radio" v-model="formData.is_bm" :disabled="true">
|
|
<view class="fui-list__item" style="display: flex;justify-content: flex-end;">
|
|
<fui-label>
|
|
<view class="fui-align__center">
|
|
<fui-radio :value="1" :disabled="true"></fui-radio>
|
|
<text class="fui-text">报名</text>
|
|
</view>
|
|
</fui-label>
|
|
<fui-label :margin="['0','0','0','40rpx']">
|
|
<view class="fui-align__center">
|
|
<fui-radio :value="2" :disabled="true"></fui-radio>
|
|
<text class="fui-text">未报名</text>
|
|
</view>
|
|
</fui-label>
|
|
</view>
|
|
</fui-radio-group>
|
|
</view>
|
|
</fui-form-item>
|
|
|
|
<!-- 面咨备注 -->
|
|
<fui-form-item label="面咨备注" labelSize='26' prop="consultation_remark" background='#434544' labelColor='#fff' :bottomBorder='false'>
|
|
<view class="textarea-container">
|
|
<fui-textarea v-model="formData.consultation_remark" placeholder="点击填写" backgroundColor="#434544" size="26" color="#fff" :maxlength="500" :minHeight="120" :isAutoHeight="true" :borderTop="false"></fui-textarea>
|
|
</view>
|
|
</fui-form-item>
|
|
<!-- 标识 -->
|
|
|
|
</view>
|
|
<!-- 添加底部安全区 -->
|
|
<view class="safe-area-bottom"></view>
|
|
</fui-form>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 选择器、日期选择等控件保留原有 -->
|
|
<fui-date-picker :show="date_picker_show" type="5" @change="change_date" @cancel="cancel_date" :value="default_date_value"></fui-date-picker>
|
|
|
|
<!-- 日期时间选择器 -->
|
|
<fui-date-picker :show="datetime_picker_show" type="1" @change="change_datetime" @cancel="cancel_datetime" :value="default_datetime_value"></fui-date-picker>
|
|
|
|
<fui-picker :linkage='picker_linkage' :options="picker_options" :layer="1" :show="picker_show" @change="changeCicker" @cancel="cancelCicker"></fui-picker>
|
|
|
|
<!-- 快速填写弹窗 -->
|
|
<view v-if="showQuickFill" class="quick-fill-mask" @tap="showQuickFill=false">
|
|
<view class="quick-fill-content" @tap.stop>
|
|
<view class="quick-fill-header">
|
|
<view class="quick-fill-title">快速填写</view>
|
|
<view class="quick-fill-close" @tap="showQuickFill=false">
|
|
<text class="close-text">✕</text>
|
|
</view>
|
|
</view>
|
|
<view class="quick-fill-body">
|
|
<view class="quick-fill-tip">
|
|
<text>请粘贴包含客户信息的文本,支持格式:</text>
|
|
<text>姓名:张三,电话:13800138000,校区:测试校区</text>
|
|
</view>
|
|
<textarea
|
|
class="quick-fill-textarea"
|
|
placeholder="请粘贴客户信息文本..."
|
|
v-model="quickFillText"
|
|
:maxlength="1000"
|
|
></textarea>
|
|
</view>
|
|
<view class="quick-fill-buttons">
|
|
<view class="quick-fill-btn cancel-btn" @click="showQuickFill=false">取消</view>
|
|
<view class="quick-fill-btn confirm-btn" @click="parseQuickFillText">解析并填写</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 底部保存按钮 -->
|
|
<view class="save-btn-box">
|
|
<fui-button background="#434544" color="#24BA9F" borderColor="#24BA9F" @click="submit">保存</fui-button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import apiRoute from '@/api/apiRoute.js';
|
|
import commonApi from '@/api/common.js';
|
|
import marketApi from '@/api/market.js';
|
|
import memberApi from '@/api/member.js';
|
|
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
is_submit: true, //是否提交(防止重复提交)|true=可提交,false=不可提交
|
|
|
|
resource_sharing_id: '', //resource_sharing_id(资源共享表id)
|
|
|
|
// 快速填写相关
|
|
showQuickFill: false, // 是否显示快速填写弹窗
|
|
quickFillText: '', // 快速填写文本内容
|
|
|
|
//表单
|
|
formData: {
|
|
// 客户基础信息
|
|
source_channel: '', //来源渠道
|
|
source: '', //来源
|
|
consultant: '', //顾问
|
|
name: '', //姓名
|
|
age: '', //年龄
|
|
birthday: '', //生日
|
|
gender: 'male', //性别|male-男性, female-女性, other-其他
|
|
phone_number: '', //联系电话
|
|
demand: '', //需求
|
|
decision_maker: '', //决策人
|
|
initial_intent: '', //客户初步意向度: high-高, medium-中, low-低
|
|
status: '', //客户状态: active-活跃, inactive-不活跃, pending-待定
|
|
|
|
//六要素信息
|
|
purchasing_power: '', //购买力
|
|
cognitive_idea: '', //认知理念
|
|
communication: '', //沟通备注
|
|
promised_visit_time: '', //承诺到访时间
|
|
staff_id: '', //人员ID
|
|
distance: '', //距离
|
|
optional_class_time: '', //可选上课时间
|
|
first_visit_status: '', //一访情况
|
|
second_visit_status: '', //二访情况
|
|
efficacious:'1',
|
|
call_intent: '', // 不设置默认值,让后端数据正常回显
|
|
emotional_stickiness_score: '' // 情感粘度
|
|
},
|
|
|
|
//下拉选择器相关
|
|
picker_input_name: '', //下拉组件的input_name
|
|
picker_show: false, //下拉组件是否展示
|
|
picker_linkage: true, //选择器是否为联动选择
|
|
picker_options: [
|
|
// {
|
|
// text:'张三',
|
|
// value:'1'
|
|
// },
|
|
], //选择器可选值列表
|
|
picker_config: {
|
|
//来源渠道
|
|
source_channel: {
|
|
text: '', //回显中文名字
|
|
options: [
|
|
// {
|
|
// text:'张三',
|
|
// value:'1'
|
|
// }
|
|
], //可选值列表
|
|
},
|
|
//来源
|
|
source: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//顾问
|
|
consultant: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//购买力
|
|
purchasing_power: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//认知理念
|
|
cognitive_idea: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//客户初步意向度
|
|
initial_intent: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//所属校区
|
|
campus: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//是否加微信
|
|
call_intent: {
|
|
text: '',
|
|
options: [
|
|
{
|
|
text:'是',
|
|
value:'1'
|
|
},
|
|
{
|
|
text:'否',
|
|
value:'2'
|
|
}
|
|
],
|
|
},
|
|
//客户状态
|
|
status: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//决策人
|
|
decision_maker: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//距离
|
|
distance: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
//情感粘度
|
|
emotional_stickiness_score: {
|
|
text: '',
|
|
options: [],
|
|
},
|
|
}, //选择器选项配置
|
|
|
|
// 年月日选择组件
|
|
data_picker_input_name: '', //时间组件的input_name
|
|
date_picker_show: false, //时间选择器是否展示
|
|
default_date_value: '', // 添加默认日期值
|
|
|
|
// 日期时间选择组件
|
|
datetime_picker_input_name: '', //日期时间组件的input_name
|
|
datetime_picker_show: false, //日期时间选择器是否展示
|
|
default_datetime_value: '', // 默认日期时间值
|
|
|
|
|
|
|
|
// 查重相关
|
|
clientUserList: [], //查重用户列表
|
|
showDuplicateCheck: false, //是否显示查重弹出层
|
|
|
|
campus_list:[],
|
|
//tab切换
|
|
optionTableId: 0,
|
|
optionTable: [{
|
|
id: 0,
|
|
name: '基础信息'
|
|
},
|
|
{
|
|
id: 1,
|
|
name: '电话六要素'
|
|
},{
|
|
id: 2,
|
|
name: '面咨记录'
|
|
}
|
|
],
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
console.log('onLoad - 接收到参数:', options);
|
|
|
|
// 检查参数是否存在
|
|
if (!options) {
|
|
console.error('onLoad - 未接收到任何参数');
|
|
this.showParameterError();
|
|
return;
|
|
}
|
|
|
|
// 检查 resource_sharing_id 参数,支持多种参数名称
|
|
const resourceSharingId = options.resource_sharing_id || options.id || options.resourceSharingId;
|
|
if (!resourceSharingId) {
|
|
console.error('onLoad - 缺少必要参数。接收到的参数:', JSON.stringify(options));
|
|
console.error('onLoad - 期望参数: resource_sharing_id 或 id');
|
|
this.showParameterError();
|
|
return;
|
|
}
|
|
|
|
this.resource_sharing_id = String(resourceSharingId);
|
|
console.log('onLoad - 成功设置 resource_sharing_id:', this.resource_sharing_id);
|
|
},
|
|
onShow() {
|
|
console.log('onShow - 开始初始化');
|
|
this.init();
|
|
},
|
|
methods: {
|
|
// 显示参数错误提示并返回
|
|
showParameterError() {
|
|
uni.showToast({
|
|
title: '缺少必要参数,即将返回',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
setTimeout(() => {
|
|
uni.navigateBack();
|
|
}, 2000);
|
|
},
|
|
|
|
//初始化
|
|
async init() {
|
|
try {
|
|
console.log('init - 开始初始化流程');
|
|
|
|
if (!this.resource_sharing_id) {
|
|
console.error('init - resource_sharing_id 为空,无法初始化');
|
|
this.showParameterError();
|
|
return;
|
|
}
|
|
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
});
|
|
|
|
console.log('init - 开始加载字典数据');
|
|
|
|
// 批量加载所有字典数据
|
|
await this.getBatchDictData();
|
|
console.log('init - 字典数据加载完成');
|
|
|
|
// 加载校区列表
|
|
console.log('init - 开始加载校区列表');
|
|
await this.get_campus_list();
|
|
console.log('init - 校区列表加载完成');
|
|
|
|
// 获取资源共享详情并回显数据
|
|
console.log('init - 开始获取客户详情');
|
|
await this.getInfo();
|
|
console.log('init - 客户详情获取完成');
|
|
|
|
} catch (error) {
|
|
console.error('初始化失败:', error);
|
|
uni.showToast({
|
|
title: '加载数据失败,请重试',
|
|
icon: 'none'
|
|
});
|
|
} finally {
|
|
uni.hideLoading();
|
|
}
|
|
},
|
|
|
|
// 批量获取字典数据
|
|
async getBatchDictData() {
|
|
const dictMapping = {
|
|
'SourceChannel': 'source_channel',
|
|
'source': 'source',
|
|
'customer_purchasing_power': 'purchasing_power',
|
|
'preliminarycustomerintention': 'initial_intent',
|
|
'cognitive_concept': 'cognitive_idea',
|
|
'kh_status': 'status',
|
|
'decision_maker': 'decision_maker',
|
|
'distance': 'distance',
|
|
'emotional_stickiness_score': 'emotional_stickiness_score'
|
|
};
|
|
|
|
try {
|
|
const batchResult = await apiRoute.common_getBatchDict(Object.keys(dictMapping));
|
|
if (batchResult?.code === 1 && batchResult.data) {
|
|
Object.entries(batchResult.data).forEach(([key, data]) => {
|
|
if (dictMapping[key] && Array.isArray(data)) {
|
|
this.processDictData(dictMapping[key], data);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
} catch (error) {
|
|
console.error('批量字典接口失败:', error);
|
|
}
|
|
|
|
// 回退到单个获取
|
|
const priorityKeys = ['source_channel', 'source'];
|
|
const otherKeys = ['purchasing_power', 'initial_intent', 'cognitive_idea', 'status', 'decision_maker', 'distance', 'emotional_stickiness_score'];
|
|
|
|
try {
|
|
await Promise.all(priorityKeys.map(key => this.getDict(key)));
|
|
setTimeout(() => {
|
|
Promise.all(otherKeys.map(key => this.getDict(key))).catch(console.error);
|
|
}, 100);
|
|
} catch (error) {
|
|
console.error('回退方案失败:', error);
|
|
}
|
|
},
|
|
|
|
// 处理字典数据
|
|
processDictData(localKey, dictData) {
|
|
if (!Array.isArray(dictData) || !dictData.length) return;
|
|
|
|
let options = dictData.map(item => ({ text: item.name || '', value: item.value || '' }));
|
|
if (localKey === 'source_channel') {
|
|
options.unshift({ text: '线下', value: '0' });
|
|
}
|
|
|
|
this.picker_config[localKey] = this.picker_config[localKey] || { text: '点击选择' };
|
|
this.picker_config[localKey].options = options;
|
|
},
|
|
|
|
async get_campus_list(){
|
|
|
|
let res = await apiRoute.common_getCampusesList({})
|
|
if (res.code != 1) {
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
this.campus_list = res.data
|
|
|
|
|
|
let arr = []
|
|
this.campus_list.forEach((v,k)=>{
|
|
arr.push({
|
|
text: v.campus_name,
|
|
value: v.id,
|
|
})
|
|
})
|
|
|
|
this.picker_config['campus'].options = arr
|
|
|
|
},
|
|
|
|
//获取资源共享-详情(客户资源详情)
|
|
async getInfo() {
|
|
try {
|
|
console.log('getInfo - 开始获取客户详情, resource_sharing_id:', this.resource_sharing_id);
|
|
|
|
if (!this.resource_sharing_id) {
|
|
console.error('getInfo - resource_sharing_id 为空,无法获取客户详情');
|
|
return;
|
|
}
|
|
|
|
let params = {
|
|
resource_sharing_id: this.resource_sharing_id
|
|
};
|
|
|
|
console.log('getInfo - 发起请求:', params);
|
|
let res = await apiRoute.xs_resourceSharingInfo(params); //资源共享-详情(客户资源详情)
|
|
console.log('getInfo - 请求响应:', res);
|
|
|
|
if (res.code != 1) {
|
|
console.error('getInfo - 请求失败:', res.msg);
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
|
|
let customerResource = res.data.customerResource || {}; //客户资源详情
|
|
let sixSpeed = res.data.customerResource.sixSpeed || {}; //六要素详情
|
|
console.log('getInfo - 客户资源详情:', customerResource);
|
|
console.log('getInfo - 六要素详情:', sixSpeed);
|
|
|
|
// 存储原始数据,用于后续回显
|
|
this._resourceDetail = res.data;
|
|
|
|
this.formData = {
|
|
resource_sharing_id: this.resource_sharing_id, //资源共享表id
|
|
// 客户基础信息
|
|
id: customerResource.id || '', //客户资源表id
|
|
source_channel: customerResource.source_channel || '', //来源渠道
|
|
source: customerResource.source || '', //来源
|
|
name: customerResource.name || '', //姓名
|
|
age: customerResource.age || '', //年龄
|
|
birthday: customerResource.birthday || '', //生日
|
|
gender: customerResource.gender || 'male', //性别|male-男性, female-女性, other-其他
|
|
phone_number: customerResource.phone_number || '', //联系电话
|
|
demand: customerResource.demand || '', //需求
|
|
decision_maker: customerResource.decision_maker || '', //决策人
|
|
initial_intent: customerResource.initial_intent || '', //客户初步意向度: high-高, medium-中, low-低
|
|
status: customerResource.status || '', //客户状态: active-活跃, inactive-不活跃, pending-待定
|
|
campus: customerResource.campus || '', // 校区
|
|
customer_type: customerResource.customer_type || '', // 客户分类
|
|
|
|
//六要素信息
|
|
purchasing_power: sixSpeed.purchase_power || '', //购买力
|
|
cognitive_idea: sixSpeed.concept_awareness || '', //认知理念
|
|
communication: sixSpeed.communication || '', //沟通备注
|
|
staff_id: sixSpeed.staff_id || '', //人员ID
|
|
distance: sixSpeed.distance || '', //距离
|
|
promised_visit_time: sixSpeed.promised_visit_time || '', //承诺到访时间
|
|
optional_class_time: sixSpeed.preferred_class_time || '', //可选上课时间
|
|
first_visit_time: sixSpeed.first_visit_time || '', // 一访时间
|
|
first_visit_status: sixSpeed.first_visit_status || '', //一访情况
|
|
second_visit_time: sixSpeed.second_visit_time || '', // 二访时间
|
|
second_visit_status: sixSpeed.second_visit_status || '', //二访情况
|
|
remark: sixSpeed.consultation_remark || '', // 备注
|
|
consultation_remark: sixSpeed.consultation_remark || '', // 面咨备注
|
|
chasing_orders: sixSpeed.chasing_orders || '', // 追单标注
|
|
is_bm: sixSpeed.is_bm || 2, // 是否报名,默认未报名
|
|
efficacious: sixSpeed.efficacious || '',
|
|
call_intent: sixSpeed.call_intent || '', // 是否加微信
|
|
emotional_stickiness_score: sixSpeed.emotional_stickiness_score || '', // 情感粘度
|
|
};
|
|
|
|
console.log('getInfo - 表单数据设置完成:', this.formData);
|
|
|
|
// 格式化日期时间
|
|
if (sixSpeed.promised_visit_time) {
|
|
// 如果包含时间部分,保持原格式;否则只格式化日期部分
|
|
if (sixSpeed.promised_visit_time.includes(' ')) {
|
|
this.formData.promised_visit_time = sixSpeed.promised_visit_time;
|
|
} else {
|
|
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time, 'Y-m-d');
|
|
}
|
|
}
|
|
|
|
// 可选上课时间保持原始文本格式,不做日期格式化
|
|
if (sixSpeed.preferred_class_time) {
|
|
this.formData.optional_class_time = sixSpeed.preferred_class_time;
|
|
}
|
|
|
|
if (sixSpeed.first_visit_time) {
|
|
this.formData.first_visit_time = this.$util.formatToDateTime(sixSpeed.first_visit_time, 'Y-m-d');
|
|
}
|
|
|
|
if (sixSpeed.second_visit_time) {
|
|
this.formData.second_visit_time = this.$util.formatToDateTime(sixSpeed.second_visit_time, 'Y-m-d');
|
|
}
|
|
|
|
console.log('getInfo - 日期格式化完成');
|
|
|
|
// 设置选择器文本回显
|
|
console.log('getInfo - 开始设置选择器文本回显');
|
|
await this.setPickerText();
|
|
console.log('getInfo - 选择器文本回显完成');
|
|
|
|
} catch (error) {
|
|
console.error('获取客户详情失败:', error);
|
|
uni.showToast({
|
|
title: '获取客户详情失败,请重试',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
|
|
// 设置选择器文本回显
|
|
async setPickerText() {
|
|
try {
|
|
const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {};
|
|
|
|
// 设置选择器文本回显
|
|
this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name);
|
|
this.setPickerTextByValue('source', this.formData.source, customerResource.source_name);
|
|
this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name);
|
|
this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name);
|
|
this.setPickerTextByValue('status', this.formData.status, customerResource.status_name);
|
|
this.setPickerTextByValue('decision_maker', this.formData.decision_maker, customerResource.decision_maker_name);
|
|
this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name);
|
|
this.setPickerTextByValue('customer_type', this.formData.customer_type, customerResource.customer_type_name);
|
|
|
|
// 六要素相关
|
|
this.setPickerTextByValue('purchasing_power', this.formData.purchasing_power, sixSpeed.purchase_power_name);
|
|
this.setPickerTextByValue('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name);
|
|
this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name);
|
|
this.setPickerTextByValue('emotional_stickiness_score', this.formData.emotional_stickiness_score, sixSpeed.emotional_stickiness_score_name);
|
|
// 不再需要设置call_intent的选择器文本,因为已改为单选组件
|
|
|
|
console.log('选择器文本回显完成');
|
|
} catch (error) {
|
|
console.error('设置选择器文本回显失败:', error);
|
|
}
|
|
},
|
|
|
|
// 根据值设置选择器文本
|
|
setPickerTextByValue(pickerName, value, defaultText) {
|
|
// 使用空值缓存加速处理
|
|
if (!value) {
|
|
this.picker_config[pickerName] = this.picker_config[pickerName] || {};
|
|
this.picker_config[pickerName].text = '点击选择';
|
|
return;
|
|
}
|
|
|
|
// 创建映射缓存,避免重复查找
|
|
if (!this._valueTextMapping) {
|
|
this._valueTextMapping = {};
|
|
}
|
|
|
|
// 检查缓存
|
|
const cacheKey = `${pickerName}_${value}`;
|
|
if (this._valueTextMapping[cacheKey]) {
|
|
this.picker_config[pickerName] = this.picker_config[pickerName] || {};
|
|
this.picker_config[pickerName].text = this._valueTextMapping[cacheKey];
|
|
return;
|
|
}
|
|
|
|
// 确保 picker_config[pickerName] 存在
|
|
if (!this.picker_config[pickerName]) {
|
|
this.picker_config[pickerName] = { options: [] };
|
|
}
|
|
|
|
// 先尝试从选项中找到匹配的文本
|
|
const options = this.picker_config[pickerName].options || [];
|
|
const option = options.find(opt => String(opt.value) === String(value));
|
|
|
|
let textValue;
|
|
if (option) {
|
|
textValue = option.text;
|
|
} else if (defaultText) {
|
|
// 如果找不到匹配的选项但有默认文本,则使用默认文本
|
|
textValue = defaultText;
|
|
} else {
|
|
textValue = '点击选择';
|
|
}
|
|
|
|
// 保存到缓存
|
|
this._valueTextMapping[cacheKey] = textValue;
|
|
this.picker_config[pickerName].text = textValue;
|
|
},
|
|
|
|
// 获取资源详情(缓存数据,避免重复请求)
|
|
async getResourceDetail() {
|
|
if (this._resourceDetail) {
|
|
return this._resourceDetail
|
|
}
|
|
|
|
let params = {
|
|
resource_sharing_id: this.resource_sharing_id
|
|
}
|
|
|
|
let res = await apiRoute.xs_resourceSharingInfo(params)
|
|
if (res.code == 1) {
|
|
this._resourceDetail = res.data
|
|
return res.data
|
|
}
|
|
return null
|
|
},
|
|
|
|
// 获取字典
|
|
async getDict(inputName) {
|
|
const keyMap = {
|
|
source_channel: 'SourceChannel',
|
|
source: 'source',
|
|
purchasing_power: 'customer_purchasing_power',
|
|
cognitive_idea: 'cognitive_concept',
|
|
decision_maker: 'decision_maker',
|
|
initial_intent: 'preliminarycustomerintention',
|
|
status: 'kh_status',
|
|
distance: 'distance',
|
|
customer_type: 'customer_type',
|
|
emotional_stickiness_score: 'emotional_stickiness_score'
|
|
};
|
|
|
|
const key = keyMap[inputName];
|
|
if (!key) return;
|
|
|
|
try {
|
|
const dictionary = await this.$util.getDict(key);
|
|
if (!dictionary?.length) return;
|
|
|
|
this.processDictData(inputName, dictionary);
|
|
} catch (error) {
|
|
console.error(`获取字典 ${inputName} 失败:`, error);
|
|
}
|
|
},
|
|
|
|
//打开结果列表
|
|
openDuplicateCheck() {
|
|
this.showDuplicateCheck = true
|
|
},
|
|
//关闭结果列表
|
|
closeDuplicateCheck(e) {
|
|
this.showDuplicateCheck = false
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
//联系电话失去焦点时间
|
|
async handlePhoneBlur() {
|
|
if (!this.formData.phone_number) {
|
|
return
|
|
}
|
|
|
|
this.clientUserList = []
|
|
|
|
let param = {
|
|
phone_number: this.formData.phone_number
|
|
}
|
|
let res = await apiRoute.xs_getAllCustomerResources(param)
|
|
if (res.code != 1) {
|
|
if (res.msg == '暂无数据') {
|
|
return
|
|
}
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
console.log('查重', res)
|
|
|
|
|
|
|
|
this.clientUserList = res.data
|
|
|
|
if (this.clientUserList.length == 1) {
|
|
if (this.clientUserList[0].id == this.formData.id) {
|
|
//查重后的手机号是自己,就不展示查重结果了
|
|
return
|
|
}
|
|
}
|
|
|
|
this.openDuplicateCheck()
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//性别选择器
|
|
changeSex(e) {
|
|
this.formData.gender = e.detail.value
|
|
},
|
|
|
|
|
|
|
|
//切换tag列表
|
|
async segmented(e) {
|
|
console.log(e)
|
|
//e.id|0=基础信息 1=六要素
|
|
let status = e.id
|
|
this.optionTableId = String(status)
|
|
},
|
|
|
|
//查看修改记录
|
|
viewEditLog() {
|
|
if (!this.resource_sharing_id) {
|
|
uni.showToast({
|
|
title: '客户信息不存在',
|
|
icon: 'none'
|
|
});
|
|
return;
|
|
}
|
|
|
|
uni.navigateTo({
|
|
url: `/pages-market/clue/edit_clues_log?customer_resource_id=${this.resource_sharing_id}`
|
|
});
|
|
},
|
|
|
|
// 快速填写相关方法
|
|
// 打开快速填写弹窗
|
|
openQuickFill() {
|
|
this.showQuickFill = true
|
|
this.quickFillText = ''
|
|
},
|
|
|
|
// 解析快速填写文本
|
|
parseQuickFillText() {
|
|
if (!this.quickFillText.trim()) {
|
|
uni.showToast({
|
|
title: '请输入要解析的文本',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
try {
|
|
// 定义字段映射规则
|
|
const fieldRules = [
|
|
{ key: 'name', patterns: ['姓名', '客户姓名', '用户姓名', '学员姓名', '学生姓名'] },
|
|
{ key: 'phone_number', patterns: ['电话', '手机', '联系电话', '手机号', '电话号码', '联系方式'] },
|
|
{ key: 'campus', patterns: ['校区', '所属校区', '校区名称'] },
|
|
{ key: 'age', patterns: ['年龄'] },
|
|
{ key: 'birthday', patterns: ['生日', '出生日期', '生日日期'] }
|
|
]
|
|
|
|
// 用于存储解析结果
|
|
const parsedData = {}
|
|
const text = this.quickFillText.trim()
|
|
|
|
// 对每个字段规则进行匹配
|
|
fieldRules.forEach(rule => {
|
|
rule.patterns.forEach(pattern => {
|
|
// 匹配模式:字段名 + 冒号/等号 + 数据内容
|
|
const regex = new RegExp(`${pattern}\\s*[::=]\\s*([^,,\\n\\s]+)`, 'g')
|
|
const match = regex.exec(text)
|
|
if (match && match[1]) {
|
|
parsedData[rule.key] = match[1].trim()
|
|
}
|
|
})
|
|
})
|
|
|
|
console.log('解析结果:', parsedData)
|
|
|
|
// 填写到表单中
|
|
let fillCount = 0
|
|
if (parsedData.name) {
|
|
this.formData.name = parsedData.name
|
|
fillCount++
|
|
}
|
|
if (parsedData.phone_number) {
|
|
this.formData.phone_number = parsedData.phone_number
|
|
fillCount++
|
|
}
|
|
if (parsedData.campus) {
|
|
// 需要在校区选项中查找匹配的项
|
|
this.findAndSetCampus(parsedData.campus)
|
|
fillCount++
|
|
}
|
|
if (parsedData.age) {
|
|
const age = parseInt(parsedData.age)
|
|
if (!isNaN(age) && age > 0 && age < 150) {
|
|
this.formData.age = age
|
|
fillCount++
|
|
}
|
|
}
|
|
if (parsedData.birthday) {
|
|
this.formData.birthday = parsedData.birthday
|
|
fillCount++
|
|
}
|
|
|
|
if (fillCount > 0) {
|
|
uni.showToast({
|
|
title: `成功填写${fillCount}个字段`,
|
|
icon: 'success'
|
|
})
|
|
this.showQuickFill = false
|
|
} else {
|
|
uni.showToast({
|
|
title: '未能识别到有效信息,请检查格式',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('解析失败:', error)
|
|
uni.showToast({
|
|
title: '解析失败,请检查格式',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
|
|
// 查找并设置校区
|
|
findAndSetCampus(campusText) {
|
|
const campusOptions = this.picker_config.campus?.options || []
|
|
const matchedCampus = campusOptions.find(option =>
|
|
option.text.includes(campusText) || campusText.includes(option.text)
|
|
)
|
|
|
|
if (matchedCampus) {
|
|
this.formData.campus = matchedCampus.value
|
|
this.picker_config.campus.text = matchedCampus.text
|
|
}
|
|
},
|
|
|
|
|
|
// 选择器相关方法
|
|
// 打开选择器
|
|
openCicker(inputName, linkage = true) {
|
|
const options = this.picker_config[inputName]?.options || [];
|
|
|
|
if (!options.length) {
|
|
uni.showToast({ title: '暂无选项', icon: 'none' });
|
|
return;
|
|
}
|
|
|
|
this.picker_input_name = inputName;
|
|
this.picker_options = options;
|
|
this.picker_linkage = linkage;
|
|
|
|
this.$nextTick(() => {
|
|
this.picker_show = true;
|
|
});
|
|
},
|
|
|
|
// 处理选择器选择
|
|
changeCicker(e) {
|
|
const inputName = this.picker_input_name;
|
|
|
|
this.updateFormField(inputName, e.value, e.text);
|
|
this.handleSpecialSelectionLogic(inputName, e.value, e.text);
|
|
this.cancelCicker();
|
|
},
|
|
|
|
// 更新表单字段
|
|
updateFormField(inputName, value, text) {
|
|
this.formData[inputName] = value;
|
|
this.picker_config[inputName].text = text;
|
|
},
|
|
|
|
// 处理特殊选择逻辑
|
|
handleSpecialSelectionLogic(inputName, value) {
|
|
if (inputName === 'source') {
|
|
this.handleSourceSelection(value);
|
|
}
|
|
},
|
|
|
|
// 处理来源选择逻辑
|
|
handleSourceSelection(value) {
|
|
if (value === '1' || value === 1) {
|
|
// 选择线上,清空来源渠道等待用户选择
|
|
this.formData.source_channel = '';
|
|
this.picker_config.source_channel.text = '点击选择';
|
|
} else {
|
|
// 其他来源,自动设置为线下
|
|
this.formData.source_channel = '0';
|
|
this.picker_config.source_channel.text = '线下';
|
|
}
|
|
},
|
|
|
|
// 关闭选择器
|
|
cancelCicker() {
|
|
this.picker_show = false;
|
|
this.picker_input_name = '';
|
|
this.picker_options = [];
|
|
},
|
|
|
|
|
|
// 日期选择器相关方法
|
|
// 打开日期选择器
|
|
openDate(inputName) {
|
|
this.data_picker_input_name = inputName;
|
|
this.setDefaultDateValue(inputName);
|
|
this.date_picker_show = true;
|
|
},
|
|
|
|
// 打开日期时间选择器
|
|
openDateTime(inputName) {
|
|
this.datetime_picker_input_name = inputName;
|
|
this.setDefaultDateTimeValue(inputName);
|
|
this.datetime_picker_show = true;
|
|
},
|
|
|
|
// 设置默认日期值
|
|
setDefaultDateValue(inputName) {
|
|
if (this.formData[inputName]) {
|
|
this.default_date_value = this.formData[inputName];
|
|
} else {
|
|
const today = new Date();
|
|
this.default_date_value = this.formatDateToString(today);
|
|
}
|
|
},
|
|
|
|
// 设置默认日期时间值
|
|
setDefaultDateTimeValue(inputName) {
|
|
if (this.formData[inputName]) {
|
|
this.default_datetime_value = this.formData[inputName];
|
|
} else {
|
|
const now = new Date();
|
|
this.default_datetime_value = this.formatDateTimeToString(now);
|
|
}
|
|
},
|
|
|
|
// 格式化日期为字符串
|
|
formatDateToString(date) {
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
return `${year}-${month}-${day}`;
|
|
},
|
|
|
|
// 格式化日期时间为字符串
|
|
formatDateTimeToString(date) {
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
},
|
|
|
|
// 处理日期选择
|
|
change_date(e) {
|
|
const val = e.result || '';
|
|
const inputName = this.data_picker_input_name;
|
|
|
|
this.formData[inputName] = val;
|
|
this.cancel_date();
|
|
},
|
|
|
|
// 关闭日期选择器
|
|
cancel_date() {
|
|
this.date_picker_show = false;
|
|
},
|
|
|
|
// 处理日期时间选择
|
|
change_datetime(e) {
|
|
console.log('日期时间选择器返回数据:', e);
|
|
|
|
let val = e.result || e.value || '';
|
|
|
|
// 确保日期时间格式正确
|
|
if (val && typeof val === 'string') {
|
|
// 如果包含时间部分但格式不对,进行格式化
|
|
if (val.includes(' ') || val.includes('T')) {
|
|
try {
|
|
const date = new Date(val);
|
|
if (!isNaN(date.getTime())) {
|
|
val = this.formatDateTimeToString(date);
|
|
}
|
|
} catch (error) {
|
|
console.warn('日期时间格式化失败:', error);
|
|
}
|
|
}
|
|
}
|
|
|
|
const inputName = this.datetime_picker_input_name;
|
|
this.formData[inputName] = val;
|
|
this.cancel_datetime();
|
|
},
|
|
|
|
// 关闭日期时间选择器
|
|
cancel_datetime() {
|
|
this.datetime_picker_show = false;
|
|
},
|
|
|
|
//下一步 index|0=添加客户,1六要素
|
|
async nextStep(index) {
|
|
this.optionTableId = String(index)
|
|
},
|
|
// 统一表单验证方法
|
|
validateField(fieldName, value, message, targetTab = '0') {
|
|
if (!value) {
|
|
uni.showToast({ title: message, icon: 'none' });
|
|
this.nextStep(targetTab);
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
// 表单验证
|
|
async validatorForm(data) {
|
|
const requiredFields = [
|
|
{ field: 'name', message: '学生姓名必填' },
|
|
{ field: 'phone_number', message: '电话必填' },
|
|
{ field: 'campus', message: '校区必填' }
|
|
];
|
|
|
|
for (const { field, message } of requiredFields) {
|
|
if (!this.validateField(field, data[field], message)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
// 统一的响应处理方法
|
|
handleResponse(res, onSuccess) {
|
|
if (res.code === 1) {
|
|
uni.showToast({ title: res.msg, icon: 'success' });
|
|
if (onSuccess) onSuccess();
|
|
} else {
|
|
uni.showToast({ title: res.msg, icon: 'none' });
|
|
}
|
|
},
|
|
|
|
// 统一的重复提交检查
|
|
canSubmit() {
|
|
if (!this.is_submit) {
|
|
uni.showToast({ title: '请勿重复提交', icon: 'none' });
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
//提交
|
|
async submit() {
|
|
const data = { ...this.formData };
|
|
|
|
// 表单验证
|
|
if (!await this.validatorForm(data)) return;
|
|
|
|
// 防止重复提交
|
|
if (!this.canSubmit()) return;
|
|
|
|
this.is_submit = false;
|
|
try {
|
|
const res = await apiRoute.xs_editCustomerResources(data);
|
|
this.handleResponse(res, () => {
|
|
setTimeout(() => {
|
|
uni.redirectTo({
|
|
url: `/pages-market/clue/clue_info?resource_sharing_id=${this.resource_sharing_id}`
|
|
});
|
|
}, 1000);
|
|
});
|
|
} finally {
|
|
this.is_submit = true;
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
@import './edit_clues.less';
|
|
</style>
|