Newer
Older
DH_Apicture / src / views / RongyunCommunication / UnitClass.vue
@zhangqy zhangqy 28 days ago 11 KB first commit
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="群组id" prop="groupId" v-show="false">
        <el-input v-model="queryParams.groupId" placeholder="请输入群组id" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="群组名称" prop="groupName">
        <el-input v-model="queryParams.groupName" placeholder="请输入群组名称" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['rcloud:rcloudUnitClass:add']"
          >新增</el-button
        >
      </el-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['rcloud:rcloudUnitClass:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['rcloud:rcloudUnitClass:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['rcloud:rcloudUnitClass:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['rcloud:rcloudUnitClass:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->

    <el-table v-loading="loading" :data="rcloudUnitClassList" @selection-change="handleSelectionChange" height="70vh">
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="群组名称" align="center" prop="groupName" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="warning" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['rcloud:rcloudUnitClass:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['rcloud:rcloudUnitClass:remove']"
            >删除</el-button
          >
          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleAddPerson(scope.row)"
            v-hasPermi="['rcloud:rcloudUnitClass:remove']"
            >人员配置</el-button
          >
          <!-- <el-button link type="primary" icon="View" @click="handleDetail(scope.row)" v-hasPermi="['rcloud:rcloudUnitClass:view']"
            >详情</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改融合通讯群组对话框 -->
    <el-dialog :title="title" v-model="open" width="500px" append-to-body>
      <el-form ref="rcloudUnitClassRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="群组名称" prop="groupName">
          <el-input v-model="form.groupName" placeholder="请输入群组名称" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 融合通讯群组详情 -->
    <el-dialog title="融合通讯群组详情" v-model="detailOpen" width="800px" append-to-body class="dialog-detail-box">
      <div class="dialog-form-detail flex flex-r flex-wrap">
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">群组id</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.groupId }}
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">群组名称</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.groupName }}
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">备注</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.remark }}
          </div>
        </div>
        <div class="flex flex-r">
          <div class="detail-label flex flex-align-center">状态</div>
          <div class="detail-value flex flex-align-center">
            {{ dialogFormDetail.status }}
          </div>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">关 闭</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 添加配置人员弹窗 -->
    <el-dialog :title="getrow.groupName + ' 人员配置'" v-model="addConfigPerson.open" width="700px" append-to-body>
      <!-- <el-input v-model="addConfigPerson.queryParams.name" placeholder="搜索" clearable @keyup.enter="handleUserQuery" /> -->
      <el-transfer
        v-model="addConfigPerson.id"
        filterable
        :titles="['所有人员', '已选人员']"
        :filter-method="filterMethod"
        filter-placeholder="搜索人员"
        :data="addConfigPerson.data"
        :props="{
          key: 'id',
          label: 'name',
        }"
        style="margin-top: 20px"
      />
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitAddConfigPerson">保 存</el-button>
          <el-button @click="addConfigPerson.open = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="RcloudUnitClass">
import {
  pagercloudUnitClass,
  getrcloudUnitClass,
  delrcloudUnitClass,
  addrcloudUnitClass,
  updatercloudUnitClass,
  queryGroupAndUserList,
  configGroupUser,
} from '@/views/RongyunCommunication/rongyunjs/rcloudUnitClass';

import { listrcloudUnitUser } from '@/views/RongyunCommunication/rongyunjs/rcloudUnitUser';

const { proxy } = getCurrentInstance();

const rcloudUnitClassList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref('');
const detailOpen = ref(false);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    groupId: null,
    groupName: null,
    status: null,
  },
  rules: {
    groupName: [{ required: true, message: '群组名称不能为空', trigger: 'blur' }],
  },
  dialogFormDetail: {}, //详情弹框数据
});

const addConfigPerson = ref({
  open: false,
  value: [],
  data: [],
  queryParams: {},
});

const getrow = ref({});

const { queryParams, form, rules, dialogFormDetail } = toRefs(data);

/** 查询融合通讯群组列表 */
function getList() {
  loading.value = true;
  pagercloudUnitClass(queryParams.value).then(response => {
    rcloudUnitClassList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

function filterMethod(query, item) {
  let string = item.userName + item.name;
  return string.indexOf(query) > -1;
}

function handleAddPerson(row) {
  addConfigPerson.value.open = true;
  getrow.value = row;
  Getrowpeople(row);
}

//获取所有人员
function getListUser() {
  listUser(addConfigPerson.value.queryParams).then(res => {
    addConfigPerson.value.data = res.data;
  });
}
//搜索人员
function handleUserQuery() {
  getListUser();
}

//保存添加配置人员
function submitAddConfigPerson() {
  let { id } = { ...addConfigPerson.value };
  // let patrolUserList = [];
  //根据选中的id过滤获取对应的数据
  // id.forEach(val => {
  //   addConfigPerson.value.data.forEach(item => {
  //     if (val == item.id) {
  //       item.sectionId = '';
  //       item.phoneNumber = item.phonenumber;
  //       patrolUserList.push(item);
  //     }
  //   });
  // });
  console.log(id);
  let data = {
    groupId: getrow.value.groupId,
    userIds: id ? id.join(',') : '',
    createBy: localStorage.getItem('userNo'),
  };

  console.log(data);

  configGroupUser(data).then(res => {
    proxy.$modal.msgSuccess('保存成功');

    // addConfigPerson.value.open = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    groupId: null,
    groupName: null,
    remark: null,
    status: null,
    delFlag: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm('rcloudUnitClassRef');
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

// 查询群组包含用户
function Getrowpeople(row) {
  let groupId = row.groupId;
  addConfigPerson.value.id = [];
  queryGroupAndUserList({ groupId }).then(res => {
    console.log(res);
    res.data[0].userList.forEach(item => {
      addConfigPerson.value.id.push(item.id);
    });
  });
}

//获取所有人列表
function Getpeople(row) {
  listrcloudUnitUser().then(res => {
    addConfigPerson.value.data = res.data;
  });
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = '添加融合通讯群组';
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value;
  getrcloudUnitClass(_id).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = '修改融合通讯群组';
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs['rcloudUnitClassRef'].validate(valid => {
    if (valid) {
      form.value.createBy = localStorage.getItem('userNo');
      form.value.groupId = new Date().getTime();

      if (form.value.id != null) {
        updatercloudUnitClass(form.value).then(response => {
          proxy.$modal.msgSuccess('修改成功');
          open.value = false;
          getList();
        });
      } else {
        addrcloudUnitClass(form.value).then(response => {
          proxy.$modal.msgSuccess('新增成功');
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm('是否确认删除融合通讯群组"' + row.groupName + '"的数据项?')
    .then(function () {
      return delrcloudUnitClass(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    'rcloud/rcloudUnitClass/export',
    {
      ...queryParams.value,
    },
    `rcloudUnitClass_${new Date().getTime()}.xlsx`
  );
}
//查看详情操作
function handleDetail(row) {
  detailOpen.value = true;
  dialogFormDetail.value = row;
}

getList();
Getpeople();
</script>