<template>
<div>
  <div class="container normal-panel normal-margin">
    <el-descriptions title="活动信息" :column="4">
      <el-descriptions-item label="活动名称">{{detailInfos.name}}</el-descriptions-item>
      <el-descriptions-item label="活动类型">{{detailInfos.type}}</el-descriptions-item>
      <el-descriptions-item label="负责人">{{detailInfos.director?detailInfos.director:'--'}}</el-descriptions-item>
      <el-descriptions-item label="线索数">{{detailInfos.ordercluecount}}</el-descriptions-item>
      <el-descriptions-item label="开始日期">{{detailInfos.begdate}}</el-descriptions-item>
      <el-descriptions-item label="结束日期">{{detailInfos.enddate?detailInfos.enddate:'--'}}</el-descriptions-item>
      <el-descriptions-item label="地点">{{detailInfos.address?detailInfos.address:'--'}}</el-descriptions-item>
      <el-descriptions-item label="状态">{{detailInfos.status}}</el-descriptions-item>
    </el-descriptions>
  </div>
  <div class="container normal-panel normal-margin">
    <el-descriptions title="系统信息" :column="3">
      <el-descriptions-item label="创建人">{{detailInfos.createby}}</el-descriptions-item>
      <el-descriptions-item label="发布人">{{detailInfos.checkby}}</el-descriptions-item>
      <el-descriptions-item label="最近编辑人">{{detailInfos.changeby}}</el-descriptions-item>
      <el-descriptions-item label="创建时间">{{detailInfos.createdate}}</el-descriptions-item>
      <el-descriptions-item label="发布时间">{{detailInfos.checkdate}}</el-descriptions-item>
      <el-descriptions-item label="最近编辑时间">{{detailInfos.changedate}}</el-descriptions-item>
    </el-descriptions>
  </div>
  <div class="my-tabs" >
    <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
      <el-tab-pane label="经销商线索" name="first"></el-tab-pane>
      <el-tab-pane label="业务员线索" name="second"></el-tab-pane>
    </el-tabs>
  </div>
  <div class="container normal-panel">
     <el-form size="small" inline label-position="right" label-width="50px" :model="pageinfo">
      <el-form-item label="搜索">
        <el-input v-model="pageinfo.condition" prefix-icon="el-icon-search" placeholder="客户姓名,手机号" @clear="clueData(pageinfo.pageNumber = 1)" @keyup.native.enter="clueData(pageinfo.pageNumber = 1)" clearable></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="pageinfo.status" placeholder="请选择" @change="clueData(pageinfo.pageNumber = 1)" clearable>
          <el-option
            v-for="item in sys_options"
            :key="item.index"
            :label="item.value"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <tableLayout :layout="activeName === 'first'?tablecols:tablecolsSaler" :data="clueList" :custom="true">
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <el-button class="inline-16" size="small" type="text" @click="$router.push({path:'/clueDetail_private',query:{id:scope.data.sat_orderclueid}})">详 情</el-button>
      </template>
    </tableLayout>
    <div style="margin-top:16px;text-align:right">
      <el-pagination
        background
        small
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="pageinfo.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</div>
</template>

<script>
import {mapGetters} from 'vuex'

export default {
  data () {
    return {
      activeName:'first',
      detailInfos:{},
      pageinfo:{
        pageNumber:1,
        pageSize:20,
        condition:"",
        status:""
      },
      clueList:[],
      CampaignList:[],
      total:0,
      currentPage:0
    }
  },
  computed:{
    ...mapGetters({
      sys_options:'sys_options'
    })
  },
  methods:{
    async detailData () {
      const res = await this.$api.requested({
        "classname":"webmanage.saletool.orderclue.ordercluecampaign",
        "method": "queryCampaignMain",
        "content": {
          "sat_campaignid":this.$route.query.id
        }
      })
      this.detailInfos = res.data
    },
    handleClick () {
      this.pageinfo = {
        pageNumber:1,
        pageSize:20,
        condition:"",
        status:""
      },
      this.clueData()
    },
    async clueData () {
      const res = await this.$api.requested({
        "classname":"webmanage.saletool.orderclue.ordercluecampaign",
        "method": "queryCampaignMx",
        "content": {
          "pageNumber": this.pageinfo.pageNumber,
          "pageSize": this.pageinfo.pageSize,
          "sat_campaignid": this.$route.query.id,
          "where":{
            "cluetype":this.activeName === 'first'?'经销商':'业务员',
            "condition":this.pageinfo.condition,
            "status":this.pageinfo.status
          }
        }
      })
      this.clueList = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
      this.$store.dispatch('optiontypeselect','cluepublic')
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.clueData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.clueData()
    },
    async activityData() {
      const res = await this.$api.requested({
        "classname":"webmanage.saletool.orderclue.ordercluecampaign",
        "method": "queryCampaignList",
        "content": {
          "isAll":true,
          "where": {
            "status": "发布"
          }
        }
      })
      this.CampaignList = res.data
    },
  },
  mounted () {
    this.detailData()
    this.clueData()
    this.activityData()
  },
  created () {
    this.tablecols = this.tool.tabelCol(this.$route.name)['clueTable'].tablecols
    this.tablecolsSaler = this.tool.tabelCol(this.$route.name)['clueSalerTable'].tablecols
    
  }
}

</script>
<style>
</style>