55 lines
1.1 KiB
Vue
55 lines
1.1 KiB
Vue
<!--
|
|
* @Author: zwq
|
|
* @Date: 2024-07-01 14:53:55
|
|
* @LastEditors: zwq
|
|
* @LastEditTime: 2024-07-10 10:00:03
|
|
* @Description:
|
|
-->
|
|
<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 {
|
|
state: false
|
|
}
|
|
},
|
|
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() {
|
|
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.factoryId = this.injectData.factoryId
|
|
payload.leaderName = this.injectData.leaderName
|
|
params.payload = payload
|
|
this.$emit('emitData', params)
|
|
}
|
|
}
|
|
}
|
|
</script>
|