<!-- wyf 2022-5-12 -->
<template>
  <z-form-item
    :label-col="{ style: { width: '120px', paddingRight: '6px' } }"
    :required="formForm?.required === '1'"
    :label="formForm?.headText ? formForm?.headText : basicForm?.titleName || '开关'"
    class="z-form-item"
  >
    <z-switch
      v-model:checked="model[basicForm.field]"
      :checked="formForm.value"
      :disabled="formForm?.disabled === '1'"
    />
  </z-form-item>
</template>
<script>
import { defineComponent, toRef, toRefs } from 'vue'
export default defineComponent({
  name: 'SwitchItem',
  props: {
    formProperty: {
      type: Array,
      default: undefined
    },
    basicProperty: {
      type: Array,
      default: undefined
    },
    formModel: {
      type: Object,
      default: undefined
    }
  },
  setup(props) {
    const basicForm = toRef(props, 'basicProperty')
    const formForm = toRef(props, 'formProperty')
    const model = props.formModel ? toRefs(props.formModel) : {}
    return {
      basicForm,
      formForm,
      model
    }
  }
})

</script>
<style lang="less" scoped>
.z-form-item{
  flex: 1;
}
</style>
