@sy-common/organize-select-help 1.0.0-beta.6 → 1.0.0-beta.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Modal
2
+ <Modal
3
3
  title=""
4
4
  v-model="modal"
5
5
  @on-ok="confirm"
@@ -7,132 +7,220 @@
7
7
  width="1180"
8
8
  :mask-closable="false"
9
9
  class="modal-tree"
10
- >
11
- <div slot="header" class="header-text"><Icon type="md-information" class="icon-tip" />人员选择</div>
12
- <div class="content-container">
13
- <div class="tree-orig">
14
- <div class="tab-content">
15
- <Tabs :value="name">
16
- <TabPane label="选择组织节点" name="name1">
17
- <div class="tab">
18
- <Input v-model="orgSearch" placeholder="搜索组织节点"/>
19
- <div class="tag-content">
10
+ >
11
+ <div slot="header" class="header-text"><Icon type="md-information" class="icon-tip" />人员选择</div>
12
+ <div class="content-container">
13
+ <div class="tree-orig">
14
+ <div class="tab-content-pro">
15
+ <Tabs :value="tabName" @input="handleTabChange">
16
+ <TabPane label="组织选择" name="org" v-if="name.includes('org')">
17
+ <div class="tab">
18
+ <span>组织搜索:</span>
19
+ <Select v-model="orgSearch" filterable :remote-method="getOrgListBySearch" @on-change="getOrgOption" :loading="loadingOrg" placeholder="请输入组织名称" style="width: 600px;" clearable>
20
+ <Option v-for="(option, index) in orgSearchList" :value="option.orgUnitId" :key="index">{{option.name}}</Option>
21
+ </Select>
22
+ <div class="tag-content" v-if="isQuickOpen && orgTagList.length > 0">
23
+ <span>快捷选择:</span>
24
+ <div class="custom-select-wrapper">
25
+ <Select
26
+ v-model="selectedOrgTagKey"
27
+ placeholder="请选择快捷标签"
28
+ transfer
29
+ clearable
30
+ @on-change="handleOrgTagSelect"
31
+ @on-clear="handleOrgTagClear"
32
+ style="width: 600px;"
33
+ :disabled="!orgTagList.length"
34
+ >
35
+ <Option
36
+ v-for="item in orgTagList"
37
+ :value="item.quickPickKey"
38
+ :key="item.quickPickKey"
39
+ :class="{ 'active-option': item.checked }"
40
+ >
41
+ {{ item.quickPickName }}
42
+ </Option>
43
+ <!-- 无数据提示 -->
44
+ <Option value="" v-if="!postTagList.length" disabled>
45
+ 暂无快捷标签
46
+ </Option>
47
+ </Select>
48
+ </div>
49
+ </div>
50
+ <div class="tree">
51
+ <organizeTree @handleChange="getOrgList" ref="orgTree" :treeList="orgTree"></organizeTree>
52
+ </div>
53
+ <div class="bottom-select">
54
+ <CheckboxGroup v-model="includeLevelOrg">
55
+ <Checkbox label="01">
56
+ <span>包含下级组织节点</span>
57
+ </Checkbox>
58
+ </CheckboxGroup>
59
+ <Button type="primary" icon="md-add" @click="addOrgList">添加节点</Button>
60
+ </div>
61
+ </div>
62
+ </TabPane>
63
+ <TabPane label="岗位选择" name="post" v-if="name.includes('post')">
64
+ <div class="tab post">
65
+ <div class="left" style="height: 450px; overflow: hidden; position: relative; z-index: 1;">
66
+ <div class="scroll-container">
67
+ <div class="position-item"
68
+ v-for="item in positiontList"
69
+ :class="[selectedPositionId === item.positionId ? 'active' : '']"
70
+ :key="item.positionId"
71
+ @click="getPosionId(item)">
72
+ {{ item.positionName }} <!-- 无需修改模板,仅通过样式实现自动换行 -->
73
+ </div>
74
+ </div>
75
+ </div>
76
+ <div class="right">
77
+ <span>组织搜索:</span>
78
+ <Select v-model="postSearch" filterable :remote-method="getPostListBySearch" @on-change="getPostOption" placeholder="组织选择" :loading="loadingPost" clearable @on-clear="handlePostSearchClear" style="width: 365px;">
79
+ <Option v-for="(option, index) in postSearchList" :value="option.orgUnitId" :key="index">{{option.name}}</Option>
80
+ </Select>
81
+ <div class="tag-content" v-if="isQuickOpen && postTagList.length > 0">
20
82
  <span>快捷选择:</span>
21
- <div class="tag-list">
22
- <span class="tag" v-for="item in tagList" :key="item.key">{{item.v}}</span>
83
+ <div class="custom-select-wrapper">
84
+ <Select
85
+ v-model="selectedPostTagKey"
86
+ placeholder="请选择快捷标签"
87
+ transfer
88
+ clearable
89
+ @on-change="handlePostTagSelect"
90
+ @on-clear="handlePostTagClear"
91
+ style="width: 365px;"
92
+ :disabled="!postTagList.length"
93
+ >
94
+ <Option
95
+ v-for="item in postTagList"
96
+ :value="item.quickPickKey"
97
+ :key="item.quickPickKey"
98
+ :class="{ 'active-option': item.checked }"
99
+ >
100
+ {{ item.quickPickName }}
101
+ </Option>
102
+ <!-- 无数据提示 -->
103
+ <Option value="" v-if="!postTagList.length" disabled>
104
+ 暂无快捷标签
105
+ </Option>
106
+ </Select>
23
107
  </div>
24
108
  </div>
25
109
  <div class="tree">
26
- <organizeTree @handleChange="getOrgList" ref="organizeTree"></organizeTree>
110
+ <organizeTree @handleChange="getPostList" ref="postTree" :treeList="postTree"></organizeTree>
27
111
  </div>
28
112
  <div class="bottom-select">
29
- <CheckboxGroup v-model="includeLevelOrg">
113
+ <CheckboxGroup v-model="includeLevelPost">
30
114
  <Checkbox label="01">
31
115
  <span>包含下级组织节点</span>
32
116
  </Checkbox>
33
117
  </CheckboxGroup>
34
- <Button type="primary" icon="md-add" @click="addOrgList">添加节点</Button>
118
+ <Button type="primary" icon="md-add" @click="addPostList">添加节点</Button>
35
119
  </div>
36
120
  </div>
37
- </TabPane>
38
- <TabPane label="选择组织节点和岗位" name="name2">
39
- <div class="tab post">
40
- <div class="left">
41
- <div v-for="item in positiontList" :class="[item.checked&&'active']" :key="item.positionId" @click="getPosionId(item)">{{ item.positionName }}</div>
42
- </div>
43
- <div class="right">
44
- <Input v-model="orgSearch" placeholder="搜索组织节点"/>
45
- <div class="tag-content">
46
- <span>快捷选择:</span>
47
- <div class="tag-list">
48
- <span class="tag" v-for="item in tagList" :key="item.key">{{item.v}}</span>
49
- </div>
50
- </div>
51
- <div class="tree">
52
- <organizeTree @handleChange="getPostList" ref="postTree"></organizeTree>
53
- </div>
54
- <div class="bottom-select">
55
- <CheckboxGroup v-model="includeLevelPost">
56
- <Checkbox label="01">
57
- <span>包含下级组织节点</span>
58
- </Checkbox>
59
- </CheckboxGroup>
60
- <Button type="primary" icon="md-add" @click="addPostList">添加节点</Button>
121
+ </div>
122
+ </TabPane>
123
+ <TabPane label="选择人员" name="staff" v-if="name.includes('staff')">
124
+ <div class="tab staff-left-right-layout">
125
+ <!-- 左侧:组织选择区域(限制高度) -->
126
+ <div class="staff-left-panel">
127
+ <div class="panel-title">组织选择</div>
128
+ <div class="tree staff-org-tree">
129
+ <div class="tree-scroll-force">
130
+ <organizeTree
131
+ @handleChange="getStaffList"
132
+ ref="staffTree"
133
+ :treeList="staffTree"
134
+ :showCheckbox="true"
135
+ :checkStrictly="true"
136
+ :autoExpandParent="true"
137
+ :isSingleSelect="true"
138
+ :default-org-unit-id="defaultOrgUnitId"
139
+ :is-custom-tree="!!defaultOrgUnitId"
140
+ :disable-lazy-load="false"
141
+ ></organizeTree>
61
142
  </div>
62
143
  </div>
63
144
  </div>
64
- </TabPane>
65
- <TabPane label="直接选择人员" name="name3">
66
- <div class="tab">
67
- <Input v-model="staffSearch" @on-blur="queryAllStaffList" placeholder="搜索组织节点"/>
68
- <div class="tree staff-content">
69
- <div :class="['gust-item',item.checked && 'staff-active']" v-for="item in staffAllList" :key="item.id" @click="handlestaff(item)">
70
- <div class="left-panel">{{item.name && item.name.slice(0,1) || ''}}</div>
71
- <div class="right-panel">
72
- <p>{{item.name}}</p>
73
- <p>{{item.orgNodeName}}</p>
145
+
146
+ <div class="staff-right-panel">
147
+ <Input v-model="staffSearch" @on-enter="searchStaff" @on-search="searchStaff" search placeholder="搜索人员"/>
148
+ <div style="position:relative;">
149
+ <div class="tree staff-content" @scroll="handleScroll">
150
+ <div :class="['gust-item',item.checked && 'staff-active']"
151
+ v-for="(item, index) in staffAllList"
152
+ :key="`staff_${index}_${item.id}`"
153
+ @click="handlestaff(item)">
154
+ <!-- 移除 Checkbox 组件 -->
155
+ <div class="left-panel-pro">{{item.name && item.name.slice(0,1) || ''}}</div>
156
+ <div class="right-panel-pro">
157
+ <p>{{item.name}}</p>
158
+ <p>{{item.orgNodeName || item.orgUnitName}}</p>
159
+ </div>
74
160
  </div>
75
- <div class="checked-icon" v-show="item.checked">✔</div>
161
+ <p v-if="staffEnding" style="color:#CCCCCC;text-align: center">---我也是有底线的---</p>
76
162
  </div>
163
+ <Spin v-if="loadingStaff" size="large" fix />
77
164
  </div>
78
- <div class="bottom-select">
79
- <div>当前已选择 <span class="num">{{getCheckedStaff}}</span>人</div>
80
- <Button type="primary" icon="md-add" @click="addStaffList">添加人员</Button>
81
- </div>
82
- </div>
83
- </TabPane>
84
- </Tabs>
85
- </div>
86
- <div class="form-content">
87
- <p>已选择条件 <span class="num">({{getCheckTypenum}})</span></p>
88
- <div class="node-list">
89
- <!-- 组织节点条件:-->
90
- <div>
91
- <div class="group-box flex-r-bt">
92
- <div>组织节点条件:</div>
93
- <div class="clear-btn" @click="clearGroup">清除全部</div>
94
- </div>
95
- <div class="group-list-content">
96
- <p class="list-item flex-r-bt" v-for="(item,index) in orgList" :ket="index">
97
- <span>{{ item.title }}</span>
98
- <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearOrgByIndex(index)">
99
- </p>
100
- <p style="color:#CCCCCC" class="list-item" v-if="!orgList.length">未选择组织节点</p>
165
+ <!-- <div class="bottom-select">-->
166
+ <!-- <div>当前已选择 <span class="num">{{getCheckedStaff}}</span>人</div>-->
167
+ <!-- <Button type="primary" icon="md-add" @click="addStaffList">添加人员</Button>-->
168
+ <!-- </div>-->
101
169
  </div>
102
170
  </div>
103
- <!-- 组织节点+岗位条件://-->
104
- <div>
105
- <div class="group-box flex-r-bt">
106
- <div>组织节点+岗位条件:</div>
107
- <div class="clear-btn" @click="clearPost">清除全部</div>
108
- </div>
109
- <div class="group-list-content">
110
- <p class="list-item flex-r-bt" v-for="(item,index) in postList">
111
- <span>{{item.positionName}}-{{item.title}}</span>
112
- <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearPostByIndex(index)">
113
- </p>
114
- <p style="color:#CCCCCC" class="list-item" v-if="!postList.length">未选择组织节点+岗位条件</p>
115
- </div>
171
+ </TabPane>
172
+ </Tabs>
173
+ </div>
174
+ <div class="form-content">
175
+ <p v-if="name.length > 1">已选择条件 <span class="num">({{getCheckTypenum}})</span></p>
176
+ <div class="node-list">
177
+ <!-- 组织节点条件:-->
178
+ <div v-if="name.includes('org')">
179
+ <div class="group-box flex-r-bt">
180
+ <div>组织节点条件:</div>
181
+ <div class="clear-btn" @click="clearGroup">清除全部</div>
116
182
  </div>
