ll
liukangdong
2024-08-23 15b5b761a15805719294e7660f4cb84b35f84af8
admin/src/components/business/OperaMemberRoleWindow.vue
@@ -50,42 +50,42 @@
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalWindow from '@/components/common/GlobalWindow'
import {getDeviceRoleList} from '@/api/business/device'
import { getDeviceRoleList } from '@/api/business/device'
export default {
  name: 'OperaDeviceRoleWindow',
  extends: BaseOpera,
  components: { GlobalWindow },
  data () {
    var validateTime = (rule, value, callback) => {
      if(this.form.timeType == null  ){
      if (this.form.timeType == null) {
        callback(new Error('请填写正确的门禁有效期时间'))
        return
      }
      if(this.form.timeType === 1 && (this.form.startTime ==null || this.form.endTime == null)){
          callback(new Error('请填写正确的门禁有效期时间'))
          return
      if (this.form.timeType === 1 && (this.form.startTime == null || this.form.endTime == null)) {
        callback(new Error('请填写正确的门禁有效期时间'))
        return
      }
      callback()
    };
    }
    return {
      // 表单数据
     time:null,
      companyType:1,
      time: null,
      companyType: 1,
      form: {
        ids: [],
        names: [],
        timeType: 0,
        roleIds: [],
        status: 1,
        startTime:null,
        endTime:null,
        startTime: null,
        endTime: null,
        radio: 0
      },
      roles:[],
      roles: [],
      rules: {
      // 验证规则
        timeType: [
          { required: true, validator: validateTime,message: '请选中门禁有效期' }
          { required: true, validator: validateTime, message: '请选中门禁有效期' }
        ],
        startTime: [
          { validator: validateTime, trigger: 'blur' }
@@ -103,15 +103,15 @@
    })
  },
  methods: {
    filterMethod(query, item) {
      if (!query) return item;
      return item.label.indexOf(query) > -1 ;
    filterMethod (query, item) {
      if (!query) return item
      return item.label.indexOf(query) > -1
    },
    seleTime (e) {
      if(e && e.length >= 2){
      if (e && e.length >= 2) {
        this.form.startTime = e[0]
        this.form.endTime = e[1]
      }else{
      } else {
        this.form.startTime = null
        this.form.endTime = null
      }
@@ -123,41 +123,40 @@
        }
        if (this.form.roleIds == null || this.form.roleIds.length == 0) {
          this.$dialog.actionConfirm('权限为空,提交后即清除所选人员已分配权限!请谨慎操作', '您确认进行该操作吗?')
              .then(() => {
                this.confirmDo();
              })
              .catch(() => {})
            .then(() => {
              this.confirmDo()
            })
            .catch(() => {})
        } else {
          this.confirmDo();
          this.confirmDo()
        }
      })
    },
    confirmDo(){
        // 调用新建接口
        this.isWorking = true
        this.api.batchRoleAuth({
          ids: this.form.ids,
          timeType: this.form.timeType,
          startTime: this.form.startTime,
          endTime: this.form.endTime,
          roleIds: this.form.roleIds
    confirmDo () {
      // 调用新建接口
      this.isWorking = true
      this.api.batchRoleAuth({
        ids: this.form.ids,
        timeType: this.form.timeType,
        startTime: this.form.startTime,
        endTime: this.form.endTime,
        roleIds: this.form.roleIds
      })
        .then(() => {
          this.visible = false
          this.$tip.apiSuccess('授权成功,可前往【人员授权记录】查看下发进度')
          this.$emit('success')
        })
            .then(() => {
              this.visible = false
              this.$tip.apiSuccess('授权成功,可前往【人员授权记录】查看下发进度')
              this.$emit('success')
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.isWorking = false
            })
      },
        .catch(e => {
          //  this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking = false
        })
    },
    // 获取设备
    getLists (){
      getDeviceRoleList({type:2})
    getLists () {
      getDeviceRoleList({ type: 2 })
        .then(res => {
          this.roles = res.map(item => {
            return {
@@ -168,7 +167,7 @@
          })
        })
    },
    open (title, ids,names,companyType) {
    open (title, ids, names, companyType) {
      this.roles = []
      this.getLists()
      this.title = title
@@ -178,8 +177,8 @@
      this.$nextTick(() => {
        this.$refs.form.resetFields()
        this.form[this.configData['field.id']] = null
        this.form.ids = ids;
        this.form.names =names;
        this.form.ids = ids
        this.form.names = names
        console.log(names)
      })