vue element ui 删除用户封装包含接口请求

vue yekong

vue element ui 删除用户封装

使用实例

<deleteUser @getdata="getList" :id="scope.row.id"></deleteUser>

组件代码

/**
* @Author: 858834013@qq.com
* @Name: deleteUser
* @Date: 2022-05-04
* @Desc: 删除用户
*/
<template>
  <div>
    <el-button @click="deleteUser" class="ml20" type="danger" size="small">删除</el-button>
  </div>
</template>
<script>
import { userEdit } from '@/api/user'

export default {
  name: 'deleteUser',
  props: {
    id: {
      type: String | Number,
      default() {
        return ''
      }
    }
  },
  methods: {
    deleteUser() {
      var that = this
      that.$confirm(' 是否删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          id: that.id,
          status: '1'
        }
        userEdit(params).then(function(res) {
          if (res.code == 200) {
            that.$message({
              type: 'success',
              message: '操作成功'
            })
            that.show = false
            that.$emit('getdata', 1)
          }
        })
      }).catch(() => {
        that.$message({
          type: 'info',
          message: '已取消'
        })
      })
    }
  }
}
</script>

喜欢