@sy-common/organize-select-help 1.0.0-beta.10

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/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import organizeTreeHelp from './src/index.vue'
2
+ export default organizeTreeHelp
3
+ export { organizeTreeHelp }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@sy-common/organize-select-help",
3
+ "version": "1.0.0-beta.10",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "author": "lambo",
7
+ "license": "ISC",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "registry": "https://registry.npmjs.org/"
11
+ },
12
+ "devDependencies": {
13
+ "@lambo-design/core": "^4.7.1-beta.140",
14
+ "@sy-common/core": "^1.0.0-beta.35"
15
+ },
16
+ "scripts": {
17
+ "release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
18
+ "release-major": "standard-version --release-as major",
19
+ "release-minor": "standard-version --release-as minor",
20
+ "release-patch": "standard-version --release-as patch",
21
+ "release-beta": "standard-version --prerelease beta",
22
+ "re-publish": "pnpm publish --access public --no-git-checks"
23
+ }
24
+ }
package/readme.md ADDED
@@ -0,0 +1,26 @@
1
+ data:{
2
+ //组织节点
3
+ orgList:{
4
+ includeLevel:true/false,//是否包含下级组织节点
5
+ orgUnitId:id, //组织id
6
+ orgNodeName:''//组织名称
7
+ },
8
+ //岗位节点
9
+ postList:{
10
+ includeLevel:true/false,//是否包含下级组织节点
11
+ orgUnitId:id, //组织id
12
+ orgNodeName:''//组织名称
13
+ positionId:''//岗位
14
+ positionName:''//岗位名称
15
+ },
16
+ 人员节点
17
+ staffList:{
18
+ name:'名称’//名称
19
+ orgNodeName:‘’//
20
+ id:''//id
21
+ }
22
+
23
+ }
24
+
25
+
26
+ v-model双向绑定是否显示帮助框
Binary file
Binary file
Binary file
package/src/index.vue ADDED
@@ -0,0 +1,797 @@
1
+ <template>
2
+ <Modal
3
+ title=""
4
+ v-model="modal"
5
+ @on-ok="confirm"
6
+ @on-visible-change="visibleChange "
7
+ width="1180"
8
+ :mask-closable="false"
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="tabName">
16
+ <TabPane label="选择组织节点" name="org">
17
+ <div class="tab">
18
+ <Select v-model="orgSearch" filterable :remote-method="getOrgListBySearch" @on-change="getOrgOption" :loading="loadingOrg" placeholder="选择组织节点" clearable>
19
+ <Option v-for="(option, index) in orgSearchList" :value="option.orgUnitId" :key="index">{{option.name}}</Option>
20
+ </Select>
21
+ <div class="tag-content">
22
+ <span>快捷选择:</span>
23
+ <div class="tag-list">
24
+ <span :class="['tag', item.checked && 'active']" v-for="item in tagList" :key="item.key" @click="fastChedkOrg(item)">{{item.v}}</span>
25
+ </div>
26
+ <Poptip content="content" placement="right-end">
27
+ <div slot="content" class="pop-content">
28
+ <span :class="['tag', item.checked && 'active']" v-for="item in tagList" :key="item.key" @click="fastChedkOrg(item)">{{item.v}}</span>
29
+ </div>
30
+ <Icon type="ios-arrow-down" />
31
+ </Poptip>
32
+ </div>
33
+ <div class="tree">
34
+ <organizeTree @handleChange="getOrgList" ref="orgTree" :treeList="orgTree"></organizeTree>
35
+ </div>
36
+ <div class="bottom-select">
37
+ <CheckboxGroup v-model="includeLevelOrg">
38
+ <Checkbox label="01">
39
+ <span>包含下级组织节点</span>
40
+ </Checkbox>
41
+ </CheckboxGroup>
42
+ <Button type="primary" icon="md-add" @click="addOrgList">添加节点</Button>
43
+ </div>
44
+ </div>
45
+ </TabPane>
46
+ <TabPane label="选择岗位" name="post">
47
+ <div class="tab post">
48
+ <div class="left">
49
+ <div v-for="item in positiontList" :class="[item.checked&&'active']" :key="item.positionId" @click="getPosionId(item)">{{ item.positionName }}</div>
50
+ </div>
51
+ <div class="right">
52
+ <Select v-model="postSearch" filterable :remote-method="getPostListBySearch" @on-change="getPostOption" placeholder="选择组织节点" :loading="loadingPost" clearable>
53
+ <Option v-for="(option, index) in postSearchList" :value="option.orgUnitId" :key="index">{{option.name}}</Option>
54
+ </Select>
55
+ <div class="tag-content">
56
+ <span>快捷选择:</span>
57
+ <div class="tag-list">
58
+ <span class="tag" v-for="item in tagList" :key="item.key">{{item.v}}</span>
59
+ </div>
60
+ <Poptip title="Title" content="content">
61
+ <Icon type="ios-arrow-down" />
62
+ </Poptip>
63
+ </div>
64
+ <div class="tree">
65
+ <organizeTree @handleChange="getPostList" ref="postTree" :treeList="postTree"></organizeTree>
66
+ </div>
67
+ <div class="bottom-select">
68
+ <CheckboxGroup v-model="includeLevelPost">
69
+ <Checkbox label="01">
70
+ <span>包含下级组织节点</span>
71
+ </Checkbox>
72
+ </CheckboxGroup>
73
+ <Button type="primary" icon="md-add" @click="addPostList">添加节点</Button>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </TabPane>
78
+ <TabPane label="选择人员" name="staff">
79
+ <div class="tab">
80
+ <Input v-model="staffSearch" @on-enter="searchStaff" @on-search="searchStaff" search placeholder="搜索人员"/>
81
+ <div style="position:relative;">
82
+ <div class="tree staff-content" @scroll="handleScroll">
83
+ <div :class="['gust-item',item.checked && 'staff-active']" v-for="item in staffAllList" :key="item.id" @click="handlestaff(item)">
84
+ <div class="left-panel">{{item.name && item.name.slice(0,1) || ''}}</div>
85
+ <div class="right-panel">
86
+ <p>{{item.name}}</p>
87
+ <p>{{item.orgNodeName}}</p>
88
+ </div>
89
+ <div class="checked-icon" v-show="item.checked">✔</div>
90
+ </div>
91
+ <p v-if="staffEnding" style="color:#CCCCCC;text-align: center">---我也是有底线的---</p>
92
+ </div>
93
+ <Spin v-if="loadingStaff" size="large" fix />
94
+ </div>
95
+ <div class="bottom-select">
96
+ <div>当前已选择 <span class="num">{{getCheckedStaff}}</span>人</div>
97
+ <Button type="primary" icon="md-add" @click="addStaffList">添加人员</Button>
98
+ </div>
99
+ </div>
100
+ </TabPane>
101
+ </Tabs>
102
+ </div>
103
+ <div class="form-content">
104
+ <p>已选择条件 <span class="num">({{getCheckTypenum}})</span></p>
105
+ <div class="node-list">
106
+ <!-- 组织节点条件:-->
107
+ <div>
108
+ <div class="group-box flex-r-bt">
109
+ <div>组织节点条件:</div>
110
+ <div class="clear-btn" @click="clearGroup">清除全部</div>
111
+ </div>
112
+ <div class="group-list-content">
113
+ <p class="list-item flex-r-bt" v-for="(item,index) in orgList" :ket="index">
114
+ <span>{{ item.title }}</span>
115
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearOrgByIndex(index)">
116
+ </p>
117
+ <p style="color:#CCCCCC" class="list-item" v-if="!orgList.length">未选择组织节点</p>
118
+ </div>
119
+ </div>
120
+ <!-- 组织节点+岗位条件://-->
121
+ <div>
122
+ <div class="group-box flex-r-bt">
123
+ <div>岗位条件+组织节点:</div>
124
+ <div class="clear-btn" @click="clearPost">清除全部</div>
125
+ </div>
126
+ <div class="group-list-content">
127
+ <p class="list-item flex-r-bt" v-for="(item,index) in postList">
128
+ <span>{{item.positionName}}-{{item.title}}</span>
129
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearPostByIndex(index)">
130
+ </p>
131
+ <p style="color:#CCCCCC" class="list-item" v-if="!postList.length">未选择岗位条件+组织节点</p>
132
+ </div>
133
+ </div>
134
+ <!-- 直接选择人员:-->
135
+ <div>
136
+ <div class="group-box flex-r-bt">
137
+ <div>直接选择人员:</div>
138
+ <div class="clear-btn" @click="clearStaff">清除全部</div>
139
+ </div>
140
+ <div class="group-list-content">
141
+ <p class="list-item flex-r-bt" v-for="(item,index) in staffList" :key="item.id">
142
+ <span>{{item.name}}</span>
143
+ <img class="clear-icon" src="./assets/delete.png" alt="" @click="clearStaffByIndex(index)">
144
+ </p>
145
+ <p style="color:#CCCCCC" class="list-item" v-if="!staffList.length">未选择直接选择人员</p>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </div>
150
+ </div>
151
+ </div>
152
+ </Modal>
153
+ </template>
154
+ <script>
155
+ import { Icon } from '@lambo-design/core'
156
+ import organizeTree from './organize-tree.vue'
157
+ import { deepCopy } from '@lambo-design/core/src/utils/assist'
158
+ import ajax from '@lambo-design/shared/utils/ajax'
159
+ import { debounce } from '@sy-common/core/src/utils/assits'
160
+ export default {
161
+ components: { organizeTree },
162
+ props: {
163
+ value:{
164
+ type: Boolean,
165
+ default: false
166
+ },
167
+ data:{
168
+ type:Object,
169
+ default:{}
170
+ },
171
+ name:{
172
+ value:String,
173
+ default:"org"
174
+ }
175
+ },
176
+ data(){
177
+ return {
178
+ tabName:this.name,
179
+ modal:false,
180
+ dialogOpen:false,
181
+ orgSearch:'',
182
+ //组织--right-form
183
+ proOrgList:[],
184
+ includeLevelOrg:[],
185
+ orgList:[],
186
+ loadingOrg:false,
187
+ orgSearchList:[],
188
+ orgTree:[],
189
+ //岗位--form
190
+ postSearch:'',
191
+ proPostList:[],
192
+ postList:[],
193
+ loadingPost:false,
194
+ postSearchList:[],
195
+ includeLevelPost:[],
196
+ positiontList:[],
197
+ postTree:[],
198
+ //直接人员
199
+ staffSearch:'',
200
+ staffAllList:[],
201
+ staffList:[],
202
+ loadingStaff:false,
203
+ lastLoadingTime:0,
204
+ offset:0,
205
+ staffEnding:false,
206
+ tagList:[{
207
+ v:'所选市公司所有部门',
208
+ checked:false,
209
+ key:'07'
210
+ },{
211
+ v:'所有市公司',
212
+ checked:false,
213
+ key:'08'
214
+ },{
215
+ v:'所有市公司',
216
+ checked:false,
217
+ key:'9'
218
+ },{
219
+ v:'所有市公司',
220
+ checked:false,
221
+ key:'10'
222
+ },{
223
+ v:'所有市公司',
224
+ checked:false,
225
+ key:'11'
226
+ },{
227
+ v:'所有市公司',
228
+ checked:false,
229
+ key:'12'
230
+ }],
231
+ }
232
+ },
233
+ mounted() {
234
+ this.queryPositionList()
235
+ this.loadMore()
236
+ },
237
+ methods:{
238
+ queryPositionList(){
239
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/queryPositionList').then((res)=>{
240
+ if(res.data.code === 1){
241
+ let positiontList = res.data.data || []
242
+ positiontList.map((item)=>item.checked = false)
243
+ this.positiontList = positiontList
244
+ }
245
+ })
246
+ },
247
+ getOrgListBySearch(query){
248
+ if (query !== '') {
249
+ this.loadingOrg = true;
250
+ this.getOrgUnitBySearchTerm(query,(res)=>{
251
+ this.loadingOrg = false
252
+ if(res.data.code === 1){
253
+ let resp = res.data.data?.items??[]
254
+ this.orgSearchList = resp
255
+ }else{
256
+ this.orgSearchList = []
257
+ this.$Message.error("获取组织节点列表失败!")
258
+ }
259
+ })
260
+ }else{
261
+ this.orgSearchList = [];
262
+ }
263
+ },
264
+ getPostListBySearch(query){
265
+ if (query !== '') {
266
+ this.loadingPost = true;
267
+ this.getOrgUnitBySearchTerm(query,(res)=>{
268
+ this.loadingPost = false
269
+ if(res.data.code === 1){
270
+ let resp = res.data.data?.items??[]
271
+ this.postSearchList = resp
272
+ }else{
273
+ this.postSearchList = []
274
+ this.$Message.error("获取组织节点列表失败!")
275
+ }
276
+ })
277
+ }else{
278
+ this.$refs.postTree.initData()
279
+ this.postSearchList = [];
280
+ }
281
+ },
282
+ getOrgUnitBySearchTerm(query,callback){
283
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitBySearchTerm?searchTerm='+query).then((res)=>{callback(res)})
284
+ },
285
+ async getOrgOption(val){
286
+ if(!val) return this.$refs.orgTree.initData();
287
+ let item = this.orgSearchList.filter((item)=> {return item.orgUnitId === val}).shift();
288
+ const leafNode = await this.judgeNodeLeafe(item.orgUnitId);
289
+ const ftem = {...item,orgNodeName:item.name,parentOrgUnitId:item.parentId,leafNode:leafNode}
290
+ try{
291
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(val)
292
+ let tree = this.buildTree([...parentsList,ftem])
293
+ this.orgTree = tree
294
+ }catch(e){
295
+ this.$Message.error("获取组织节点列表失败!")
296
+ }
297
+ },
298
+ async getPostOption(val){
299
+ if(!val) return this.$refs.postTree.initData();
300
+ let item = this.postSearchList.filter((item)=> {return item.orgUnitId === val}).shift();
301
+ const leafNode = await this.judgeNodeLeafe(item.orgUnitId);
302
+ const ftem = {...item,orgNodeName:item.name,parentOrgUnitId:item.parentId,leafNode:leafNode}
303
+ try{
304
+ let parentsList = await this.getParentOrgNodesByOrgUnitId(val)
305
+ let tree = this.buildTree([...parentsList,ftem])
306
+ this.postTree = tree
307
+ }catch(e){
308
+ this.$Message.error("获取组织节点列表失败!")
309
+ }
310
+ },
311
+ getParentOrgNodesByOrgUnitId(val){
312
+ return new Promise((resolve,reject)=>{
313
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getParentOrgNodesByOrgUnitId?orgUnitId='+val).then((res)=>{
314
+ if(res.data.code === 1){
315
+ let parentsList = res.data?.data?.items??[]
316
+ resolve(parentsList)
317
+ }else{
318
+ reject(false)
319
+ }
320
+ })
321
+ })
322
+ },
323
+ judgeNodeLeafe(orgUnitId){
324
+ return new Promise((resolve,reject)=>{
325
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitList', { params:{
326
+ containsCurLevel:true,
327
+ orgUnitId:orgUnitId,
328
+ }
329
+ }).then((res)=>{
330
+ if(res.data.code === 1){
331
+ let treeList = res.data.data
332
+ if(treeList && treeList.length){
333
+ resolve(false)
334
+ }else{
335
+ resolve(true)
336
+ }
337
+ }else{
338
+ resolve(false)
339
+ }
340
+ })
341
+ })
342
+ },
343
+ buildTree(items) {
344
+ // 创建一个映射表,用于快速查找节点
345
+ const map = {};
346
+ const roots = [];
347
+
348
+ // 初始化所有节点,添加children属性
349
+ items.forEach(item => {
350
+ map[item.orgUnitId] = { ...item, orgChildrenList: [] };
351
+ });
352
+
353
+ // 构建树形结构
354
+ items.forEach(item => {
355
+ const node = map[item.orgUnitId];
356
+ if (item.parentOrgUnitId === null) {
357
+ // 根节点
358
+ roots.push(node);
359
+ } else {
360
+ // 子节点,找到父节点并添加到其children中
361
+ const parent = map[item.parentOrgUnitId];
362
+ if (parent) {
363
+ parent.orgChildrenList.push(node);
364
+ }
365
+ }
366
+ });
367
+ return roots;
368
+ },
369
+
370
+ searchStaff(){
371
+ this.staffEnding = false;
372
+ this.offset = 0
373
+ this.staffAllList = []
374
+ this.loadMore()
375
+ },
376
+ queryAllStaffList(){
377
+ return new Promise((resolve,reject)=>{
378
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/queryAllStaffList',{
379
+ params:{
380
+ search:this.staffSearch,
381
+ offset:this.offset,
382
+ limit:10,
383
+ }
384
+ }).then((res)=>{
385
+ if(res.data.code === 1){
386
+ let resp = res.data.data
387
+ resolve(resp)
388
+ }else{
389
+ reject(false)
390
+ }
391
+ })
392
+ })
393
+ },
394
+ handleScroll(e){
395
+ const { scrollTop, clientHeight, scrollHeight } = e.target;
396
+ if (scrollHeight - (scrollTop + clientHeight) < 50) {
397
+ this.loadMore();
398
+ }
399
+ },
400
+ async loadMore(){
401
+ let nowTime = Date.now()
402
+ if (this.loadingStaff || this.staffEnding || (nowTime - this.lastLoadingTime < 1000)) return
403
+ this.loadingStaff = true
404
+ try {
405
+ console.log("--触底加载---")
406
+ let res = await this.queryAllStaffList()
407
+ let list = res.rows;
408
+ list.map((item)=>item.checked=false)
409
+ this.staffAllList = this.staffAllList.concat(list)
410
+ this.offset += 10;
411
+ this.loadingStaff = false
412
+ this.lastLoadingTime = Date.now()
413
+ if(res.total===this.staffAllList.length){
414
+ this.staffEnding = true
415
+ }
416
+ }catch (e){
417
+ this.loadingStaff = false
418
+ this.lastLoadingTime = Date.now()
419
+ console.log(e)
420
+ }
421
+ },
422
+ getOrgList(data){
423
+ this.proOrgList = data
424
+ },
425
+ getPostList(data){
426
+ this.proPostList = data
427
+ },
428
+ addOrgList(){
429
+ if(!this.proOrgList.length) return this.$Message.error("请先选择组织节点!")
430
+ let proOrgList = deepCopy(this.proOrgList)
431
+ proOrgList.forEach(item=>{
432
+ item.title = this.includeLevelOrg.includes('01')?`${item.orgNodeName}(包含下级组织节点)`:item.orgNodeName
433
+ item.id = this.includeLevelOrg.includes('01')?('01'+'-' + item.orgUnitId):('00'+'-'+item.orgUnitId)
434
+ item.includeLevel = this.includeLevelOrg.includes('01')
435
+ })
436
+ let list = this.orgList.concat(proOrgList)
437
+ let uniqueArray = list.filter((item, index, self) =>
438
+ index === self.findIndex(t => (
439
+ t.id === item.id // 基于id属性去重
440
+ ))
441
+ );
442
+ this.orgList = uniqueArray
443
+ this.$refs.orgTree.upDataTree()
444
+ this.proOrgList = []
445
+ },
446
+ clearGroup(){
447
+ this.orgList = []
448
+ },
449
+ clearOrgByIndex(index){
450
+ this.orgList.splice(index,1)
451
+ },
452
+ //岗位
453
+ getPosionId(item){
454
+ item.checked = !item.checked;
455
+ },
456
+ addPostList(){
457
+ if(!this.proPostList.length) return this.$Message.error("请选择组织节点!")
458
+ let proPostList = deepCopy(this.proPostList)
459
+ let checkedPosition = this.positiontList.filter((item)=>item.checked === true)
460
+ if(!checkedPosition.length){return this.$Message.error("请选择岗位!!")}
461
+ //summary data
462
+ let totalList = []
463
+ for(let it of checkedPosition){
464
+ proPostList.forEach(item=>{
465
+ totalList.push({
466
+ ...item,
467
+ ...it,
468
+ title:`${this.includeLevelPost.length?(item.orgNodeName+'(包含下级组织节点)'):item.orgNodeName}`,
469
+ includeLevel:this.includeLevelPost.includes('01'),
470
+ id:this.includeLevelPost.includes('01')?('01'+'-'+it.positionId + '-' + item.orgUnitId):('00'+'-'+it.positionId + '-' + item.orgUnitId),
471
+ })
472
+ })
473
+ }
474
+ let list = this.postList.concat(totalList)
475
+ let uniqueArray = list.filter((item, index, self) =>
476
+ index === self.findIndex(t => (
477
+ t.id === item.id // 基于id属性去重
478
+ ))
479
+ );
480
+ this.postList = uniqueArray
481
+ this.$refs.postTree.upDataTree()
482
+ this.proPostList = []
483
+ this.positiontList.map((item)=>{item.checked=false})
484
+ },
485
+ clearPost(){
486
+ this.postList= []
487
+ },
488
+ clearPostByIndex(index){
489
+ this.postList.splice(index,1)
490
+ },
491
+ //staff
492
+ addStaffList(){
493
+ let staffList = this.staffAllList.filter((item)=>item.checked===true)
494
+ let list = this.staffList.concat(staffList)
495
+ let uniqueArray = list.filter((item, index, self) =>
496
+ index === self.findIndex(t => (
497
+ t.id === item.id // 基于id属性去重
498
+ ))
499
+ );
500
+ this.staffList = uniqueArray
501
+ this.staffAllList.map((item)=>item.checked=false)
502
+ },
503
+ handlestaff(item){
504
+ item.checked=!item.checked
505
+ },
506
+ clearStaff(){
507
+ this.staffList = []
508
+ },
509
+ clearStaffByIndex(index){
510
+ this.staffList.splice(index,1)
511
+ },
512
+ confirm(){
513
+ const v = {
514
+ orgList:this.orgList,
515
+ postList:this.postList,
516
+ staffList:this.staffList
517
+ }
518
+ this.$emit('confirm',deepCopy(v))
519
+ },
520
+ visibleChange(val){
521
+ this.$emit('input',val);
522
+ },
523
+ fastChedkOrg(item){
524
+ item.checked = !item.checked
525
+ },
526
+ },
527
+ computed:{
528
+ getCheckedStaff(){
529
+ return this.staffAllList.filter((item)=>item.checked===true).length
530
+ },
531
+ getCheckTypenum(){
532
+ let l1 = this.orgList.length?1:0;
533
+ let l2 = this.postList.length?1:0;
534
+ let l3 = this.staffList.length?1:0;
535
+ return l1+l2+l3
536
+ }
537
+ },
538
+ watch:{
539
+ value(val){
540
+ this.modal = val
541
+ },
542
+ data:{
543
+ handler(val){
544
+ let map = deepCopy(val)
545
+ let orgList = map.orgList || []
546
+ orgList.forEach(item=>{
547
+ item.title = item.includeLevel?`${item.orgNodeName}(包含下级组织节点)`:item.orgNodeName
548
+ item.id = item.includeLevel?('01'+'-' + item.orgUnitId):('00'+'-'+item.orgUnitId)
549
+ })
550
+ this.orgList = orgList
551
+ let postList = map.postList || []
552
+ postList.forEach(item=>{
553
+ item.title=`${item.includeLevel?(item.orgNodeName+'(包含下级组织节点)'):item.orgNodeName}`
554
+ item.id=item.includeLevel?('01'+'-'+item.positionId + '-' + item.orgUnitId):('00'+'-'+item.positionId + '-' + item.orgUnitId)
555
+ })
556
+ this.postList = postList
557
+ this.staffList = map.staffList || []
558
+ },
559
+ deep: true,
560
+ immediate: true,
561
+ }
562
+ }
563
+ }
564
+ </script>
565
+ <style lang="less" scoped>
566
+ .modal-tree{
567
+ .header-text{
568
+ font-weight: bold;
569
+ font-size: 16px;
570
+ color: #333333;
571
+ }
572
+ .icon-tip{
573
+ width: 16px;
574
+ height: 16px;
575
+ background: var(--primary-color);
576
+ border-radius: 50%;
577
+ color: #fff;
578
+ line-height: 16px;
579
+ }
580
+ .content-container{
581
+ }
582
+ .tree-orig{
583
+ width:100%;
584
+ display: flex;
585
+ height: 700px;
586
+ background: #fff;
587
+ /deep/.ivu-tabs-nav{
588
+ font-weight: bold;
589
+ font-size: 16px;
590
+ }
591
+ /deep/.ivu-tabs-nav{
592
+ width: 100%;
593
+ display: flex;
594
+ }
595
+ /deep/.ivu-tabs-nav .ivu-tabs-tab{
596
+ flex:1;
597
+ text-align: center;
598
+ }
599
+ .tab-content{
600
+ width: 720px;
601
+ border-radius: 8px;
602
+ border: 1px solid #EAECF0;
603
+ .tab{
604
+ padding:20px;
605
+ .tag-content{
606
+ margin-top:20px;
607
+ height:37px;
608
+ display:flex;
609
+ align-items: center;
610
+ }
611
+ .tree{
612
+ height:450px;
613
+ margin-top:20px;
614
+ }
615
+ .staff-content{
616
+ overflow:auto;
617
+ }
618
+ .bottom-select{
619
+ display:flex;
620
+ align-items: center;
621
+ justify-content: space-between;
622
+ margin-top:20px;
623
+ .num{
624
+ color:var(--primary-color);
625
+ }
626
+ }
627
+ }
628
+ .tag-list{
629
+ flex:1;
630
+ display:inline-block;
631
+ height:100%;
632
+ overflow:hidden;
633
+ }
634
+ .tag{
635
+ display: inline-block;
636
+ padding:7px 13px;
637
+ background: #F4F6FA;
638
+ border-radius: 4px;
639
+ border: 1px solid #EAECF0;
640
+ margin-left:10px;
641
+ font-weight: bold;
642
+ cursor: pointer;
643
+ &.active{
644
+ background: var(--primary-color);
645
+ border-radius: 4px;
646
+ color: #fff;
647
+ }
648
+ }
649
+ .pop-content{
650
+ display: flex;
651
+ flex-wrap: wrap;
652
+ width:500px;
653
+ .tag{
654
+ margin-top: 10px;
655
+ &.active{
656
+ background: var(--primary-color);
657
+ border-radius: 4px;
658
+ color: #fff;
659
+ }
660
+ }
661
+ }
662
+ .post{
663
+ display: flex;
664
+ height: 100%;
665
+ .left{
666
+ width:200px;
667
+ overflow: auto;
668
+ >div{
669
+ background: #FFFFFF;
670
+ border-radius: 4px;
671
+ border: 1px solid #EAECF0;
672
+ margin-top:10px;
673
+ padding:10px 20px;
674
+ font-weight: 400;
675
+ font-size: 14px;
676
+ color: #333333;
677
+ cursor: pointer;
678
+ }
679
+ .active{
680
+ background: #F2F8FF;
681
+ font-weight: bold;
682
+ color:var(--primary-color);
683
+ }
684
+ }
685
+ .right{
686
+ margin-left:20px;
687
+ flex: 1;
688
+ }
689
+ }
690
+ .gust-item{
691
+ display:flex;
692
+ align-items: center;
693
+ width: 100%;
694
+ padding: 15px 10px;
695
+ margin-top:10px;
696
+ cursor: pointer;
697
+ .left-panel{
698
+ background:url("./assets/name-bg.png") no-repeat;
699
+ width:30px;
700
+ height:30px;
701
+ border-radius: 50%;
702
+ font-weight: bold;
703
+ font-size: 16px;
704
+ color: #FFFFFF;
705
+ line-height:30px;
706
+ text-align:center;
707
+ }
708
+ .right-panel{
709
+ margin-left:10px;
710
+ flex:1;
711
+ >p:first-child{
712
+ color: #333333;
713
+ }
714
+ >p:last-child{
715
+ color: #AFAFAF;
716
+ }
717
+ }
718
+ .checked-icon{
719
+ margin-left:auto;
720
+ color:var(--primary-color);
721
+ font-size:18px;
722
+ }
723
+ }
724
+ .staff-active{
725
+ background:#E9F4FF;
726
+ >p:first-child{
727
+ color: var(--primary-color);
728
+ }
729
+ }
730
+ }
731
+ .form-content{
732
+ flex:1;
733
+ overflow: hidden;
734
+ border-radius: 8px;
735
+ border: 1px solid #EAECF0;
736
+ margin-left:20px;
737
+ padding:10px 20px;
738
+ >p{
739
+ font-weight: 500;
740
+ font-size: 16px;
741
+ color: #333333;
742
+ .num{
743
+ color:var(--primary-color);
744
+ }
745
+ }
746
+ .node-list{
747
+ display: flex;
748
+ flex-direction: column;
749
+ height: calc(100% - 26px);
750
+ >div{
751
+ flex: 1;
752
+ overflow: hidden;
753
+ }
754
+ .group-box{
755
+ margin-top:20px;
756
+ color:#666666;
757
+ .clear-btn{
758
+ color:#CCCCCC;
759
+ cursor: pointer;
760
+ &:hover{
761
+ color:var(--error-color);
762
+ }
763
+ }
764
+ }
765
+ .group-list-content {
766
+ height: calc(100% - 26px);
767
+ overflow: auto;
768
+ .clear-icon{
769
+ cursor:pointer;
770
+ }
771
+ }
772
+ .list-item{
773
+ background:#F4F6FA;
774
+ border-radius: 4px;
775
+ padding:10px;
776
+ margin-top:10px;
777
+ color: #333333;
778
+ white-space: nowrap;
779
+ >span{
780
+ flex:1;
781
+ overflow: hidden;
782
+ text-overflow: ellipsis;
783
+ }
784
+ &:last-child{
785
+ margin-bottom:10px;
786
+ }
787
+ }
788
+ }
789
+ }
790
+ .flex-r-bt{
791
+ display: flex;
792
+ align-items: center;
793
+ justify-content: space-between;
794
+ }
795
+ }
796
+ }
797
+ </style>
@@ -0,0 +1,177 @@
1
+ <template>
2
+ <div class="content">
3
+ <Spin fix v-if="loading"></Spin>
4
+ <Tree :data="data" ref="tree" :load-data="loadData" :render="renderContent" check-directly
5
+ @on-select-change ="handleChange" multiple></Tree>
6
+ </div>
7
+ </template>
8
+ <script>
9
+ import { deepCopy } from '@lambo-design/core/src/utils/assist';
10
+ import ajax from '@lambo-design/shared/utils/ajax'
11
+ export default {
12
+ props:{
13
+ disabled:{
14
+ type: Boolean,
15
+ default: false
16
+ },
17
+ treeList:{
18
+ type: Array,
19
+ default: () => []
20
+ }
21
+ },
22
+ data(){
23
+ return {
24
+ data:[],
25
+ manageUnitId:'',
26
+ loading:true
27
+ }
28
+ },
29
+ mounted() {
30
+ this.initData()
31
+ },
32
+ methods:{
33
+ async initData(){
34
+ let data = await this.getOrgChildren()
35
+ this.loading = false
36
+ this.data = data;
37
+ },
38
+ handleChange(data){
39
+ this.$emit('handleChange',data)
40
+ },
41
+ async loadData(item, callback){
42
+ // 模拟异步获取数据
43
+ let children = await this.getOrgChildren(item.orgUnitId)
44
+ callback(children); // 调用callback传入子节点数据
45
+ },
46
+ checkNode(data){
47
+ // console.log(data,'data')
48
+ },
49
+ getOrgChildren(orgUnitId=''){
50
+ return new Promise((resolve,reject)=>{
51
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitList', { params:{
52
+ containsCurLevel:true,
53
+ orgUnitId:orgUnitId,
54
+ }
55
+ }).then((res)=>{
56
+ if(res.data.code === 1){
57
+ let treeList = res.data.data
58
+ this.initTree(treeList)
59
+ resolve(treeList)
60
+ }else{
61
+ resolve([])
62
+ }
63
+ }).catch(err=>{
64
+ console.log(err)
65
+ })
66
+ })
67
+ },
68
+ initTree(treeList){
69
+ const defineTree = function(list){
70
+ if(!list)return
71
+ list.forEach((item) => {
72
+ item.title=item.orgNodeName;
73
+ item.loading = false;
74
+ item.children = [];
75
+ item.expand = false;
76
+ item.checked = false;
77
+ if(item.leafNode){
78
+ delete item.loading;
79
+ delete item.children;
80
+ }
81
+ if(item.orgChildrenList && item.orgChildrenList.length){
82
+ item.children = defineTree(item.orgChildrenList);
83
+ item.expand = true;
84
+ }
85
+ })
86
+ return list
87
+ }
88
+ treeList.forEach(item=>{
89
+ item.title=item.orgNodeName;
90
+ item.loading = false;
91
+ item.children = [];
92
+ item.expand = false;
93
+ item.checked = false;
94
+ if(item.orgChildrenList && item.orgChildrenList.length){
95
+ item.children = defineTree(item.orgChildrenList);
96
+ item.expand = true;
97
+ }
98
+ if(this.disabled){
99
+ item.disabled = true;
100
+ }
101
+ if(item.leafNode){
102
+ delete item.loading;
103
+ delete item.children;
104
+ }
105
+ })
106
+ },
107
+ renderContent(h, { root, node, data }){
108
+ return h('div', {
109
+ style: {
110
+ width: '100%',
111
+ overflow:'hidden',
112
+ display:'flex',
113
+ alignItems: 'center',
114
+ }
115
+ }, [
116
+ h('img', {
117
+ attrs: {
118
+ src: require('./assets/icon.png'),
119
+ },
120
+ style: {
121
+ marginRight: '8px',
122
+ width:'14px',
123
+ height:'14px',
124
+ }
125
+ }),
126
+ h('span',{
127
+ style: {
128
+ overflow: 'hidden',
129
+ textOverflow:'ellipsis',
130
+ flex:1
131
+ },
132
+ on:{
133
+ click:()=>{
134
+ this.checkNode(data)
135
+ }
136
+ }
137
+ }, data.title)
138
+ ]);
139
+ },
140
+ upDataTree(){
141
+ const unCheck = (list)=>{
142
+ list.forEach((item)=>{
143
+ this.$set(item, 'selected', false);
144
+ if(item.children && item.children.length){
145
+ unCheck(item.children)
146
+ }
147
+ })
148
+ }
149
+ unCheck(this.data)
150
+ }
151
+ },
152
+ watch:{
153
+ 'treeList':{
154
+ handler:function(val,oldVal){
155
+ let tree = deepCopy(val)
156
+ this.initTree(tree)
157
+ this.data = tree
158
+ },
159
+ deep:true
160
+ }
161
+ }
162
+ }
163
+ </script>
164
+ <style lang="less" scoped>
165
+ .content{
166
+ width: 100%;
167
+ height: 100%;
168
+ overflow: auto;
169
+ }
170
+ /deep/.ivu-tree ul li{
171
+ overflow: hidden;
172
+ }
173
+ /deep/.ivu-tree-title{
174
+ width: calc(100% - 20px);
175
+ }
176
+
177
+ </style>