<!-- @Descripttion: 财务管理 - 在线退款明细 -->
<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="main">
      <el-form
        ref="select"
        :model="select"
        style="background-color: #fff"
        label-width="100px"
      >
        <el-row>
          <!-- 一层 -->
          <el-col :span="4">
            <el-form-item :label="'会员编号'">
              <el-input clearable v-model="queryParams.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'会员姓名'">
              <el-input clearable v-model="queryParams.memberName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'交易类型'">
              <el-select
                clearable
                :placeholder="'请选择'"
                v-model="queryParams.businessType"
              >
                <el-option
                  v-for="item in tradeTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'支付渠道'">
              <el-select
                clearable
                :placeholder="'请选择'"
                v-model="queryParams.refundChannel"
              >
                <el-option
                  v-for="item in channelList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'退款状态'">
              <el-select
                clearable
                :placeholder="'请选择'"
                v-model="queryParams.refundStatus"
              >
                <el-option
                  v-for="item in statusList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'单据编号'">
              <el-input clearable v-model="queryParams.businessCode"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item :label="'创建日期'">
              <el-date-picker
                v-model="queryParams.creationTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :range-separator="'至'"
                :start-placeholder="'开始日期'"
                :end-placeholder="'结束日期'"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item :label="'退款完成日期'">
              <el-date-picker
                v-model="queryParams.finishTime"
                value-format="yyyy-MM-dd"
                type="daterange"
                :range-separator="'至'"
                :start-placeholder="'开始日期'"
                :end-placeholder="'结束日期'"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button
              class="my_search"
              style="margin-left: 30px"
              @click="getDataList"
            >
              {{ '搜索' }}</el-button
            >
            <el-button class="my_reset" @click="reset">
              {{ '重置' }}</el-button
            >
          </el-col>
        </el-row>
      </el-form>
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="small"
            @click="handleExport"
            v-has-buttons="['OnlineRefundDetailsExport']"
            class="thebtn2"
          >
            {{ '导出' }}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          :data="tableData"
          height="680px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          :row-class-name="tableRowClassName"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55"> </el-table-column>

          <el-table-column
            align="center"
            prop="memberCode"
            :label="'会员编号'"
            min-width="120px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="memberName"
            :label="'会员姓名'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="payBusinessTypeVal"
            :label="'交易类型'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="refundMoney"
            :formatter="stateFormat"
            :label="'退款金额' + `(${isLocalSymbol()})`"
            width="150"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="finishMoney"
            :formatter="stateFormat"
            :label="'实际退款金额' + `(${isLocalSymbol()})`"
            width="150"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="refundChannelVal"
            :label="'退款渠道'"
          >
          </el-table-column>

          <el-table-column
            align="center"
            prop="refundStatusVal"
            :label="'退款状态'"
          >
            <template slot-scope="scope">
              <el-tooltip placement="top" v-if="scope.row.refundStatus == 3">
                <div slot="content">{{ scope.row.errorMsg }}</div>
                <el-text>{{ scope.row.refundStatusVal }}</el-text>
              </el-tooltip>
              <span v-else>{{ scope.row.refundStatusVal }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="creationTime"
            :label="'创建日期'"
            width="200"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="finishTime"
            :label="'退款完成日期'"
            width="200"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="payBusinessCode"
            :label="'单据编号'"
            min-width="180px"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="time"
            :label="'操作'"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button
                v-if="scope.row.refundStatus != 2"
                @click="toFixed(scope.row.pkId)"
                type="text"
                v-hasButtons="['memberConsumSee']"
                style="color: #48b2fd"
                size="small"
              >
                {{ $t("查询结果") }}
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getDataList"
    />
  </div>
</template>

<script>
import topBar from "@/components/topBar";
import * as api from "@/api/financialCase.js";
import { userCountryList } from "@/api/user";

export default {
  name: "Bzpz",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "onlineRefundDetails",
      topList: [
        {
          name: '在线退款明细',
          path: "onlineRefundDetails",
        },
      ],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      tableData: [],
      statusList: [],
      channelList: [],
      tradeTypeList: [],
    };
  },
  mounted() {
    // 获取下拉
    this.getData();
    // 获取列表
    this.getDataList();
  },
  methods: {
    getData() {
      api.payChannel().then((res) => {
        this.channelList = res.data;
      });
      api.getRefundStatus().then((res) => {
        this.statusList = res.data;
      });
      api.businessType().then((res) => {
        this.tradeTypeList = res.data;
      });
    },

    reset() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
      };
      this.getDataList();
    },
    // 点击修改
    toFixed(id) {
      api.onlineRefundQueryStatus({ pkId: id }).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: res.msg,
            type: "success",
          });
        }
      });
    },

    getDataList() {
      api.getRefundList(this.queryParams).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
      });
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        this.download(
          "/pay/manage/online-refund/refund-export",
          { ...this.queryParams },
          `${'在线退款明细'}${new Date().getTime()}.xlsx`
        );
      });
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 == 1) {
        return "warning-row";
      } else if (rowIndex % 2 == 0) {
        return "success-row";
      }
      return "";
    },
  },
};
</script>
<style scoped lang="scss">
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}

::v-deep .el-table .success-row {
  background: #ffffff;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-select {
  width: 100%;
}
.uploadIcon ::v-deep .el-upload--picture-card {
  display: none !important; /* 上传按钮隐藏 */
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    .maintop {
      display: flex;
      padding: 0px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          background: #3181e5;
          color: #ffffff;
        }
        .thebtn2 {
          background: #ffad41;
          color: #ffffff;
          width: 68px;
          height: 32px;
        }
      }
      .maintitle {
        font-size: 10px;
        font-family: MicrosoftYaHei;
        color: #999999;
      }
    }
  }
  .tem {
    img {
      width: 28px;
      height: 20px;
      margin-right: 3px;
    }
  }
  .isRed {
    color: #ed1d25;
  }
  .isGreen {
    color: #1ab62b;
  }
  .bgImg {
    width: 48px;
    height: 48px;
  }
}
.openClose {
  text-align: right;
  margin-right: 10px;
  color: #3181e5;
}
</style>
