From e423d8afcf5b9666e166565d0509b621ebab17e7 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 13 一月 2025 14:11:00 +0800
Subject: [PATCH] !172 合并 warmflow 功能分支 * update 优化 流程定义页面 点击复制之后跳转到未发布列表 * update 优化 流程定义页面 增加加载loading层 * fix: v-model处理有延迟 需要手动处理 * update 调整流程定义查询 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * update 调整可驳回的节点 * update: 调整文案 * update: 激活/挂起改为switch操作 * update 优化 代码删除无用输出 * update 统一抄送人使用昵称展示 * update 调整分类接口 * update 统一业务id参数 * update 删除默认顶节点 * !168 优化流程分类 * update 恢复误删除代码 * update 优化流程分类 * update 修复 路由跳转未改全 * [update] * fix 修复一些问题 * update 重构流程分类表 * update 流程定义增加表单路径与编辑功能 修复一些其他bug * fix 修复 一些问题 * update 变量统一命名 * add 增加示例 * Merge branch 'warm-flw-future' of https://gitee.com/JavaLionLi/plus-ui… * update 调整办理人 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * add 增加示例 * update 调整审批记录 添加流程导出 * remove 删除无用代码 * remove 删除无用代码 * [update] * [fix] * 流程干预删除委托 * 增加附件 * 附件修改 * 申请人查询修改 * 1.修改查询条件 * !167 fix 修复 import路径修改不全问题 * fix 修复 import路径修改不全问题 * !166 update 清除 ProcessPreview 引用 * update 清除 ProcessPreview 引用 * remove 删除 bpmn.js 设计器 * remove 删除 bpmn.js 设计器 * remove 删除 bpmn.js 设计器 * remove 删除 bpmn.js 设计器 * fix 修复 前端路径修改不全问题 * update 优化接口请求路径 * add 添加作废 * add 添加流程干预 * update 调整加签,减签 * update 调整加签,减签 * add 增加流程查看 * update 调整委托,转办 * update 调整流程变量显示 * update 调整办理人修改 * update 调整流程实例状态页面 * update 调整已办页面 * add 添加流程撤销 * update 调整任务,流程实例 ,流程定义页面 * Merge branch 'dev' into warm-flw-future * update 调整流程定义页面 * add 添加流程变量查看 * update 调整设计器路由名称 * update 调整办理人 * update 调整设计器uri * update 调整设计器请求uri 调整待办状态 * update 调整办理 驳回 终止等状态 * add 添加模型新增 * add 添加warm-ui设计器,删除无用代码 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * add 添加流程设计 * update 调整驳回 * update 调整视图类型错误 * Merge branch 'warm-flw-future' of https://gitee.com/JavaLionLi/plus-ui… * 添加已办,未办 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * update 调整流程实例,待办查询 * add 添加代办人,调整提交按钮校验 * update 调整流程定义查询 * add添加流程定义激活 挂起 * add 添加流程文件部署 调整流程发布 * update 优化 时间搜索组件统一 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * fix 修复 用户管理编辑安全权限错误问题 * Merge remote-tracking branch 'origin/dev' into warm-flw-future * update 优化 类型报错问题 * update 优化 切换租户后刷新首页 * update 优化 实现表格行选中切换 * update 优化 使用 vueuse 重构 websocket 实现 * update 优化 使用 vueuse 重构 websocket 实现 * fix 修复 登出后重新登录 sse推送报错问题 * reset 回滚 代码修改 采用其他方案 * fix 修复 登出后重新登录 sse推送报错问题 * update 优化 删除无用代码 * update element-plus 2.7.5 => 2.7.8 * reset 回滚 错误修复 * update 优化 代码生成器编辑页禁用缓存 防止同步后页面不更新问题 * fix 修复 代码生成同步点击取消报错问题 * 初始化添加warm-flow

---
 src/components/RoleSelect/index.vue |  107 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 79 insertions(+), 28 deletions(-)

diff --git a/src/components/RoleSelect/index.vue b/src/components/RoleSelect/index.vue
index a9a07d3..6ba2076 100644
--- a/src/components/RoleSelect/index.vue
+++ b/src/components/RoleSelect/index.vue
@@ -4,12 +4,12 @@
       <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
         <div v-show="showSearch" class="mb-[10px]">
           <el-card shadow="hover">
-            <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="68px">
+            <el-form ref="queryFormRef" :model="queryParams" :inline="true">
               <el-form-item label="瑙掕壊鍚嶇О" prop="roleName">
-                <el-input v-model="queryParams.roleName" placeholder="璇疯緭鍏ヨ鑹插悕绉�" clearable style="width: 180px" @keyup.enter="handleQuery" />
+                <el-input v-model="queryParams.roleName" placeholder="璇疯緭鍏ヨ鑹插悕绉�" clearable @keyup.enter="handleQuery" />
               </el-form-item>
               <el-form-item label="鏉冮檺瀛楃" prop="roleKey">
-                <el-input v-model="queryParams.roleKey" placeholder="璇疯緭鍏ユ潈闄愬瓧绗�" clearable style="width: 180px" @keyup.enter="handleQuery" />
+                <el-input v-model="queryParams.roleKey" placeholder="璇疯緭鍏ユ潈闄愬瓧绗�" clearable @keyup.enter="handleQuery" />
               </el-form-item>
 
               <el-form-item>
@@ -36,7 +36,7 @@
           :data="roleList"
           :loading="loading"
           :row-config="{ keyField: 'roleId' }"
