<template>
  <a-switch :checked="modelValue" :checked-children="checkedText"
    :un-checked-children="unCheckedText" :disabled="see || disabled" @change="handleChange" v-bind="$attrs" />
</template>

<script>
export default {
  name: "PaasSwitch",
  inheritAttrs: false, // 禁用自动继承，手动控制透传
  computed: {
    see() {
      return this.$store?.forms?.see || false;
    }
  },
  props: {
    modelValue: {
      type: [Number, Boolean],
      required: true,
    },
    checkedText: {
      type: String,
      default: "开",
    },
    unCheckedText: {
      type: String,
      default: "关",
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    handleChange(value) {
      // Ant Design Vue 的 a-switch 在 change 事件中返回的是 value（非对象）
      this.$emit("update:modelValue", value);
      this.$emit("change", value);
    },
  },
};
</script>