<template>
  <div class="content-main">
    <el-form :inline="true" :model="searchForm" class="search-bm-boder">
      <el-row>
        <el-form-item label="合同号:">
          <el-input v-model="searchForm.htbh" clearable style="width:170px" placeholder="请输入合同号"></el-input>
        </el-form-item>
        <el-form-item label="状态:">
          <el-select clearable v-model="searchForm.cszt" placeholder="请选择状态" style="width:170px">
            <el-option
              v-for="item in status"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item>
          <div class="search-button">
            <span class="search-line"></span>
            <el-button type="primary" @click="getList" size="small" class="iconfont iconchaxun">查询</el-button>
            <el-button
              type="primary"
              @click="chongzhi"
              size="small"
              class="iconfont iconzhongzhi"
            >重置</el-button>
          </div>
        </el-form-item>
      </el-row>
    </el-form>

    <el-table :data="tableData" border stripe tooltip-effect="dark" id="out-table">
      <el-table-column type="index" label="序号" align="center" width="60"></el-table-column>
      <el-table-column prop="apcc" label="场次" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="htbh" label="合同号" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="lsxz" label="粮食性质" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="pz" label="品种" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="csdwmc" label="申诉单位" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="ccmc" label="买方" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="sgmc" label="卖方" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column prop="csztmc" label="状态" align="center" show-overflow-tooltip width="80"></el-table-column>
      <el-table-column align="center" label="操作" width="180px">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="light" content="查看" placement="top">
            <el-button
              type="primary"
              size="small"
              @click="showInfo(scope.row)"
              class="operate_show_btn iconfont iconchakan2"
            ></el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="light" content="处理" placement="top">
            <el-button
              type="primary"
              size="small"
              @click="updateInfoSave(scope.row)"
              class="operate_edit_btn iconfont iconxiugai"
              v-if="scope.row.cszt == '1'"
            ></el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-row class="pagination-wrap">
      <el-pagination
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        :current-page.sync="pageForm.pageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageForm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageForm.total"
      ></el-pagination>
    </el-row>
  </div>
</template>

<script>
import {
  selectComplainPageList,
  deleteComplain
} from "@/api/transaction/transactionComplaint/transactionFiling.js";

export default {
  data() {
    return {
      pageForm: {
        pageNum: 1,
        pageSize: 10,
        total: null
      },
      searchForm: { htbh: null, cszt: null, pageType: 0, sjlx: 0 },
      tableData: [],
      status: [
        { name: "已提交", value: "1" },
        { name: "已处理", value: "2" }
      ]
    };
  },
  created() {
    this.getList();
  },
  methods: {
    chongzhi() {
      this.searchForm = { htbh: null, cszt: null, pageType: 0, sjlx: 0 };
      this.getList();
    },
    getList() {
      selectComplainPageList({
        ...this.searchForm,
        ...this.pageForm
      }).then(res => {
        if (res.infoCode == 200) {
          this.tableData = res.data.items;
          this.pageForm.total = res.data.total;
        }
      });
    },
    showInfo(row) {
      this.$router.push({
        name: "transactionHandleDetail",
        query: { state: "detail", csbm: row.csbm }
      });
    },
    updateInfoSave(row) {
      this.$router.push({
        name: "transactionHandleDetail",
        query: { state: "edit", csbm: row.csbm }
      });
    },
    handleSizeChange(val) {
      this.pageForm.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.pageForm.pageNum = val;
      this.getList();
    }
  }
};
</script>