<!--
 * @Descripttion:
 * @version:
 * @Author: kBank
 * @Date: 2022-10-24 15:45:01
-->
<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="会员编号">
                <el-input clearable v-model="select.memberCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-button type="primary" size="small" @click="getDataList">
                {{ '搜索' }}</el-button
              >
              <el-button size="small" class="resetBtn" @click="reset">
                {{ '重置' }}</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div class="main_a">
        <div class="mainbtn">
          <el-button
            size="small"
            @click="handleExport"
            v-hasButtons="['RetailPickExport']"
            class="addBtn"
            >导出</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="memberCode"
              :label="$t('会员编号')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="memberName"
              :label="$t('会员姓名')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="usableQuantity"
              :label="$t('可提数量')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="usedQuantity"
              :label="$t('已提数量')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="creationTime"
              :label="$t('创建时间')"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="modifiedTime"
              :label="$t('修改时间')"
            >
            </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: "Bzpz",
  components: {
    topBar,
  },
  filters: {
    isAgree(val) {
      if (!val) {
        return '允许';
      } else {
        return '禁止';
      }
    },
  },
  data() {
    return {
      creationTime: [],
      creationTime1: [],
      creationTime2: [],
      select: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      addOrEdit: "",
      total: 0,
      dialogVisible: false,
      tableData: [],
      loading: false,
      moren: "retailPickList",
      topList: [
        {
          name: "提货会员数据",
          path: "retailPickList",
        },
      ],
      form: {
        name: "",
      },
      actStatus: [],
      teamNameList: [],
      options: [],
    };
  },
  mounted() {
    // 获取下拉
    this.getData();
    // 获取列表
    this.getDataList();
  },
  methods: {
    //重置
    reset() {
      this.select = {};
      this.creationTime = [];
      this.creationTime1 = [];
      this.creationTime2 = [];
      this.getDataList();
    },
    getData() {
      api.vertexFindAll().then((res) => {
        this.options = res.data;
      });
      api.listNoPage().then((res) => {
        this.teamNameList = res.rows;
      });
    },
    changeTime(val) {
      this.select.actStartDate = val ? val[0] : "";
      this.select.actEndDate = val ? val[1] : "";
    },
    handleClose() {
      this.dialogVisible = false;
      this.$refs["form"].clearValidate();
      this.$refs["form"].resetFields();
    },
    // 获取列表
    getDataList() {
      this.loading = true;
      api
        .retailPickList(Object.assign({}, this.queryParams, this.select))
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.loading = false;
        });
    },
    handleSelectionChange(val) {},
    /** 导出按钮操作 */
    handleExport() {
      this.$confirm('是否确认导出所有数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: "warning",
      }).then((_) => {
        this.download(
          "/sale/manage/retail-pick/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>
