
<template>
  <div>
    <basicLayout 
      ref="list" 
      :oldFormPath="{
        add:'SManagement/orderclue/components',
        edit:'SManagement/orderclue/components'
      }"
      tableName="orderclueList"
      idName="sat_orderclueid"
      :specialKey="[{key:'leader',value:'name'}]"
      :apiId="{query:20221101094502,del:''}" 
      :options="options"
      :detailPath="{path:'/orderclue_detail',param:{tabIndex:tabIndex}}"
      @listCreate="list"
      @listData="list2"
    >
    <template #custom>
      <div class="mt-10">
        <p class="search__label">范围:</p>
        <el-select
          class="inline-24"
          size="small"
          v-model="area"
          placeholder="请选择范围"
          @change="areaChange"
        >
         <el-option
            v-for="item in areaList2"
            :key="item.index"
            :label="item.templetname"
            :value="item.templetid"
          ></el-option>
        </el-select>
      </div>
      <div class="mt-10">
        <p class="search__label">跟进状态:</p>
        <el-select v-model="status" clearable class="inline-24" size="small" placeholder="请选择线索状态" @change="$refs.list.param.content.pageNumber=1;$refs.list.param.content.where.status = status;$refs.list.listData()">
          <el-option v-for="item in statusList" :label="item.value" :key="item.rowindex" :value="item.remarks">
          </el-option>
        </el-select>
      </div>
    </template>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname == 'status'">
          <span style="color:#999999" v-if="scope.data.column.data[[scope.data.column.columnname]] == '已过期'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span style="color:#52c41a" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '跟进中'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span style="color:#3874f6" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '待跟进'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span style="color:#333333" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '已无效'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span style="color:#fa8c16" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '已转化'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span v-else>{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
        </div>
        <div v-else-if="scope.data.column.columnname == 'totalinvestment'">
          <span>{{scope.data.column.data[[scope.data.column.columnname]] !== 0?tool.formatAmount(scope.data.column.data[[scope.data.column.columnname]],2):'--'}}</span>
        </div>
        <div v-else-if="scope.data.column.columnname == 'costofconstruction'">
          <span>{{scope.data.column.data[[scope.data.column.columnname]] !== 0?tool.formatAmount(scope.data.column.data[[scope.data.column.columnname]],2):'--'}}</span>
        </div>
        <div v-else-if="scope.data.column.columnname == 'leader'">
          <span v-if="scope.data.column.data[[scope.data.column.columnname]].length !== 0">{{scope.data.column.data[[scope.data.column.columnname]].length > 0 && scope.data.column.data[[scope.data.column.columnname]][0].name}}</span>
          <span v-else>--</span>
        </div>
        <div v-else>
          {{scope.data.column.data[[scope.data.column.columnname]]?scope.data.column.data[[scope.data.column.columnname]]:'--'}}
        </div>
<!--        <span v-if="!scope.data.column.data[scope.data.column.columnname] ">&#45;&#45;</span>-->
        
      </template>
    </basicLayout>
  </div>
</template>

<script>
export default {
  components:{
  },
  data () {
    return {
      options:[],
      arealist:[],
      teamList:[],
      areaList2:[
      ],
      area:'',
      tabIndex:"1",
      status:'',
      statusList:[]
    }
  },
  provide() {
    return {
      arealist:() => this.arealist,
      teamList:() => this.teamList
    }
  },
  async created () {
    this.getTeamList()
    this.query_arealist()
    this.queryUserInfo()
    this.querytemplet()
   /* const res = await this.$store.dispatch('optiontypeselect','dataarea')
    this.areaList2 = res.data*/

    const res2 = await this.$store.dispatch('optiontypeselect','datafollowuptype')
    this.statusList = res2.data
    console.log(this.statusList);
    
  },
  methods:{
    async getTeamList () {
      let res = await this.$api.requested({
        /*"classname": "sale.team.team",
        "method": "query_teamList",*/
        "id":'20221107094704',
        "content": {
          "pageNumber": 1,
          "pageSize": 99999,
          "where": {
              "condition": ""
          }
        }
      })
      this.teamList = res.data
    },
    async query_arealist() {
      const res = await this.$api.requested({
        "classname": "system.tools",
        "method": "query_arealist",
        "content": {
        }
      })
      
      this.arealist = this.tool.createMenu(res.data)
    },
    areaChange(){
      this.tabIndex = this.area
      this.$refs.list.param.content.pageNumber=1;
      this.$refs.list.param.content.type=this.area;
      this.$refs.list.listData()
    },
    async queryUserInfo() {
      let res = await this.$api.requested({
        "classname": "common.usercenter.usercenter",
        "method": "queryUserMsg",
        "content": {
        }
      })
      console.log(res.data);
      
      this.userInfo = {
        isAuth : res.data.hr.isleader,
        userid: res.data.hr.userid
      }
      console.log(this.userInfo,'user')
      window.sessionStorage.setItem('userInfo',JSON.stringify(this.userInfo))
      console.log(JSON.parse(window.sessionStorage.getItem('userInfo')));
      
    },
    list (param) {
      param.content.isAll = 0
      param.content.deleted = 0
      param.content.type = 1
    },
    list2 (data) {
      console.log(data,"数据");
  
    },
    async querytemplet () {
      const res = await this.$api.requested({
        "classname": "sysmanage.develop.querytemplet.querytemplet",
        "method":"query",
        "content": {}
      })
      this.areaList2 = res.data
      this.area = res.data[0].templetid
    }
  }
}

</script>
<style>
</style>