transferDia.vue 6.64 KB
<template>
  <div>
    <GLDialog :mode="'big'" :visible.sync="dialogTransferVisible" @close="closeDia">
      <!-- 自定义标题 -->
      <div slot="title">
        <span class="title-left">选择转移员工</span>
        <span class="title-right">接口有效期至:{{ transferInfo.expireTime }}</span>
      </div>
      <div class="gl-form-min">
        <el-form :inline="true" class="member-form" :model="searchForm">
          <el-form-item label="员工姓名:">
            <el-input v-model="searchForm.staffName" :size="size" placeholder="输入关键字搜索"></el-input>
          </el-form-item>
          <el-form-item label="启用状态:">
            <el-select v-model="searchForm.openJoinStatus" placeholder="全部" :size="size">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" :size="size" class="gap8" @click="findNotActiveStaff">查询</el-button>
            <el-button plain :size="size" class="btn-three" @click="handleReset">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="table-title">员工列表</div>
      <GLTable :hasPage="false" :hasNum="false" :searchForm="searchForm" v-loading="loading" ref="transferTable" :tableParams="tableParams" :tableData="tableActiveData" :noDataImg="url">
        <div slot="association" slot-scope="scope" class="association">
          <el-radio :label="scope.scope.id" v-model="associationRadio" @change.native="getTransferInfo()"></el-radio>
        </div>
        <div slot="openJoinStatusString" class="dot" slot-scope="scope">
          <div :class="status[scope.scope.openJoinStatusString]"></div>
          <span v-if="scope.scope.openJoinStatusString == '未开启'">未开启</span>
          <span v-if="scope.scope.openJoinStatusString == '已开启'">已开启</span>
          <span v-if="scope.scope.openJoinStatusString == '未授权'">未授权</span>
        </div>
      </GLTable>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDia">取 消</el-button>
        <el-button size="small" type="primary" @click="transferStaff">确 定</el-button>
      </span>
    </GLDialog>
  </div>
</template>

<script>
import url from '@/assets/empty.png'
const status = {
  未开启: 'dot3',
  已开启: 'dot2',
  未授权: 'dot3'
}
const options = [
  {
    value: 0,
    label: '未开启'
  },
  {
    value: 1,
    label: '已开启'
  },
  {
    value: 2,
    label: '未授权'
  }
]
export default {
  name: 'TransferDia',
  data() {
    return {
      url,
      options: options,
      status,
      dialogTransferVisible: false,
      associationRadio: '',
      loading: false,
      searchForm: {
        openJoinStatus: '',
        staffName: ''
      },
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            prop: 'association',
            addHtml: 'association',
            width: '50'
          },
          {
            label: '序号',
            prop: 'num',
            width: '100'
          },
          {
            label: '员工姓名',
            prop: 'staffName'
          },
          {
            label: '员工手机号',
            prop: 'departmentName'
          },
          {
            label: '部门',
            prop: 'departmentName'
          },
          {
            label: '启用状态',
            prop: 'openJoinStatusString',
            addHtml: 'openJoinStatusString'
          }
        ]
      },
      tableActiveData: [],
      transferInfo: {},
      selectStaff: {},
      routerInfo: {}
    }
  },

  mounted() {},

  methods: {
    init(scope, routerInfo) {
      this.transferInfo = scope
      this.routerInfo = routerInfo
      this.dialogTransferVisible = true
      this.findNotActiveStaff()
    },
    findNotActiveStaff() {
      const { corpId, merchantId } = this.routerInfo
      var params = {
        ...JSON.parse(JSON.stringify(this.searchForm)),
        corpId,
        merchantId
      }
      this.loading = true
      this.$apis.accountConfig.findNotActiveStaff(params).then(res => {
        if (res.code == 0) {
          this.tableActiveData = res.data
          let num = 0
          this.tableActiveData.forEach(item => {
            item.num = ++num
          })
          this.loading = false
        } else {
          this.loading = false
          this.$message({
            message: res.message,
            type: 'error',
            customClass: 'global-messageZindex'
          })
        }
      })
    },
    // 重置搜索框搜索
    handleReset() {
      this.searchForm = {
        openJoinStatus: '',
        staffName: ''
      }
      this.findNotActiveStaff()
    },
    // 选择转移员工
    getTransferInfo() {
      let inx = this.tableActiveData.filter(value => value.id == this.associationRadio)
      this.selectStaff = inx[0]
    },
    // 转移员工
    transferStaff() {
      this.loading = true
      const { merchantId, corpId } = this.routerInfo
      let params = {
        merchantId,
        corpId
      }
      params.handoverUserid = this.transferInfo.userid
      params.takeoverUserid = this.selectStaff.userId
      this.$apis.accountConfig.transferLicenseAccount(params).then(res => {
        if (res.code == 0) {
          this.loading = false
          this.$message({
            message: '账号转移成功',
            type: 'success',
            customClass: 'global-messageZindex'
          })
          this.dialogTransferVisible = false
          this.$emit('transferStaff')
        } else {
          this.loading = false
          this.$message({
            message: res.message,
            type: 'error',
            customClass: 'global-messageZindex'
          })
          this.dialogTransferVisible = false
        }
      })
    },
    // 关闭转移员工弹窗
    closeDia() {
      this.associationRadio = ''
      this.selectStaff = {}
      this.dialogTransferVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.table-title {
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 600;
  color: #333333;
  line-height: 22px;
  margin-bottom: 6px;
}
.title-left {
  font-size: 20px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 600;
  color: #333333;
  line-height: 28px;
  margin-right: 16px;
}
.title-right {
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #333333;
  line-height: 20px;
}
.association {
  /deep/ .el-radio__label {
    display: none;
  }
}
.global-messageZindex {
  z-index: 3000 !important;
}
</style>