<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.billno?basic.billno:"--" }}</el-descriptions-item>
        <el-descriptions-item label="报价类型">{{ basic.quotedpricetype?basic.quotedpricetype:"--" }}</el-descriptions-item>
        <el-descriptions-item v-if="basic.quotedpricetype === '项目报价'" label="项目名称">{{ basic.projectname?basic.projectname:"--"}}</el-descriptions-item>
         <el-descriptions-item v-if="basic.quotedpricetype === '项目报价'" label="项目编号">{{ basic.projectnum?basic.projectnum:"--" }}</el-descriptions-item>

        <el-descriptions-item label="产品系列">
          <span v-for="(item,index) in basic.itemtype">
            {{basic.itemtype.length === 0?item:index === basic.itemtype.length -1?item:item+','}}
          </span>
        </el-descriptions-item>
        <el-descriptions-item label="客户">{{ basic.enterprisename?basic.enterprisename:"--" }}</el-descriptions-item>
        <el-descriptions-item label="电话">{{ basic.telephone?basic.telephone:"--" }}</el-descriptions-item>
        <el-descriptions-item label="联系人">{{ basic.contactsname?basic.contactsname:"--" }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ basic.contactsphonenumber?basic.contactsphonenumber:"--" }}</el-descriptions-item>
        <el-descriptions-item label="报价日期">{{ basic.contactsphonenumber?basic.contactsphonenumber:"--" }}</el-descriptions-item>
        <el-descriptions-item label="有效期">{{ basic.begdate?basic.begdate + '至' + basic.enddate:"--" }}</el-descriptions-item>
        <el-descriptions-item label="折扣(%)">{{ basic.discountrate !== 0?Math.round((basic.discountrate * 100)*100)/100:"--" }}</el-descriptions-item>
        <el-descriptions-item label="总金额(元)">{{ totalPrice?totalPrice:"--" }}</el-descriptions-item>

        <el-descriptions-item label="品牌">{{ basic.brandname?basic.brandname:"--" }}</el-descriptions-item>
        <el-descriptions-item label="领域">{{ basic.tradefield?basic.tradefield:"--" }}</el-descriptions-item>

        <el-descriptions-item label="是否特价">{{ basic.specialoffer === 1?'是':'否' }}</el-descriptions-item>
        <el-descriptions-item label="状态" >
          <p :style="colorStyle">{{ basic.status?basic.status:"--" }}</p>
        </el-descriptions-item>
        <el-descriptions-item label="负责人">{{ basic.leader.length !== 0?basic.leader[0].name:"--" }}</el-descriptions-item>
        <el-descriptions-item label="备注">{{ basic.remarks?basic.remarks:"--" }}</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="创建人">{{ basic.createby?basic.createby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ basic.createdate?basic.createdate:"--" }}</el-descriptions-item>
        <!--        <el-descriptions-item label="锁定状态">{{ basic.locked?basic.locked:"&#45;&#45;"}}</el-descriptions-item>-->
        <el-descriptions-item label="最近编辑人">{{ basic.changeby?basic.changeby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="最近编辑时间">{{ basic.changedate?basic.changedate:"--" }}</el-descriptions-item>
        <el-descriptions-item label="提交人">{{ basic.submitby?basic.submitby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="提交时间">{{ basic.submitdate?basic.submitdate:"--" }}</el-descriptions-item>
        <el-descriptions-item label="审核人">{{ basic.checkby?basic.checkby:"--" }}</el-descriptions-item>
        <el-descriptions-item label="审核时间">{{ basic.checkdate?basic.checkdate:"--" }}</el-descriptions-item>
        <el-descriptions-item label="作废原因">{{ basic.deleteReason.length !== 0?basic.deleteReason[0].deletereason:'--'}}</el-descriptions-item>
        <el-descriptions-item label-class-name="my-label" label="转手次数">{{ data.leader.length !== 0?data.leader[0].leadernum === 0?'0':data.leader[0].leadernum:'--' }}</el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  props:["data","totalPrice"],
  data(){
    return {
      basic:[],
      colorStyle:{
        color:''
      }
    }
  },
  methods:{
    async basicData(id){
      const res = await this.$api.requested({
        "id": 20221020165203,
        "version":1,
        "content": {
          "sa_quotedpriceid":id
        }
      })
      this.basic = res.data
      this.style(this.basic.status)
    },
    detailedList(data){
      console.log("输出")
      console.log(data)
      this.basicData(data.sa_quotedpriceid)
    },
    style(val) {
      let style = {}
      console.log(val,'执行了')
      switch (val) {
        case '新建':
          style = {color:'#3874f6'}
          break;
        case '提交':
          style = {color:'#52c41a'}
          break;
        case '审核':
          style = {color:'#333333'}
          break;
        default:
          break;
      }
      console.log(style)
      this.colorStyle.color = style.color
      console.log(this.colorStyle)
      return style

    }
  },
  created() {
    console.log(this.data)
    this.basicData(this.data.sa_quotedpriceid)
  }
}
</script>

<style scoped>

</style>