<!-- @desc:客户跟进  @auth:付斌  @time:2024/1/30 15:15 -->
<template>
  <div class="main-div">
    <!--  按钮区域  -->
    <BaseIndexButtonGroup id="BaseIndexButtonGroup">
      <template #left>
        <BaseIndexButton ref="search" name="search"></BaseIndexButton>
        <BaseIndexButton ref="clear" name="clear"></BaseIndexButton>
        <BaseIndexButton ref="follow" name="follow" :isMustChooseFlag="false"></BaseIndexButton>
        <BaseIndexButton ref="reception" name="reception" :isMustChooseFlag="false"></BaseIndexButton>
        <BaseIndexButton ref="measuringStickReceipt" name="measuringStickReceipt"
                         :isMustChooseFlag="false"></BaseIndexButton>
      </template>
    </BaseIndexButtonGroup>

    <!--  卡片区  -->
    <div class="index-card">
      <!--  查询条件区域  -->
      <div id="search-cond-div" ref="search-cond-div" class="search-cond-class">
        <SearchCond ref="searchCond" v-model="searchCond"
                    @collapse-change="collapseChange" :setFlag="false"
                    :search-content="searchContent"></SearchCond>
      </div>
      <!--  table区域  -->
      <DkTabs ref="tab" v-model="tabsModel" :options="tabsOptions" @on-click="clickTab"></DkTabs>
      <DkTable :id="'table-'+$options.name" ref="table-select" :data="tableData"
               :height="this.tableHeight-60"
               primaryKey="followId"
               :page-size-opts="pageSizeOpts"
               :page-size="pageInfo.pageSize"
               :choose-flag="false"
               name="table">
        <DkTableColumn :type="$libaray.checkButtonHasRight('customer-detail')?'link':''" field="cusCode"
                       @on-link="openCustomerMessage"></DkTableColumn>
        <DkTableColumn :type="$libaray.checkButtonHasRight('customer-detail')?'link':''" field="cusName"
                       @on-link="openCustomerMessage"></DkTableColumn>
        <DkTableColumn field="cusPhone"></DkTableColumn>
        <DkTableColumn field="addressFull"></DkTableColumn>
        <DkTableColumn field="contactName"></DkTableColumn>
        <DkTableColumn field="contactPhones"></DkTableColumn>
        <DkTableColumn field="orgName"></DkTableColumn>
        <DkTableColumn field="intentionTagsName"></DkTableColumn>
        <DkTableColumn field="intentionQuantityTag"></DkTableColumn>
        <DkTableColumn field="saleStatusName"></DkTableColumn>
        <DkTableColumn field="customerTagNames"></DkTableColumn>
        <DkTableColumn field="loseReasonName"></DkTableColumn>
        <DkTableColumn field="followTime"></DkTableColumn>
        <DkTableColumn field="followUserName"></DkTableColumn>
        <DkTableColumn field="followData"></DkTableColumn>
        <DkTableColumn field="nextFollowPlan"></DkTableColumn>
        <DkTableColumn field="nextFollowTime"></DkTableColumn>
        <DkTableColumn field="reportUserName"></DkTableColumn>
        <DkTableColumn field="followCount" :digits="0"></DkTableColumn>
        <DkTableColumn field="customerFromName"></DkTableColumn>
        <DkTableColumn field="toiletCountName"></DkTableColumn>
        <DkTableColumn field="fitupTypeName"></DkTableColumn>
        <DkTableColumn field="houseTypeName"></DkTableColumn>
        <DkTableColumn field="fitupStyleName"></DkTableColumn>
        <DkTableColumn field="ageCompositionName"></DkTableColumn>
        <DkTableColumn field="decisionMakerName"></DkTableColumn>
        <DkTableColumn field="remarks"></DkTableColumn>
        <DkTableColumn field="measureRemarks"></DkTableColumn>
        <DkTableColumn field="measureTime"></DkTableColumn>
        <DkTableColumn field="flgAgainMeasure"></DkTableColumn>
        <vxe-column field="measureAnnexCount">
          <template #default="{row}">
            <a @click="showFiles(row)">{{ row.measureAnnexCount }}</a>
          </template>
        </vxe-column>
        <vxe-column fixed="right" type="operate" v-if="tabsModel === $t('followTask2')">
          <template #default="{row}">
            <DkButton @click="finishFollow(row)">
              {{ $v('finish') }}
            </DkButton>
          </template>
        </vxe-column>
      </DkTable>
    </div>

    <!--    接待-->
    <DkModal v-model="receptionModal" :title="$t('reception')" width="1000px" ref="modal_reception"
             @on-cancel="cancelReception"
             @modalOk="submitReception"
             @modalCancel="cancelReception"
             :saveFlag="true">
      <RadioGroup v-model="receptionType">
        <Radio label="2">{{ $t('receptionNew') }}</Radio>
        <Radio label="1">{{ $t('receptionOld') }}</Radio>
      </RadioGroup>
      <DkCollapse ref="collapse" v-if="receptionType=='1'">
        <DkPanel prop="customerInfo">
          <DkForm slot="content" ref="formReception" v-model="customerInfo4" style="width:100%;">
            <!--客户名称-->
            <DkFormItem prop="cusName" :required="true">
              <InputPop v-model="customerInfo4.cusName"/>
            </DkFormItem>
            <!--客户电话-->
            <DkFormItem prop="cusPhone" :required="true">
              <InputPop :telephone="true" v-model="customerInfo4.cusPhone" @on-change="changeTel"/>
            </DkFormItem>
            <!--客户区域-->
            <DkFormItem prop="addressName" :required="true">
              <RegionsChoose v-model="addressArea" :options="cityData" :default-value="customerInfo4.addressName"
                             ref="customerDistrict"
                             @on-choose="chooseAddress"></RegionsChoose>
            </DkFormItem>
            <!--门牌号-->
            <DkFormItem :label="$t('addressNo')" prop="addressNo">
              <InputPop v-model="customerInfo4.addressNo" @input="setAddressFull"/>
            </DkFormItem>
            <!--详细地址-->
            <DkFormItem :label="$t('addressFull')" prop="addressFull">
              <InputPop v-model="customerInfo4.addressFull" readonly/>
            </DkFormItem>
          </DkForm>
        </DkPanel>
        <DkPanel prop="receptionOld" v-if="receptionType=='1'">
          <DkForm slot="content" ref="formReceptionNew" style="width:100%;">
            <!-- 客户意向-->
            <DkFormItem prop="intention" :required="true">
              <SelectPop v-model="customerInfo4.intention" :options="intentionList"
                         :multiple="false" :clearable="false"
                         label-key="kindName" value-key="kindCode" transfer/>
            </DkFormItem>
            <!--留店时长-->
            <DkFormItem prop="stayTimeLen">
              <SelectPop v-model="customerInfo4.stayTimeLen" :options="stayTimeLenList" :multiple="false"
                         :clearable="false"
                         label-key="kindName" value-key="kindCode" transfer/>
            </DkFormItem>
            <!--下次邀约时间（提醒时间）-->
            <DkFormItem prop="nextFollowTime">
              <DatePickerPop type="datetime" v-model="customerInfo4.nextFollowTime" transfer
                             format="yyyy-MM-dd HH:mm:ss"/>
            </DkFormItem>
            <!--跟进内容-->
            <DkFormItem prop="followData" :required="true">
              <InputPop textarea-flag v-model="customerInfo4.followData" maxlength="100"/>
            </DkFormItem>
          </DkForm>
        </DkPanel>
      </DkCollapse>
      <DkCollapse ref="collapse" v-if="receptionType=='2'">
        <DkPanel prop="receptionNew">
          <DkForm slot="content" ref="formReceptionNew" style="width:100%;">
            <!-- 客户意向-->
            <DkFormItem prop="intention" :required="true">
              <SelectPop v-model="customerInfo4.intention" :options="intentionList"
                         :multiple="false" :clearable="false"
                         label-key="kindName" value-key="kindCode" transfer/>
            </DkFormItem>
            <!--留店时长-->
            <DkFormItem prop="stayTimeLen">
              <SelectPop v-model="customerInfo4.stayTimeLen" :options="stayTimeLenList" :multiple="false"
                         :clearable="false"
                         label-key="kindName" value-key="kindCode" transfer/>
            </DkFormItem>
            <!--跟进内容-->
            <DkFormItem prop="followData" :required="true">
              <InputPop v-model="customerInfo4.followData" maxlength="100"/>
            </DkFormItem>
          </DkForm>
        </DkPanel>
      </DkCollapse>
      <Card class="follow-card">
        <p slot="title">
          {{ $t('appendix') }}
        </p>
        <DkPicWall v-model="customerInfo4.annexPaths" folder="t_csm_follow/annex_paths"></DkPicWall>
      </Card>


    </DkModal>
    <!--    量尺回执-->
    <DkModal v-model="measureModal" :title="$t('measuringStickReceipt2')" width="800px" ref="modal_measure"
             @on-cancel="cancelMeasure" @modalOk="submitMeasure"
             @modalCancel="cancelMeasure"
             :saveFlag="true">
      <DkCollapse ref="collapse">
        <DkPanel prop="customerInfo">
          <DkForm slot="content" ref="formMeasure" style="width:100%;" name="dk-form" v-model="customerInfo5">
            <!--客户名称-->
            <DkFormItem prop="cusName">
              <InputPop v-model="customerInfo.cusName" :readonly="true"/>
            </DkFormItem>
            <!--客户电话-->
            <DkFormItem prop="cusPhone">
              <InputPop v-model="customerInfo.cusPhone" :readonly="true"/>
            </DkFormItem>
            <!--详细地址-->
            <DkFormItem :label="$t('addressFull')" prop="addressFull">
              <InputPop v-model="customerInfo.addressFull" :readonly="true"/>
            </DkFormItem>
            <!--门牌号-->
            <DkFormItem :label="$t('addressNo')" prop="addressNo">
              <InputPop v-model="customerInfo.addressNo" :readonly="true"/>
            </DkFormItem>
            <!--导购员-->
            <DkFormItem :label="$t('staffName')">
              <InputPop v-model="customerInfo.staffName" :readonly="true"/>
            </DkFormItem>
            <!--是否复尺-->
            <DkFormItem prop="flgAgainMeasure" :required="true">
              <RadioGroup v-model="customerInfo5.flgAgainMeasure">
                <Radio label="true">{{ $t('yes') }}</Radio>
                <Radio label="false">{{ $t('no') }}</Radio>
              </RadioGroup>
            </DkFormItem>
            <!--量尺备注-->
            <DkFormItem prop="measureRemarks">
              <InputPop textarea-flag v-model="customerInfo5.measureRemarks" maxlength="100"/>
            </DkFormItem>
            <!--量尺时间-->
            <DkFormItem prop="measureTime" :required="true">
              <DatePickerPop type="datetime" v-model="customerInfo5.measureTime" transfer/>
            </DkFormItem>
          </DkForm>
        </DkPanel>
        <DkPanel prop="appendix">
          <!--  下拉区域  -->
          <DkForm slot="content" ref="formInline" v-model="customerInfo5" style="width: 100%" :labelMaxWords="7"
                  :col-count="1">
            <div v-for="(item,index) of customerInfo5.measureRoomList" :key="index" style="width: 100%;margin:25px 35px">
              <DkFormItem :label="$t('usedLocation2')" prop="roomName"  :required="true">
                <InputPop v-model="item.roomName" maxlength="100"/>
              </DkFormItem>
              <div style="display: flex;justify-content: space-between;align-items: center">
                <DkPicWall v-model="item.measureAnnex"></DkPicWall>
                <Button @click="removeNewMeasureAnnex(index)" icon="md-close" long type="error" style="width: 30px"></Button>
              </div>
            </div>
            <Button @click="addNewMeasureAnnex" icon="md-add" long style="margin-top: 10px;margin-left: 20px"></Button>
          </DkForm>
        </DkPanel>
      </DkCollapse>
    </DkModal>

    <!--    跟进任务-->
    <FollowTask v-model="followTaskModal" :customer-names="customerInfo6.cusNames"
                :customer-ids="customerInfo6.customerIds" @ok="initData(1)"/>

    <!--    跟进-->
    <Follow v-model="followModal" :goods-specs="goodsSpecsList" :customer-data="customerInfo"
            :goods-specs-list-back-up="goodsSpecsListBackUp" ref="modal_inner_follow"
            :intention-list="intentionList" :invite-result-list="inviteResultList"
            :follow-type-list="followTypeList" :stay-time-len="stayTimeLenList"></Follow>

    <Modal v-model="filesShow" :title="$t('files')" @on-cancel="currentRow={}">

      <div
        v-if="currentRow && currentRow.annexPaths && currentRow.annexPaths.annexPaths && currentRow.annexPaths.annexPaths.length>0">
        <span>{{ $t('annexPaths') }}</span>
        <DkPicWall v-model="currentRow.annexPaths.annexPaths" only-show></DkPicWall>


      </div>

      <divider v-if="currentRow && currentRow.annexPaths && currentRow.annexPaths.annexPaths &&
        currentRow.annexPaths.annexPaths.length>0 && currentRow.measureRoomList"/>

      <div v-if="currentRow.measureRoomList">
        <span v-if="currentRow.measureRoomList">{{ $t('measureRoomList') }}</span>
        <div v-for="(item, index) of currentRow.measureRoomList" :key="index">
          <Tag style="margin-left: 5px">{{ item.roomName }}</Tag>
          <DkPicWall v-model="item.measureAnnex" only-show></DkPicWall>
        </div>
      </div>
    </Modal>
  </div>