117
- <!-- 直接选择人员:-->
118
- <div>
119
- <div class="group-box flex-r-bt">
120
- <div>直接选择人员:</div>
121
- <div class="clear-btn" @click="clearStaff">清除全部</div>
122
- </div>
123
- <div class="group-list-content">
124
- <p class="list-item flex-r-bt" v-for="(item,index) in staffList" :key="item.id">
125
- <span>{{item.name}}</span>
126
- <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearStaffByIndex(index)">
127
- </p>
128
- <p style="color:#CCCCCC" class="list-item" v-if="!staffList.length">未选择直接选择人员</p>
129
- </div>
183
+ <div class="group-list-content">
184
+ <p class="list-item flex-r-bt" v-for="(item,index) in orgList" :ket="index">
185
+ <span>{{ item.title }}</span>
186
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearOrgByIndex(index)">
187
+ </p>
188
+ <p style="color:#CCCCCC" class="list-item" v-if="!orgList.length">未选择组织节点</p>
189
+ </div>
190
+ </div>
191
+ <!-- 组织节点+岗位条件://-->
192
+ <div v-if="name.includes('post')">
193
+ <div class="group-box flex-r-bt">
194
+ <div>岗位条件+组织节点:</div>
195
+ <div class="clear-btn" @click="clearPost">清除全部</div>
196
+ </div>
197
+ <div class="group-list-content">
198
+ <p class="list-item flex-r-bt" v-for="(item,index) in postList">
199
+ <span>{{item.positionName}}-{{item.title}}</span>
200
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearPostByIndex(index)">
201
+ </p>
202
+ <p style="color:#CCCCCC" class="list-item" v-if="!postList.length">未选择岗位条件+组织节点</p>
203
+ </div>
204
+ </div>
205
+ <!-- 直接选择人员:-->
206
+ <div v-if="name.includes('staff')">
207
+ <div class="group-box flex-r-bt">
208
+ <div>直接选择人员:</div>
209
+ <div class="clear-btn" @click="clearStaff">清除全部</div>
210
+ </div>
211
+ <div class="group-list-content">
212
+ <p class="list-item flex-r-bt" v-for="(item,index) in staffList" :key="item.userId">
213
+ <span>{{item.name}}</span>
214
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearStaffByIndex(index)">
215
+ </p>
216
+ <p style="color:#CCCCCC" class="list-item" v-if="!staffList.length">未选择直接选择人员</p>
130
217
  </div>
131
218
  </div>
132
219
  </div>
133
220
  </div>
134
221
  </div>
135
- </Modal>
222
+ </div>
223
+ </Modal>
136
224
  </template>
137
225
  <script>
138
226
  import organizeTree from './organize-tree.vue'
@@ -147,44 +235,241 @@ export default {
147
235
  },
148
236
  data:{
149
237
  type:Object,
150
- default:{}
238
+ default:()=>{}
239
+ },
240
+ name:{
241
+ type:Array ,
242
+ default(){return ['org','post','staff']}
243
+ },
244
+ isQuickOpen:{
245
+ type: Boolean,
246
+ default: false
247
+ },
248
+ defaultOrgUnitId:{
249
+ type: String,
250
+ default: ''
251
+ },
252
+ staffSingle:{
253
+ type: Boolean,
254
+ default: false
151
255
  }
152
256
  },
153
257
  data(){
154
258
  return {
259
+ tabName:this.name[0],
155
260
  modal:false,
156
- name:'name1',
157
261
  dialogOpen:false,
158
262
  orgSearch:'',
159
263
  //组织--right-form
160
264
  proOrgList:[],
161
265
  includeLevelOrg:[],
162
266
  orgList:[],
267
+ loadingOrg:false,
268
+ orgSearchList:[],
269
+ orgTree:[],
163
270
  //岗位--form
271
+ postSearch:'',
164
272
  proPostList:[],
165
273
  postList:[],
274
+ loadingPost:false,
275
+ postSearchList:[],
166
276
  includeLevelPost:[],
167
277
  positiontList:[],
278
+ postTree:[],
168
279
  //直接人员
169
280
  staffSearch:'',
170
281
  staffAllList:[],
171
282
  staffList:[],
172
- tagList:[{
173
- v:'所选市公司所有部门',
174
- on:false,
175
- key:'07'
176
- },{
177
- v:'所有市公司',
178
- on:false,
179
- key:'08'
180
- }],
283
+ loadingStaff:false,
284
+ lastLoadingTime:0,
285
+ offset:0,
286
+ staffEnding:false,
287
+ parentOrgList: [],
288
+ orgTagList:[],
289
+ postTagList:[],
290
+ selectedPositionId: null, // 新增:岗位单选的选中状态存储
291
+ selectedOrgTagKey: '', // 存储选中标签的唯一标识
292
+ selectedPostTagKey: '', // 存储选中标签的唯一标识
293
+ //人员选择
294
+ staffTree:[],
295
+ staffTagList:[],
296
+ staffOrgList:[],
297
+ staffSearchList:[],
298
+ selectedStaffOrgId: '', // 新增:选中的组织节点ID
299
+ proStaffOrgList: [], // 新增:暂存选中的组织节点
300
+ initialDefaultOrgUnitId: '', // 缓存初始defaultOrgUnitId
301
+ staffTreeInited: false, // 组织树初始化完成标记(用于需求3)
181
302
  }
182
303
  },
183
304
  mounted() {
305
+ this.queryTagList()
184
306
  this.queryPositionList()
185
- this.queryAllStaffList()
307
+ // this.loadMore()
308
+ this.initialDefaultOrgUnitId = this.defaultOrgUnitId || ''; // 缓存初始值
309
+ this.initStaffOrgTree()
186
310
  },
