<template>
  <div>
    <basicDetails
        ref="details"
        :titleText="mainData.uploadbillnum"
        :editData="mainData"
        :mainAreaData="mainAreaData"
        turnPageId="20221101094702"
        delApiId="20221101100702"
        idname="sat_orderclueuploadbillid"
        :statusCheck="[{key:'status',value:'已审核'}]"
        :tabs="['线索','详细信息']"
        @pageChange="pageChange"
        @onEditSuccess="queryMainData($route.query.id)"
        @detailCreate="detailCreate">
      <div slot="tags">
      </div>
      <div slot="customOperation">
        <!-- <edit :data="mainData" @onSuccess="queryMainData"></edit> -->
        <!-- <div v-if="tool.checkAuth($route.name,'update') && mainData.status === '待审核'" class="container normal-panel sticky inline-16">
          <save  @onSave="updateOrderclueuploadbill"></save>
        </div> -->
        <!-- <onDel v-if="tool.checkAuth($route.name,'delete') && mainData.status === '待审核'"></onDel> -->
        <onCheck v-if="tool.checkAuth($route.name,'check')" :status="mainData.status" @onSuccess="queryMainData"></onCheck>
      </div>
      <div slot="slot0" class="normal-panel">
        <billBody :mainData="mainData"/>
      </div>
      <div slot="slot1" class="container normal-panel">
        <BaseInfo :detailInfo="detailInfo"></BaseInfo>
      </div>
      
    </basicDetails>
  </div>
</template>

<script>
import save from './modules/op_save.vue'
import onDel from './modules/op_del.vue'
import onCheck from './modules/op_check.vue'
import switchData from './modules/switchData.vue'
import billBody from './modules/billBody'
import edit from './modules/edit'

import BaseInfo from '@/HDrpManagement/projectChange/modules/modules/baseInfo/baseInfo'

export default {
  name: "detail",
  data() {
    return {
      mainData:{},
      mainAreaData:{},
      detailInfo:{},
      recordlist:[],
      isdesc:1,
      value2:'',
      dateParam:{
        "start": "",
        "end": ""
      },
    }
  },
  components:{
    BaseInfo,save,onDel,onCheck,switchData,billBody,edit
  },
  methods:{
    detailCreate (param) {
      param.content.isAll = 0
    },
    async queryMainData(id) {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.orderclue.orderclue",
        "method": "queryOrderclueuploadbillMain",
        "content": {
            "sat_orderclueuploadbillid": this.$route.query.id

        }
      })
      this.mainData = res.data
      this.changeDataStructure()
    },
    async updateOrderclueuploadbill () {
      const res = await this.$api.requested({
        "classname":"webmanage.saletool.orderclue.orderclue",
        "method": "updateOrderclueuploadbill",
        "content": {
            "sat_orderclueuploadbillid":this.$route.query.id,
            "notes":this.mainData.notes
        }
      })
      this.tool.showMessage(res)
    },
    changeDataStructure() {
      let that = this
      this.mainAreaData = [
          {
          label:'单号',
          value:this.mainData.uploadbillnum
        },
        {
          label:'状态',
          value:this.mainData.status,
          style:function () {
            let style = {}
            switch (that.mainData.status) {
              case '待审核':
                style = {color: '#3874f6'}
                break;
              case '已审核':
                style = {color: '#333333'}
                break;
              default:
                break;
            }
            return style
          }
        },
        {
          label:'线索类型',
          value:this.mainData.cluetype
        },
        {
          label:'导入人',
          value:this.mainData.createby
        },
      ]
      this.detailInfo = {
        baseInfo: [
          {
            label:'单号',
            value:this.mainData.uploadbillnum
          },
          {
            label:'状态',
            value:this.mainData.status,
            style:function () {
              let style = {}
              switch (that.mainData.status) {
                case '待审核':
                  style = {color: '#3874f6'}
                  break;
                case '已审核':
                  style = {color: '#333333'}
                  break;
                default:
                  break;
              }
              return style
            }
          },
          {
            label:'备注',
            value:this.mainData.notes
          },
          {
            label:'线索类型',
            value:this.mainData.cluetype
          },
          {
            label:'线索数',
            value:this.mainData.xiansuocount
          },
          {
            label:'关联活动',
            value:this.mainData.campaignname
          },
        ],
        systemInfo: [
          {label:'创建人',value:this.mainData.createby},
          {label:'创建时间',value:this.mainData.createdate},
          {label:'导入人', value:this.mainData.createby},
          {label:'导入时间', value:this.mainData.createdate},
          {label:'分配人',value:this.mainData.assignedby},
          {label:'分配时间',value:this.mainData.assigneddate},
          {label:'最近编辑人',value:this.mainData.editby},
          {label:'最近编辑时间',value:this.mainData.editdate},
          {label:'最近跟进人',value:this.mainData.followby},
          {label:'最近跟进时间',value:this.mainData.followdate},
          {label:'审核人', value:this.mainData.checkby},
          {label:'审核时间', value:this.mainData.checkdate},
        ]
      }
    },
    // 监听切换数据,上一页,下一页
    pageChange (id,rowindex) {
      this.flag = false
      this.$router.replace({path:'/importClueDetail',query:{id:id,rowindex:rowindex}})
      this.queryMainData(id)
    }
  },
  mounted () {
    this.queryMainData(this.$route.query.id)
  },
  created() {
  }
}
</script>

<style scoped>

</style>