<template>
  <el-switch :value="value" active-color="#3874F6" inactive-color="#ff4949" @change="releaseNotice"
    :disabled="!disabled">
  </el-switch>
</template>

<script>
export default {
  props: ['value', "data", "disabled", 'onSuccess'],
  data() {
    return {}
  },
  methods: {
    async releaseNotice() {
      let params = this.data;
      delete (params.children);
      params.isenable = params.isenable == 1 ? 0 : 1;
      params.issystem = true;

      const res = await this.$api.requested({
        "classname": "webmanage.saletool.sharematerial.sharematerialClass",
        "method": "insertOrUpdate",
        "content": { ...params }
      })
      this.tool.showMessage(res)
      res.code === 1 ? this.$emit('onSuccess') : ''
    }
  }
}
</script>