12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <template>
- <el-radio-group v-model="radio" @change="change">
- <el-radio :label="1">在线</el-radio>
- <el-radio :label="0">休眠</el-radio>
- </el-radio-group>
- </template>
- <script setup>
- import { otherEquipState } from '@/api/base/equipment.js'
- import { nextTick, ref, onMounted } from 'vue'
- const emit = defineEmits();
- const radio = ref(null)
- const props = defineProps({
- propConfig:{},
- propValue:{},
- parentValue:{}
- })
- const setValue = data => {
- radio.value = data ? data : 0
- }
- const getValue = () => {
- return radio.value
- }
- const change = () => {
- emit('onChange',radio.value);
- if(props.parentValue.equipmentCode&&props.parentValue.equipmentId){
- otherEquipState({
- equipmentCode:props.parentValue.equipmentCode,
- change:radio.value ? true : false
- }).then(() => {
- proxy.$message({
- message:'设备状态更新成功!',
- type:'success'
- });
- }).catch(() => {
- proxy.$message({
- message:'设备状态更新失败!',
- type:'error'
- });
- })
- }
-
- }
- defineExpose({
- setValue,getValue
- })
- // const onMounted = () =>{
- // nextTick(() => {
- // if(props.parentValue && Number(props.parentValue.onState) >= 0){
- // setValue(props.parentValue.onState)
- // }else{
- // radio.value = 1
- // change()
- // }
- // })
- // }
-
-
- </script>
- <style lang="scss" scoped>
- </style>
|