<!--添加跟进-->
<template>
  <view class="assemble">
    <view class="form-style">
      <fui-form ref="form" top="0" :model="formData" :show="false">
        <view class="input-style">
          <fui-form-item
              label="选择线索"
              asterisk
              asteriskPosition="right"
              labelSize='26'
              prop="name"
              background='#434544'
              labelColor='#fff'
              :bottomBorder='false'
          >
            <view class="input-title" style="margin-right:14rpx;" v-if="result_leixing == ''"
                  @click="selectCon(2)">点击选择
            </view>
            <view class="input-title" style="margin-right:14rpx;" v-else @click="selectCon(2)">{{ result_leixing }}
            </view>
          </fui-form-item>


          <fui-form-item label="跟进时间" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                         background='#434544' labelColor='#fff' :bottomBorder='false'>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(1)"
                  v-if="result_date == ''">点击选择
            </view>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(1)" v-else>{{ result_date }}
            </view>
          </fui-form-item>

          <fui-form-item label="上传录音" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                         background='#434544' labelColor='#fff'
                         :bottomBorder='false'>
            <fui-input :borderBottom="false" :padding="[0]" placeholder="选择附件" v-model="formData.mobile"
                       backgroundColor="#434544" size="26" color="#fff"></fui-input>
          </fui-form-item>
        </view>
        <view>
          <fui-form-item label="跟进内容" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                         background='#434544' labelColor='#fff' :bottomBorder='false'>
          </fui-form-item>
          <view style="width: 100%;background: #434544;">
            <view style="margin: auto;width: 92%;padding: 20rpx 0 50rpx;">
              <fui-textarea :padding="[0]" v-model="formData.mobile"
                            backgroundColor="#434544" size="26" color="#fff" :textareaBorder="true"></fui-textarea>
            </view>
          </view>
        </view>

        <view class="input-style" style="margin-top: 50rpx;">

<!--          <fui-form-item label="学员名称" labelSize='26' asterisk asteriskPosition="right" prop="mobile"-->
<!--                         background='#434544' labelColor='#fff' :bottomBorder='false'>-->
<!--            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(3)"-->
<!--                  v-if="result_student == ''">点击选择-->
<!--            </view>-->
<!--            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(3)" v-else>{{ result_student }}-->
<!--            </view>-->
<!--          </fui-form-item>-->

          <fui-form-item label="客户状态" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                         background='#434544' labelColor='#fff' :bottomBorder='false'>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(4)"
                  v-if="result_status == ''">点击选择
            </view>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(4)" v-else>{{ result_status }}
            </view>
          </fui-form-item>

          <fui-form-item label="签单意向联系人" labelWidth="230" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                         background='#434544' labelColor='#fff' :bottomBorder='false'>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(5)"
                  v-if="result_intention == ''">点击选择
            </view>
            <view class="input-title" style="margin-right:14rpx;" @click="selectCon(5)" v-else>{{ result_intention }}
            </view>
          </fui-form-item>
        </view>

        <view class="title" style="margin-top: 20rpx;">跟进任务</view>
        <view class="input-style">
          <fui-form-item label="创建下次跟进任务" labelWidth="250" labelSize='26' asterisk asteriskPosition="right"
                         prop="mobile"
                         background='#434544' labelColor='#fff' :bottomBorder='false'>
            <fui-switch @change="switchChange" checked></fui-switch>
          </fui-form-item>
          <view v-if="switchChange_type == 1">

            <fui-form-item label="跟进时间" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                           background='#434544' labelColor='#fff' :bottomBorder='false'>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(6)"
                    v-if="result_dates == ''">点击选择
              </view>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(6)" v-else>{{ result_dates }}
              </view>
            </fui-form-item>
            <fui-form-item label="跟进内容" labelSize='26' prop="mobile" background='#434544' labelColor='#fff'
                           :bottomBorder='false'>
              <fui-input :borderBottom="false" :padding="[0]" placeholder="点击填写" v-model="formData.mobile"
                         backgroundColor="#434544" size="26" color="#fff"></fui-input>
            </fui-form-item>
            <fui-form-item label="跟进人员" labelSize='26' asterisk asteriskPosition="right" prop="mobile"
                           background='#434544' labelColor='#fff' :bottomBorder='false'>
              <fui-input :borderBottom="false" :padding="[0]" placeholder="点击填写" v-model="formData.mobile"
                         backgroundColor="#434544" size="26" color="#fff"></fui-input>
            </fui-form-item>
            <fui-form-item label="任务提醒" labelSize='26' prop="mobile" background='#434544' labelColor='#fff'
                           :bottomBorder='false'>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(7)"
                    v-if="result_renwu == ''">点击选择
              </view>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(7)" v-else>{{ result_renwu }}
              </view>
            </fui-form-item>
            <fui-form-item label="提醒方式" labelSize='26' prop="mobile" background='#434544' labelColor='#fff'
                           :bottomBorder='false'>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(8)"
                    v-if="result_fangshi == ''">点击选择
              </view>
              <view class="input-title" style="margin-right:14rpx;" @click="selectCon(8)" v-else>{{ result_fangshi }}
              </view>
            </fui-form-item>


          </view>
        </view>
      </fui-form>
    </view>
    <view class="fui-btn__box">
      <fui-button background="#434544" color="#24BA9F" borderColor="#24BA9F" @click="submit">保存</fui-button>
    </view>


    <!-- 年月日-选择时间 -->
    <fui-date-picker :show="show_date" type="3" @change="change_date" @cancel="cancel_date"></fui-date-picker>

    <!-- 下拉选择器 -->
    <fui-picker :linkage='linkage' :options="options" :layer="1" :show="show" @change="changeOptions"
                @cancel="cancel"></fui-picker>
  </view>
