From 40a8157440e3b906da8f52e07d939d78c3f4c313 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 12 四月 2026 16:14:06 +0800
Subject: [PATCH] feat: 任务增加统计、同步增加通知

---
 ruoyi-ui/src/views/system/user/index.vue |   85 +++++++++++++++++++++++++++++++++---------
 1 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index d10e40c..2f33959 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -248,16 +248,30 @@
     </el-dialog>
 
     <!-- 鏂板锛氱敤鎴风鐞嗗垎鍏徃閰嶇疆瀵硅瘽妗� -->
-    <el-dialog title="閰嶇疆绠$悊鍒嗗叕鍙�" :visible.sync="branchDialog.open" width="500px" append-to-body>
-      <el-form label-width="100px">
-        <el-form-item label="鍙鐞嗗垎鍏徃">
+    <el-dialog title="閰嶇疆绠$悊鍒嗗叕鍙�" :visible.sync="branchDialog.open" width="520px" append-to-body>
+      <el-form label-width="100px" v-loading="branchDialog.loading">
+        <el-form-item label="宸插叧鑱斿垎鍏徃">
+          <div style="margin-bottom:8px;color:#666;font-size:12px;">OA鑷姩鍏宠仈锛堝彧璇伙級锛�</div>
           <div>
-            <el-tag v-for="bc in branchDialog.companies" :key="bc.deptId" type="info" size="small" style="margin-right:6px;margin-bottom:6px">{{ bc.deptName }}</el-tag>
-            <span v-if="branchDialog.companies.length === 0" style="color:#999">鏆傛棤鍒嗗叕鍙�</span>
+            <el-tag v-for="bc in branchDialog.companies" :key="'oa-'+bc.deptId" type="success" size="small" style="margin-right:6px;margin-bottom:6px">{{ bc.deptName }}</el-tag>
+            <span v-if="branchDialog.companies.length === 0" style="color:#999;font-size:12px">鏃燨A鑷姩鍏宠仈</span>
           </div>
+        </el-form-item>
+        <el-form-item label="鎵嬪姩娣诲姞">
+          <div style="margin-bottom:6px;color:#666;font-size:12px;">閫夋嫨闇�瑕侀澶栨坊鍔犵殑鍒嗗叕鍙革細</div>
+          <el-checkbox-group v-model="branchDialog.selectedDeptIds">
+            <el-checkbox
+              v-for="branch in branchDialog.allBranches"
+              :key="branch.deptId"
+              :label="branch.deptId"
+              style="display:block;margin-bottom:4px;"
+            >{{ branch.deptName }}</el-checkbox>
+          </el-checkbox-group>
+          <div v-if="branchDialog.allBranches.length === 0" style="color:#999;font-size:12px">鏆傛棤鍒嗗叕鍙告暟鎹�</div>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitBranchCompanies" :loading="branchDialog.loading">淇� 瀛�</el-button>
         <el-button @click="branchDialog.open = false">鍏� 闂�</el-button>
       </div>
     </el-dialog>
@@ -266,13 +280,14 @@
 
 <script>
 import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
+import { updateUserBranch } from "@/api/system/user";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import { Splitpanes, Pane } from "splitpanes";
 import "splitpanes/dist/splitpanes.css";
 import request from "@/utils/request";
-import { listDept, listBranchByUser } from "@/api/system/dept";
+import { listDept, listBranchByUser, listAllBranches } from "@/api/system/dept";
 
 export default {
   name: "User",
@@ -388,9 +403,10 @@
       branchDialog: {
         open: false,
         userId: null,
-        deptOptions: [],
+        allBranches: [],
         selectedDeptIds: [],
-        companies: []
+        companies: [],
+        loading: false
       },
       // 鍩轰簬 oa_order_class 璁$畻鐨勫垎鍏徃鍒楄〃锛堝彧璇诲睍绀猴級
       userBranchCompanies: []
@@ -606,22 +622,53 @@
     handleManageBranch(row) {
       const userId = row.userId;
       this.branchDialog.userId = userId;
-      // 鍔犺浇鍒嗗叕鍙稿垪琛紙OA鑷姩鎺у埗锛屽彧璇诲睍绀猴級
-      listBranchByUser(userId).then(res => {
-        const list = res.data || [];
-        this.branchDialog.companies = (list || []).map(d => ({ deptId: d.deptId, deptName: d.deptName }));
-        this.branchDialog.open = true;
+      this.branchDialog.companies = [];
+      this.branchDialog.allBranches = [];
+      this.branchDialog.selectedDeptIds = [];
+      this.branchDialog.loading = true;
+      this.branchDialog.open = true;
+      // 骞惰鍔犺浇锛氬綋鍓嶇敤鎴稯A鍏宠仈鍒嗗叕鍙� + 鎵�鏈夊垎鍏徃鍒楄〃
+      const p1 = listBranchByUser(userId).then(res => {
+        return (res.data || []).map(d => ({ deptId: d.deptId, deptName: d.deptName }));
+      });
+      const p2 = listAllBranches().then(res => {
+        return res.data || [];
+      });
+      Promise.all([p1, p2]).then(([oaCompanies, allBranches]) => {
+        this.branchDialog.companies = oaCompanies;
+        this.branchDialog.allBranches = allBranches;
+        // 鍒濆鍖栧凡閫夛細浠� userList 涓壘鍒拌鐢ㄦ埛鐨� oaOrderClass锛屽尮閰嶅垎鍏徃
+        const userRow = (this.userList || []).find(u => u.userId === userId);
+        if (userRow && userRow.oaOrderClass) {
+          const codes = userRow.oaOrderClass.split(',').map(s => s.trim()).filter(s => s);
+          const codeSet = new Set(codes);
+          const selected = allBranches
+            .filter(d => {
+              return (d.serviceOrderClass && codeSet.has(d.serviceOrderClass.trim()))
+                || (d.dispatchOrderClass && codeSet.has(d.dispatchOrderClass.trim()));
+            })
+            .map(d => d.deptId);
+          this.branchDialog.selectedDeptIds = selected;
+        }
+        this.branchDialog.loading = false;
       }).catch(() => {
         this.$modal.msgError('鍔犺浇鍒嗗叕鍙搁厤缃け璐�');
+        this.branchDialog.loading = false;
       });
     },
     /** 淇濆瓨鍒嗗叕鍙搁厤缃� */
-    // 宸插彇娑堜繚瀛橈紝OA鑷姩鎺у埗锛堜粎鍙灞曠ず锛�
-    // submitBranchCompanies() {
-    //   const userId = this.branchDialog.userId;
-    //   const deptIds = this.branchDialog.selectedDeptIds || [];
-    //   // 淇濈暀鍗犱綅锛岄伩鍏嶈璋冪敤
-    // },
+    submitBranchCompanies() {
+      this.branchDialog.loading = true;
+      updateUserBranch(this.branchDialog.userId, this.branchDialog.selectedDeptIds).then(() => {
+        this.$modal.msgSuccess('鍒嗗叕鍙搁厤缃繚瀛樻垚鍔�');
+        this.branchDialog.loading = false;
+        this.branchDialog.open = false;
+        this.getList();
+      }).catch(() => {
+        this.$modal.msgError('淇濆瓨鍒嗗叕鍙搁厤缃け璐�');
+        this.branchDialog.loading = false;
+      });
+    },
     /** 鎻愪氦鎸夐挳 */
     submitForm: function() {
       this.$refs["form"].validate(valid => {

--
Gitblit v1.9.1