<template>
  <base-list>
    <template slot="n_header">
      <el-form v-model="pagerDto" inline>
        <el-form-item label="跟踪单号">
          <el-input type="textarea" v-model="TrackingNumber" />
        </el-form-item>
        <el-form-item label="补充节点">
          <xyy-a-enum
            :url.sync="enumUrl"
            :model.sync="pagerDto._Eq_JudgmentNode"
            title="补充节点"
            enum-name="JudgmentNode"
          />
        </el-form-item>
        <el-form-item label="补充位置">
          <xyy-a-enum
            :url.sync="enumUrl"
            :model.sync="pagerDto._Eq_TrackSupplementLocation"
            title="补充位置"
            enum-name="TrackSupplementLocation"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="pagerSerach(1)">搜索</el-button>
        </el-form-item>
      </el-form>
    </template>
    <template slot="n_option">
      <el-button @click="downExcel()"> 按搜索条件导出记录 </el-button>
    </template>
    <template>
      <el-table
        v-loading="dataLoading"
        :data="data"
        :highlight-current-row="true"
        :select-on-indeterminate="true"
        width="100%"
      >
        <el-table-column prop="TrackingNumber" label="跟踪单号" />
        <el-table-column prop="JudgmentNodeStr" label="补充节点" />
        <el-table-column prop="TrackSupplementLocationStr" label="补充位置" />
        <el-table-column prop="TrackSupplementTimeStr" label="补充时间" />
        <el-table-column prop="TrackSupplementText" label="补充内容" />
        <el-table-column prop="IsSuccessStr" label="执行结果" />
        <el-table-column prop="ErrorMsg" label="错误原因" />
      </el-table>
      <el-pagination
        :page-sizes="[10, 20, 40, 100, 400]"
        :current-page="pagerDto.PageIndex"
        :page-size.sync="pagerDto.PageSize"
        background
        layout="prev, pager, next ,total ,jumper,sizes,slot "
        :total="pagerDto.total"
        @size-change="changePager"
        @current-change="pagerSerach"
      />
    </template>
  </base-list>
</template>
<script>
import ajaxEnum from '@/components/Xyy/Enums/ajaxEnums'
import BaseList from "@/components/Xyy/baselist";
import { _query, _down } from "@/api/tracking/traceSupplementLogApi";
export default {
  name: "SupplementLogList",
  components: { "base-list": BaseList, 'xyy-a-enum': ajaxEnum },
  data() {
    return {
      data: [],
      dataLoading: false,
      TrackingNumber:"",
      enumUrl: process.env.VUE_APP_Tracking_API + "/Enum",
      pagerDto: {
        PageIndex: 0,
        PageSize: 10,
        total: 0,
        QuerySort: [{ Field: "Id", IsDesc: true }],
      },
    };
  },
  mounted() {
    this.pagerSerach(1);
  },
  methods: {
    pagerSerach(index) {
      this.dataLoading = true;
      if (index) {
        this.pagerDto.PageIndex = index;
      }
      this.pagerDto._In_TrackingNumber=this.TrackingNumber.split(/[\n,]/g);
      _query(this.pagerDto)
        .then((res) => {
          this.data = res.Result;
          this.pagerDto.total = res.TotalCount;
        })
        .finally((res) => {
          this.dataLoading = false;
        });
    },
    downExcel() {
      _down(this.pagerDto);
    },
    changePager(v) {
      this.PageSize = v;
      this.pagerSerach();
    },
  },
};
</script>