</template>

<script>
import commonApi from '@/api/common.js';
import marketApi from '@/api/market.js';

const rules = [{
  name: "mobile",
  rule: ["required", "isMobile"],
  msg: ["请输入手机号", "请输入正确的手机号"]
}];
export default {
  data() {
    return {
      rules,
      //表单数据
      formData:{
        //##### 基础表单 #####
        sales_id:'',//选择线索(线索id)
        entry_type:'',//跟进类型(1=市场人员录入的,2=销售人员录入)
        staff_id:'',//跟进人员
        follow_up_time:'',//跟进时间(2025-03-20 16:04:50)
        requirement:'',//需求
        purchasing_power:'',//购买力(1=低,2=中,3=高)
        cognitive_concept:'',//认知理念|1=低,2=中,3=高
        schooltime:'',//可选上课时间(2025-03-20 16:04:50)
        distance:'',//距离
        decision_maker:'',//决策人
        emotional_intensity:'',//情感粘度|1=低,2=中,3=高
        //##### 初步意向 #####
        initial_customer_intent:'',//意向分类(客户初步意向度|A+,A,A-,B+B,B-,C)
        initial_relationship_intent:'',//意向度(客情初步意向度|A,B,C)
        follow_up_content:'',//备注
        //##### 跟进任务 #####
        is_warn:'1',//是否转角跟进任务(是否提醒 1提醒 2不提醒)
        is_warn_btn:true,//是否转角跟进任务(是否提醒 true=提醒 false=不提醒),只做前端按钮展示使用
        //跟进类型
        follow_staff_id:'',//跟进人员
        reminder_time:'',//跟进时间
        follow_content:'',//备注
      },

      //下拉选择器组件
      options_type: undefined,//选择器标识
      show: false,//是否显示下拉选择器
      linkage: true,//是否联动选择
      options: [
        // {
        //   'value': 1,
        //   'text': '类型1'
        // }
      ],//下拉选择器可选值列表

      //时间选择器相关
      show_date: false,//是否显示时间选择器|true=是,false=否

      //选择线索-相关
      //字典-选择线索
      options_sales_id:[],
      //文本展示-选择线索
      str_sales_id:'',

      //跟进类型-相关
      //字典-跟进类型
      options_entry_type:[],
      //文本展示-跟进类型
      str_entry_type:'',

      //跟进人员-相关
      //字典-跟进人员
      options_staff_id:[],
      //文本展示-跟进人员
      str_staff_id:'',

      //购买力-相关
      //字典-购买力
      options_purchasing_power:[],
      //文本展示-购买力
      str_purchasing_power:'',

      //认知理念-相关
      //字典-认知理念
      options_cognitive_concept:[],
      //文本展示-认知理念
      str_cognitive_concept:'',

      //情感粘度-相关
      //字典-情感粘度
      options_emotional_intensity:[],
      //文本展示-情感粘度
      str_emotional_intensity:'',

      //意向分类-相关
      //字典-意向分类
      options_initial_customer_intent:[],
      //文本展示-意向分类
      str_initial_customer_intent:'',

      //意向度-相关
      //字典-意向度
      options_initial_relationship_intent:[],
      //文本展示-意向度
      str_initial_relationship_intent:'',

      //跟进任务-跟进人员-相关
      //字典-跟进任务-跟进人员(市场)
      options_follow_staff_id_sc:[],
      //字典-跟进任务-跟进人员(销售)
      options_follow_staff_id_xs:[],
      //文本展示-跟进任务-跟进人员
      str_follow_staff_id:'',
    }
  },
  onLoad(options) {

  },
  onShow() {
    this.init()
  },
  methods: {
    //初始化
    async init() {
      this.getDicFollow_up_type()//获取字典-跟进类型
    },

    //获取字典-选择线索
    //获取字典-跟进类型
    //获取字典-跟进人员(全部)
    //获取字典-跟进任务-跟进人员(市场)
    //获取字典-跟进任务-跟进人员(销售)
    //获取字典-购买力
    //获取字典-认知理念
    //获取字典-情感粘度
    //获取字典-意向分类
    //获取字典-意向度


    //获取字典-跟进类型
    async getDicFollow_up_type() {
      let key = 'follow_up_type'
      let res = await commonApi.getDictionary(key)
      if (res.code != 1) {
        uni.showToast({
          title: res.msg,
          icon: 'none'
        })
        return
      }
      this.follow_up_type = res.data.dictionary

      this.options_leixing = []
      res.data.dictionary.forEach((v, k) => {
        this.options_leixing.push({
          value: v.value,
          text: v.name,
        })
      })
    },

    //验证表单
    async validatorForm(data) {
    },
    //提交表单
    async submit() {
    },


    //选择弹窗
    selectCon(type) {
      this.options_type = type
      switch (type) {
          //来源渠道
        case 'source_channel':
          this.options = this.options_source_channel
          this.show = true
          this.linkage = true
          break;
          //客户来源
        case 'customer_source':
          this.options = this.options_customer_source
          this.show = true
          this.linkage = true
          break;
          //顾问
        case 'add_staff_id':
          this.options = this.options_add_staff_id
          this.show = true
          this.linkage = true
          break;
          // 跟进类型
        case 'entry_type':
          this.options = this.options_entry_type
          this.show = true
          this.linkage = true
          break;
          // 跟进人员
        case 'staff_id':
          this.options = this.options_staff_id
          this.show = true
          this.linkage = true
          break;
          //跟进时间
        case 'follow_up_time':
          this.show_date = true
          break;
      }
    },
    //监听-下拉选择框
    changeOptions(e) {
      console.log('选择器选中',e)
      this.show = false
      let type = this.options_type
      switch (type) {
          //来源渠道
        case 'source_channel':
          this.str_source_channel = e.text//选中的text值
          this.formData.source_channel = e.value//选中value值
          break;
          //客户来源
        case 'customer_source':
          this.str_customer_source = e.text//选中的text值
          this.formData.customer_source = e.value//选中value值
          break;
          //顾问
        case 'add_staff_id':
          this.str_add_staff_id = e.text//选中的text值
          this.formData.add_staff_id = e.value//选中value值
          break;
          // 跟进类型
        case 'entry_type':
          this.str_entry_type = e.text//选中的text值
          this.formData.entry_type = e.value//选中value值
          break;
          // 跟进人员
        case 'staff_id':
          this.str_staff_id = e.text//选中的text值
          this.formData.staff_id = e.value//选中value值
          break;
          //跟进时间
        case 'follow_up_time':
          break;
      }
    },

    //监听-时间选择器
    change_date(e) {
      //跟进时间
      this.show_date = false
      this.formData.follow_up_time = e.result ?? ''
    },
    //关闭时间选择器
    cancel_date() {
      this.show_date = false
    },

  }
}
</script>

<style lang="less" scoped>
	.assemble {
		width: 100%;
		height: 100vh;
		background: #292929;
		overflow: auto;
	}

	.title {
		font-size: 26rpx;
		color: #fff;
		padding: 26rpx 0 26rpx 32rpx;
	}

	.input-title {
		font-size: 26rpx;
		color: #fff;
	}

	.form-style {
		width: 100%;
		// background: #434544;
	}

	.form-style-vid {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 12rpx 0;
	}

	.input-style {
		text-align: right !important;
	}

	.fui-btn__box {
		margin: 50rpx auto 120rpx;
		width: 92%;
	}
</style>