forked from sachatrauwaen/vuecrud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckboxGroup.vue
70 lines (69 loc) · 1.89 KB
/
checkboxGroup.vue
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
<template>
<el-checkbox-group v-model="model">
<el-checkbox v-for="item in options" :label="item.value" :key="item.value">{{item.label}}</el-checkbox>
</el-checkbox-group>
</template>
<script>
export default {
name: 'oa-checkbox-group',
props: {
value: {
type: Array,
default: function () {
return []
}
},
schema: {},
prop: String
},
data: function () {
return {
options: []
}
},
computed: {
model: {
get: function () {
return this.value
},
set: function (val) {
this.$emit('input', val)
}
},
resource: function () {
return this.$route.params.resource
}
},
created: function () {
var self = this
var enumAction = this.schema['x-enum-action']
if (enumAction) {
var enumValueField = this.schema['x-enum-valuefield']
var enumTextField =
this.schema['x-enum-textfield'] || this.schema['x-enum-valuefield']
var service = abp.services.app[self.resource][enumAction]
service()
.done(function (data) {
self.options = data.items.map(function (p) {
return {
value: p[enumValueField],
label: p[enumTextField]
}
})
})
.always(function () {
// abp.ui.clearBusy(_$app);
})
} else if (this.schema.enum) {
this.options = this.schema.enum.map(function (val) {
return {
value: val,
label: val
}
})
} else {
return []
}
}
}
</script>