File tree Expand file tree Collapse file tree 3 files changed +123
-5
lines changed Expand file tree Collapse file tree 3 files changed +123
-5
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ export default {
21
21
}
22
22
} ,
23
23
methods : {
24
- handlePlus ( ... args ) {
25
- this . $emit ( 'onAdd ' , { args } )
24
+ handlePlus ( item ) {
25
+ this . $emit ( 'add ' , item )
26
26
} ,
27
27
handleTitleClick ( ...args ) {
28
28
this . $emit ( 'titleClick' , { args } )
@@ -44,7 +44,7 @@ export default {
44
44
< Item key = { item . key } >
45
45
{ this . renderIcon ( item . icon ) }
46
46
{ item . title }
47
- < a class = "btn" > < a-icon type = "plus" onClick = { ( ) => this . handlePlus ( item ) } /> </ a >
47
+ < a class = "btn" style = "width: 20px;z-index:1300" { ... { on : { click : ( ) => this . handlePlus ( item ) } } } > < a-icon type = "plus" /> </ a >
48
48
</ Item >
49
49
)
50
50
} ,
Original file line number Diff line number Diff line change 2
2
<a-card :bordered =" false" >
3
3
<a-row :gutter =" 8" >
4
4
<a-col :span =" 5" >
5
- <s-tree :dataSource =" orgTree" :search =" true" @click =" handleClick" ></s-tree >
5
+ <s-tree :dataSource =" orgTree" :search =" true" @click =" handleClick" @add = " handleAdd " @titleClick = " handleTitleClick " ></s-tree >
6
6
</a-col >
7
7
<a-col :span =" 19" >
8
8
<s-table
38
38
</s-table >
39
39
</a-col >
40
40
</a-row >
41
+
42
+ <org-modal ref =" modal" @ok =" handleSaveOk" @close =" handleSaveClose" />
41
43
</a-card >
42
44
</template >
43
45
44
46
<script >
45
47
import STree from ' @/components/Tree/Tree'
46
48
import STable from ' @/components/table/'
49
+ import OrgModal from ' ./modules/OrgModal'
47
50
import { getOrgTree , getServiceList } from ' @/api/manage'
48
51
49
52
export default {
50
53
name: ' TreeList' ,
51
54
components: {
52
55
STable,
53
- STree
56
+ STree,
57
+ OrgModal
54
58
},
55
59
data () {
56
60
return {
@@ -118,9 +122,23 @@ export default {
118
122
}
119
123
this .$refs .table .refresh (true )
120
124
},
125
+ handleAdd (item ) {
126
+ console .log (' add button, item' , item)
127
+ this .$message .info (` 提示:你点了 ${ item .key } - ${ item .title } ` )
128
+ this .$refs .modal .add (item .key )
129
+ },
130
+ handleTitleClick (item ) {
131
+ console .log (' handleTitleClick' , item)
132
+ },
121
133
titleClick (e ) {
122
134
console .log (' titleClick' , e)
123
135
},
136
+ handleSaveOk () {
137
+
138
+ },
139
+ handleSaveClose () {
140
+
141
+ },
124
142
125
143
onSelectChange (selectedRowKeys , selectedRows ) {
126
144
this .selectedRowKeys = selectedRowKeys
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <a-modal
3
+ title =" 操作"
4
+ :width =" 600"
5
+ :visible =" visible"
6
+ :confirmLoading =" confirmLoading"
7
+ @ok =" handleOk"
8
+ @cancel =" handleCancel"
9
+ >
10
+ <a-spin :spinning =" confirmLoading" >
11
+ <a-form :form =" form" >
12
+
13
+ <a-form-item
14
+ label =" 父级ID"
15
+ >
16
+ <a-input v-decorator =" ['parentId', {}]" disabled />
17
+ </a-form-item >
18
+
19
+ <a-form-item
20
+ label =" 机构名称"
21
+ >
22
+ <a-input v-decorator =" ['orgName', {}]" />
23
+ </a-form-item >
24
+ </a-form >
25
+ </a-spin >
26
+ </a-modal >
27
+ </template >
28
+
29
+ <script >
30
+ export default {
31
+ name: ' OrgModal' ,
32
+ data () {
33
+ return {
34
+ labelCol: {
35
+ xs: { span: 24 },
36
+ sm: { span: 5 },
37
+ },
38
+ wrapperCol: {
39
+ xs: { span: 24 },
40
+ sm: { span: 16 },
41
+ },
42
+ visible: false ,
43
+ confirmLoading: false ,
44
+ mdl: {},
45
+ }
46
+ },
47
+ beforeCreate () {
48
+ this .form = this .$form .createForm (this )
49
+ console .log (' form::' , this .form )
50
+ },
51
+ created () {
52
+
53
+ },
54
+ methods: {
55
+ add (id ) {
56
+ this .edit ({ parentId: id })
57
+ },
58
+ edit (record ) {
59
+ this .mdl = Object .assign ({}, record)
60
+ this .visible = true
61
+ this .$nextTick (() => {
62
+ this .form .setFieldsValue ( { ... record } )
63
+ })
64
+ },
65
+ close () {
66
+ this .$emit (' close' )
67
+ this .visible = false
68
+ },
69
+ handleOk () {
70
+ const _this = this
71
+ // 触发表单验证
72
+ this .form .validateFields ((err , values ) => {
73
+ // 验证表单没错误
74
+ if (! err) {
75
+ console .log (' form values' , values)
76
+
77
+ _this .confirmLoading = true
78
+ // 模拟后端请求 2000 毫秒延迟
79
+ new Promise ((resolve ) => {
80
+ setTimeout (() => resolve (), 2000 )
81
+ }).then (() => {
82
+ // Do something
83
+ _this .$message .success (' 保存成功' )
84
+ _this .$emit (' ok' )
85
+ }).catch (() => {
86
+ // Do something
87
+ }).finally (() => {
88
+ _this .confirmLoading = false
89
+ _this .close ()
90
+ })
91
+ }
92
+ })
93
+ },
94
+ handleCancel () {
95
+ this .close ()
96
+ }
97
+
98
+ }
99
+ }
100
+ </script >
You can’t perform that action at this time.
0 commit comments