1010 <span class =" text-h6" >Role Create</span >
1111 </v-card-title >
1212 <v-card-text >
13- <v-container v-if =" !loading" >
14- <v-form ref =" form" lazy-validation >
15- <v-row >
16- <v-col cols =" 12" >
17- <v-text-field
18- v-model =" roleModel.name"
19- label =" Role Name"
20- required
21- :error-messages =" errors.name"
22- ></v-text-field >
23- </v-col >
24- <div class =" my-10" ></div >
25- <v-col v-for =" roleItem in roleItems" :key =" roleItem.id" cols =" 6" >
26- <v-switch
27- v-model =" roleModel.roles[roleItem.id]"
28- :label =" roleItem.description"
13+ <v-form ref =" form" lazy-validation >
14+ <v-row justify =" start" >
15+ <v-col cols =" 4" >
16+ <v-row >
17+ <v-col >
18+ <v-text-field
19+ v-model =" roleModel.name"
20+ label =" Role Name"
21+ required
22+ :error-messages =" errors.name"
23+ ></v-text-field >
24+ </v-col >
25+ </v-row >
26+ <v-row >
27+ <v-col >
28+ <v-btn color =" primary" @click =" store" >Create</v-btn >
29+ <v-btn @click =" close" >Close</v-btn >
30+ </v-col >
31+ </v-row >
32+ </v-col >
33+ <v-divider vertical ></v-divider >
34+ <v-col cols =" 8" class =" px-10" >
35+ <v-row >
36+ <v-col cols =" 12" class =" py-0" >
37+ <v-switch
38+ v-model =" isAllSelect"
39+ color =" indigo"
40+ label =" All"
41+ @click =" toggleSwitch"
42+ >
43+ </v-switch >
44+ <v-divider ></v-divider >
45+ </v-col >
46+ <v-col
47+ v-for =" roleItem in roleItems"
48+ :key =" roleItem.id"
49+ cols =" 3"
2950 >
30- </v-switch >
31- </v-col >
32- </v-row >
33- <div class =" my-5" ></div >
34- <v-btn color =" primary" @click =" store" >Create</v-btn >
35- </v-form >
36- </v-container >
51+ <v-switch
52+ v-model =" roleModel.roles[roleItem.id]"
53+ :label =" roleItem.description"
54+ >
55+ <template #label
56+ ><span class =" text-caption font-weight-bold" >
57+ {{ roleItem.description }}</span
58+ ></template
59+ >
60+ </v-switch >
61+ </v-col >
62+ </v-row >
63+ </v-col >
64+ </v-row >
65+ </v-form >
3766 </v-card-text >
3867 <v-card-actions >
3968 <v-spacer ></v-spacer >
@@ -58,6 +87,7 @@ export default {
5887 data () {
5988 return {
6089 loading: false ,
90+ isAllSelect: false ,
6191 roleModel: {
6292 name: ' ' ,
6393 roles: {},
@@ -80,13 +110,14 @@ export default {
80110 ... mapActions (' account' , [' sendMessage' ]),
81111 ... mapActions (' role' , [' storeRole' ]),
82112 close () {
113+ this .resetForm ()
83114 this .errors = {}
84115 this .$emit (' close' )
85116 },
86117 resetForm () {
87118 this .roleModel = {
88119 name: ' ' ,
89- roles: [] ,
120+ roles: {} ,
90121 }
91122 },
92123 async store () {
@@ -126,6 +157,11 @@ export default {
126157 this .close ()
127158 this .loading = false
128159 },
160+ toggleSwitch () {
161+ for (const key in this .roleItems ) {
162+ this .roleModel .roles [this .roleItems [key].id ] = this .isAllSelect
163+ }
164+ },
129165 },
130166}
131167 </script >
0 commit comments