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

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,23 @@
1
+ {
2
+ "name": "@sy-common/organize-select-help",
3
+ "version": "1.0.0-beta.3",
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
+ },
15
+ "scripts": {
16
+ "release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
17
+ "release-major": "standard-version --release-as major",
18
+ "release-minor": "standard-version --release-as minor",
19
+ "release-patch": "standard-version --release-as patch",
20
+ "release-beta": "standard-version --prerelease beta",
21
+ "re-publish": "pnpm publish --access public --no-git-checks"
22
+ }
23
+ }
Binary file
Binary file
Binary file
package/src/index.vue ADDED
@@ -0,0 +1,532 @@
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="name">
16
+ <TabPane label="选择组织节点" name="name1">
17
+ <div class="tab">
18
+ <Input v-model="orgSearch" placeholder="搜索组织节点"/>
19
+ <div class="tag-content">
20
+ <span>快捷选择:</span>
21
+ <div class="tag-list">
22
+ <span class="tag" v-for="item in tagList" :key="item.key">{{item.v}}</span>
23
+ </div>
24
+ </div>
25
+ <div class="tree">
26
+ <organizeTree @handleChange="getOrgList" ref="organizeTree"></organizeTree>
27
+ </div>
28
+ <div class="bottom-select">
29
+ <CheckboxGroup v-model="includeLevelOrg">
30
+ <Checkbox label="01">
31
+ <span>包含下级组织节点</span>
32
+ </Checkbox>
33
+ </CheckboxGroup>
34
+ <Button type="primary" icon="md-add" @click="addOrgList">添加节点</Button>
35
+ </div>
36
+ </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>
61
+ </div>
62
+ </div>
63
+ </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>
74
+ </div>
75
+ <div class="checked-icon" v-show="item.checked">✔</div>
76
+ </div>
77
+ </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">(1)</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 src="./assets/delete.png" alt="" @click="clearOrgByIndex(index)">
99
+ </p>
100
+ <p style="color:#CCCCCC" class="list-item" v-if="!orgList.length">未选择组织节点</p>
101
+ </div>
102
+ </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 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>
116
+ </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 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>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </Modal>
136
+ </template>
137
+ <script>
138
+ import organizeTree from './organize-tree.vue'
139
+ import { deepCopy } from '@lambo-design/core/src/utils/assist'
140
+ import ajax from '@lambo-design/shared/utils/ajax'
141
+ export default {
142
+ components: { organizeTree },
143
+ props: {
144
+ value:{
145
+ type: Boolean,
146
+ default: false
147
+ }
148
+ },
149
+ data(){
150
+ return {
151
+ modal:false,
152
+ name:'name1',
153
+ dialogOpen:false,
154
+ orgSearch:'',
155
+ //组织--right-form
156
+ proOrgList:[],
157
+ includeLevelOrg:[],
158
+ orgList:[],
159
+ //岗位--form
160
+ proPostList:[],
161
+ postList:[],
162
+ includeLevelPost:[],
163
+ positiontList:[],
164
+ //直接人员
165
+ staffSearch:'',
166
+ staffAllList:[],
167
+ staffList:[],
168
+ tagList:[{
169
+ v:'所选市公司所有部门',
170
+ on:false,
171
+ key:'07'
172
+ },{
173
+ v:'所有市公司',
174
+ on:false,
175
+ key:'08'
176
+ }],
177
+ }
178
+ },
179
+ mounted() {
180
+ this.queryPositionList()
181
+ this.queryAllStaffList()
182
+ },
183
+ methods:{
184
+ queryPositionList(){
185
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/queryPositionList').then((res)=>{
186
+ if(res.data.code === 1){
187
+ let positiontList = res.data.data || []
188
+ positiontList.map((item)=>item.checked = false)
189
+ this.positiontList = positiontList
190
+ }
191
+ })
192
+ },
193
+ queryAllStaffList(){
194
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/queryAllStaffList?search='+this.staffSearch).then((res)=>{
195
+ if(res.data.code === 1){
196
+ let staffAllList = res.data.data && res.data.data.rows || []
197
+ staffAllList.map((item)=>item.checked=false)
198
+ this.staffAllList = staffAllList
199
+ }
200
+ })
201
+ },
202
+ getOrgList(data){
203
+ this.proOrgList = data
204
+ },
205
+ getPostList(data){
206
+ this.proPostList = data
207
+ },
208
+ addOrgList(){
209
+ if(!this.proOrgList.length) return this.$Message.error("请先选择组织节点!")
210
+ let proOrgList = deepCopy(this.proOrgList)
211
+ proOrgList.forEach(item=>{
212
+ item.title = `${item.orgNodeName}(包含下级组织节点)`
213
+ item.id = this.includeLevelOrg.includes('01')?('01'+'-' + item.orgUnitId):('00'+'-'+item.orgUnitId)
214
+ item.includeLevel = this.includeLevelOrg.includes('01')
215
+ })
216
+ let list = this.orgList.concat(proOrgList)
217
+ let uniqueArray = list.filter((item, index, self) =>
218
+ index === self.findIndex(t => (
219
+ t.id === item.id // 基于id属性去重
220
+ ))
221
+ );
222
+ this.orgList = uniqueArray
223
+ this.$refs.organizeTree.upDataTree()
224
+ this.proOrgList = []
225
+ },
226
+ clearGroup(){
227
+ this.orgList = []
228
+ },
229
+ clearOrgByIndex(index){
230
+ this.orgList.splice(index,1)
231
+ },
232
+ //岗位
233
+ getPosionId(item){
234
+ item.checked = !item.checked;
235
+ },
236
+ addPostList(){
237
+ if(!this.proPostList.length) return this.$Message.error("请选择组织节点!")
238
+ let proPostList = deepCopy(this.proPostList)
239
+ let checkedPosition = this.positiontList.filter((item)=>item.checked === true)
240
+ if(!checkedPosition.length){return this.$Message.error("请选择岗位!!")}
241
+ //summary data
242
+ let totalList = []
243
+ for(let it of checkedPosition){
244
+ proPostList.forEach(item=>{
245
+ totalList.push({
246
+ ...item,
247
+ ...it,
248
+ title:`${this.includeLevelPost.length?(item.orgNodeName+'(包含下级组织节点)'):item.orgNodeName}`,
249
+ includeLevel:this.includeLevelPost.includes('01'),
250
+ id:this.includeLevelPost.includes('01')?('01'+'-'+it.positionId + '-' + item.orgUnitId):('00'+'-'+it.positionId + '-' + item.orgUnitId),
251
+ })
252
+ })
253
+ }
254
+ let list = this.postList.concat(totalList)
255
+ let uniqueArray = list.filter((item, index, self) =>
256
+ index === self.findIndex(t => (
257
+ t.id === item.id // 基于id属性去重
258
+ ))
259
+ );
260
+ this.postList = uniqueArray
261
+ this.$refs.postTree.upDataTree()
262
+ this.proPostList = []
263
+ this.positiontList.map((item)=>{item.checked=false})
264
+ },
265
+ clearPost(){
266
+ this.postList= []
267
+ },
268
+ clearPostByIndex(index){
269
+ this.postList.splice(index,1)
270
+ },
271
+ //staff
272
+ addStaffList(){
273
+ let staffList = this.staffAllList.filter((item)=>item.checked=true)
274
+ let list = this.staffList.concat(staffList)
275
+ let uniqueArray = list.filter((item, index, self) =>
276
+ index === self.findIndex(t => (
277
+ t.id === item.id // 基于id属性去重
278
+ ))
279
+ );
280
+ this.staffList = uniqueArray
281
+ this.staffAllList.map((item)=>item.checked=false)
282
+ },
283
+ handlestaff(item){
284
+ item.checked=!item.checked
285
+ },
286
+ clearStaff(){
287
+ this.staffList = []
288
+ },
289
+ clearStaffByIndex(index){
290
+ this.staffList.splice(index,1)
291
+ },
292
+ confirm(){
293
+ this.$emit('confirm',{
294
+ orgList:this.orgList,
295
+ postList:this.postList,
296
+ staffList:this.staffList
297
+ })
298
+ },
299
+ visibleChange(val){
300
+ this.$emit('input',val);
301
+ },
302
+ },
303
+ computed:{
304
+ getCheckedStaff(){
305
+ return this.staffAllList.filter((item)=>item.checked===true).length
306
+ }
307
+ },
308
+ watch:{
309
+ value(val){
310
+ this.modal = val
311
+ }
312
+ }
313
+ }
314
+ </script>
315
+ <style lang="less" scoped>
316
+ .modal-tree{
317
+ .header-text{
318
+ font-weight: bold;
319
+ font-size: 16px;
320
+ color: #333333;
321
+ }
322
+ .icon-tip{
323
+ width: 16px;
324
+ height: 16px;
325
+ background: #145DFF;
326
+ border-radius: 50%;
327
+ color: #fff;
328
+ line-height: 16px;
329
+ }
330
+ .content-container{
331
+ }
332
+ .tree-orig{
333
+ width:100%;
334
+ display: flex;
335
+ height: 700px;
336
+ background: #fff;
337
+ /deep/.ivu-tabs-nav{
338
+ font-weight: bold;
339
+ font-size: 16px;
340
+ }
341
+ /deep/.ivu-tabs-nav{
342
+ width: 100%;
343
+ display: flex;
344
+ }
345
+ /deep/.ivu-tabs-nav .ivu-tabs-tab{
346
+ flex:1;
347
+ text-align: center;
348
+ }
349
+ .tab-content{
350
+ width: 720px;
351
+ border-radius: 8px;
352
+ border: 1px solid #EAECF0;
353
+ .tab{
354
+ padding:20px;
355
+ .tag-content{
356
+ margin-top:20px;
357
+ height:37px;
358
+ display:flex;
359
+ align-items: center;
360
+ }
361
+ .tree{
362
+ height:450px;
363
+ margin-top:20px;
364
+ }
365
+ .staff-content{
366
+ overflow:auto;
367
+ }
368
+ .bottom-select{
369
+ display:flex;
370
+ align-items: center;
371
+ justify-content: space-between;
372
+ margin-top:20px;
373
+ .num{
374
+ color:var(--primary-color);
375
+ }
376
+ }
377
+ }
378
+ .tag-list{
379
+ flex:1;
380
+ display:inline-block;
381
+ height:100%;
382
+ overflow:hidden;
383
+ }
384
+ .tag{
385
+ display: inline-block;
386
+ padding:7px 13px;
387
+ background: #F4F6FA;
388
+ border-radius: 4px;
389
+ border: 1px solid #EAECF0;
390
+ margin-left:10px;
391
+ font-weight: bold;
392
+ &.active{
393
+ background: #145DFF;
394
+ border-radius: 4px;
395
+ color: #fff;
396
+ }
397
+ }
398
+ .post{
399
+ display: flex;
400
+ height: 100%;
401
+ .left{
402
+ width:200px;
403
+ overflow: auto;
404
+ >div{
405
+ background: #FFFFFF;
406
+ border-radius: 4px;
407
+ border: 1px solid #EAECF0;
408
+ margin-top:10px;
409
+ padding:10px 20px;
410
+ font-weight: 400;
411
+ font-size: 14px;
412
+ color: #333333;
413
+ cursor: pointer;
414
+ }
415
+ .active{
416
+ background: #F2F8FF;
417
+ font-weight: bold;
418
+ color:var(--primary-color);
419
+ }
420
+ }
421
+ .right{
422
+ margin-left:20px;
423
+ flex: 1;
424
+ }
425
+ }
426
+ .gust-item{
427
+ display:flex;
428
+ align-items: center;
429
+ width: 100%;
430
+ padding: 15px 10px;
431
+ margin-top:10px;
432
+ cursor: pointer;
433
+ .left-panel{
434
+ background:url("./assets/name-bg.png") no-repeat;
435
+ width:30px;
436
+ height:30px;
437
+ border-radius: 50%;
438
+ font-weight: bold;
439
+ font-size: 16px;
440
+ color: #FFFFFF;
441
+ line-height:30px;
442
+ text-align:center;
443
+ }
444
+ .right-panel{
445
+ margin-left:10px;
446
+ flex:1;
447
+ >p:first-child{
448
+ color: #333333;
449
+ }
450
+ >p:last-child{
451
+ color: #AFAFAF;
452
+ }
453
+ }
454
+ .checked-icon{
455
+ margin-left:auto;
456
+ color:#145DFF;
457
+ font-size:18px;
458
+ }
459
+ }
460
+ .staff-active{
461
+ background:#E9F4FF;
462
+ >p:first-child{
463
+ color: var(--primary-color);
464
+ }
465
+ }
466
+ }
467
+ .form-content{
468
+ flex:1;
469
+ overflow: hidden;
470
+ border-radius: 8px;
471
+ border: 1px solid #EAECF0;
472
+ margin-left:20px;
473
+ padding:10px 20px;
474
+ >p{
475
+ font-weight: 500;
476
+ font-size: 16px;
477
+ color: #333333;
478
+ .num{
479
+ color:var(--primary-color);
480
+ }
481
+ }
482
+ .node-list{
483
+ display: flex;
484
+ flex-direction: column;
485
+ height: calc(100% - 26px);
486
+ >div{
487
+ flex: 1;
488
+ overflow: hidden;
489
+ }
490
+ .group-box{
491
+ margin-top:20px;
492
+ color:#666666;
493
+ .clear-btn{
494
+ color:#CCCCCC;
495
+ cursor: pointer;
496
+ &:hover{
497
+ color:var(--error-color);
498
+ }
499
+ }
500
+ }
501
+ .group-list-content {
502
+ height: calc(100% - 26px);
503
+ overflow: auto;
504
+ }
505
+ .list-item{
506
+ background:#F4F6FA;
507
+ border-radius: 4px;
508
+ padding:10px;
509
+ margin-top:10px;
510
+ color: #333333;
511
+ white-space: nowrap;
512
+ >span{
513
+ flex:1;
514
+ overflow: hidden;
515
+ text-overflow: ellipsis;
516
+ }
517
+ &:last-child{
518
+ margin-bottom:10px;
519
+ }
520
+ }
521
+ }
522
+ }
523
+ .flex-r-bt{
524
+ display: flex;
525
+ align-items: center;
526
+ justify-content: space-between;
527
+ }
528
+ }
529
+ /deep/.ivu-modal-body-no-scrollbar-width :not([class^="ivu-table"])::-webkit-scrollbar{
530
+ }
531
+ }
532
+ </style>
@@ -0,0 +1,158 @@
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 ajax from '@lambo-design/shared/utils/ajax'
10
+ export default {
11
+ props:{
12
+ disabled:{
13
+ type: Boolean,
14
+ default: false
15
+ }
16
+ },
17
+ data(){
18
+ return {
19
+ data:[],
20
+ manageUnitId:'',
21
+ loading:true
22
+ }
23
+ },
24
+ mounted() {
25
+ this.initData()
26
+ },
27
+ methods:{
28
+ async initData(){
29
+ let data = await this.getOrgChildren()
30
+ this.loading = false
31
+ this.data = data;
32
+ },
33
+ handleChange(data){
34
+ this.$emit('handleChange',data)
35
+ },
36
+ async loadData(item, callback){
37
+ // 模拟异步获取数据
38
+ let children = await this.getOrgChildren(item.orgUnitId)
39
+ callback(children); // 调用callback传入子节点数据
40
+ },
41
+ checkNode(data){
42
+ // console.log(data,'data')
43
+ },
44
+ getOrgChildren(orgUnitId){
45
+ return new Promise((resolve,reject)=>{
46
+ ajax.get('/pub-manage-server/pub/personHelpBox/q/getOrgUnitList', { params:{
47
+ containsCurLevel:true,
48
+ orgUnitId:orgUnitId,
49
+ }
50
+ }).then((res)=>{
51
+ if(res.data.code === 1){
52
+ let treeList = res.data.data
53
+ this.initTree(treeList)
54
+ resolve(treeList)
55
+ }else{
56
+ resolve([])
57
+ }
58
+ }).catch(err=>{
59
+ console.log(err)
60
+ })
61
+ })
62
+ },
63
+ initTree(treeList){
64
+ const defineTree = function(list){
65
+ if(!list)return
66
+ list.forEach((item) => {
67
+ item.title=item.orgNodeName;
68
+ item.loading = false;
69
+ item.children = [];
70
+ item.expand = false;
71
+ item.checked = false;
72
+ if(item.leafNode){
73
+ delete item.loading;
74
+ delete item.children;
75
+ }
76
+ })
77
+ return list
78
+ }
79
+ treeList.forEach(item=>{
80
+ item.title=item.orgNodeName;
81
+ item.loading = false;
82
+ item.children = [];
83
+ item.expand = false;
84
+ item.checked = false;
85
+ if(item.orgChildrenList && item.orgChildrenList.length){
86
+ item.children = defineTree(item.orgChildrenList);
87
+ item.expand = true;
88
+ }
89
+ if(this.disabled){
90
+ item.disabled = true;
91
+ }
92
+ if(item.leafNode){
93
+ delete item.loading;
94
+ delete item.children;
95
+ }
96
+ })
97
+ },
98
+ renderContent(h, { root, node, data }){
99
+ return h('div', {
100
+ style: {
101
+ width: '100%',
102
+ overflow:'hidden',
103
+ display:'flex',
104
+ alignItems: 'center',
105
+ }
106
+ }, [
107
+ h('img', {
108
+ attrs: {
109
+ src: require('./assets/icon.png'),
110
+ },
111
+ style: {
112
+ marginRight: '8px',
113
+ width:'14px',
114
+ height:'14px',
115
+ }
116
+ }),
117
+ h('span',{
118
+ style: {
119
+ overflow: 'hidden',
120
+ textOverflow:'ellipsis',
121
+ flex:1
122
+ },
123
+ on:{
124
+ click:()=>{
125
+ this.checkNode(data)
126
+ }
127
+ }
128
+ }, data.title)
129
+ ]);
130
+ },
131
+ upDataTree(){
132
+ const unCheck = (list)=>{
133
+ list.forEach((item)=>{
134
+ this.$set(item, 'selected', false);
135
+ if(item.children && item.children.length){
136
+ unCheck(item.children)
137
+ }
138
+ })
139
+ }
140
+ unCheck(this.data)
141
+ }
142
+ },
143
+ }
144
+ </script>
145
+ <style lang="less" scoped>
146
+ .content{
147
+ width: 100%;
148
+ height: 100%;
149
+ overflow: auto;
150
+ }
151
+ /deep/.ivu-tree ul li{
152
+ overflow: hidden;
153
+ }
154
+ /deep/.ivu-tree-title{
155
+ width: calc(100% - 20px);
156
+ }
157
+
158
+ </style>