index.vue 6.61 KB
<template>
  <div>
    <el-button type="primary" :size="'small'" @click="handleOpen">添加白名单
    </el-button>
    <div class="ctnr">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchFormWhite" :searchSelectObj="searchSelectObj"
                   :formData="searchFormData" @handleOk="selConfig" @handleRest="selConfig('reset')"></GLCombiForm>

      <div class="operate-wrap">
        <div class="table-title1">白名单列表
          <p class="table-des">门店助手小程序的积分提现功能对白名单下的门店可见,其门店员工可进行积分提现。</p>
        </div>

        <div class="operate-btn">
        </div>
      </div>

      <GLTable @setTableFinishFun="setTableFinishFun" ref="table" :pageConf="pageConf" :searchForm="searchFormWhite"
               :tableParams="tableParams" :getListApi="getListApi">

        <div slot="auth-button" slot-scope="scope">
          <GLTableButton :buttonList="buttonList" :buttonItem="scope" :buttonNum="3"></GLTableButton>
        </div>
      </GLTable>

      <whiteStore v-if="relateStoreVisible" ref="relateStore" :relateStoreVisible="relateStoreVisible"
                  :storeApi="storeApi" :storeSearchForm="searchForm" :storeSelected="tableData"
                  @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose">
        <div slot class="header">
          <el-form :model="searchForm" ref="relate" :inline="true" label-width="90px" class="configDialog">
            <el-form-item>
              <el-input placeholder="请输入内容" clear v-model="searchForm.selectInput" class="input-with-select"
                        size="small">
                <el-select v-model="searchForm.select" slot="prepend" placeholder="请选择">
                  <el-option label="商户名称" value="1"></el-option>
                  <el-option label="商户号" value="2"></el-option>
                </el-select>
              </el-input>
            </el-form-item>
            <el-form-item style="margin-top: -1px;margin-left:-16px;">
              <el-button size="small" type="primary" @click="handleSearchStore">查询</el-button>
            </el-form-item>
          </el-form>
        </div>
      </whiteStore>
    </div>
  </div>
</template>


<script>
import whiteStore from "views/whiteList/components/whiteStore";

export default {
  name: "index",
  components: {
    whiteStore
  },
  data() {
    return {
      searchForm: {
        select:'1'
      },
      searchFormWhite: {
        selectMerchantName:'',
        selectMerchantId:''
      },
      storeApi: this.$apis.whiteList.subscribeMerchant,
      tableData: [],
      selectedList: [],
      relateStoreVisible: false,
      searchSelectObj: {
        idOrName: {
          attr: 'selectMerchantName',
          value: ''
        }
      },
      searchFormData: [
        {
          type: 'selectInput',
          selectName: 'idOrName',
          isClear: true,
          inputWidth: '325px',
          selectWidth: '110px',
          selectOption: [
            {
              label: '商户名称',
              name: 'selectMerchantName'
            },
            {
              label: '商户号',
              name: 'selectMerchantId'
            }
          ],
          handleSelectChange: value => {
            this.searchSelectObj.idOrName.value = ''
          }
        },
      ],
      getListApi: this.$apis.whiteList.whiteListPage,
      pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'},
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '商户名称',
            minWidth: 300,
            prop: 'merchantName'
          },
          {
            label: '商户号',
            prop: 'merchantId',
            width: 250,
          },
          {
            label: '配置时间',
            prop: 'configTime',
            width: 180
          }
        ]
      },
      buttonList: [
        {
          type: 'el-button',
          name: '删除',
          attrs: {
            type: 'text',
            fn: '删除'
          },
          listeners: {
            click: row => this.handleDel(row.scope)
          }
        }
      ],
    }
  },
  methods: {

    handleDel(scope) {
      const params = {
        ids: [scope.id]
      }
      this.$confirm(`是否确认删除${scope.merchantName} ?`, '提示', {
        type: 'warning',
        callback: action => {
          if (action == 'confirm') {
            this.$apis.whiteList.whiteListDelete(params).then(res => {
              if (res) {
                this.$message.success('操作成功')
                this.selConfig()
              }
            })
          }
        }
      })
    },
    selConfig(e) {
      if (e == 'reset') {
        this.searchFormWhite = {
          selectMerchantName:'',
          selectMerchantId:''
        }
        this.searchSelectObj = {
          idOrName: {
            attr: 'selectMerchantName',
            value: ''
          }
        }
      }
      this.searchFormWhite[this.searchSelectObj.idOrName.attr] = this.searchSelectObj.idOrName.value
      this.$refs.table.refreshTable()
    },
    handleOpen() {
      this.tableData = []
      this.relateStoreVisible = !this.relateStoreVisible
    },
    handleRelateStoreConfirm(selectedData) {
      this.merchantList = []
      selectedData.forEach(item => {
        this.merchantList.push({
          merchantId: item.merchantId,
          merchantName: item.merchantName,
        })
      })

      this.tableData = selectedData
      const params = {
        merchantList: [...this.merchantList]
      }

      this.$apis.whiteList.whiteListSave(params).then(res => {
        if (res) {
          this.$message.success('操作成功')
          this.selConfig()
        }
      })
      this.handleRelateStoreClose()
    },
    //搜索门店table
    handleSearchStore() {
      this.$refs.relateStore.handleCurrentChange(1)
    },
    handleRelateStoreClose() {
      this.relateStoreVisible = false
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.table.data.length ? (this.$refs.table.tableHeightValues = '') : this.$refs.table.setTableHeightFun()
    },
  }
}
</script>

<style scoped lang="scss">
.ctnr {
  margin-top: 16px;
  background-color: #fff;
  padding: 20px;

}
.operate-wrap{
  .table-title1{
    display: flex;
    height: 32px;
    font-weight: 600;
    font-size: 16px;
    color: #333;
    line-height: 32px;
    .table-des{
      line-height: 34px;
      margin-left: 8px;
      font-weight: 400;
      color: #666666;
      font-size: 14px;
    }

  }
}
</style>