</template>

<script>
import {indexMixin} from '@/mixins'
import Follow from './follow'

export default {
  name: 'cus-follow',
  mixins: [indexMixin],
  components: {
    Follow
  },
  data() {
    let self = this
    return {
      addressArea: [],
      cityData: [],
      //当前展示行附件
      currentRow: {},
      // 客户信息
      customerInfo: {},
      customerReadOnly: false,
      // 客户信息 接待
      customerInfo4: {
        cusId: null,
        cusName: '',
        cusPhone: null,
        followData: null,
        followType: null,
        stayTimeLen: 1,
        nextFollowTime: null,
        intention: null,
        competitiveBrands: null,
        intentionInfo: [],
        addressArea: null,              // 行政区划
        addressGcj02: null,             // 经纬度
        addressName: null,              // 小区
        addressNo: null,                // 门牌号
        addressFull: null,              // 详细地址
        annexPaths: null,
      },
      // 客户信息 量尺回执
      customerInfo5: {
        cusId:null,
        followId: null,
        flgAgainMeasure: 'false',
        measureRemarks: null,
        measureTime: new Date().format(),
        measureRoomList: [{roomName: null, measureAnnex: null,displayNo:null,}],
      },
      // 客户信息 跟进任务
      customerInfo6: {
        customerIds: [],
        cusNames: [],
        followUsers: []
      },
      // 错误信息
      errMessage: {},
      //  查看附件
      filesShow: false,
      // 跟进弹窗
      followModal: false,
      // 跟进任务弹窗
      followTaskModal: false,
      // 跟进方式list
      followTypeList: [],
      //  商品规格品类
      goodsSpecsList: [],
      //  商品规格品类备份
      goodsSpecsListBackUp: [],
      // 意向list
      intentionList: [],
      // 邀约结果list
      inviteResultList: [],
      // 量尺回执弹窗
      measureModal: false,
      otherIntentionInfo: null,
      // 接待弹窗
      receptionModal: false,
      // 接待类型 1 留资 2 陌生
      receptionType: '2',
      // 留店时长list
      stayTimeLenList: [],
      // 查询条件
      searchCond: {},
      searchContent: [
        {
          valueFormat: {code: 'cusCode'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'cusName'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'cusPhone'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'contactName'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'contactPhones'},
          valueKind: 'STR'
        },
      ],
      tableData: [],
      tabsModel: self.$t('allReceipt'),
      tabsOptions: [
        {label: self.$t('allReceipt'), name: self.$t('allReceipt')},
        {label: self.$t('followTask2'), name: self.$t('followTask2')},
        {label: self.$t('followToStore'), name: self.$t('followToStore')},
        {label: self.$t('followReserve'), name: self.$t('followReserve')}
      ],
      pageInfo: {
        total: 0,
        pageSize: 20,
        currentPage: 1
      },
    }
  },
  methods: {
    /**
     * @desc   : 进入客户页面
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    openCustomerMessage(row) {
      if (row['cusId']) {
        this.$router.push('/sale/customer/detail/' + row['cusId'])
      }
    },
    /**
     * @desc   : 添加附件行
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    addNewMeasureAnnex() {
      this.customerInfo5.measureRoomList.push({"roomName": null, "measureAnnex": null, "displayNo": null})
    },
    /**
     * @desc   : 关闭接待弹窗
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    cancelReception() {
      this.receptionModal = false
      this.customerInfo4.cusId = null
      this.customerInfo4.cusName = null
      this.customerInfo4.cusPhone = null
      this.customerInfo4.addressFull = null
      this.customerInfo4.addressNo = null
      this.customerInfo4.addressName = null
      this.customerInfo4.addressArea = null
      this.customerInfo4.addressGcj02 = null
      this.customerInfo4.followData = null
      this.customerInfo4.intention = null
      this.customerInfo4.nextFollowTime = null
      this.customerInfo4.stayTimeLen = null
    },
    /**
     * @desc   : 取消量尺回执
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    cancelMeasure() {
      this.measureModal = false
      this.$refs['formMeasure'].$refs['dk-form'].resetFields()
      this.customerInfo5.measureRoomList = [{roomName: null, annexPaths: null}]
    },
    /**
     * @desc   : 接待输入电话
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    changeTel() {
      this.$nextTick(() => {
        if (this.customerInfo4.cusPhone == null || this.customerInfo4.cusPhone == '') {
          return
        }
        let params = {
          cusPhone: this.customerInfo4.cusPhone
        }
        this.excute(this.$service.customerService, this.$service.customerService.selectByCondNoPage, params).then(res => {
          if (res.code === this.$config.SUCCESS_CODE) {
            if (res.data) {
              this.customerInfo4.cusId = res.data[0].cusId
              this.customerInfo4.cusName = res.data[0].cusName
              this.customerInfo4.cusPhone = res.data[0].cusPhone
              this.customerInfo4.addressFull = res.data[0].addressFull
              this.customerInfo4.addressNo = res.data[0].addressNo
              this.customerInfo4.addressName = res.data[0].addressName
              this.customerInfo4.addressArea = res.data[0].addressArea
              this.customerInfo4.addressGcj02 = res.data[0].addressGcj02
            } else {
              this.customerInfo4.cusId = null
            }
          } else {
            this.$Message.error(res.message)
          }
        })
      })
    },
    /**
     * @desc   : 选择地址
     * @author : 付斌
     * @date   : 2024-02-01 14:23
     */
    chooseAddress(value) {
      this.customerInfo4.customerDistrict = value;
      // 说明是清空
      if (!value) {
        this.customerInfo4.addressName = null;
        this.customerInfo4.addressArea = {};
        this.customerInfo4.addressFull = null;
        this.customerInfo4.addressGcj02 = {};
      } else {
        //按照title进行
        this.customerInfo4.addressName = value.addressName;
        this.customerInfo4.addressArea = value.addressArea;
        this.customerInfo4.addressGcj02 = value.addressGcj02;
        this.customerInfo4.addressFull = value.addressFull + (this.customerInfo4.addressNo ? this.customerInfo4.addressNo : '');
      }
    },
    /**
     * @desc   : 点击tab
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    clickTab() {
      this.$nextTick(() => {
        //查询条件
        this.loading = true
        this.tableData = []
        this.pageInfo.currentPage = 1
        this.searchData()
      })
    },
    /**
     * @desc   : 跟进任务完成
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    finishFollow(row) {

    },
    /**
     * @desc   : 完成跟进任务
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    finishFollowPlan(id) {

    },
    /**
     * @desc   : 打开跟进弹窗
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    follow() {
      if (this.$refs['table-select'].batchKeys.length == 1) {
        if (!this.$refs['table-select'].batchRows[0].cusId) {
          this.$Message.error(this.$t('W_068'))
          return
        }
        this.followModal = true
        // 查询客户信息
        this.getCustomerInfo()
      } else {
        this.$Message.error(this.$t('W_013'))
      }
    },
    /**
     * @desc   : 跟进任务
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    followTask() {
      this.followTaskModal = true
    },

    /**
     * @desc   : 查询参数设定
     * @author : 常皓宁
     * @date   : 2024/4/7 11:22
     */
    setSearchParams(params) {
      params.flgValid = true
      if (this.tabsModel === this.$t('allReceipt')) {
        params.followStatus = ''
      } else if (this.tabsModel === this.$t('followTask2')) {
        params.followStatus = '跟进状态-跟进'
      } else if (this.tabsModel === this.$t('followToStore')) {
        params.followStatus = '跟进状态-邀约'
      } else if (this.tabsModel === this.$t('followReserve')) {
        params.followStatus = '跟进状态-约尺'
      }
      return params
    },
    /**
     * @desc   : 查询数据
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    getData(params) {
      // 查询数据
      this.excute(this.$service.cusFollowService, this.$service.cusFollowService.selectByCond, params).then(res => {
        if (res.code === this.$config.SUCCESS_CODE) {
          this.tableData = res.data.list
        }
      })
    },
    /**
     * @desc   : 量尺回执
     * @author : 付斌
     * @date   : 2024-02-01 14:25
     */
    measuringStickReceipt() {
      if (this.$refs['table-select'].batchKeys.length == 1 &&
        this.$refs['table-select'].batchRows[0].followStatus == '跟进状态-约尺') {
        if (!this.$refs['table-select'].batchRows[0].cusId) {
          this.$Message.error(this.$t('W_068'))
          return
        }
        this.measureModal = true
        this.customerInfo5.followId = this.$refs['table-select'].batchRows[0].followId
        this.customerInfo5.cusId = this.$refs['table-select'].batchRows[0].cusId
        this.getCustomerInfo()
      } else {
        this.$Message.error(this.$t('W_040'))
      }
    },

    /**
     * @desc   : 查询客户信息
     * @author : 常皓宁
     * @date   : 2024/4/8 13:00
     */
    getCustomerInfo() {
      this.excuteNoParam(this.$service.customerService, this.$service.customerService.selectById, [this.$refs['table-select'].batchRows[0].cusId], false).then(res => {
        if (res.code === this.$config.SUCCESS_CODE) {
          this.customerInfo = res.data
        } else {
          this.$Message.error(res.message)
        }
      })
    },
    /**
     * @desc   : 打开接待弹窗
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    reception() {
      this.receptionModal = true
      this.customerInfo = {}
    },
    /**
     * @desc   : 移除量尺的附件
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    removeNewMeasureAnnex(index) {
    },
    /**
     * @desc   : 拼写详细地址
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    setAddressFull(e) {
      // 客户区域有值才会拼接详细地址
      if (!this.setCustomerFlag && this.customerInfo4.customerDistrict && this.customerInfo4.customerDistrict.addressFull) {
        this.customerInfo4.addressFull = this.customerInfo4.customerDistrict.addressFull + (this.customerInfo4.addressNo ? this.customerInfo4.addressNo : '')
      }
    },
    /**
     * @desc   : 展示附件
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    showFiles(row) {

    },
    /**
     * @desc   : 提交接待
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    submitReception() {
      this.$refs['formReception'].validate().then(valid => {
        // 校验
        if (!valid) {
          return
        }
        let param
        // 1 留资 建客户是报备，旧客户是接待 2 陌生
        if (this.receptionType == 1) {
          param = Object.assign({
            followStatus: (this.customerInfo4.cusId ? '跟进状态-接待' : '跟进状态-报备')
          }, this.customerInfo4)
        } else {
          param = Object.assign({
            followStatus: '跟进状态-报备'
          }, {
            stayTimeLen: this.customerInfo4.stayTimeLen,
            followData: this.customerInfo4.followData,
            annexPaths: this.customerInfo4.annexPaths,
            followType: this.customerInfo4.followType,
          })
        }

        // 下次邀约时间
        if (param.nextFollowTime) {
          param.nextFollowTime = param.nextFollowTime.format()
        }

        //附件
        if (param.annexPaths && param.annexPaths.annexPaths) {
          param.annexPaths.annexPaths = param.annexPaths.annexPaths.map(m => m.path)
        }
        param.followOrg = this.$store.state.user.orgId
        this.loading = true
        // 保存
        this.excute(this.$service.cusFollowService, this.$service.cusFollowService.insert, param).then(res => {
          this.loading = false
          if (res.code === this.$config.SUCCESS_CODE) {
            this.$Message.success(res.message)
            //关闭接待弹窗
            this.cancelReception()
            this.initData(1)
          } else {
            this.$Message.error(res.message)
          }
        })
      })

    },
    /**
     * @desc   : 提交量尺回执
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    submitMeasure() {
      this.$refs['formMeasure'].validate().then(valid => {
        // 校验
        if (!valid) {
          return
        }
        let param = Object.assign({}, this.customerInfo5)

        //量尺附件
        if (param.measureRoomList) {
          for (let it of param.measureRoomList) {
            let i = 1
            it.displayNo = i
            i++
            if (it.measureAnnex) {
              it.measureAnnex = it.measureAnnex.map(m => {
                return {
                  name: m.name,
                  url: m.path,
                  type: m.type,
                  createTime: m.createTime
                }
              })
            }
          }
        }
        this.loading = true
        //保存
        this.excute(this.$service.cusFollowService,this.$service.cusFollowService.updateMeasure,param).then(res => {
          this.loading = false
          if (res.code === 200) {
            this.$Message.success(res.message)
            //关闭接待弹窗
            this.cancelMeasure()
          } else {
            this.$Message.error(res.message)
          }
        })

      })
    },
    /**
     * @desc   : 上传文件
     * @author : 付斌
     * @date   : 2024-02-01 14:26
     */
    uploadFile(response, file, fileList) {

    },
    /**
     * @desc   : 获取客户意向
     * @author : 常皓宁
     * @date   : 2024/4/7 13:30
     */
    getIntention() {
      let params = {
        dataSourceCode: 'customerIntention'
      }
      this.excute(this.$service.commonService, this.$service.commonService.getInitData, params, false).then(res => {//调用api查询方法
        if (res.code === this.$config.SUCCESS_CODE) {
          this.intentionList = res.data
        }
      })
    },
    /**
     * @desc   : 获取留店时长
     * @author : 常皓宁
     * @date   : 2024/4/7 13:31
     */
    getStayTimeLen() {
      let params = {
        dataSourceCode: 'storeRetentionTime'
      }
      this.excute(this.$service.commonService, this.$service.commonService.getInitData, params, false).then(res => {//调用api查询方法
        if (res.code === this.$config.SUCCESS_CODE) {
          this.stayTimeLenList = res.data
        }
      })
    },

    /**
     * @desc   : 获取邀约结果
     * @author : 常皓宁
     * @date   : 2024/4/7 13:31
     */
    getInviteResult() {
      let params = {
        dataSourceCode: 'inviteResult'
      }
      this.excute(this.$service.commonService, this.$service.commonService.getInitData, params, false).then(res => {//调用api查询方法
        if (res.code === this.$config.SUCCESS_CODE) {
          this.inviteResultList = res.data
        }
      })
    },

    /**
     * @desc   : 查询事件
     * @author : 付斌
     * @date   : 2024-02-01 14:24
     */
    initData() {
      this.getStayTimeLen()
      this.getIntention()
      this.getInviteResult()
    },
  },
  created() {
    this.primaryKey = 'followId'  // 设置主键Id
    this.routeObjName = 'cusFollow'  // 设置路由名称
  }
}
</script>
