<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="main">
      <div class="form_all">
        <el-form ref="select" :model="select" label-width="auto">
          <el-row :gutter="40">
            <!-- 一层 -->
            <el-col :span="4">
              <el-form-item :label="$t('MN_F_T_639')">
                <el-input clearable v-model="select.actName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item :label="$t('N_I_124')">
                <el-input clearable v-model="select.memberCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('CK_KS_4')">
                <el-date-picker
                  v-model="creationTime"
                  @change="changeTime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="datetimerange"
                  :range-separator="$t('w_0139')"
                  :start-placeholder="$t('CK_KS_4')"
                  :end-placeholder="$t('CK_KS_5')"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('CK_KS_5')">
                <el-date-picker
                  v-model="creationTime1"
                  @change="changeTime1"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="datetimerange"
                  :range-separator="$t('w_0139')"
                  :start-placeholder="$t('CK_KS_4')"
                  :end-placeholder="$t('CK_KS_5')"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item :label="$t('PER_DA_9')">
                <el-date-picker
                  v-model="creationTime2"
                  @change="changeTime2"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="datetimerange"
                  :range-separator="$t('w_0139')"
                  :start-placeholder="$t('CK_KS_4')"
                  :end-placeholder="$t('CK_KS_5')"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-button type="primary" size="small" @click="getDataList">
                {{ $t("MN_T_2") }}</el-button
              >
              <el-button size="small" class="resetBtn" @click="reset">
                {{ $t("MN_T_3") }}</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="main_a">
        <div class="mainbtn">
          <el-button
            size="small"
            @click="handleExport"
            v-hasButtons="['TourismDataExport']"
            class="exportBtn"
          >
            {{ $t("MN_T_8") }}</el-button
          >
        </div>
        <div class="maintable">
          <el-table
            :data="tableData"
            v-loading="loading"
            style="width: 100%"
            height="710px"
            :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="actName"
              :label="$t('MN_F_T_639')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="memberCode"
              :label="$t('N_I_124')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="memberName"
              :label="$t('CK_KS_14')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="pkGradeVal"
              :label="$t('CK_KS_15')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="pkAwardsVal"
              :label="$t('CK_KS_16')"
            >
            </el-table-column>
            <el-table-column align="center" prop="legalRightOldVal" label="升级前权益">
            </el-table-column>
            <el-table-column align="center" prop="legalRightNewVal" label="升级后权益">
            </el-table-column>
            <el-table-column align="center" prop="memberPoint" label="点位数量">
            </el-table-column>
            <el-table-column
              align="center"
              prop="actStartDate"
              :label="$t('CK_KS_4')"
              min-width="120px"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="actEndDate"
              min-width="120px"
              :label="$t('CK_KS_5')"
            >
            </el-table-column>

            <el-table-column
              align="center"
              prop="creationTime"
              min-width="120px"
              :label="$t('PER_DA_9')"
            >
            </el-table-column>
          </el-table>
        </div>
      </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/giftGoods.js";
export default {
  name: "EquitygiftDataList",
  components: {
    topBar,
  },
  data() {
    return {
      creationTime: [],
      creationTime1: [],
      creationTime2: [],
      select: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      tableData: [],
      loading:false,
      moren: "equitygiftDataList",
      topList: [
        {
          name: "权益赠送数据",
          path: "equitygiftDataList",
        },
      ],
      form: {
        name: "",
      },
    };
  },
  mounted() {
    // 获取列表
    this.getDataList();
  },
  methods: {
    //重置
    reset() {
      this.select = {};
      this.creationTime = [];
      this.creationTime1 = [];
      this.creationTime2 = [];
      this.getDataList();
    },
    changeTime(val) {
      this.select.startActStartDate = val ? val[0] : "";
      this.select.endActStartDate = val ? val[1] : "";
    },
    changeTime1(val) {
      this.select.startActEndDate = val ? val[0] : "";
      this.select.endActEndDate = val ? val[1] : "";
    },
    changeTime2(val) {
      this.select.startCreationTime = val ? val[0] : "";
      this.select.endCreationTime = val ? val[1] : "";
    },
    // 获取列表
    getDataList() {
      this.loading = true
      api
        .getBenefitsRuleLogList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.loading = false
        });
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm(this.$t("MN_F_T_407"), this.$t("MN_F_T_304"), {
        confirmButtonText: this.$t("w_0035"),
        cancelButtonText: this.$t("ENU_P_TYPE0"),
        type: "warning",
      }).then((_) => {
        this.download(
          "/activity/manage/gift-benefits/export",
          Object.assign({}, this.queryParams, this.select),
          `权益赠送数据${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-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%;
}
.page {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
  .main {
    // background: #ffffff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    .main_a {
      background: #fff;
      border-radius: 8px;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);
    }
    .mainbtn {
      padding: 0;
    }
    .maintable {
      flex: 1;
    }
  }
}
::v-deep .el-date-editor.el-input,
.el-date-editor.el-input__inner {
  width: 100%;
}
.form_all {
  padding: 0 20px;
  margin-bottom: 10px;
  background: #fff;
}
</style>
  