<template>
  <div class="page">
    <topBar
      v-if="topList.length > 0"
      :topList="topList"
      :moren="moren"
    ></topBar>
    <div class="thetopbox">
      <el-form label-width="100px">
        <el-row>
          <el-col :span="4">
            <el-form-item class="dizhi" label="门店名称" prop="">
              <el-input v-model="queryParams.storeName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item class="dizhi" :label="'会员编号'" prop="">
              <el-input v-model="queryParams.memberCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item class="dizhi" :label="'会员姓名'" prop="">
              <el-input v-model="queryParams.memberName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <div class="searchbox">
              <el-button class="my_search" @click="getSearch">
                {{ '搜索' }}</el-button
              >
              <el-button class="my_reset" @click="reChongzhi">
                {{ '重置' }}</el-button
              >
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main">
      <div class="maintop">
        <div class="mainbtn">
          <el-button
            size="mini"
            style="background: #ffad41; color: #fff; border: none"
            class="addBtn"
            @click="handleExport"
            >{{'导出'}}</el-button
          >
        </div>
      </div>
      <div class="maintable">
        <el-table
          ref="multipleTable"
          :data="tableData"
          v-loading="loading"
          height="720px"
          style="width: 100%"
          :header-cell-style="{ background: '#EEEEEE' }"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55"> </el-table-column>

          <el-table-column align="center" prop="orderCode" label="门店图片">
            <template slot-scope="scope">
              <img
                style="width: 44px; height: 44px; border-radius: 8px"
                :src="scope.row.path"
                alt=""
              />
            </template>
          </el-table-column>
          <el-table-column align="center" prop="storeName" label="门店名称">
          </el-table-column>
          <el-table-column align="center" prop="memberCode" :label="'会员编号'">
          </el-table-column>
          <el-table-column align="center" prop="memberName" :label="'会员姓名'">
          </el-table-column>
          <el-table-column align="center" prop="num" :label="'总次数'">
          </el-table-column>
          <el-table-column align="center" prop="usedNum" label="已用次数">
          </el-table-column>
          <el-table-column align="center" prop="surplusNum" label="剩余次数">
          </el-table-column>
          <el-table-column
            align="center"
            prop="time"
            :label="'操作'"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button
                class="button-s"
                type="text"
                style="color: #ffad41"
                size="small"
                @click="goDetail(scope.row)"
              >
                查看详情
              </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="getSearch"
    />
  </div>
</template>

        <script>
import topBar from "@/components/topBar";

import * as equ from "@/api/equipment.js";
export default {
  name: "Purchases",
  components: {
    topBar,
  },
  data() {
    return {
      moren: "purchases",
      topList: [
        {
          name: "设备列表",
          path: "devices",
        },
        {
          name: "购买次数",
          path: "purchases",
        },
      ],
      tableData: [],
      loading:false,
      queryParams: {
        pageNum: 1,
        pageSize: 50,
      },
      total: 0,
      multipleSelection: [],
    };
  },
  created() {
    this.getSearch();
  },
  methods: {
    //查看详情
    goDetail(row) {
      this.$router.push({
        path: "purchaseDetail",
        query: { pkMember: row.pkMember, pkMakerSpace: row.pkMakerSpace },
      });
    },
    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(
          "/system/manage/bd-machine-maker-space/export-silo-num-list",
          Object.assign({}, this.queryParams),
          `购买次数${new Date().getTime()}.xlsx`
        );
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    reChongzhi() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 50,
      };
      this.getSearch();
    },
    getSearch() {
      this.loading = true
      equ.getMakerSpaceSilonumList(this.queryParams).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
        this.loading = false
      });
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-range-editor.el-input__inner {
  width: 100%;
}
::v-deep .el-table thead {
  color: #000000;
}
::v-deep .el-table .warning-row {
  background: #f9f9f9;
}
.page {
  padding: 10px 20px;
  background: #f9f9f9;
  font-size: 14px;
  .thetopbox {
    padding: 15px 20px 15px 0;
    background: #ffffff;
    border-radius: 8px;
    .searchbox {
      display: flex;
      align-items: center;
      margin-left: 40px;
    }
    .searchtitle {
      margin-right: 10px;
    }
    .searchbtn {
      background: #08143f;
      color: #ffffff;
    }
  }
  .main {
    //margin-top: 20px;
    background: #f9f9f9;
    //border-radius: 8px;
    //box-shadow: 0px 2px 20px 0px rgba(238, 238, 238, 0.5);

    .maintop {
      display: flex;
      // padding: 10px 0;
      justify-content: space-between;
      align-items: center;
      .mainbtn {
        .thebtn1 {
          color: #ffffff;
          background: #48b2fd;
        }
        .thebtn2 {
          color: #ffffff;
          background: #ffad41;
        }
      }
    }
  }
}
</style>
