element table批量删除_前后端分离Element UI删除和批量删除

批量删除

取消选择

{{ scope.row.name }}

删除

export default {

data() {

return {

multipleSelection: [],

delarr: [], //存放删除的数据

techSort: []

}

},

mounted: function() {

this.getTechSort();

},

methods: {

toggleSelection() {

this.$refs.multipleTable.clearSelection();

},

getTechSort: function() {

var _this = this;

_this.$http({

methods: 'GET',

url: 'http://47.101.51.245:8888/api/news/farmingTechnologySort',

header: {

'content-type': 'application/json'

}

}).then(function(res) {

if (res.data.code == 0) {

_this.techSort = res.data.data;

} else {

console.log(res.data.code);

alert('数据加载失败!');

}

})

},

handleSelectionChange(val) {

this.multipleSelection = val;

},

// 多选删除

delArray: function() {

var _this = this;

const length = this.multipleSelection.length;

for (let i = 0; i < length; i++) {

// console.log(this.multipleSelection[i])

this.delarr.push(this.multipleSelection[i].id);

console.log(this.delarr[i])

}

_this.$http({

method: 'GET',

url: 'http://localhost:8888/advertise2/deleteAll?ids=' + this.delarr,

header: {

'content-type': 'application/json'

}

}).then(function(res) {

if (res.data.code == 0) {

alert('成功!');

_this.getTechSort();

} else {

alert('数据加载失败!');

}

})

},

//单行删除

handleDelete(row) {

var _this = this;

_this.$http({

method: 'GET',

url: 'http://localhost:8888/advertise2/deleteAll?ids=' + row,

header: {

'content-type': 'application/json'

}

}).then(function(res) {

if (res.data.code == 0) {

alert('成功!');

_this.getTechSort();

} else {

alert('数据加载失败!');

}

})

}

}

}

公众号.png


版权声明:本文为weixin_34481252原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。