<!-- @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="edit" name="edit"></BaseIndexButton>
        <BaseIndexButton ref="check" name="check" :isMustChooseFlag="false"></BaseIndexButton>
        <BaseIndexButton ref="followTask" name="followTask" :isMustChooseFlag="false"></BaseIndexButton>
        <BaseIndexButton ref="downloadTemplate" name="downloadTemplate"></BaseIndexButton>
        <BaseIndexButton ref="import" name="import"></BaseIndexButton>
      </template>
      <template #right>
        <BaseIndexButton ref="add" name="add"></BaseIndexButton>
      </template>
    </BaseIndexButtonGroup>

    <!--  查询条件区域  -->
    <div id="search-cond-div" ref="search-cond-div" style="margin-top: 1px;padding: 0">
      <SearchCond ref="searchCond" v-model="searchCond"
                  @collapse-change="collapseChange" :setFlag="false"
                  :search-content="searchContent"></SearchCond>
    </div>
    <!--  table区域  -->
    <card style="padding: 0">
      <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-50" primaryKey="customerId"
               :page-size="pageInfo.pageSize"
               @pageChange="pageSizeChange"
               name="table">
        <DkTableColumn :type="$libaray.checkButtonHasRight('customer-detail')?'link':''" field="customerCode"
                       fixed="left" @on-link="openCustomerMessage"></DkTableColumn>
        <DkTableColumn :type="$libaray.checkButtonHasRight('customer-detail')?'link':''" field="customerName"
                       fixed="left" @on-link="openCustomerMessage"></DkTableColumn>
        <DkTableColumn field="customerPhone"></DkTableColumn>
        <DkTableColumn field="channelName"></DkTableColumn>
        <DkTableColumn field="addressFull"></DkTableColumn>
        <DkTableColumn field="contactName"></DkTableColumn>
        <DkTableColumn field="contactPhones"></DkTableColumn>
        <DkTableColumn field="orgName"></DkTableColumn>
        <DkTableColumn field="intentionTagsName"></DkTableColumn>
        <DkTableColumn field="customerClassifiedName" title="客户分类"></DkTableColumn>
        <DkTableColumn field="intentionQuantityTag"></DkTableColumn>
        <DkTableColumn field="saleStatusName"></DkTableColumn>
        <DkTableColumn field="customerTagNames"></DkTableColumn>
        <DkTableColumn field="opCreateTime"></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>
        <vxe-column fixed="right" type="operate" width="100px" v-if="checkOperateIsVisible('follow')">
          <template #default="{row}">
            <DkButton @click="follow(Object.assign({row:row}))" v-if="checkOperateIsVisible('follow')">
              {{ $v('follow') }}
            </DkButton>
          </template>
        </vxe-column>
      </DkTable>
    </card>

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

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


    <!--    导入-->
    <Upload v-show="false"
            :headers="{Authorization: 'Bearer ' + $store.state.user.token}"
            :action="this.$config.serviceUrl + '/customer-server/sale/customer/import'"
            accept=".xls, .xlsx" :on-success="uploadSuccess"
    >
      <Button ref="uploadButton">
      </Button>
    </Upload>

  </div>
</template>

<script>
import {indexMixin} from '@/mixins'
import FollowTask from '../cus-follow/follow-task'
import Follow from "../cus-follow/follow";

