<template>
  <div>
    <div class="normal-margin">
      <el-descriptions :column="2" labelClassName="my-label" contentClassName="my-content" border>
        <div slot="title" class="my-label__title">基本信息</div>
        <el-descriptions-item  label="客户名称">{{ basic.enterprisename?basic.enterprisename:"--" }}</el-descriptions-item>
        <el-descriptions-item label="客户编号">{{ basic.sa_customersid?basic.sa_customersid:"--" }}</el-descriptions-item>
        <el-descriptions-item label="erp编号">{{ basic.erpagentnum?basic.erpagentnum:"--"}}</el-descriptions-item>
        <el-descriptions-item label="企业简称">{{ basic.abbreviation?basic.abbreviation:"--"}}</el-descriptions-item>
        <el-descriptions-item label="客户类型">{{ basic.type?basic.type:"--" }}</el-descriptions-item>

        <el-descriptions-item label-class-name="my-label" label="客户等级">{{ basic.grade?basic.grade:"--" }}</el-descriptions-item>
        <el-descriptions-item label-class-name="my-label" label="客户分类">{{ basic.customergrade?basic.customergrade:"--" }}</el-descriptions-item>

        <el-descriptions-item label-class-name="my-label" label="客户行业">
          <div v-if="basic.industry">
             <span v-for="(item,index) in basic.industry">
              {{basic.industry.length === 0?item:index === basic.industry.length -1?item:item+','}}
            </span>
          </div>
          <div v-else>
            --
          </div>

        </el-descriptions-item>
        <el-descriptions-item label-class-name="my-label" label="税号">{{ basic.taxno?basic.taxno:"--" }}</el-descriptions-item>

        <el-descriptions-item label-class-name="my-label" label="法人">{{ basic.contact?basic.contact:"--" }}</el-descriptions-item>
        <el-descriptions-item label-class-name="my-label" label="电话">{{ basic.telephone?basic.telephone:"--" }}</el-descriptions-item>
        <el-descriptions-item label="省市县">{{ basic.province?basic.province + '-' + basic.city + '-' + basic.county:"--" }}</el-descriptions-item>
        <el-descriptions-item label="详细地址">{{ basic.address?basic.address:"--" }}</el-descriptions-item>
        <el-descriptions-item label="上级企业">{{ basic.superiorenterprisename?basic.superiorenterprisename:"--" }}</el-descriptions-item>
        <el-descriptions-item label="客户来源">{{ basic.source?basic.source:"--" }}</el-descriptions-item>
        <el-descriptions-item label="所属公海">{{ basic.poolname?basic.poolname:"--" }}</el-descriptions-item>


        <el-descriptions-item label="成交状态">
          <span :style="tradingstatusStyle">{{ basic.tradingstatus?basic.tradingstatus:"--" }}</span>
        </el-descriptions-item>
        <el-descriptions-item label-class-name="my-label" label="成交次数">
          {{ basic.contact_signnum === 0?0:basic.contact_signnum }}
        </el-descriptions-item>
        <el-descriptions-item label="合作状态">
          <span :style="statusStyle">{{ basic.status?basic.status:"--" }}</span>
        </el-descriptions-item>
        <!-- <el-descriptions-item label="负责人">{{ basic.leader.length === 0?"--":basic.leader[0].name }}</el-descriptions-item> -->
        <el-descriptions-item label-class-name="my-label" label="负责人">{{ length !== 0?data.leader[0].name:"--" }}</el-descriptions-item>
      </el-descriptions>
    </div>

    <div>
      <el-descriptions :column="2" labelClassName="my-label" contentClassName="my-content" border>
        <div slot="title" class="my-label__title">系统信息</div>
        <el-descriptions-item label="创建人">{{ system.createby?system.createby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ system.createdate?system.createdate:"--" }}</el-descriptions-item>m>
        <el-descriptions-item label="最近编辑人">{{ system.changeby?system.changeby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="最近编辑时间">{{ system.changedate?system.changedate:"--" }}</el-descriptions-item>
        <el-descriptions-item  label="作废原因">{{ system.returnreson?system.returnreson:"--" }}</el-descriptions-item>
        <el-descriptions-item label="转手次数">{{length !== 0?data.leader[0].leadernum === '0'?'0':data.leader[0].leadernum:'--' }}</el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script>
export default {
  name: "detailedData",
  props:["data","length"],
  data(){
    return {
      basic:[],
      system:[],
      sa_customersid:"",
      tradingstatusStyle:{
        color:''
      },
      statusStyle:{
        color:''
      }
    }
  },
  mounted() {
    this.basicData(this.$route.query.id)
    this.systemData(this.$route.query.id)
  },
  methods:{
    /*基本信息*/
    async basicData(id){
      const res = await this.$api.requested({
        "id": 20221012164302,
        "content": {
          "sa_customersid": this.$route.query.id
        },
      })
      this.basic = res.data
      this.style(this.basic.tradingstatus)
      this.styleStatus(this.basic.status)
    },
    style(val) {
      let style = {}
      switch (val) {
        case '已成交':
          style = {color:'#fa8c16'}
          break;
        case '未成交':
          style = {color:'#3874f6'}
          break;
        case '多次成交':
          style = {color:'#333333'}
          break;
        default:
          break;
      }
      this.tradingstatusStyle.color = style.color
      return style

    },
    styleStatus(val) {
      let style = {}
      switch (val) {
        case '潜在':
          style = {color:'#3874f6'}
          break;
        case '合作中':
          style = {color:'#52c41a'}
          break;
        case '已终止':
          style = {color:'#999999'}
          break;
        default:
          break;
      }
      this.statusStyle.color = style.color
      return style

    },
    /*系统信息*/
    async systemData(id){
      const res = await this.$api.requested({
        "id": 20221019091602,
        "content": {
          "sa_customersid": this.$route.query.id
        },
      })
      this.system = res.data
    },
  }
}
</script>

<style scoped>

</style>