<template>
  <div class="app-container">
    <el-button
      type="primary"
      size="mini"
      @click="handleAdd"
      style="margin-bottom:20px"
      >代写代办添加</el-button
    >
    <el-table :data="list" border style="width: 100%">
      <el-table-column label="业务单编号">
        <template slot-scope="scope">
          <el-tag
            type="primary"
            @click="handleRead(scope.row)"
            style="cursor: pointer"
            >{{ scope.row.serialNumber }}</el-tag
          >
        </template>
      </el-table-column>

      <el-table-column label="业务类型">
        <template slot-scope="scope">
          <span>{{ scope.row.type }}</span>
        </template>
      </el-table-column>

      <el-table-column label="申请人身份证">
        <template slot-scope="scope">
          <span>{{ scope.row.applicant.idCard }}</span>
        </template>
      </el-table-column>

      <el-table-column label="申请人">
        <template slot-scope="scope">
          <span>{{ scope.row.applicant.name }}</span>
        </template>
      </el-table-column>

      <el-table-column label="创建时间">
        <template slot-scope="scope">
          <span>{{
            scope.row.createDate | parseTime("{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </el-table-column>

      <el-table-column label="办理人">
        <template slot-scope="scope">
          <span>{{ scope.row.handler.name }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" fixed="right" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            style="font-size:14px;padding:10px 20px"
            @click="handlePrint(scope.row)"
            >打印</el-button
          >
        </template>
      </el-table-column>

      <!-- <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
      <el-table-column prop="address" label="地址"> </el-table-column> -->
    </el-table>

    <!-- <div>
      <span @click="listQuery.lastPageIndex = listQuery.lastPageIndex - 1"
        >上一页</span
      ><el-link
        :disabled="listQuery.lastPageIndex"
        @click="listQuery.lastPageIndex = listQuery.lastPageIndex + 1"
        >下一页</el-link
      >
    </div> -->

    <pagination
      v-if="total > 0"
      :total="total"
      :page.sync="listQuery.lastPageIndex"
      :limit.sync="listQuery.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import Pagination from "@/components/Pagination";
import { list } from "@/api/helpPrint";
export default {
  components: { Pagination },
  data() {
    return {
      total: 0,
      listQuery: {
        lastPageIndex: 1,
        // params: {},
        size: 10
      },
      list: undefined
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      list(this.listQuery).then(res => {
        // console.log(res);
        this.list = res.d.list;
        this.total = res.d.total;
        this.pageSize = res.d.pageSize;
        // if (!res.d.lastPageIndex) {
        //   this.listQuery.lastPageIndex;
        // }
      });
    },
    handleAdd() {
      // console.log(123);
      this.$router.push("/helpPrint/detail");
    },
    handlePrint(row) {
      localStorage.setItem("print", JSON.stringify(row));
      window.open("../print.html");
    },
    handleRead(row) {
      console.log(row);
      localStorage.setItem("dxdbOjb", JSON.stringify(row));
      this.$router.push("/helpPrint/read");
    }
  },
  watch: {
    "listQuery.lastPageIndex": {
      handler(val) {
        this.getList();
      },
      deep: true //true 深度监听
    }
  }
};
</script>

<style></style>