export default {
  name: 'customer',
  mixins: [indexMixin],
  components: {
    FollowTask,
    Follow
  },
  data() {
    let self = this
    return {
      pullCondModal: false,
      ibossCustomersShow: false,//iboss客户资料弹窗
      //页面初始化标识
      created: false,
      // 客户信息
      customerInfo: {},
      // 客户信息 跟进任务
      customerInfo6: {
        customerIds: [],
        customerNames: [],
        followUsers: []
      },
      // 错误信息
      errMessage: {},
      // 跟进弹窗
      followModal: false,
      // 跟进任务弹窗
      followTaskModal: false,
      // 跟进方式list
      followTypeList: [],
      //  商品规格品类
      goodsSpecsList: [],
      //  商品规格品类备份
      goodsSpecsListBackUp: [],
      // 邀约结果list
      inviteResultList: [],
      // 意向list
      intentionList: [],
      // 合并弹窗
      mergeModal: false,
      // 合并目标
      mergeTarget: null,
      // 合并来源
      mergeSource: null,
      // 接待弹窗
      receptionModal: false,
      // 客成状态list
      saleStatusList: [],
      // 查询条件
      searchCond: {},
      searchContent: [
        {
          valueFormat: {code: 'customerName'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'customerPhone'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'contactName'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'contactPhones'},
          valueKind: 'STR'
        },
        {
          itemName: 'opCreateTime',
          valueFormat: {
            code: 'opCreateTime',
            default: [new Date().addMonths(-1).format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')]
          },
          valueKind: 'DATE_RANGE'
        },
        {
          valueFormat: {code: 'reportUserName'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'followCount'},
          valueKind: 'STR'
        },
        {
          valueFormat: {
            code: 'customerFromList',
            data: [],
            valueKey: 'fromId',
            labelKey: 'fromName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          valueFormat: {
            code: 'customerTags',
            data: [],
            valueKey: 'tagId',
            labelKey: 'tagName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          valueFormat: {
            code: 'intentionTags',
            data: [],
            valueKey: 'dataCode',
            labelKey: 'dataName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          itemName: self.$t('intentionQuantityTag'),
          valueFormat: {code: 'intentionQuantity'},
          valueKind: 'STR'
        },
        {
          valueFormat: {code: 'addressFull'},
          valueKind: 'STR'
        },
        {
          valueFormat: {
            code: 'channelList',
            data: [],
            valueKey: 'channelId',
            labelKey: 'channelName',
          },
          valueKind: 'M-CHOICE'
        },
        {
          valueFormat: {
            code: 'neverFollowFlag',
            data: [
              {label: self.$t('yes'), value: 'true'}, {label: self.$t('no'), value: 'false'}
            ],
          },
          valueKind: 'RADIO'
        },
        {
          valueFormat: {
            code: 'overFollowTimeFlag',
            data: [
              {label: self.$t('yes'), value: 'true'}, {label: self.$t('no'), value: 'false'}
            ],
          },
          valueKind: 'RADIO'
        },
      ],
      tableData: [],
      tabsModel: null,
      tabsOptions: [
        {label: self.$t('allCustomers'), name: self.$t('allCustomers'), index: 3},
      ],
      //业务部门list
      orgList: [],
      ruleInline: {
        erpOrgCode: [
          {required: true, trigger: 'none', type: 'array'}
        ],
      },
      ibossCustomersFormData: {
        orgId: null,
        orgCode: null,
        orgName: null,
        erpOrgCode: null,
      },
      pageInfo: {
        total: 0,
        pageSize: 20,
        currentPage: 1
      },
    }
  },
  methods: {
    /**
     *   @desc   : 新建
     *   @date   : 2023/4/10 14:40
     *   @author : 付斌
     */
    add() {
      this.$router.push('/core/customer/add');
    },
    /**
     * @desc   : 判断操作是否可见
     * @author : 付斌
     * @date   : 2024-02-01 14:20
     */
    checkOperateIsVisible(name) {

    },
    /**
     * @desc   : 进入客户页面
     * @author : 付斌
     * @date   : 2024-02-01 14:20
     */
    openCustomerMessage(row) {
      this.$router.push('/sale/customer/detail/' + row['customerId'])
    },
    /**
     * @desc   : 点击tab
     * @author : 付斌
     * @date   : 2024-02-01 14:20
     */
    clickTab(val) {
    },
    /**
     * @desc   : 下载模板
     * @author : 付斌
     * @date   : 2024-02-01 14:20
     */
    downloadTemplate() {

    },
    /**
     * @desc   : 打开跟进弹窗
     * @author : 付斌
     * @date   : 2024-02-01 14:20
     */
    follow(e) {
      this.followModal = true

    },
    /**
     * @desc   : 跟进任务
     * @author : 付斌
     * @date   : 2024-02-01 14:21
     */
    followTask() {
      this.followTaskModal = true
    },

    /**
     * @desc   : 分页
     * @author : 付斌
     * @date   : 2024-02-01 14:21
     */
    pageSizeChange(pageInfo) {

    },
    /**
     * @desc   : 查询事件
     * @author : 付斌
     * @date   : 2024-02-01 14:21
     */
    initData(currentPage) {

    },
    /**
     * @desc   : 导入
     * @author : 付斌
     * @date   : 2024-02-01 14:21
     */
    importExcel() {
    },
    /**
     * @desc   : 导入成功
     * @author : 付斌
     * @date   : 2024-02-01 14:21
     */
    uploadSuccess(res) {

    },
    /**
     * @desc   : 查询数据
     * @author : 付斌
     * @date   : 2024-02-01 14:22
     */
    getData() {

    },
  },
  created() {
    this.primaryKey = 'customerId'  // 设置主键Id
    this.routeObjName = 'customer'  // 设置路由名称
  }
}
</script>
