<template>
  <!-- 返工序号页面 -->
  <div>
    <div class="divborder newSearchDiv" style="margin:0px;">
      <!-- 工单 -->
      <div class="filter">
        <label>{{ $t("900053") }}：</label>
        <Select label-in-value class="searchSelect" v-model="workOrder">
          <Option v-for="item in orderList" :value="item.id" :key="item.id"
            >{{ item.title }}
          </Option>
        </Select>
      </div>
      <!-- 总数量 -->
      <div class="filter">
        <label>{{ $t("1950517") }}：</label>
        <Input class="searchInput" v-model="totalNumber" type="text" readonly />
      </div>
      <!-- 已刷数量 -->
      <div class="filter">
        <label>{{ $t("300096") }}：</label>
        <Input class="searchInput" v-model="brushNumber" type="text" readonly />
      </div>
      <!-- sn -->
      <div class="filter">
        <label>{{ $t("sn") }}：</label>
        <Input class="searchInput" v-model="snNumber" type="text" />
      </div>
      <div class="searchBtn">
        <Button type="primary" class="twoWord" @click="Save()">
          {{ $t("900306") }}
        </Button>
      </div>
    </div>
    <!-- 表格区域 -->
    <div class="divborder newTableDiv">
      <Table
        highlight-row
        class="tableClass"
        :data="tableData1"
        :columns="tableColumns1"
        @on-current-change="handleRowChange"
      >
      </Table>
      <div class="pageDiv">
        <div class="pageDirection">
          <Page
            :total="total"
            :current="page"
            @on-change="changePage"
            show-elevator
            show-sizer
            show-total
            @on-page-size-change="handlePageSize"
            :page-size-opts="[10, 20, 30, 40, 100]"
          ></Page>
        </div>
      </div>
    </div>
  </div>
</template>>

<script>
import axios from "@/libs/api.request";
export default {
  data() {
    return {
      total: 0, // 总条数
      page: 1, // 当前条数
      pagesize: 10, // 每一页条数
      workOrder: 0, // 工单
      orderList: [], // 工单数据
      totalNumber: "", // 总数量
      brushNumber: "", // 已刷数量
      snNumber: "", // sn 数据
      tableData1: [], // 表格数据
      detailobj: {},
      tableColumns1: [
        {
          type: "sort",
          title: this.$t("1008"),
          key: "xuhao",
          render: (h, params) => {
            return h(
              "span",
              params.index + (this.page - 1) * this.pagesize + 1
            );
          },
          width: "80px"
        },
        {
          title: this.$t("WO"), // WO
          key: ""
        },
        {
          title: this.$t("SN"), // SN
          key: ""
        },
        {
          title: this.$t("Line"), // Line
          key: ""
        },
        {
          title: this.$t("status"), // status
          key: ""
        }
      ]
    };
  },
  created() {
    // this.GetWoList();
    this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1); // 格式化表格样式
  },
  // 事件处理函数
  methods: {
    // (这个接口, 后端没有写好)
    getorderList() {
      axios
        .request({
          url: "/apis/acc/ReworkBindSerial/GetWoList",
          method: "get"
        })
        .then(res => {
          let result = res.data.data;
          if (res.data.ret === 1&&result&&Array.isArray(result)&&result.length) {
            this.orderList = result;
          }else {
            this.orderList = [];
          }
        });
    },
    // 监听保存事件
    Save() {
      if (!this.snNumber) {
        this.$Message.error(this.$t("请填写sn"));
        return false;
      }
      let data = {
        sn: this.snNumber,
        wo: this.workOrder,
      }
      // (后台接口没有,  待定...)
      // axios
      //  .request({
      //    url: "/apis/acc/ReworkBindSerial/Add",
      //    data,
      //    method: "post"
      //  })
      //  .then (res => {
      //    console.log(res);
      //    return false;
      //  }) 
    },
    handleRowChange(currentRow, oldcurrentRow) {
      this.detailobj = currentRow;
    },
    changePage (value) {
      this.page = value;
      // this.tableData1 = this.tableSearch(this.page, this.pagesize);
    },
    handlePageSize(value) {
      this.pagesize = value;
      // this.pagesize = this.tableSearch(this.page, this.pagesize);
    }
  }
};
</script>

<style lang="less" scoped>
</style>