<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
<!--      <el-form-item label="订单编号" prop="businessCode">-->
<!--        <el-input-->
<!--          v-model="queryParams.businessCode"-->
<!--          placeholder="请输入订单号"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <el-form-item label="外部订单" prop="tradeNo">
        <el-input
          v-model="queryParams.tradeNo"
          placeholder="请输入外部订单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>



      <el-form-item label="业务类型" prop="businessType">
        <el-select v-model="queryParams.businessType" placeholder="请选择业务类型" clearable size="small">
          <el-option
            v-for="dict in busineOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table height="600" v-loading="loading" border :data="storePaymentList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="订单编号" align="center" prop="orderNo" width="170px"/>
      <el-table-column label="外部单号" align="center" prop="orderFlowNo" width="350px"/>
      <el-table-column label="业务类型 " align="center" prop="businessType" width="100">
        <template slot-scope="scope">
          <dict-tag :options="busineOptions" :value="scope.row.businessType"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="状态" align="center" prop="status">-->
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="statusOptions" :value="scope.row.status"/>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="错误信息" align="center" prop="msg" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="155" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listStorePaymentError } from "@/api/his/storePayment";
export default {
  name: "StoreErrorPayment",
  data() {
    return {
      busineOptions:[],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 支付明细表格数据
      storePaymentList: [],
      payModeOptions:[],
      shareOptions:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态 0未处理 1已处理
      statusOptions: [
        {dictValue:'0',dictLabel:"未处理"},
        {dictValue:'1',dictLabel:"已处理"}
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        businessType: null,
        status: '0',

      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();

    this.getDicts("sys_store_payment_business_type").then(response => {
      this.busineOptions = response.data;
    });
  },
  methods: {
    /** 查询支付明细列表 */
    getList() {
      this.loading = true;
      listStorePaymentError(this.queryParams).then(response => {
        this.storePaymentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        paymentId: null,
        payCode: null,
        payTypeCode: null,
        payMoney: null,
        payTime: null,
        createTime: null,
        tradeNo: null,
        userId: null,
        openId: null,
        businessType: null,
        businessId: null,
        status: 0,
        remark: null,
        bankTransactionId: null,
        bankSerialNo: null,
        refundMoney: null,
        refundTime: null,
        storeId: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.paymentId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    }
  }
};
</script>
