<template slot-scope="scope">
          <el-switch
            v-model="scope.row.status"
            :active-value="1"
            :inactive-value="0"
            @change="switchChange($event, scope.row)"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </template>

scope.row.status 是后端返回的值   0 或 1     当前状态 0 停用 1 启用

switchChange(e, data) {
        let url = ''
        let message = ''
      if (e == 1) {
        url = '/tpPringTemplate/enable/'
        message = '启用成功 !'
      } else if (e == 0) {
        url = '/tpPringTemplate/disable/'
        message = '停用成功 !'
      }
      this.$ajax.get(`${url + data.ptId}`).then((res) => {
          if (res.code == 0) return this.$message({ type: "success", message });
        });
    },

效果

Logo

前往低代码交流专区

更多推荐