<template>
  <div style="margin:10px 0">
    <el-switch
      :disabled="data.status==='新建' || !tool.checkAuth($route.name,'update') "
      v-model="data.isonsale"
      :active-value="1"
      :inactive-value="0"
      active-color="#3874f6"
      inactive-color="#999"
      @change="setOnsale">
    </el-switch>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {}
  },
  methods:{
    async setOnsale (val) {
      const res = await this.$api.requested({
        "id": 20220923154802,
        "content": {
          "itemids": [
           this.data.itemid
          ],
          "isonsale":val
        }
      })
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
      })
    }
  }
}

</script>
<style>
</style>