-          :checkbox-config="{ reserve: true, checkRowKeys: roleIds }"
+          :checkbox-config="{ reserve: true, checkRowKeys: defaultSelectRoleIds }"
           highlight-current-row
           @checkbox-all="handleCheckboxAll"
           @checkbox-change="handleCheckboxChange"
@@ -63,42 +63,41 @@
           v-model:total="total"
           v-model:page="queryParams.pageNum"
           v-model:limit="queryParams.pageSize"
-          @pagination="getList"
+          @pagination="pageList"
         />
       </el-card>
       <template #footer>
-        <el-button @click="roleDialog.closeDialog">鍙栨秷</el-button>
+        <el-button @click="close">鍙栨秷</el-button>
         <el-button type="primary" @click="confirm">纭畾</el-button>
       </template>
     </el-dialog>
   </div>
 </template>
 
-<script setup name="Role" lang="ts">
-import { listRole } from '@/api/system/role';
+<script setup lang="ts">
 import { RoleVO, RoleQuery } from '@/api/system/role/types';
 import { VxeTableInstance } from 'vxe-table';
 import useDialog from '@/hooks/useDialog';
+import api from '@/api/system/role';
 interface PropType {
-  modelValue?: RoleVO[];
+  modelValue?: RoleVO[] | RoleVO | undefined;
+  multiple?: boolean;
+  data?: string | number | (string | number)[];
 }
 const prop = withDefaults(defineProps<PropType>(), {
-  modelValue: () => []
+  multiple: true,
+  modelValue: undefined,
+  data: undefined
 });
-const emit = defineEmits(['update:modelValue']);
+const emit = defineEmits(['update:modelValue', 'confirmCallBack']);
 
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { sys_normal_disable } = toRefs<any>(proxy?.useDict('sys_normal_disable'));
 
-const roleIds = computed(() => prop.modelValue.map((item) => item.roleId as string));
-
 const roleList = ref<RoleVO[]>();
 const loading = ref(true);
 const showSearch = ref(true);
-const ids = ref<Array<string | number>>([]);
-const single = ref(true);
-const multiple = ref(true);
 const total = ref(0);
 const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
 const selectRoleList = ref<RoleVO[]>([]);
@@ -117,22 +116,46 @@
   roleKey: '',
   status: ''
 });
+
+const defaultSelectRoleIds = computed(() => computedIds(prop.data));
+
 const confirm = () => {
-  emit('update:modelValue', [...selectRoleList.value]);
+  emit('update:modelValue', selectRoleList.value);
+  emit('confirmCallBack', selectRoleList.value);
   roleDialog.closeDialog();
 };
+
+const computedIds = (data) => {
+  if (data instanceof Array) {
+    return [...data];
+  } else if (typeof data === 'string') {
+    return data.split(',');
+  } else if (typeof data === 'number') {
+    return [data];
+  } else {
+    console.warn('<RoleSelect> The data type of data should be array or string or number, but I received other');
+    return [];
+  }
+};
+
 /**
  * 鏌ヨ瑙掕壊鍒楄〃
  */
 const getList = () => {
   loading.value = true;
-  listRole(proxy?.addDateRange(queryParams.value, dateRange.value)).then((res) => {
+  api.listRole(proxy?.addDateRange(queryParams.value, dateRange.value)).then((res) => {
     roleList.value = res.rows;
     total.value = res.total;
     loading.value = false;
   });
 };
-
+const pageList = async () => {
+  await getList();
+  const roles = roleList.value.filter((item) => {
+    return selectRoleList.value.some((role) => role.roleId === item.roleId);
+  });
+  await tableRef.value.setCheckboxRow(roles, true);
+};
 /**
  * 鎼滅储鎸夐挳鎿嶄綔
  */
@@ -149,6 +172,10 @@
 };
 
 const handleCheckboxChange = (checked) => {
+  if (!prop.multiple && checked.checked) {
+    tableRef.value.setCheckboxRow(selectRoleList.value, false);
+    selectRoleList.value = [];
+  }
   const row = checked.row;
   if (checked.checked) {
     selectRoleList.value.push(row);
@@ -181,19 +208,43 @@
   tableRef.value?.setCheckboxRow(rows, false);
   selectRoleList.value.splice(index, 1);
 };
+/**
+ * 鍒濆鍖栭�変腑鏁版嵁
+ */
+const initSelectRole = async () => {
+  if (defaultSelectRoleIds.value.length > 0) {
+    const { data } = await api.optionSelect(defaultSelectRoleIds.value);
+    selectRoleList.value = data;
+    const users = roleList.value.filter((item) => {
+      return defaultSelectRoleIds.value.includes(String(item.roleId));
+    });
+    await nextTick(() => {
+      tableRef.value.setCheckboxRow(users, true);
+    });
+  }
+};
+const close = () => {
+  roleDialog.closeDialog();
+};
 watch(
-  () => prop.modelValue,
-  (newVal, oldValue) => {
-    Object.assign(selectRoleList.value, newVal);
-  },
-  { deep: true }
+  () => roleDialog.visible.value,
+  (newValue: boolean) => {
+    if (newValue) {
+      initSelectRole();
+    } else {
+      tableRef.value.clearCheckboxReserve();
+      tableRef.value.clearCheckboxRow();
+      resetQuery();
+      selectRoleList.value = [];
+    }
+  }
 );
+onMounted(() => {
+  getList(); // 鍒濆鍖栧垪琛ㄦ暟鎹�
+});
+
 defineExpose({
   open: roleDialog.openDialog,
   close: roleDialog.closeDialog
-});
-
-onMounted(() => {
-  getList();
 });
 </script>

--
Gitblit v1.9.3