2023-08-02 09:17:46 +08:00
|
|
|
<template>
|
|
|
|
<el-switch v-model="state" type="text" size="small" :disabled="readonly" @change="changeHandler" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
injectData: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-10-24 15:16:20 +08:00
|
|
|
state: false
|
2023-08-02 09:17:46 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
readonly() {
|
|
|
|
return !!this.injectData.readonly
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.mapToState()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
mapToState() {
|
|
|
|
if (this.injectData.prop === 'enabled') {
|
|
|
|
this.state = this.injectData.enabled === 1 ? true : false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
changeHandler() {
|
2023-10-24 15:16:20 +08:00
|
|
|
let params = {}
|
|
|
|
let payload = {}
|
|
|
|
params.name = 'state'
|
|
|
|
payload.id = this.injectData.id
|
|
|
|
payload.enabled = this.state ? '1' : '0'
|
|
|
|
payload.code = this.injectData.code
|
|
|
|
payload.name = this.injectData.name
|
|
|
|
payload.leaderId = this.injectData.leaderId
|
|
|
|
params.payload = payload
|
|
|
|
this.$emit('emitData', params)
|
2023-08-02 09:17:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|