311
+
187
312
  methods:{
313
+ async initStaffOrgTree() {
314
+ try {
315
+ // 关键修复:初始化时重置选中状态
316
+ this.$set(this, 'selectedStaffOrgId', '');
317
+ this.proStaffOrgList = [];
318
+
319
+ const rootOrgId = this.defaultOrgUnitId || '';
320
+ let rootNode = null;
321
+ let treeSourceData = []; // 存储树原始数据,避免后续覆盖
322
+
323
+ if (rootOrgId) {
324
+ const orgDetailRes = await ajax.get(`/pub-manage-server/pub/organ/q/queryOrg`, {
325
+ params: { orgUnitId: rootOrgId }
326
+ });
327
+ if (orgDetailRes.data.code === 1 && orgDetailRes.data.data) {
328
+ const orgData = orgDetailRes.data.data;
329
+ const leafNode = await this.judgeNodeLeafe(rootOrgId);
330
+ rootNode = this.safeDeepCopy({
331
+ ...orgData,
332
+ orgNodeName: orgData.orgUnitName || '',
333
+ title: orgData.orgUnitName || `未命名组织(${orgData.orgUnitId || ''})`,
334
+ leafNode,
335
+ expand: true,
336
+ parentOrgUnitId: orgData.parentOrgUnitId || orgData.parentId,
337
+ orgChildrenList: [], // 初始化自定义子节点字段
338
+ children: [] // 关键:初始化 Tree 组件识别的 children 字段
339
+ });
340
+ // 父节点列表同样同步初始化 children 字段
341
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(rootOrgId);
342
+ const safeParents = this.safeDeepCopy(parentsList);
343
+ safeParents.forEach(node => {
344
+ node.expand = true;
345
+ node.parentOrgUnitId = node.parentId;
346
+ node.orgNodeName = node.orgUnitName || node.orgNodeName || '';
347
+ node.title = node.orgUnitName || node.name || `未命名组织(${node.orgUnitId || ''})`;
348
+ node.orgChildrenList = [];
349
+ node.children = []; // 父节点也初始化 children 字段
350
+ node.leafNode = false;
351
+ });
352
+ treeSourceData = [...safeParents, rootNode];
353
+ } else {
354
+ this.$Message.error("根据默认组织ID查询根节点失败!");
355
+ return;
356
+ }
357
+ } else {
358
+ // defaultOrgUnitId为空时,沿用原有接口/pub/personHelpBox/q/getOrgUnitList
359
+ const res = await ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitList', {
360
+ params: { containsCurLevel: true }
361
+ });
362
+ if (res.data.code === 1) {
363
+ rootNode = res.data.data[0] || null;
364
+ if (rootNode) {
365
+ rootNode.expand = true;
366
+ rootNode.parentOrgUnitId = rootNode.parentId;
367
+ treeSourceData = [rootNode];
368
+ }
369
+ }
370
+ }
371
+
372
+ // 构建组织树,且仅赋值一次,避免后续覆盖(需求3)
373
+ if (treeSourceData.length > 0) {
374
+ const tree = this.buildTree(treeSourceData);
375
+ this.staffTree = this.safeDeepCopy(tree);
376
+ // 关键:标记树已初始化完成,防止后续重复构建覆盖
377
+ this.staffTreeInited = true;
378
+ }
379
+ } catch (e) {
380
+ this.$Message.error("人员选择组织树初始化失败!");
381
+ console.error(e);
382
+ }
383
+ },
384
+ handlePostTagSelect(quickPickKey) {
385
+ // 清空暂存列表
386
+ this.proPostList = [];
387
+ // 找到选中的标签对象
388
+ const selectedItem = this.postTagList.find(
389
+ item => item.quickPickKey === quickPickKey
390
+ );
391
+
392
+ if (selectedItem) {
393
+ // 重置其他标签的选中状态
394
+ this.postTagList.forEach(tag => tag.checked = false);
395
+ // 触发原有的处理方法
396
+ this.fastChedkPost(selectedItem);
397
+ // 清空搜索框绑定的值
398
+ this.postSearch = '';
399
+ // 清空搜索结果列表
400
+ this.postSearchList = [];
401
+ }
402
+ },
403
+ handleOrgTagSelect(quickPickKey) {
404
+ // 清空暂存列表
405
+ this.proOrgList = [];
406
+ // 找到选中的标签对象
407
+ const selectedItem = this.orgTagList.find(
408
+ item => item.quickPickKey === quickPickKey
409
+ );
410
+
411
+ if (selectedItem) {
412
+ // 重置其他标签的选中状态
413
+ this.orgTagList.forEach(tag => tag.checked = false);
414
+ // 触发原有的处理方法
415
+ this.fastChedkOrg(selectedItem);
416
+ // 清空搜索框绑定的值
417
+ this.orgSearch = '';
418
+ // 清空搜索结果列表
419
+ this.orgSearchList = [];
420
+ }
421
+ },
422
+ handleOrgTagClear() {
423
+ this.selectedOrgTagKey = '';
424
+ // 重置所有标签的选中状态
425
+ this.orgTagList.forEach(tag => {
426
+ tag.checked = false;
427
+ });
428
+
429
+ // 3. 清空树选择状态和暂存列表
430
+ if (this.$refs.orgTree && this.orgSearchList) {
431
+ this.$refs.orgTree.initData();
432
+ }
433
+ // 4. 可选:添加清空提示
434
+ this.$Message.info("已清空快捷标签选择");
435
+ },
436
+ // 修正清空逻辑方法(与事件名称对应)
437
+ handlePostTagClear() {
438
+ // 1. 重置选中的标签key
439
+ this.selectedPostTagKey = '';
440
+
441
+ // 2. 重置所有标签的选中状态
442
+ this.postTagList.forEach(tag => {
443
+ tag.checked = false;
444
+ });
445
+
446
+ // 3. 清空树选择状态和暂存列表
447
+ if (this.$refs.postTree) {
448
+ this.$refs.postTree.initData();
449
+ this.proPostList = [];
450
+ }
451
+
452
+ // 4. 可选:添加清空提示
453
+ this.$Message.info("已清空快捷标签选择");
454
+ },
455
+ handlePostSearchClear() {
456
+ // 清空搜索框绑定的值
457
+ this.postSearch = '';
458
+
459
+ // 清空搜索结果列表
460
+ this.postSearchList = [];
461
+
462
+ // 重置树组件状态(与原有逻辑保持一致)
463
+ if (this.$refs.postTree) {
464
+ this.$refs.postTree.initData();
465
+ }
466
+
467
+ // 清空暂存列表
468
+ this.proPostList = [];
469
+
470
+ // 可选:添加清空提示
471
+ this.$Message.info("已清空组织选择搜索");
472
+ },
188
473
  queryPositionList(){
189
474
  ajax.get('/pub-manage-server/pub/personHelpBox/q/queryPositionList').then((res)=>{
190
475
  if(res.data.code === 1){
@@ -194,38 +479,409 @@ export default {
194
479
  }
195
480
  })
196
481
  },
197
- queryAllStaffList(){
198
- ajax.get('/pub-manage-server/pub/personHelpBox/q/queryAllStaffList?search='+this.staffSearch).then((res)=>{
199
- if(res.data.code === 1){
200
- let staffAllList = res.data.data && res.data.data.rows || []
201
- staffAllList.map((item)=>item.checked=false)
202
- this.staffAllList = staffAllList
482
+ getOrgListBySearch(query){
483
+ if (query !== '') {
484
+ this.loadingOrg = true;
485
+ this.getOrgUnitBySearchTerm(query,(res)=>{
486
+ this.loadingOrg = false
487
+ if(res.data.code === 1){
488
+ let resp = res.data.data?.items??[]
489
+ this.orgSearchList = resp
490
+ }else{
491
+ this.orgSearchList = []
492
+ this.$Message.error("获取组织节点列表失败!")
493
+ }
494
+ })
495
+ }else{
496
+ this.orgSearchList = [];
497
+ }
498
+ },
499
+ getPostListBySearch(query) {
500
+ if (query !== '') {
501
+ this.loadingPost = true;
502
+ this.getOrgUnitBySearchTerm(query, (res) => {
503
+ this.loadingPost = false;
504
+ if (res.data.code === 1) {
505
+ let resp = res.data.data?.items ?? [];
506
+ // 修复:岗位搜索结果深拷贝,避免引用污染
507
+ this.postSearchList = this.safeDeepCopy(resp);
508
+ } else {
509
+ this.postSearchList = [];
510
+ this.$Message.error("获取组织节点列表失败!");
511
+ }
512
+ });
513
+ } else {
514
+ // 修复:清空搜索时,同时清空树数据和暂存列表(与组织Tab一致)
515
+ this.postSearchList = [];
516
+ if (this.$refs.postTree) {
517
+ this.$refs.postTree.initData();
203
518
  }
204
- })
519
+ this.proPostList = []; // 清空岗位暂存列表
520
+ this.$set(this, 'postTree', []); // 清空岗位树数据
521
+ }
522
+ },
523
+ getOrgUnitBySearchTerm(query,callback){
524
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitBySearchTerm?searchTerm='+query).then((res)=>{callback(res)})
525
+ },
526
+ async getOrgOption(val) {
527
+ this.selectedOrgTagKey = '';
528
+ this.orgTagList.forEach(tag => {
529
+ tag.checked = false;
530
+ });
531
+ this.proOrgList = [];
532
+ if(!val) return this.$refs.orgTree.initData();
533
+ let item = this.orgSearchList.filter((item)=> item.orgUnitId === val).shift();
534
+ if (!item) return;
535
+
536
+ const leafNode = await this.judgeNodeLeafe(item.orgUnitId);
537
+ const ftem = this.safeDeepCopy({
538
+ ...item,
539
+ orgNodeName: item.name,
540
+ parentOrgUnitId: item.parentId,
541
+ leafNode: leafNode
542
+ });
543
+
544
+ try{
545
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(val);
546
+ // 对父节点列表进行安全拷贝
547
+ const safeParents = this.safeDeepCopy(parentsList);
548
+ let tree = this.buildTree([...safeParents, ftem]);
549
+ this.orgTree = this.safeDeepCopy(tree);
550
+ }catch(e){
551
+ this.$Message.error("获取组织节点列表失败!");
552
+ }
553
+ },
554
+ async getPostOption(val) {
555
+ // 1. 重置选中的标签key
556
+ this.selectedPostTagKey = '';
557
+
558
+ // 2. 重置所有标签的选中状态
559
+ this.postTagList.forEach(tag => {
560
+ tag.checked = false;
561
+ });
562
+ if (!val) {
563
+ // 修复:岗位树清空时,同时清空暂存列表和搜索框
564
+ if (this.$refs.postTree) {
565
+ this.$refs.postTree.initData();
566
+ }
567
+ this.proPostList = []; // 清空岗位暂存列表(与组织Tab保持一致)
568
+ this.postSearch = ''; // 清空搜索框
569
+ return;
570
+ }
571
+
572
+ let item = this.postSearchList.filter(item => item.orgUnitId === val).shift();
573
+ if (!item) return;
574
+
575
+ const leafNode = await this.judgeNodeLeafe(item.orgUnitId);
576
+ // 修复:岗位节点深拷贝,避免引用污染
577
+ const ftem = this.safeDeepCopy({
578
+ ...item,
579
+ orgNodeName: item.name || `未命名组织(${item.orgUnitId})`,
580
+ parentOrgUnitId: item.parentId,
581
+ leafNode: leafNode
582
+ });
583
+
584
+ try {
585
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(val);
586
+ const safeParents = this.safeDeepCopy(parentsList);
587
+ let tree = this.buildTree([...safeParents, ftem]);
588
+ // 修复:用$set确保岗位树数据响应式更新
589
+ this.$set(this, 'postTree', this.safeDeepCopy(tree));
590
+
591
+ // 修复:设置节点展开和选中(与组织Tab逻辑一致)
592
+ this.$nextTick(() => {
593
+ if (this.$refs.postTree && this.$refs.postTree.setCheckedNodes) {
594
+ this.$refs.postTree.setCheckedNodes([val]); // 选中当前节点
595
+ this.proPostList = [ftem]; // 同步暂存列表
596
+ }
597
+ });
598
+ } catch (e) {
599
+ this.$Message.error("获取组织节点列表失败!");
600
+ }
205
601
  },
206
- getOrgList(data){
207
- this.proOrgList = data
602
+ async getStaffOption(val) {
603
+ this.staffOrgList = [];
604
+ if(!val) return this.$refs.staffTree.initData();
605
+ let item = this.staffSearchList.filter((item)=> item.orgUnitId === val).shift();
606
+ if (!item) return;
607
+
608
+ const leafNode = await this.judgeNodeLeafe(item.orgUnitId);
609
+ const ftem = this.safeDeepCopy({
610
+ ...item,
611
+ orgNodeName: item.name,
612
+ parentOrgUnitId: item.parentId,
613
+ leafNode: leafNode
614
+ });
615
+
616
+ try{
617
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(val);
618
+ // 对父节点列表进行安全拷贝
619
+ const safeParents = this.safeDeepCopy(parentsList);
620
+ let tree = this.buildTree([...safeParents, ftem]);
621
+ this.staffTree = this.safeDeepCopy(tree);
622
+ }catch(e){
623
+ this.$Message.error("获取组织节点列表失败!");
624
+ }
208
625
  },
209
- getPostList(data){
210
- this.proPostList = data
626
+ getParentOrgNodesByOrgUnitId(val){
627
+ return new Promise((resolve,reject)=>{
628
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getParentOrgNodesByOrgUnitId?orgUnitId='+val).then((res)=>{
629
+ if(res.data.code === 1){
630
+ let parentsList = res.data?.data?.items??[]
631
+ resolve(parentsList)
632
+ }else{
633
+ reject(false)
634
+ }
635
+ })
636
+ })
211
637
  },
212
- addOrgList(){
213
- if(!this.proOrgList.length) return this.$Message.error("请先选择组织节点!")
214
- let proOrgList = deepCopy(this.proOrgList)
215
- proOrgList.forEach(item=>{
216
- item.title = this.includeLevelOrg.includes('01')?`${item.orgNodeName}(包含下级组织节点)`:item.orgNodeName
217
- item.id = this.includeLevelOrg.includes('01')?('01'+'-' + item.orgUnitId):('00'+'-'+item.orgUnitId)
218
- item.includeLevel = this.includeLevelOrg.includes('01')
638
+ judgeNodeLeafe(orgUnitId){
639
+ return new Promise((resolve,reject)=>{
640
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitList', { params:{
641
+ containsCurLevel:true,
642
+ orgUnitId:orgUnitId,
643
+ }
644
+ }).then((res)=>{
645
+ if(res.data.code === 1){
646
+ let treeList = res.data.data
647
+ if(treeList && treeList.length){
648
+ resolve(false)
649
+ }else{
650
+ resolve(true)
651
+ }
652
+ }else{
653
+ resolve(false)
654
+ }
655
+ })
219
656
  })
220
- let list = this.orgList.concat(proOrgList)
657
+ },
658
+ buildTree(items) {
659
+ const map = {};
660
+ const roots = [];
661
+ const copiedItems = this.safeDeepCopy(items);
662
+
663
+ copiedItems.forEach(item => {
664
+ if (!item.orgUnitId) return;
665
+ map[item.orgUnitId] = this.safeDeepCopy({
666
+ ...item,
667
+ orgChildrenList: [],
668
+ children: [], // 强制初始化 children 空数组
669
+ title: item.orgUnitName || item.orgNodeName || item.name || `未命名组织(${item.orgUnitId || ''})`
670
+ });
671
+ });
672
+
673
+ copiedItems.forEach(item => {
674
+ if (!item.orgUnitId || !map[item.orgUnitId]) return;
675
+
676
+ const node = map[item.orgUnitId];
677
+ if (!item.parentOrgUnitId || !map[item.parentOrgUnitId]) {
678
+ roots.push(node);
679
+ } else {
680
+ const parent = map[item.parentOrgUnitId];
681
+ parent.orgChildrenList.push(node);
682
+ parent.children.push(node); // 同步 children 字段
683
+ parent.leafNode = false;
684
+ parent.expand = true;
685
+ }
686
+ });
687
+ return roots;
688
+ },
689
+
690
+ searchStaff(){
691
+ this.staffEnding = false;
692
+ this.offset = 0;
693
+ this.staffAllList = [];
694
+ // 关键修复:50ms延迟,解决极端情况下的异步更新问题
695
+ setTimeout(() => {
696
+ this.loadMore();
697
+ }, 50);
698
+ },
699
+ queryAllStaffList() {
700
+ const params = {
701
+ search: this.staffSearch,
702
+ offset: this.offset,
703
+ limit: 10
704
+ };
705
+
706
+ if (this.selectedStaffOrgId && typeof this.selectedStaffOrgId === 'string' && this.selectedStaffOrgId.trim()) {
707
+ params.orgUnitId = this.selectedStaffOrgId.trim();
708
+ } else if (this.initialDefaultOrgUnitId && this.initialDefaultOrgUnitId.trim()) {
709
+ // 初始化及未选中节点时,使用传入的defaultOrgUnitId
710
+ params.orgUnitId = this.initialDefaultOrgUnitId.trim();
711
+ } else {
712
+ params.orgUnitId = '';
713
+ }
714
+
715
+ console.log('人员查询接口参数:', params);
716
+
717
+ return new Promise((resolve, reject) => {
718
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/queryAllStaffList', {
719
+ params: params
720
+ }).then((res) => {
721
+ if (res.data.code === 1) {
722
+ resolve(res.data.data);
723
+ } else {
724
+ reject(false);
725
+ }
726
+ }).catch((err) => {
727
+ reject(err);
728
+ });
729
+ });
730
+ },
731
+ handleScroll(e){
732
+ const { scrollTop, clientHeight, scrollHeight } = e.target;
733
+ if (scrollHeight - (scrollTop + clientHeight) < 50) {
734
+ this.loadMore();
735
+ }
736
+ },
737
+ async loadMore(){
738
+ if (this.loadingStaff || this.staffEnding) return
739
+ this.loadingStaff = true
740
+ try {
741
+ console.log("--触底加载/强制加载---", new Date().getTime());
742
+ let res = await this.queryAllStaffList()
743
+ let list = res.rows;
744
+ // 移除这行:list.map((item)=>item.checked=false)
745
+ this.staffAllList = this.staffAllList.concat(list)
746
+ this.offset += 10;
747
+ this.loadingStaff = false
748
+ this.lastLoadingTime = Date.now()
749
+ if(res.total===this.staffAllList.length){
750
+ this.staffEnding = true
751
+ }
752
+ }catch (e){
753
+ this.loadingStaff = false
754
+ this.lastLoadingTime = Date.now()
755
+ console.log(e)
756
+ }
757
+ },
758
+ getOrgList(data) {
759
+ const validNodes = Array.isArray(data)
760
+ ? data.filter(node => node.orgUnitId)
761
+ : [];
762
+
763
+ // 去重:基于orgUnitId避免重复
764
+ const uniqueNodes = validNodes.filter((node, index, self) =>
765
+ self.findIndex(item => item.orgUnitId === node.orgUnitId) === index
766
+ );
767
+
768
+
769
+ const completeNodes = uniqueNodes.map(node => ({
770
+ ...node,
771
+ orgNodeName: node.orgNodeName || node.name || `未命名组织(${node.orgUnitId})`,
772
+ orgUnitName: node.orgNodeName || node.name || `未命名组织(${node.orgUnitId})`
773
+ }));
774
+
775
+ this.proOrgList = this.safeDeepCopy(completeNodes);
776
+ },
777
+
778
+ getPostList(data) {
779
+ // 过滤有效节点:仅要求orgUnitId
780
+ const validNodes = Array.isArray(data)
781
+ ? data.filter(node => node.orgUnitId)
782
+ : [];
783
+
784
+ // 去重:基于orgUnitId
785
+ const uniqueNodes = validNodes.filter((node, index, self) =>
786
+ self.findIndex(item => item.orgUnitId === node.orgUnitId) === index
787
+ );
788
+
789
+ // 补全缺失字段
790
+ const completeNodes = uniqueNodes.map(node => ({
791
+ ...node,
792
+ orgNodeName: node.orgNodeName || node.name || `未命名组织(${node.orgUnitId})`,
793
+ orgUnitName: node.orgNodeName || node.name || `未命名组织(${node.orgUnitId})`
794
+ }));
795
+
796
+ // 覆盖暂存列表(而非concat,避免累积无效数据)
797
+ this.proPostList = this.safeDeepCopy(completeNodes);
798
+ },
799
+ getStaffList(data) {
800
+ if (!Array.isArray(data) || data.length === 0) {
801
+ this.proStaffOrgList = [];
802
+ // 强制清空并触发响应式更新
803
+ this.$set(this, 'selectedStaffOrgId', '');
804
+ // 立即触发搜索,确保orgUnitId参数实时更新为空
805
+ this.$nextTick(() => this.searchStaff());
806
+ return;
807
+ }
808
+
809
+ // 关键修复1:过滤仅含有效orgUnitId的节点,排除无效数据
810
+ const validNodes = data.filter(node =>
811
+ node.orgUnitId && typeof node.orgUnitId === 'string' // 确保orgUnitId存在且为字符串
812
+ );
813
+
814
+ if (validNodes.length === 0) {
815
+ this.$Message.warning("所选节点无效,请重新选择");
816
+ this.proStaffOrgList = [];
817
+ this.$set(this, 'selectedStaffOrgId', '');
818
+ // 立即触发搜索,更新参数为空
819
+ this.$nextTick(() => this.searchStaff());
820
+ return;
821
+ }
822
+
823
+ // 关键修复2:单选逻辑强化,仅保留最后一个有效选中节点
824
+ const currentNode = validNodes[validNodes.length - 1];
825
+ const currentOrgUnitId = currentNode.orgUnitId.trim(); // 去除空格,避免无效字符串
826
+
827
+ // 补全节点字段,确保orgUnitId绝对存在
828
+ const pureNode = this.safeDeepCopy({
829
+ ...currentNode,
830
+ orgNodeName: currentNode.orgNodeName || currentNode.name || `未命名组织(${currentOrgUnitId})`,
831
+ orgUnitName: currentNode.orgNodeName || currentNode.name || `未命名组织(${currentOrgUnitId})`
832
+ });
833
+
834
+ // 清除子节点引用,避免循环引用导致的更新延迟
835
+ if (pureNode.orgChildrenList) pureNode.orgChildrenList = [];
836
+ if (pureNode.children) pureNode.children = [];
837
+
838
+ // 关键修复3:强制响应式更新,避免Vue数据延迟
839
+ this.$set(this, 'proStaffOrgList', [pureNode]);
840
+ this.$set(this, 'selectedStaffOrgId', currentOrgUnitId);
841
+
842
+ // 关键修复4:双重nextTick确保数据完全更新后再查询
843
+ this.$nextTick(() => {
844
+ if (this.selectedStaffOrgId !== currentOrgUnitId) {
845
+ this.$set(this, 'selectedStaffOrgId', currentOrgUnitId);
846
+ this.$nextTick(() => this.searchStaff());
847
+ } else {
848
+ this.searchStaff();
849
+ }
850
+ console.log('人员选择-当前选中orgUnitId:', this.selectedStaffOrgId); // 调试日志
851
+ });
852
+ },
853
+
854
+ addOrgList() {
855
+ // 过滤空节点(仅校验orgUnitId)
856
+ const validOrgList = this.proOrgList.filter(node => node.orgUnitId);
857
+ if (!validOrgList.length) return this.$Message.error("请先选择组织节点!");
858
+
859
+ let proOrgList = deepCopy(validOrgList);
860
+ proOrgList.forEach(item => {
861
+ // 用补全后的orgNodeName,避免空显示
862
+ item.title = this.includeLevelOrg.includes('01')
863
+ ? `${item.orgNodeName}(包含下级组织节点)`
864
+ : item.orgNodeName;
865
+ item.id = this.includeLevelOrg.includes('01')
866
+ ? (`01-${item.orgUnitId}`)
867
+ : (`00-${item.orgUnitId}`);
868
+ item.includeLevel = this.includeLevelOrg.includes('01');
869
+ });
870
+
871
+ // 去重合并
872
+ let list = this.orgList.concat(proOrgList);
221
873
  let uniqueArray = list.filter((item, index, self) =>
222
- index === self.findIndex(t => (
223
- t.id === item.id // 基于id属性去重
224
- ))
874
+ index === self.findIndex(t => t.id === item.id)
225
875
  );
226
- this.orgList = uniqueArray
227
- this.$refs.organizeTree.upDataTree()
228
- this.proOrgList = []
876
+ this.orgList = uniqueArray;
877
+
878
+ // 清空选中状态
879
+ if (this.$refs.orgTree && this.$refs.orgTree.clearAllChecked) {
880
+ this.$refs.orgTree.clearAllChecked(this.$refs.orgTree.data);
881
+ this.$refs.orgTree.$emit('handleChange', []);
882
+ }
883
+ this.$refs.orgTree.upDataTree();
884
+ this.proOrgList = [];
229
885
  },
230
886
  clearGroup(){
231
887
  this.orgList = []
@@ -235,36 +891,47 @@ export default {
235
891
  },
236
892
  //岗位
237
893
  getPosionId(item){
238
- item.checked = !item.checked;
239
- },
240
- addPostList(){
241
- if(!this.proPostList.length) return this.$Message.error("请选择组织节点!")
242
- let proPostList = deepCopy(this.proPostList)
243
- let checkedPosition = this.positiontList.filter((item)=>item.checked === true)
244
- if(!checkedPosition.length){return this.$Message.error("请选择岗位!!")}
245
- //summary data
246
- let totalList = []
247
- for(let it of checkedPosition){
248
- proPostList.forEach(item=>{
249
- totalList.push({
250
- ...item,
251
- ...it,
252
- title:`${this.includeLevelPost.length?(item.orgNodeName+'(包含下级组织节点)'):item.orgNodeName}`,
253
- includeLevel:this.includeLevelPost.includes('01'),
254
- id:this.includeLevelPost.includes('01')?('01'+'-'+it.positionId + '-' + item.orgUnitId):('00'+'-'+it.positionId + '-' + item.orgUnitId),
255
- })
256
- })
257
- }
258
- let list = this.postList.concat(totalList)
894
+ // item.checked = !item.checked;
895
+ this.selectedPositionId = item.positionId
896
+ },
897
+ addPostList() {
898
+ // 过滤空节点
899
+ const validPostList = this.proPostList.filter(node => node.orgUnitId);
900
+ if (!validPostList.length) return this.$Message.error("请选择组织节点!");
901
+
902
+ let checkedPosition = this.positiontList.find(item => item.positionId === this.selectedPositionId);
903
+ if (!checkedPosition) { return this.$Message.error("请选择岗位!"); }
904
+
905
+ let totalList = [];
906
+ validPostList.forEach(item => {
907
+ totalList.push({
908
+ ...item,
909
+ ...checkedPosition,
910
+ title: `${this.includeLevelPost.length ? (item.orgNodeName + '(包含下级组织节点)') : item.orgNodeName}`,
911
+ includeLevel: this.includeLevelPost.includes('01'),
912
+ id: this.includeLevelPost.includes('01')
913
+ ? (`01-${checkedPosition.positionId}-${item.orgUnitId}`)
914
+ : (`00-${checkedPosition.positionId}-${item.orgUnitId}`),
915
+ });
916
+ });
917
+
918
+ // 去重合并
919
+ let list = this.postList.concat(totalList);
259
920
  let uniqueArray = list.filter((item, index, self) =>
260
- index === self.findIndex(t => (
261
- t.id === item.id // 基于id属性去重
262
- ))
921
+ index === self.findIndex(t => t.id === item.id)
263
922
  );
264
- this.postList = uniqueArray
265
- this.$refs.postTree.upDataTree()
266
- this.proPostList = []
267
- this.positiontList.map((item)=>{item.checked=false})
923
+ this.postList = uniqueArray;
924
+
925
+ // 清空选中状态
926
+ if (this.$refs.postTree && this.$refs.postTree.clearAllChecked) {
927
+ this.$refs.postTree.clearAllChecked(this.$refs.postTree.data);
928
+ this.$refs.postTree.$emit('handleChange', []);
929
+ }
930
+ this.$refs.postTree.upDataTree();
931
+ this.proPostList = [];
932
+ this.selectedPositionId = null;
933
+ // this.$refs.postTree.initData();
934
+ this.selectedPostTagKey = '';
268
935
  },
269
936
  clearPost(){
270
937
  this.postList= []
@@ -273,19 +940,50 @@ export default {
273
940
  this.postList.splice(index,1)
274
941
  },
275
942
  //staff
276
- addStaffList(){
277
- let staffList = this.staffAllList.filter((item)=>item.checked===true)
278
- let list = this.staffList.concat(staffList)
279
- let uniqueArray = list.filter((item, index, self) =>
280
- index === self.findIndex(t => (
281
- t.id === item.id // 基于id属性去重
282
- ))
283
- );
284
- this.staffList = uniqueArray
285
- this.staffAllList.map((item)=>item.checked=false)
286
- },
943
+ // addStaffList(){
944
+ // console.log("this.staffSingle", this.staffSingle)
945
+ // let staffList = this.staffAllList.filter((item)=>item.checked===true);
946
+ //
947
+ // if (!staffList.length) {
948
+ // this.$Message.error("请选择人员");
949
+ // return;
950
+ // }
951
+ // if (this.staffSingle && this.staffList.length >= 1) {
952
+ // this.$Message.error("请先清除已选人员,再重新添加");
953
+ // return;
954
+ // }
955
+ //
956
+ // if(this.staffSingle && staffList.length > 1){
957
+ // this.$Message.error("温馨提示:当前业务暂时只支持选择一位人员");
958
+ // return;
959
+ // }
960
+ //
961
+ // // 基于item.id去重,不修改原数据字段,仅过滤重复项
962
+ // let uniqueStaffList = staffList.filter(newItem =>
963
+ // // 检查右侧条件区域(staffList)是否已有该人员,避免重复添加
964
+ // !this.staffList.some(existItem => existItem.userId === newItem.userId)
965
+ // );
966
+ // // 合并去重后的列表
967
+ // this.staffList = this.staffList.concat(uniqueStaffList);
968
+ // // 清空选中状态
969
+ // this.staffAllList.forEach(item => item.checked = false);
970
+ // },
287
971
  handlestaff(item){
288
- item.checked=!item.checked
972
+ // 处理单选逻辑
973
+ if (this.staffSingle) {
974
+ // 单选时先清空已选人员
975
+ this.staffList = [];
976
+ }
977
+ // 去重校验:避免重复添加
978
+ const isExist = this.staffList.some(existItem => existItem.userId === item.userId);
979
+ if (!isExist) {
980
+ // 深拷贝防止原数据引用污染
981
+ const newItem = this.safeDeepCopy(item);
982
+ this.staffList.push(newItem);
983
+ this.$Message.success(`已添加【${item.name}】`);
984
+ } else {
985
+ this.$Message.warning(`【${item.name}】已在选择列表中`);
986
+ }
289
987
  },
290
988
  clearStaff(){
291
989
  this.staffList = []
@@ -294,20 +992,613 @@ export default {
294
992
  this.staffList.splice(index,1)
295
993
  },
296
994
  confirm(){
297
- this.$emit('confirm',{
995
+ const v = {
298
996
  orgList:this.orgList,
299
997
  postList:this.postList,
300
998
  staffList:this.staffList
301
- })
999
+ }
1000
+ this.$emit('confirm',deepCopy(v))
302
1001
  },
303
- visibleChange(val){
304
- this.$emit('input',val);
1002
+ visibleChange(val) {
1003
+ this.$emit('input', val);
1004
+ if (val) {
1005
+ this.resetStaffTreeChecked();
1006
+ this.staffEnding = false;
1007
+ this.offset = 0;
1008
+ this.staffAllList = [];
1009
+ this.loadingStaff = false;
1010
+ if (this.tabName === 'staff') {
1011
+ this.loadMore().catch(err => console.log("弹窗打开加载失败:", err));
1012
+ this.$nextTick(() => {
1013
+ setTimeout(() => {
1014
+ this.loadMore();
1015
+ }, 100);
1016
+ });
1017
+ }
1018
+ } else {
1019
+ this.staffEnding = false;
1020
+ this.offset = 0;
1021
+ this.staffAllList = [];
1022
+ this.$set(this, 'selectedStaffOrgId', '');
1023
+ if (this.$refs.staffTree) {
1024
+ this.$refs.staffTree.clearAllChecked(this.$refs.staffTree.data);
1025
+ this.$refs.staffTree.$emit('handleChange', []);
1026
+ }
1027
+ }
305
1028
  },
1029
+ resetStaffTreeChecked() {
1030
+ this.$set(this, 'selectedStaffOrgId', '');
1031
+ this.proStaffOrgList = [];
1032
+ if (this.$refs.staffTree) {
1033
+ this.$refs.staffTree.clearAllChecked(this.$refs.staffTree.data);
1034
+ this.$refs.staffTree.$emit('handleChange', []);
1035
+ }
1036
+ if (this.tabName === 'staff') {
1037
+ this.$nextTick(() => {
1038
+ this.loadMore();
1039
+ });
1040
+ }
1041
+ },
1042
+
1043
+ handleTabChange(tabName) {
1044
+ this.tabName = tabName;
1045
+
1046
+ if (tabName === 'staff') {
1047
+ this.resetStaffTreeChecked();
1048
+ this.staffEnding = false;
1049
+ this.offset = 0;
1050
+ this.staffAllList = [];
1051
+ this.loadingStaff = false;
1052
+ this.loadMore().catch(err => console.log("同步加载失败:", err));
1053
+ this.$nextTick(() => {
1054
+ setTimeout(() => {
1055
+ this.loadMore();
1056
+ }, 100);
1057
+ });
1058
+ } else if (tabName === 'post' && this.$refs.postTree && this.proPostList.length === 0) {
1059
+ this.proPostList = [];
1060
+ this.$refs.postTree.initData();
1061
+ }
1062
+ },
1063
+ initStaffList() {
1064
+ this.staffEnding = false;
1065
+ this.offset = 0;
1066
+ this.staffAllList = [];
1067
+ // 小幅延迟,确保树重置完成后再发起查询(避免时序差)
1068
+ this.$nextTick(() => {
1069
+ setTimeout(() => {
1070
+ this.loadMore();
1071
+ }, 50); // 50ms足够,可根据实际情况调整
1072
+ });
1073
+ },
1074
+ async fastChedkOrg(item) {
1075
+ // 1. 改用组织 Tab 专属标签列表判断
1076
+ if (!this.orgTagList.length) {
1077
+ this.$Message.warning("快捷选择标签正在加载中,请稍后");
1078
+ return;
1079
+ }
1080
+ const treeRef = this.$refs.orgTree;
1081
+ const proListKey = 'proOrgList';
1082
+ const treeDataKey = 'orgTree';
1083
+ this[proListKey] = [];
1084
+ if (treeRef) await treeRef.initData();
1085
+ if (!treeRef) {
1086
+ this.$Message.error("组织树组件未初始化,请稍后再试");
1087
+ item.checked = !item.checked;
1088
+ return;
1089
+ }
1090
+
1091
+ // 2. 清空组织 Tab 标签选中状态(仅操作 orgTagList)
1092
+ this.orgTagList.forEach(tag => {
1093
+ tag.checked = false;
1094
+ });
1095
+
1096
+ // 3. 后续逻辑保持不变,仅操作当前 item(属于 orgTagList)
1097
+ const isCurrentlyChecked = item.checked;
1098
+ if (!isCurrentlyChecked) {
1099
+ item.checked = true;
1100
+ }
1101
+
1102
+ if (!item.checked) {
1103
+ this.$Message.info("已取消该快捷选择");
1104
+ return;
1105
+ }
1106
+
1107
+ try {
1108
+ await this.querySpecificParam(item, true, treeRef, proListKey, treeDataKey);
1109
+ } catch (error) {
1110
+ this.$Message.error(`快捷选择处理失败:${error.message.slice(0, 50)}`);
1111
+ item.checked = !item.checked;
1112
+ }
1113
+ },
1114
+ async fastChedkPost(item) {
1115
+ // 1. 改用岗位 Tab 专属标签列表判断
1116
+ if (!this.postTagList.length) {
1117
+ this.$Message.warning("快捷选择标签正在加载中,请稍后");
1118
+ return;
1119
+ }
1120
+
1121
+ const isOrgTab = this.tabName === 'org';
1122
+ const treeRef = isOrgTab ? this.$refs.orgTree : this.$refs.postTree;
1123
+ const proListKey = isOrgTab ? 'proOrgList' : 'proPostList';
1124
+ const treeDataKey = isOrgTab ? 'orgTree' : 'postTree';
1125
+
1126
+ this[proListKey] = [];
1127
+ const isCurrentlyChecked = item.checked;
1128
+ if (treeRef) await treeRef.initData();
1129
+
1130
+ // 2. 清空岗位 Tab 标签选中状态(仅操作 postTagList)
1131
+ this.postTagList.forEach(tag => {
1132
+ tag.checked = false;
1133
+ });
1134
+
1135
+ // 3. 后续逻辑保持不变,仅操作当前 item(属于 postTagList)
1136
+ if (!isCurrentlyChecked) {
1137
+ item.checked = true;
1138
+ }
1139
+
1140
+ if (!item.checked) {
1141
+ this.$Message.info("已取消该快捷选择");
1142
+ return;
1143
+ }
1144
+
1145
+ try {
1146
+ await this.querySpecificParam(item, isOrgTab, treeRef, proListKey, treeDataKey);
1147
+ } catch (error) {
1148
+ this.$Message.error(`快捷选择处理失败:${error.message.slice(0, 50)}`);
1149
+ item.checked = !item.checked;
1150
+ }
1151
+ },
1152
+ queryTagList() {
1153
+ ajax.get('/pub-manage-server/pub/helpBoxTag/q/queryQuickPickTags').then((res) => {
1154
+ if (res.data.code === 1) {
1155
+ let baseTagList = res.data.data || [];
1156
+ // 组织 Tab 标签:深拷贝并初始化选中状态
1157
+ this.orgTagList = this.safeDeepCopy(baseTagList).map(item => ({
1158
+ ...item,
1159
+ checked: false // 独立选中状态
1160
+ }));
1161
+ // 岗位 Tab 标签:深拷贝并初始化选中状态(与组织 Tab 完全独立)
1162
+ this.postTagList = this.safeDeepCopy(baseTagList).map(item => ({
1163
+ ...item,
1164
+ checked: false // 独立选中状态
1165
+ }));
1166
+ }
1167
+ });
1168
+ },
1169
+
1170
+ querySpecificParam: function (item, isOrgTab, treeRef, proListKey, treeDataKey) {
1171
+ return new Promise((resolve, reject) => {
1172
+ // 取消选中时处理(仅当手动点击已选中的标签时触发)
1173
+ if (!item.checked) {
1174
+ if (treeRef && treeRef.initData) {
1175
+ treeRef.initData(); // 清空对应树组件
1176
+ }
1177
+ this[proListKey] = []; // 清空对应暂存列表
1178
+ this.$Message.info("已取消该快捷选择");
1179
+ resolve();
1180
+ return;
1181
+ }
1182
+
1183
+ // 请求快捷选择对应的orgUnitId列表
1184
+ ajax.get(`/pub-manage-server/pub/helpBoxTag/q/querySpecificParam?quickPickKey=${item.quickPickKey}`)
1185
+ .then(async (res) => {
1186
+ if (res.data.code !== 1) {
1187
+ this.$Message.error("获取快捷选择配置失败");
1188
+ item.checked = !item.checked;
1189
+ reject(new Error("获取配置失败"));
1190
+ return;
1191
+ }
1192
+
1193
+ const orgUnitIds = res.data.data?.param || [];
1194
+ const safeOrgUnitIds = Array.isArray(orgUnitIds) ? orgUnitIds : [];
1195
+ if (safeOrgUnitIds.length === 0) {
1196
+ this.$Message.warning("该快捷选择未配置任何组织节点");
1197
+ item.checked = !item.checked;
1198
+ reject(new Error("无配置节点"));
1199
+ return;
1200
+ }
1201
+
1202
+ // 校验树组件是否存在(通用校验)
1203
+ if (!treeRef) {
1204
+ this.$Message.error("树组件未初始化");
1205
+ item.checked = !item.checked;
1206
+ reject(new Error("树组件不存在"));
1207
+ return;
1208
+ }
1209
+ const originalTreeData = treeRef.data && treeRef.data.length ? this.safeDeepCopy(treeRef.data) : [];
1210
+ const matchedNodes = [];
1211
+
1212
+ // 批量处理每个orgUnitId(循环逻辑不变,通用处理)
1213
+ for (const orgUnitId of safeOrgUnitIds) {
1214
+ try {
1215
+ // 节点详情查询(复用原有方法)
1216
+ let currentNode = await this.queryOrgNodeDetail(orgUnitId);
1217
+ if (!currentNode || !currentNode.orgUnitId) {
1218
+ this.$Message.warning(`节点【${orgUnitId}】数据异常,跳过处理`);
1219
+ continue;
1220
+ }
1221
+
1222
+ // 循环引用检测与处理(复用原有方法)
1223
+ const cycle = this.detectCircularReferences(currentNode);
1224
+ if (cycle) {
1225
+ this.$Message.warning(`节点【${orgUnitId}】存在循环引用,已自动修复`);
1226
+ currentNode = this.safeDeepCopy(currentNode);
1227
+ }
1228
+
1229
+ // 节点名称默认值处理(复用原有逻辑)
1230
+ currentNode.orgNodeName = currentNode.orgNodeName || currentNode.orgUnitName || `未命名组织(${orgUnitId})`;
1231
+ currentNode.orgUnitName = currentNode.orgNodeName;
1232
+
1233
+ // 节点是否已在树中检测(复用原有方法)
1234
+ const nodeInTree = this.findNodeInTree(originalTreeData, orgUnitId);
1235
+ if (nodeInTree) {
1236
+ if (this.detectCircularReferences(nodeInTree)) {
1237
+ this.$Message.warning(`树中节点【${orgUnitId}】存在循环引用,已跳过`);
1238
+ continue;
1239
+ }
1240
+ matchedNodes.push(nodeInTree);
1241
+ continue;
1242
+ }
1243
+
1244
+ // 父节点追溯与节点链挂载(修复:使用当前Tab的树数据originalTreeData,而非固定orgTree)
1245
+ let targetParent = null;
1246
+ let nodeChain = [currentNode];
1247
+ const MAX_DEPTH = 8;
1248
+ let depth = 0;
1249
+ let lastParentId = '';
1250
+
1251
+ while (!targetParent && depth < MAX_DEPTH) {
1252
+ const parentId = currentNode.parentOrgUnitId;
1253
+ if (!parentId || typeof parentId !== 'string' || parentId === lastParentId) {
1254
+ break;
1255
+ }
1256
+ lastParentId = parentId;
1257
+
1258
+ const parentNode = await this.queryOrgNodeDetail(parentId);
1259
+ if (!parentNode || !parentNode.orgUnitId) {
1260
+ break;
1261
+ }
1262
+
1263
+ if (this.detectCircularReferences(parentNode)) {
1264
+ this.$Message.warning(`父节点【${parentId}】存在循环引用,已跳过`);
1265
+ break;
1266
+ }
1267
+
1268
+ parentNode.orgNodeName = parentNode.orgNodeName || parentNode.orgUnitName || `未命名组织(${parentId})`;
1269
+ // 修复:查询父节点是否在当前Tab的树数据中(originalTreeData),而非固定orgTree
1270
+ const parentInTree = this.findNodeInTree(originalTreeData, parentNode.orgUnitId);
1271
+
1272
+ if (parentInTree) {
1273
+ targetParent = parentInTree;
1274
+ break;
1275
+ }
1276
+
1277
+ nodeChain.unshift(parentNode);
1278
+ currentNode = parentNode;
1279
+ depth++;
1280
+ }
1281
+
1282
+ // 节点链挂载(复用原有方法)
1283
+ if (targetParent) {
1284
+ let currentMountParent = targetParent;
1285
+ for (const node of nodeChain) {
1286
+ const formattedNode = this.safeDeepCopy({
1287
+ ...node,
1288
+ leafNode: await this.judgeNodeLeafe(node.orgUnitId),
1289
+ expand: true,
1290
+ checked: false,
1291
+ orgChildrenList: [],
1292
+ children: []
1293
+ });
1294
+
1295
+ if (!Array.isArray(currentMountParent.orgChildrenList)) {
1296
+ currentMountParent.orgChildrenList = [];
1297
+ currentMountParent.children = [];
1298
+ }
1299
+
1300
+ const isDuplicate = currentMountParent.orgChildrenList.some(
1301
+ child => child.orgUnitId === formattedNode.orgUnitId
1302
+ );
1303
+ if (!isDuplicate) {
1304
+ currentMountParent.orgChildrenList.push(formattedNode);
1305
+ currentMountParent.leafNode = false;
1306
+ }
1307
+
1308
+ currentMountParent = currentMountParent.orgChildrenList.find(
1309
+ child => child.orgUnitId === formattedNode.orgUnitId
1310
+ ) || formattedNode;
1311
+ }
1312
+
1313
+ const mountedTarget = this.findNodeInTree(originalTreeData, orgUnitId);
1314
+ if (mountedTarget) {
1315
+ matchedNodes.push(mountedTarget);
1316
+ }
1317
+ }
1318
+
1319
+ } catch (error) {
1320
+ this.$Message.error(`处理节点【${orgUnitId}】失败:${error.message.slice(0, 50)}`);
1321
+ continue;
1322
+ }
1323
+ }
1324
+
1325
+ // 最终数据赋值(根据Tab类型区分,核心统一逻辑)
1326
+
1327
+ if (matchedNodes.length > 0) {
1328
+ // 同步暂存列表(组织proOrgList/岗位proPostList)
1329
+ this[proListKey] = matchedNodes;
1330
+ const finalTreeData = this.safeDeepCopy(originalTreeData);
1331
+ // 响应式更新对应树数据(组织orgTree/岗位postTree)
1332
+ this.$set(this, treeDataKey, finalTreeData);
1333
+
1334
+ await this.$nextTick(async () => {
1335
+ // 更新树组件数据(通用逻辑)
1336
+ if (treeRef.updateTreeData) {
1337
+ treeRef.updateTreeData(this.safeDeepCopy(finalTreeData));
1338
+ } else {
1339
+ treeRef.data = this.safeDeepCopy(finalTreeData);
1340
+ }
1341
+
1342
+ // 设置树选中状态(通用逻辑)
1343
+ const safeNodeIds = matchedNodes.map(node => node.orgUnitId);
1344
+ if (treeRef.setCheckedNodes) {
1345
+ treeRef.setCheckedNodes([]);
1346
+ treeRef.setCheckedNodes(safeNodeIds);
1347
+ treeRef.handleChange(matchedNodes); // 触发子组件选中事件
1348
+ } else {
1349
+ this.updateTreeNodesStatus(
1350
+ finalTreeData,
1351
+ new Set(safeNodeIds),
1352
+ new Set(safeNodeIds)
1353
+ );
1354
+ treeRef.handleChange(matchedNodes);
1355
+ }
1356
+
1357
+ // 提示信息(通用逻辑)
1358
+ this.$Message.success(`成功选中${matchedNodes.length}个组织节点`);
1359
+ });
1360
+ } else {
1361
+ this.$Message.warning("未找到任何可匹配的组织节点");
1362
+ item.checked = !item.checked;
1363
+ }
1364
+ resolve();
1365
+ })
1366
+ .catch((error) => {
1367
+ const errMsg = error.message || '网络异常';
1368
+ this.$Message.error(`快捷选择失败:${errMsg.slice(0, 50)}`);
1369
+ item.checked = !item.checked;
1370
+ reject(error);
1371
+ });
1372
+ });
1373
+ },
1374
+
1375
+ // 新增:移除树数据中的 parent 引用,避免子组件处理时形成循环
1376
+ removeParentReferences(treeData) {
1377
+ if (!Array.isArray(treeData)) return;
1378
+ treeData.forEach(node => {
1379
+ // 删除可能存在的 parent 引用(如果节点有此属性)
1380
+ if (node.parent) delete node.parent;
1381
+ // 递归处理子节点
1382
+ if (Array.isArray(node.orgChildrenList)) {
1383
+ this.removeParentReferences(node.orgChildrenList);
1384
+ }
1385
+ if (Array.isArray(node.children)) {
1386
+ this.removeParentReferences(node.children);
1387
+ }
1388
+ });
1389
+ },
1390
+ // 在 methods 中添加循环引用检测工具函数
1391
+ detectCircularReferences(obj, path = [], visited = new Map()) {
1392
+ if (obj === null || typeof obj !== 'object') return null;
1393
+
1394
+ if (visited.has(obj)) {
1395
+ return { path: [...path, visited.get(obj)], node: obj };
1396
+ }
1397
+
1398
+ visited.set(obj, Array.isArray(obj) ? 'Array' : `Object(${obj.orgUnitId || 'unknown'})`);
1399
+
1400
+ const keys = Array.isArray(obj) ? obj.map((_, i) => i) : Object.keys(obj);
1401
+ for (const key of keys) {
1402
+ const value = obj[key];
1403
+ const newPath = [...path, key];
1404
+ if (value && typeof value === 'object') {
1405
+ const cycle = this.detectCircularReferences(value, newPath, visited);
1406
+ if (cycle) return cycle;
1407
+ }
1408
+ }
1409
+
1410
+ visited.delete(obj);
1411
+ return null;
1412
+ },
1413
+
1414
+ // 增强安全深拷贝,主动移除循环引用字段
1415
+ safeDeepCopy(obj, hash = new WeakMap()) {
1416
+ if (obj === null || typeof obj !== 'object') {
1417
+ return obj;
1418
+ }
1419
+
1420
+ // 检测到循环引用时,保留核心字段(orgUnitId必选,其他字段尽可能保留)
1421
+ if (hash.has(obj)) {
1422
+ const safeObj = {
1423
+ orgUnitId: obj.orgUnitId,
1424
+ orgNodeName: obj.orgNodeName || obj.name || `未命名组织(${obj.orgUnitId || 'unknown'})`,
1425
+ orgUnitName: obj.orgUnitName || obj.orgNodeName || obj.name || `未命名组织(${obj.orgUnitId || 'unknown'})`,
1426
+ parentOrgUnitId: obj.parentOrgUnitId || obj.parentId || null
1427
+ };
1428
+ hash.set(obj, safeObj);
1429
+ return safeObj;
1430
+ }
1431
+
1432
+ let copy;
1433
+ if (obj instanceof Array) {
1434
+ copy = [];
1435
+ hash.set(obj, copy);
1436
+ for (let i = 0; i < obj.length; i++) {
1437
+ copy[i] = this.safeDeepCopy(obj[i], hash);
1438
+ }
1439
+ } else if (obj instanceof Object) {
1440
+ copy = {};
1441
+ hash.set(obj, copy);
1442
+ for (let key in obj) {
1443
+ if (obj.hasOwnProperty(key)) {
1444
+ // 仅过滤vue内部字段,保留业务字段
1445
+ if (['__vue__', '__ob__', '$parent', '$children'].includes(key)) {
1446
+ continue;
1447
+ }
1448
+ // 子节点数组特殊处理
1449
+ if (['orgChildrenList', 'children'].includes(key) && Array.isArray(obj[key])) {
1450
+ copy[key] = obj[key].map(child => this.safeDeepCopy(child, hash));
1451
+ } else {
1452
+ // 保留所有业务字段,不额外过滤
1453
+ copy[key] = this.safeDeepCopy(obj[key], hash);
1454
+ }
1455
+ }
1456
+ }
1457
+ } else {
1458
+ copy = obj;
1459
+ }
1460
+ return copy;
1461
+ },
1462
+
1463
+ /**
1464
+ * 查询单个节点的原生详情(适配后端接口,返回原生字段)
1465
+ * @param {string} orgUnitId - 节点ID(如11510101)
1466
+ * @returns {Promise<Object|null>} 原生节点详情(无数据返回null)
1467
+ */
1468
+ getOrgNodeDetail(orgUnitId) {
1469
+ return new Promise((resolve) => {
1470
+ ajax.get(`/pub-manage-server/pub/organ/q/queryOrg`, {
1471
+ params: { orgUnitId: orgUnitId }
1472
+ }).then((res) => {
1473
+ if (res.data.code === 1 && res.data.data) {
1474
+ // 仅保留原生树结构必需字段(过滤业务冗余字段)
1475
+ const { orgUnitId, parentOrgUnitId, orgNodeName, orgChildrenList } = res.data.data;
1476
+ resolve({
1477
+ orgUnitId,
1478
+ parentOrgUnitId,
1479
+ orgNodeName,
1480
+ orgChildrenList: orgChildrenList || [] // 兼容接口返回空的情况
1481
+ });
1482
+ } else {
1483
+ resolve(null);
1484
+ }
1485
+ }).catch(() => {
1486
+ this.$Message.error(`查询节点【${orgUnitId}】详情失败`);
1487
+ resolve(null);
1488
+ });
1489
+ });
1490
+ },
1491
+
1492
+ /**
1493
+ * 迭代查找节点(替代递归,避免栈溢出)
1494
+ * @param {Array} treeData - 树形数据
1495
+ * @param {string} targetOrgUnitId - 目标节点ID
1496
+ * @returns {Object|null} 找到的节点
1497
+ */
1498
+ findNodeInTree(treeData, targetOrgUnitId) {
1499
+ if (!Array.isArray(treeData) || !targetOrgUnitId || typeof targetOrgUnitId !== 'string') {
1500
+ return null;
1501
+ }
1502
+
1503
+ const queue = [...treeData];
1504
+ while (queue.length > 0) {
1505
+ const currentNode = queue.shift();
1506
+ // 兼容子组件可能的字段映射(orgUnitId可能存储在id字段)
1507
+ const nodeId = currentNode.orgUnitId || currentNode.id || '';
1508
+ if (nodeId === targetOrgUnitId) {
1509
+ return currentNode;
1510
+ }
1511
+ // 兼容children和orgChildrenList两种子节点字段
1512
+ const childNodes = currentNode.orgChildrenList || currentNode.children || [];
1513
+ if (childNodes.length > 0) {
1514
+ queue.push(...childNodes);
1515
+ }
1516
+ }
1517
+ return null;
1518
+ },
1519
+
1520
+ /**
1521
+ * 辅助方法:查询单个orgUnitId的节点详情
1522
+ * @param {string} orgUnitId - 组织节点ID
1523
+ * @returns {Promise<Object|null>} 节点详情
1524
+ */
1525
+ queryOrgNodeDetail(orgUnitId) {
1526
+ return new Promise((resolve) => {
1527
+ // 前置校验:避免无效请求
1528
+ if (!orgUnitId || typeof orgUnitId !== 'string') {
1529
+ resolve(null);
1530
+ return;
1531
+ }
1532
+
1533
+ ajax.get(`/pub-manage-server/pub/organ/q/queryOrg?orgUnitId=${orgUnitId}`)
1534
+ .then((res) => {
1535
+ if (res.data.code === 1 && res.data.data && res.data.data.orgUnitId) {
1536
+ // 深拷贝并清理无效字段
1537
+ const node = this.safeDeepCopy(res.data.data);
1538
+ // 核心修复:确保节点名称有默认值,避免空显示
1539
+ const nodeName = node.orgNodeName || node.orgUnitName || node.name || `未命名组织(${orgUnitId})`;
1540
+ node.orgNodeName = nodeName;
1541
+ node.orgUnitName = nodeName; // 同步更新orgUnitName,确保所有使用场景都有值
1542
+ // 确保关键字段存在
1543
+ node.parentOrgUnitId = node.parentOrgUnitId || null;
1544
+ node.orgChildrenList = node.orgChildrenList || [];
1545
+ resolve(node);
1546
+ } else {
1547
+ // 接口返回空时,返回默认结构避免报错
1548
+ resolve({
1549
+ orgUnitId,
1550
+ orgNodeName: `未命名组织(${orgUnitId})`,
1551
+ orgUnitName: `未命名组织(${orgUnitId})`,
1552
+ parentOrgUnitId: null,
1553
+ orgChildrenList: []
1554
+ });
1555
+ }
1556
+ })
1557
+ .catch(() => {
1558
+ // 请求失败时,返回默认结构避免报错
1559
+ resolve({
1560
+ orgUnitId,
1561
+ orgNodeName: `未命名组织(${orgUnitId})`,
1562
+ orgUnitName: `未命名组织(${orgUnitId})`,
1563
+ parentOrgUnitId: null,
1564
+ orgChildrenList: []
1565
+ });
1566
+ });
1567
+ });
1568
+ },
1569
+
1570
+
1571
+ /**
1572
+ * 手动更新树节点状态(如果树组件没有提供update方法)
1573
+ * @param {Array} nodeList - 节点列表
1574
+ * @param {Set} expandIds - 需要展开的节点ID集合
1575
+ * @param {Set} checkedIds - 需要选中的节点ID集合
1576
+ */
1577
+ updateTreeNodesStatus(nodeList, expandIds, checkedIds) {
1578
+ nodeList.forEach(node => {
1579
+ // 更新展开状态
1580
+ if (expandIds.has(node.orgUnitId)) {
1581
+ node.expand = true;
1582
+ }
1583
+
1584
+ // 更新选中状态
1585
+ if (checkedIds.has(node.orgUnitId)) {
1586
+ node.checked = true;
1587
+ }
1588
+
1589
+ // 递归处理子节点
1590
+ const children = node.children || node.orgChildrenList;
1591
+ if (children && children.length > 0) {
1592
+ this.updateTreeNodesStatus(children, expandIds, checkedIds);
1593
+ }
1594
+ });
1595
+ }
1596
+
306
1597
  },
307
1598
  computed:{
308
- getCheckedStaff(){
309
- return this.staffAllList.filter((item)=>item.checked===true).length
310
- },
1599
+ // getCheckedStaff(){
1600
+ // return this.staffAllList.filter((item)=>item.checked===true).length
1601
+ // },
311
1602
  getCheckTypenum(){
312
1603
  let l1 = this.orgList.length?1:0;
313
1604
  let l2 = this.postList.length?1:0;
@@ -321,6 +1612,7 @@ export default {
321
1612
  },
322
1613
  data:{
323
1614
  handler(val){
1615
+ if(!val) return
324
1616
  let map = deepCopy(val)
325
1617
  let orgList = map.orgList || []
326
1618
  orgList.forEach(item=>{
@@ -343,6 +1635,380 @@ export default {
343
1635
  }
344
1636
  </script>
345
1637
  <style lang="less" scoped>
1638
+ // 新增checkbox样式
1639
+ //.staff-checkbox {
1640
+ // margin-right: 12px;
1641
+ // flex-shrink: 0;
1642
+ //
1643
+ // /deep/ .ivu-checkbox-wrapper {
1644
+ // display: flex;
1645
+ // align-items: center;
1646
+ // cursor: pointer;
1647
+ // }
1648
+ //
1649
+ // /deep/ .ivu-checkbox {
1650
+ // width: 18px;
1651
+ // height: 18px;
1652
+ //
1653
+ // &:checked {
1654
+ // /deep/ .ivu-checkbox-inner {
1655
+ // background-color: var(--primary-color);
1656
+ // border-color: var(--primary-color);
1657
+ // }
1658
+ // }
1659
+ // }
1660
+ //}
1661
+
1662
+ .staff-left-right-layout {
1663
+ display: flex;
1664
+ height: 650px !important;
1665
+ gap: 15px;
1666
+ padding: 0 5px;
1667
+ width: 100%;
1668
+ box-sizing: border-box;
1669
+ flex-wrap: nowrap !important;
1670
+
1671
+ & > .staff-left-panel {
1672
+ width: 320px !important;
1673
+ min-width: 320px !important;
1674
+ max-width: 320px !important;
1675
+ display: flex !important;
1676
+ flex-direction: column !important;
1677
+ box-sizing: border-box !important;
1678
+ flex-shrink: 0 !important;
1679
+ flex-grow: 0 !important;
1680
+ height: 100% !important;
1681
+ position: relative !important; // 确保子元素 z-index 生效
1682
+
1683
+ ::v-deep(.panel-title) {
1684
+ all: unset !important;
1685
+ display: flex !important; // 改为flex,方便对齐竖条和文字
1686
+ align-items: center !important; // 文字垂直居中
1687
+ visibility: visible !important;
1688
+ opacity: 1 !important;
1689
+ height: 20px !important;
1690
+ line-height: 20px !important;
1691
+ font-size: 14px !important;
1692
+ font-weight: 500 !important;
1693
+ color: #333 !important;
1694
+ margin-bottom: 8px !important;
1695
+ background: #fff !important;
1696
+ z-index: 999 !important;
1697
+ padding: 0 !important;
1698
+ box-sizing: border-box !important;
1699
+ position: relative !important;
1700
+ width: 100% !important;
1701
+ // 左侧竖条核心样式
1702
+ &::before {
1703
+ content: '' !important;
1704
+ display: inline-block !important;
1705
+ width: 5px !important; // 竖条宽度
1706
+ height: 16px !important; // 竖条高度(略小于文字行高)
1707
+ background-color: #1890ff !important; // 蓝色竖条(可改颜色)
1708
+ margin-right: 8px !important; // 竖条与文字间距
1709
+ //border-radius: 1.5px !important;
1710
+ }
1711
+ }
1712
+
1713
+ .staff-org-tree {
1714
+ height: calc(100% - 28px) !important; /* 28 = 标题高度20 + 间距8 */
1715
+ border: 1px solid #EAECF0;
1716
+ border-radius: 4px;
1717
+ padding: 0 !important;
1718
+ box-sizing: border-box;
1719
+ width: 100% !important;
1720
+ overflow-x: auto !important;
1721
+ overflow-y: auto !important;
1722
+ position: relative;
1723
+ flex-shrink: 1;
1724
+ min-height: 0 !important;
1725
+
1726
+ &::-webkit-scrollbar {
1727
+ width: 8px !important;
1728
+ height: 8px !important;
1729
+ background: #f9f9f9 !important;
1730
+ }
1731
+ &::-webkit-scrollbar-thumb {
1732
+ background: #ccc !important;
1733
+ border-radius: 4px !important;
1734
+ }
1735
+ scrollbar-width: thin !important;
1736
+ scrollbar-color: #ccc #f9f9f9 !important;
1737
+ }
1738
+
1739
+ .tree-scroll-force {
1740
+ width: 100% !important;
1741
+ height: 100% !important;
1742
+ margin: 0 !important;
1743
+ padding: 8px !important;
1744
+ box-sizing: border-box;
1745
+ overflow: visible !important;
1746
+ position: relative;
1747
+ }
1748
+ }
1749
+
1750
+ .staff-right-panel {
1751
+ flex: 1 !important;
1752
+ min-width: 0 !important;
1753
+ width: calc(100% - 335px) !important;
1754
+ display: flex;
1755
+ flex-direction: column;
1756
+ box-sizing: border-box;
1757
+ gap: 8px; /* 搜索框与列表、列表与底部选择栏的间距统一为8px */
1758
+ padding: 0 5px;
1759
+ flex-shrink: 1 !important;
1760
+
1761
+ // 搜索框:固定高度
1762
+ .ivu-input-wrapper {
1763
+ height: 32px;
1764
+ flex-shrink: 0;
1765
+ }
1766
+
1767
+ // 右侧人员列表容器:高度 = 父容器高度 - 搜索框高度 - 底部选择栏高度 - 两次间距(8*2)
1768
+ .staff-content {
1769
+ height: calc(100% - 32px - 40px - 16px) !important; /* 40=底部选择栏高度,16=8*2间距 */
1770
+ border: 1px solid #EAECF0;
1771
+ border-radius: 4px;
1772
+ overflow-x: hidden !important;
1773
+ overflow-y: auto !important;
1774
+ flex-shrink: 1;
1775
+
1776
+ &::-webkit-scrollbar {
1777
+ width: 8px !important;
1778
+ height: 8px !important;
1779
+ background: #f9f9f9 !important;
1780
+ }
1781
+ &::-webkit-scrollbar-thumb {
1782
+ background: #ccc !important;
1783
+ border-radius: 4px !important;
1784
+ }
1785
+ scrollbar-width: thin !important;
1786
+ scrollbar-color: #ccc #f9f9f9 !important;
1787
+ }
1788
+
1789
+ // 底部选择栏:固定高度
1790
+ .bottom-select {
1791
+ height: 40px;
1792
+ flex-shrink: 0;
1793
+ display: flex;
1794
+ align-items: center;
1795
+ justify-content: space-between;
1796
+ padding: 8px 0;
1797
+ background: #fff !important;
1798
+ border-top: 1px solid #f0f0f0;
1799
+
1800
+ //.num {
1801
+ // color: var(--primary-color);
1802
+ //}
1803
+ }
1804
+ }
1805
+ }
1806
+
1807
+ .tab-content-pro {
1808
+ .tab {
1809
+ .tree {
1810
+ height: 500px !important;
1811
+ max-height: 500px !important;
1812
+ margin-top:20px;
1813
+ overflow-y: auto !important;
1814
+ overflow-x: auto !important;
1815
+ border: 1px solid #EAECF0;
1816
+ border-radius: 4px;
1817
+ box-sizing: border-box;
1818
+
1819
+ &::-webkit-scrollbar {
1820
+ width: 8px !important;
1821
+ height: 8px !important;
1822
+ display: block !important;
1823
+ background: #f9f9f9 !important;
1824
+ }
1825
+ &::-webkit-scrollbar-thumb {
1826
+ background: #ccc !important;
1827
+ border-radius: 4px !important;
1828
+ }
1829
+ }
1830
+
1831
+ &.post .right .tree {
1832
+ height: 380px !important;
1833
+ max-height: 380px !important;
1834
+ }
1835
+
1836
+ .bottom-select {
1837
+ display:flex;
1838
+ align-items: center;
1839
+ justify-content: space-between;
1840
+ margin-top:15px !important;
1841
+ padding: 8px 0;
1842
+ background: #fff !important;
1843
+ position: relative;
1844
+ z-index: 10;
1845
+ border-top: 1px solid #f0f0f0;
1846
+ .num{
1847
+ color:var(--primary-color);
1848
+ }
1849
+ }
1850
+ }
1851
+ }
1852
+
1853
+
1854
+ /deep/ .ivu-tree {
1855
+ width: 100% !important;
1856
+ box-sizing: border-box;
1857
+ }
1858
+
1859
+ /deep/ .ivu-tree-node-content {
1860
+ width: 100% !important;
1861
+ box-sizing: border-box;
1862
+ }
1863
+
1864
+ .gust-item {
1865
+ display: flex;
1866
+ align-items: center;
1867
+ width: 100% !important;
1868
+ padding: 12px 12px;
1869
+ margin-top: 8px;
1870
+ cursor: pointer;
1871
+ box-sizing: border-box;
1872
+ border: none !important;
1873
+ &:hover {
1874
+ background-color: #f2f8ff;
1875
+ border-radius: 4px;
1876
+ }
1877
+ }
1878
+
1879
+ // 滚动条样式
1880
+ .staff-content::-webkit-scrollbar {
1881
+ width: 8px !important;
1882
+ height: 8px;
1883
+ display: block !important;
1884
+ }
1885
+
1886
+ .staff-content::-webkit-scrollbar-thumb {
1887
+ background-color: #ccc !important;
1888
+ border-radius: 4px !important;
1889
+ }
1890
+
1891
+ .staff-content::-webkit-scrollbar-track {
1892
+ background-color: #f9f9f9 !important;
1893
+ }
1894
+
1895
+ .tab.post .left {
1896
+ width: 200px;
1897
+ height: 450px !important;
1898
+ overflow: hidden !important;
1899
+ padding-right: 10px;
1900
+ box-sizing: border-box;
1901
+ }
1902
+
1903
+ .scroll-container {
1904
+ height: 100% !important;
1905
+ overflow-y: auto !important;
1906
+ overflow-x: hidden !important;
1907
+ padding: 8px 0;
1908
+ margin: 0;
1909
+ box-sizing: border-box;
1910
+ }
1911
+
1912
+ .scroll-container::-webkit-scrollbar {
1913
+ width: 8px !important;
1914
+ height: 8px;
1915
+ display: block !important;
1916
+ }
1917
+
1918
+ .scroll-container::-webkit-scrollbar-thumb {
1919
+ background-color: #ccc !important;
1920
+ border-radius: 4px !important;
1921
+ transition: background-color 0.2s;
1922
+ }
1923
+
1924
+ .scroll-container::-webkit-scrollbar-thumb:hover {
1925
+ background-color: #999 !important;
1926
+ }
1927
+
1928
+ .scroll-container::-webkit-scrollbar-track {
1929
+ background-color: #f9f9f9 !important;
1930
+ border-radius: 4px !important;
1931
+ }
1932
+
1933
+ .position-item {
1934
+ border: 1px solid #ddd;
1935
+ margin: 5px 0;
1936
+ padding: 8px 10px;
1937
+ border-radius: 2px;
1938
+ cursor: pointer;
1939
+ transition: background-color 0.2s;
1940
+ white-space: normal !important;
1941
+ overflow: visible !important;
1942
+ text-overflow: clip !important;
1943
+ line-height: 1.4;
1944
+ min-height: 40px;
1945
+ word-wrap: break-word;
1946
+ }
1947
+
1948
+ .position-item.active {
1949
+ border-color: #1890ff;
1950
+ background-color: #e6f7ff;
1951
+ }
1952
+
1953
+ .position-item:hover:not(.active) {
1954
+ background-color: #f5f5f5;
1955
+ }
1956
+
1957
+ .custom-select-wrapper {
1958
+ position: relative;
1959
+
1960
+ /deep/ .ivu-select-clear {
1961
+ right: 32px;
1962
+ color: #999;
1963
+ font-size: 16px;
1964
+ opacity: 1 !important;
1965
+ transition: all 0.2s ease;
1966
+
1967
+ &:hover {
1968
+ color: #ff4d4f;
1969
+ transform: scale(1.1);
1970
+ }
1971
+ }
1972
+
1973
+ /deep/ .ivu-select-arrow {
1974
+ right: 12px;
1975
+ }
1976
+
1977
+ /deep/ .ivu-select-input {
1978
+ padding-right: 45px !important;
1979
+ }
1980
+
1981
+ /deep/ .active-option {
1982
+ background-color: #f2f8ff;
1983
+ color: var(--primary-color);
1984
+ }
1985
+
1986
+ /deep/ .ivu-select-option-disabled {
1987
+ color: #ccc !important;
1988
+ background: #f5f5f5 !important;
1989
+ }
1990
+ }
1991
+
1992
+ .tag-select-container {
1993
+ margin-left: 10px;
1994
+
1995
+ /deep/ .ivu-select-dropdown {
1996
+ max-height: 200px;
1997
+ overflow-y: auto;
1998
+ }
1999
+
2000
+ /deep/ .active-option {
2001
+ background-color: #f2f8ff;
2002
+ color: var(--primary-color);
2003
+ }
2004
+
2005
+ /deep/ .ivu-select-selected-value {
2006
+ max-width: 150px;
2007
+ overflow: hidden;
2008
+ text-overflow: ellipsis;
2009
+ }
2010
+ }
2011
+
346
2012
  .modal-tree{
347
2013
  .header-text{
348
2014
  font-weight: bold;
@@ -352,7 +2018,7 @@ export default {
352
2018
  .icon-tip{
353
2019
  width: 16px;
354
2020
  height: 16px;
355
- background: #145DFF;
2021
+ background: var(--primary-color);
356
2022
  border-radius: 50%;
357
2023
  color: #fff;
358
2024
  line-height: 16px;
@@ -364,19 +2030,48 @@ export default {
364
2030
  display: flex;
365
2031
  height: 700px;
366
2032
  background: #fff;
2033
+
2034
+ :global(.ivu-tabs-ink-bar) {
2035
+ height: 0 !important;
2036
+ display: none !important;
2037
+ width: 0 !important;
2038
+ background: transparent !important;
2039
+ visibility: hidden !important;
2040
+ }
2041
+
367
2042
  /deep/.ivu-tabs-nav{
368
2043
  font-weight: bold;
369
2044
  font-size: 16px;
370
- }
371
- /deep/.ivu-tabs-nav{
372
2045
  width: 100%;
373
2046
  display: flex;
2047
+ margin: 0 !important;
2048
+ padding: 0 !important;
374
2049
  }
375
2050
  /deep/.ivu-tabs-nav .ivu-tabs-tab{
376
2051
  flex:1;
377
2052
  text-align: center;
2053
+ background: #F0F2F5 !important;
2054
+ margin: 0 !important;
2055
+ padding: 12px 0 !important;
2056
+ border: none !important;
2057
+ line-height: 1 !important;
2058
+ border-right: 2px solid #E5E6EB !important; // 页签右侧竖线
2059
+ line-height: 1 !important;
2060
+ // 最后一个页签去掉右侧竖线
2061
+ &:last-child {
2062
+ border-right: none !important;
2063
+ }
2064
+ }
2065
+ /deep/.ivu-tabs-nav .ivu-tabs-tab-active {
2066
+ background: #1890FF !important;
2067
+ color: #fff !important;
2068
+ margin: 0 !important;
2069
+ border-right: 1px solid #E5E6EB !important;
2070
+ &:last-child {
2071
+ border-right: none !important;
2072
+ }
378
2073
  }
379
- .tab-content{
2074
+ .tab-content-pro{
380
2075
  width: 720px;
381
2076
  border-radius: 8px;
382
2077
  border: 1px solid #EAECF0;
@@ -388,9 +2083,30 @@ export default {
388
2083
  display:flex;
389
2084
  align-items: center;
390
2085
  }
391
- .tree{
392
- height:450px;
2086
+ .tree {
2087
+ height: 500px !important; // 从450px下调,预留下方复选框空间
2088
+ max-height: 500px !important; // 强制最大高度,禁止超出
393
2089
  margin-top:20px;
2090
+ overflow-y: auto !important; // 纵向溢出时滚动,而非超出
2091
+ overflow-x: auto !important; // 横向溢出时滚动
2092
+ border: 1px solid #EAECF0; // 明确容器边界(可选)
2093
+ border-radius: 4px;
2094
+ box-sizing: border-box; // 包含边框/内边距计算
2095
+ // 滚动条样式统一(与人员Tab保持一致)
2096
+ &::-webkit-scrollbar {
2097
+ width: 8px !important;
2098
+ height: 8px !important;
2099
+ display: block !important;
2100
+ background: #f9f9f9 !important;
2101
+ }
2102
+ &::-webkit-scrollbar-thumb {
2103
+ background: #ccc !important;
2104
+ border-radius: 4px !important;
2105
+ }
2106
+ }
2107
+ &.post .right .tree {
2108
+ height: 380px !important;
2109
+ max-height: 380px !important;
394
2110
  }
395
2111
  .staff-content{
396
2112
  overflow:auto;
@@ -399,7 +2115,12 @@ export default {
399
2115
  display:flex;
400
2116
  align-items: center;
401
2117
  justify-content: space-between;
402
- margin-top:20px;
2118
+ margin-top:15px !important; // 增加间距
2119
+ padding: 8px 0; // 内边距提升可读性
2120
+ background: #fff !important; // 白色背景覆盖树溢出内容
2121
+ position: relative;
2122
+ z-index: 10; // 层级高于树容器
2123
+ border-top: 1px solid #f0f0f0; // 视觉分隔(可选)
403
2124
  .num{
404
2125
  color:var(--primary-color);
405
2126
  }
@@ -419,12 +2140,26 @@ export default {
419
2140
  border: 1px solid #EAECF0;
420
2141
  margin-left:10px;
421
2142
  font-weight: bold;
2143
+ cursor: pointer;
422
2144
  &.active{
423
- background: #145DFF;
2145
+ background: var(--primary-color);
424
2146
  border-radius: 4px;
425
2147
  color: #fff;
426
2148
  }
427
2149
  }
2150
+ .pop-content{
2151
+ display: flex;
2152
+ flex-wrap: wrap;
2153
+ width:500px;
2154
+ .tag{
2155
+ margin-top: 10px;
2156
+ &.active{
2157
+ background: var(--primary-color);
2158
+ border-radius: 4px;
2159
+ color: #fff;
2160
+ }
2161
+ }
2162
+ }
428
2163
  .post{
429
2164
  display: flex;
430
2165
  height: 100%;
@@ -460,7 +2195,7 @@ export default {
460
2195
  padding: 15px 10px;
461
2196
  margin-top:10px;
462
2197
  cursor: pointer;
463
- .left-panel{
2198
+ .left-panel-pro{
464
2199
  background:url("./assets/name-bg.png") no-repeat;
465
2200
  width:30px;
466
2201
  height:30px;
@@ -471,7 +2206,7 @@ export default {
471
2206
  line-height:30px;
472
2207
  text-align:center;
473
2208
  }
474
- .right-panel{
2209
+ .right-panel-pro{
475
2210
  margin-left:10px;
476
2211
  flex:1;
477
2212
  >p:first-child{
@@ -483,16 +2218,21 @@ export default {
483
2218
  }
484
2219
  .checked-icon{
485
2220
  margin-left:auto;
486
- color:#145DFF;
2221
+ color:var(--primary-color);
487
2222
  font-size:18px;
488
2223
  }
489
2224
  }
490
- .staff-active{
491
- background:#E9F4FF;
492
- >p:first-child{
493
- color: var(--primary-color);
494
- }
495
- }
2225
+ //.staff-active {
2226
+ // background: transparent !important; // 彻底移除背景色
2227
+ // border: none !important; // 彻底移除边框高亮
2228
+ // border-radius: 0 !important; // 移除圆角
2229
+ //
2230
+ // > .right-panel > p:first-child {
2231
+ // color: inherit !important; // 可选:也移除文字颜色变化,仅保留Checkbox选中
2232
+ // // 如果需要保留文字变色,删除上面这行,保留下面注释的行
2233
+ // // color: var(--primary-color);
2234
+ // }
2235
+ //}
496
2236
  }
497
2237
  .form-content{
498
2238
  flex:1;
@@ -559,7 +2299,5 @@ export default {
559
2299
  justify-content: space-between;
560
2300
  }
561
2301
  }
562
- /deep/.ivu-modal-body-no-scrollbar-width :not([class^="ivu-table"])::-webkit-scrollbar{
563
- }
564
2302
  }
565
2303
  </style>