index.vue 7.52 KB
<!--
 * @Author: huyue
 * @Date: 2022-02-11 10:20:32
 * @LastEditTime: 2022-07-12 09:54:50
 * @LastEditors: huyue
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \scrm-micro-pay\src\views\account\index.vue
-->
<template>
  <div class="container">
    <div class="container-header">
      <span>帐号接口许可</span>
      <el-popover placement="bottom" width="280" trigger="hover" content="企微代开发应用的帐号接口许可管理">
        <img src="@/assets/icon-tip.png" slot="reference" class="count-item-question" />
      </el-popover>
    </div>
    <div class="table-box">
      <GLCombiForm :formObj="searchForm" :rowNumber="1" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <div class="header-text">帐号接口许可列表</div>
        <div>
          <el-button class="table-btn" @click="handleSync" :loading="syncLoad" :size="size" type="primary" plain mode="el-button">同步购买订单</el-button>
        </div>
      </div>
      <GLTable ref="accountTable" :noDataImg="url" :getListApi="getListApi" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
        <!-- 是否已购许可 -->
        <div slot="isBuyPermit" slot-scope="scope">
          <span v-if="scope.scope.isBuyPermit == 1">是</span>
          <span v-if="scope.scope.isBuyPermit == 0">否</span>
        </div>
        <template slot="auth-button" slot-scope="scope" :data="scope.scope" v-if="scope.scope.isBuyPermit">
          <GLTableButton :buttonList="buttonList" :buttonItem="scope.scope"></GLTableButton>
          <!-- <el-button type="text" @click="viewConfig(scope.scope)">查看</el-button> -->
          <!-- <el-button type="text" @click="handelActivate(scope.scope)" :loading="loading">一键激活许可</el-button> -->
        </template>
      </GLTable>
      <ActivateDia ref="activateDia" :dialogActivateVisible="dialogActivateVisible" @activeStaff="handleSearch"></ActivateDia>
    </div>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
import Icon from '@/assets/empty.png'
import ActivateDia from './activateDia.vue'
export default {
  name: 'AccountInterface',
  components: {
    ActivateDia
  },
  data() {
    return {
      url,
      Icon,
      loading: false,
      syncLoad: false,
      dialogActivateVisible: false,
      searchForm: {
        isBuyPermit: '',
        merchantId: '',
        merchantName: ''
      },
      searchFormData: [
        {
          label: '是否已购许可',
          name: 'isBuyPermit',
          type: 'select',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            {
              label: '是',
              value: 1
            },
            {
              label: '否',
              value: 0
            }
          ],
          optionId: 'value',
          optionLabel: 'label',
          isClear: true
        },
        {
          label: '商户名称',
          name: 'merchantName',
          type: 'input',
          isClear: true,
          placeholder: '输入关键字搜索'
        },
        {
          label: '商户号',
          name: 'merchantId',
          type: 'input',
          isClear: true,
          placeholder: '请输入商户号',
          listeners: {
            input: value => {
              this.searchForm.condition.merchantId = value.replace(/[^\d]/g, '')
            }
          }
        }
      ],
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '商户号',
            prop: 'merchantId',
            width: '120'
          },
          {
            label: '商户名称',
            prop: 'merchantName',
            width: '300'
          },
          {
            label: '关联企业微信名称',
            prop: 'corpFullName',
            width: '300'
          },
          {
            label: '是否已购许可',
            prop: 'isBuyPermit',
            addHtml: 'isBuyPermit'
          },
          {
            label: '许可数量',
            prop: 'permitCount',
            formatter: cellValue => {
              return cellValue.permitCount || '-'
            }
          },
          {
            label: '已激活数量',
            prop: 'activeCount',
            formatter: cellValue => {
              return cellValue.activeCount || '-'
            }
          },
          {
            label: '操作',
            prop: 'auth-button',
            width: '220',
            addHtml: 'auth-button',
            fixed: 'right'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      getListApi: this.$apis.accountConfig.listCustomizedAgentWithPage,
      buttonList: [
        {
          type: 'GLButton',
          name: row => {
            return '查看'
          },
          attrs: {
            type: 'text',
            fn: '查看激活列表'
          },
          condition: row => {
            return true
          },
          listeners: {
            click: row => this.viewConfig(row)
          }
        },
        {
          type: 'el-button',
          name: row => {
            return '批量激活许可'
          },
          attrs: {
            type: 'text',
            loading: this.loading
          },
          listeners: {
            click: row => this.handelActivate(row)
          }
        }
      ]
    }
  },
  mounted() {},
  methods: {
    // 查看配置
    viewConfig(row) {
      const { merchantId, corpId, merchantName } = row
      this.$router.push({
        path: '/accountInterface/viewConfig',
        query: {
          merchantId,
          corpId,
          merchantName
        }
      })
    },
    // 搜索框搜索
    handleSearch() {
      this.$refs.accountTable.refreshTable()
    },
    // 重置搜索框搜索
    handleReset() {
      this.searchForm = {
        isBuyPermit: '',
        merchantId: '',
        merchantName: ''
      }
      this.handleSearch()
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.accountTable.data.length ? (this.$refs.accountTable.tableHeightValues = '') : this.$refs.accountTable.setTableHeightFun()
    },
    // 一键激活许可
    handelActivate(row) {
      this.dialogActivateVisible = true
      this.$refs.activateDia.init(row)
    },
    // 同步购买订单
    handleSync() {
      this.syncLoad = true
      this.$apis.accountConfig.syncCorpAccountCode({}).then(res => {
        if (res.code == 0) {
          this.syncLoad = false
          this.$message({
            message: '同步成功',
            type: 'success'
          })
          this.handleSearch()
        } else {
          this.syncLoad = false
          this.$message({
            message: '同步门店许可数据异常',
            type: 'error'
          })
          this.handleSearch()
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  .table-box {
    margin: 20px 0;
    padding: 20px;
    background-color: #fff;
  }
  .footer-btns {
    float: right;
  }
  .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .header-text {
      font-size: 16px;
      color: #333333;
      font-weight: 600;
    }
  }
  .table-btn {
    color: #5850ff;
    border: 1px solid #5850ff;
  }
}
/deep/ {
  .el-table th > .cell {
    padding: 0 16px;
  }
}
</style>