<template>
  <div>
    <el-table
      :data="tableData"
      style="width: 100%"
      size="small"
      border>
      <el-table-column
        prop="billno"
        label="发货单号"
        width="180">
        <template slot-scope="scope">
          <a class="table_row_link" @click="linkDetail(scope.row)">{{scope.row.billno}}</a>
        </template>
      </el-table-column>
      <el-table-column
        prop="status"
        label="状态"
        width="90">
        <template slot-scope="scope">
          <span style="color:#000000" v-if="scope.row.status == '新建'">{{scope.row.status}}</span>
          <span style="color:#d90a0a" v-else-if="scope.row.status == '提交'">{{scope.row.status}}</span>
          <span style="color:#52C41A" v-else-if="scope.row.status == '审核'">{{scope.row.status}}</span>
          <span style="color:#3874f6" v-else-if="scope.row.status == '复核'">{{scope.row.status}}</span>
          <span style="color:#b2c0ea" v-else-if="scope.row.status == '关闭'">{{scope.row.status}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="billdate"
        label="单据日期">
      </el-table-column>
      <el-table-column
        prop="address"
        label="备注">
      </el-table-column>
    </el-table>
    <div class="container normal-panel" style="text-align:right">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[20, 50, 100, 200]"
        layout="total,sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData:[],
      param:{
        "id": 20221205111302,
        "content": {
          "sa_orderid": this.$route.query.id,
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "condition": ""
          }
        },
      },
      total:0,
      currentPage:0,
    }
  },
  methods:{
    async listData() {
      const res = await this.$api.requested(this.param)
      this.tableData = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      this.param.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      this.param.pageNumber = val
      this.listData()
    },
    linkDetail (item) {
        let route = this.$route
        if (route.path !== '/taskDetails') {
          this.oldRoute = {path:route.path,query:route.query}
          this.$store.dispatch('setHistoryRouter',this.oldRoute)
        }
        this.$router.replace({path:'/dispatchdetail',query:{id:item.sa_dispatchid,rowindex:item.rowindex}})
      }
  },
  mounted () {
    this.listData()
  }
}

</script>
<style>
</style>