1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
| <template>
| <div>
| <el-input v-model="text" :disabled="disabled" @click.native="open()" suffix-icon="el-icon-arrow-down" slot="reference"
| :placeholder="placeholder"/>
| <zt-dialog ref="dialog" title="菜单项" @confirm="formSubmit" append-to-body>
| <el-form :model="dataForm" ref="dataForm">
| <zt-tree-menu-selector ref="tree" @NodeClickEvent="getRouteName" v-model="dataForm.menuIdList" url="/sys/menu/ofUser" has-half-checked/>
| </el-form>
| </zt-dialog>
| </div>
| </template>
|
| <script>
| export default {
| name: 'MenuTreeSelector',
| components: {},
| props:{
| multiple: {
| type: Boolean
| },
| disabled: {
| type: Boolean,
| default: false
| },
| id:{
| type:String,
| default:''
| }
| },
| data() {
| return {
| text:'',
| dataForm: {
| roleId: '',
| menuIdList: []
| }
| }
| },
| watch:{
| 'id'(){
| this.getTaskCount()
| }
| },
| mounted() {
| this.getTaskCount()
| },
| methods: {
| // init(roleId) {
| // this.dataForm.roleId = roleId
| // },
| async getTaskCount() {
| if(this.id){
| let res2 = await this.$http.get(`/sys/menu/${this.id}`)
| console.log(res2.data,'res2')
| // alert(res2.data.name,'res2.data.name')
| this.text = res2.data.name
| }
| },
| // 获取信息
| open(){
| if (this.disabled) {
| // 只读
| } else {
| //this.getShipId()
| //this.dataForm = {}
| // this.text = this.stepRouterId
| this.$refs.dialog.open()
| }
|
| },
| getRouteName(id){
| let that = this
| that.id = id
| that.$emit('input', id)
| that.$emit('NodeEvent', id)
| that.$refs.dialog.close()
| },
| async getInfo() {
| // let res = await this.$http.get(`/sys/role/menu?roleId=${this.dataForm.roleId}`)
| // if (res.success) {
| // this.dataForm.menuIdList = res.data
| // }
| },
| // 表单提交
| async formSubmit() {
| let res = await this.$http.post(`/sys/role/menu`, this.dataForm)
| if (res.success) {
| this.$tip.success()
| this.$refs.dialog.close()
| this.$emit('refreshDataList')
| }
| }
| }
| }
| </script>
|
|