<!--
 * @Descripttion: 23
 * @version: 13
 * @Author: kangkang
 * @Date: 2020-09-30 21:48:44
 * @LastEditors: kangkang
 * @LastEditTime: 2020-11-05 17:08:04
-->
<template>
  <div v-loading="loading">
    <div class="heior_box">
       <el-button size="small" type="primary" icon="el-icon-sold-out" @click="dataExport" v-if="$local.isRoot()">导出</el-button>
      <div class="search-box">
        <el-select size=small v-model="searchModel.shop" placeholder="请选择类型">
          <el-option
            v-for="item in shops"
            :key="item.text"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
        <el-date-picker
          size="small"
          v-model="dateRange"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
        <el-input v-model="searchModel.keyWord" placeholder="请输入订单号、用户名" clearable size="small">
          <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
        </el-input>
      </div>
    </div>
    <el-table :data="retData.Data" row-key="Id" border size="medium" :height="$getHeight(100)">
      <el-table-column prop="CreateDate" label="支付日期" width="180"></el-table-column>
      <el-table-column prop="Tid" label="订单号" width="180"></el-table-column>
      <el-table-column prop="SellerNick" label="销售人" width="180"></el-table-column>
      <el-table-column prop="BuyerNick" label="购买人" width="180"></el-table-column>
      <el-table-column prop="Phone" label="购买人手机号">
        <template slot-scope="scope">
          <phoneHide :text="scope.row.Phone"></phoneHide>
        </template>
      </el-table-column>
      <el-table-column prop="Price" label="单价"></el-table-column>
      <el-table-column prop="Num" label="数量"></el-table-column>
      <el-table-column prop="TotalFee" label="订单金额"></el-table-column>
      <el-table-column prop="Payment" label="实付金额"></el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        v-if="retData.Data.length>0"
        @current-change="get"
         :current-page.sync="searchModel.PageIndex"
        :page-size="50"
        layout="total,prev, pager, next"
        :total="retData.TotalCount"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  name: 'treeTable',
  components: {
    phoneHide: () => import('@/components/common/phonehide')
  },
  data () {
    return {
      loading: false,
      retData: { TotalCount: 0, Data: [] },
      dateRange:[],
      searchModel: {
        PageIndex: 1,
        keyWord: '',
        shop: '',
        Btime: '',
        Etime: ''
      },
      shops: [
        { text: "可乐开发商", value: "可乐开发商" },
        { text: "老鹰动态pptp", value: "老鹰动态pptp" },
        { text: "强子pptp动态", value: '强子pptp动态' },
      ],
    }
  },
  created () {
    this.$store.commit('setCurrentNav', '订单管理>>淘宝订单')
    this.get()
  },
  methods: {
    search () {
      this.searchModel.PageIndex = 1
      if (this.dateRange && this.dateRange.length == 2) {
        this.searchModel.Btime = this.dateRange[0];
        this.searchModel.Etime = this.dateRange[1];
      }
      this.get()
    },
    get () {
      this.$api.get('sells/v1/taobao/page', this.searchModel).then(res => {
        this.retData = res
      })
    },
    dataExport () {
      this.$api.getDownloadFile('/sells/v1/taobao/Export', this.searchModel)
    }
  }
}
</script>
<style scoped>
</style>
