viewConfig.vue 8.47 KB
<template>
  <div>
    <div class="container">
      <div class="title">{{ routerInfo.merchantName }}</div>
      <GLCombiForm :formObj="searchForm" :rowNumber="1" :formData="searchFormData" @handleOk="getListApi" @handleRest="handleReset"></GLCombiForm>
      <div class="tableBox">
        <GLTable ref="accountCodeTable" @refreshTable="getListApi" :noDataImg="url" :layout="layout" :tableData="accountTableData" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :tableTotal="tableTotal" @setTableFinishFun="setTableFinishFun">
          <!-- 账号许可类型 -->
          <div slot="type" slot-scope="scope">
            <span v-if="scope.scope.type == 1">基础帐号</span>
            <span v-else>互通帐号</span>
          </div>
          <!-- 账号激活状态 -->
          <div slot="status" class="dot" slot-scope="scope">
            <div :class="accountStatus[scope.scope.status]"></div>
            <span v-if="scope.scope.status == 1">未绑定</span>
            <span v-if="scope.scope.status == 2">已绑定</span>
            <span v-if="scope.scope.status == 3">已过期</span>
            <span v-if="scope.scope.status == 4">待转移</span>
            <span v-if="scope.scope.status == 5">已合并</span>
          </div>
          <template slot="auth-button" slot-scope="scope" :data="scope.scope" v-if="scope.scope.status == 2">
            <el-button type="text" @click="handelTransfer(scope.scope)">转移</el-button>
          </template>
        </GLTable>
      </div>
    </div>
    <GLDialog class="trans-dia" title="帐号接口许可转移" :visible.sync="dialogTransferVisible">
      <el-form :model="transferForm">
        <el-form-item label="转移员工:">
          <el-select @change="selectTransferStaff" v-model="transferForm.staff" filterable :size="size" placeholder="请选择或输入关键字搜索">
            <el-option v-for="item in notActiveStaffList" :key="item.userId" :label="item.staffName" :value="item.userId"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="接口有效期至:">{{ expireTime }}</el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button :size="size" @click="handleClose">取消</el-button>
        <el-button :size="size" type="primary" @click="transferCount">提交</el-button>
      </span>
    </GLDialog>
  </div>
</template>

<script>
const accountStatus = {
  '1': 'dot1',
  '2': 'normal',
  '3': 'dot3',
  '4': 'dot6',
  '5': 'normal'
}
import url from '@/assets/empty.png'
export default {
  name: 'ConfigDetail',
  data() {
    return {
      url,
      accountStatus,
      searchForm: {
        status: '',
        staffName: ''
      },
      transferForm: {
        staff: ''
      },
      routerInfo: '',
      dialogTransferVisible: false,
      accountTableData: [],
      tableTotal: 0,
      notActiveStaffList: [],
      expireTime: '',
      takeoverUserid: '',
      handoverUserid: '',
      searchFormData: [
        {
          label: '激活状态',
          name: 'status',
          type: 'select',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            {
              label: '未绑定',
              value: 1
            },
            {
              label: '已绑定',
              value: 2
            },
            {
              label: '已过期',
              value: 3
            },
            {
              label: '待转移',
              value: 4
            },
            {
              label: '已合并',
              value: 5
            }
          ],
          optionId: 'value',
          optionLabel: 'label',
          isClear: true
        },
        {
          label: '员工姓名',
          name: 'staffName',
          type: 'input',
          isClear: true,
          placeholder: '输入关键字搜索'
        }
      ],
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '帐号许可类型',
            prop: 'type',
            addHtml: 'type'
          },
          {
            label: '激活状态',
            prop: 'status',
            addHtml: 'status'
          },
          {
            label: '绑定员工',
            prop: 'staffName'
          },
          {
            label: '手机号码',
            prop: 'staffPhone'
          },
          {
            label: '激活时间',
            prop: 'activeTime'
          },
          {
            label: '有效期',
            prop: 'expireTime'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      layout: 'sizes, prev, pager, next, jumper, ->, total'
    }
  },
  mounted() {
    this.routerInfo = this.$route.query
    this.getListApi()
  },
  methods: {
    getListApi() {
      const { status, staffName } = this.searchForm
      const { merchantId, corpId } = this.routerInfo
      let params = {
        merchantId,
        corpId,
        status,
        staffName
      }
      params.pageSize = this.$refs.accountCodeTable.page.pageSize
      params.pageNum = this.$refs.accountCodeTable.page.pageNum
      this.$apis.accountConfig.listAccountCodeWithPage(params).then(res => {
        this.accountTableData = res.list
        this.tableTotal = res.total
      })
    },
    // 账号许可转移弹窗
    handelTransfer(scope) {
      const { merchantId, corpId } = this.routerInfo
      let params = {
        merchantId,
        corpId
      }
      this.handoverUserid = scope.userid
      this.expireTime = scope.expireTime
      this.$apis.accountConfig.findNotActiveStaff(params).then(res => {
        if (res.data) {
          this.dialogTransferVisible = true
          this.notActiveStaffList = res.data
        } else {
          // var txt = '<i class="el-icon-warning" style="color:#e6a23c;font-size:48px;"></i><p>无可用的用户转移</p>'
          this.$confirm('无可用的用户转移', '提示', {
            confirmButtonText: '我知道了',
            dangerouslyUseHTMLString: true,
            showClose: true,
            showCancelButton: false,
            confirmButtonClass: 'confirmbtn',
            type: 'warning',
            customClass: 'gl-message-box confirm-btn'
          })
        }
      })
    },
    // 选择转移员工
    selectTransferStaff(id) {
      this.takeoverUserid = id
    },
    // 账号许可转移
    transferCount() {
      const { merchantId, corpId } = this.routerInfo
      let params = {
        merchantId,
        corpId
      }
      params.handoverUserid = this.handoverUserid
      params.takeoverUserid = this.takeoverUserid
      this.$apis.accountConfig.transferLicenseAccount(params).then(res => {
        if (res.code == 0) {
          this.$message({
            message: '账号转移成功',
            type: 'success',
            customClass: 'global-messageZindex'
          })
          this.getListApi()
          this.dialogTransferVisible = false
          this.transferForm.staff = ''
        } else {
          this.$message({
            message: '账号转移失败,请联系管理员',
            type: 'error',
            customClass: 'global-messageZindex'
          })
          this.dialogTransferVisible = false
          this.transferForm.staff = ''
        }
      })
    },
    // 关闭弹窗
    handleClose() {
      this.dialogTransferVisible = false
      this.transferForm.staff = ''
    },
    // 搜索框搜索
    handleSearch() {
      this.$refs.accountCodeTable.refreshTable()
    },
    // 重置搜索框搜索
    handleReset() {
      this.searchForm = {
        status: '',
        staffName: ''
      }
      this.getListApi()
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.accountCodeTable.data.length ? (this.$refs.accountCodeTable.tableHeightValues = '') : this.$refs.accountCodeTable.setTableHeightFun()
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  background-color: #fff;
  .title {
    height: 58px;
    margin-bottom: 20px;
    padding-left: 20px;
    font-size: 16px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 600;
    color: #333333;
    line-height: 58px;
    border-bottom: 1px solid #e5e5e5;
  }
  .tableBox {
    padding: 0 20px 60px 20px;
  }
}
.trans-dia {
  /deep/ .el-form-item__label {
    width: 154px;
  }
  /deep/ .el-select {
    width: 474px;
  }
}
/deep/ .el-dialog__title {
  font-weight: 600;
}
.global-messageZindex {
  z-index: 3000 !important;
}
</style>