2023-04-19 05:20:02 +08:00
|
|
|
import {onSelect} from '../services/dom';
|
|
|
|
import {Component} from './component';
|
2020-07-01 05:12:45 +08:00
|
|
|
|
2022-11-15 07:19:02 +08:00
|
|
|
export class AjaxDeleteRow extends Component {
|
2023-04-19 05:20:02 +08:00
|
|
|
|
2020-07-01 05:12:45 +08:00
|
|
|
setup() {
|
|
|
|
this.row = this.$el;
|
|
|
|
this.url = this.$opts.url;
|
|
|
|
this.deleteButtons = this.$manyRefs.delete;
|
|
|
|
|
|
|
|
onSelect(this.deleteButtons, this.runDelete.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
runDelete() {
|
|
|
|
this.row.style.opacity = '0.7';
|
|
|
|
this.row.style.pointerEvents = 'none';
|
|
|
|
|
|
|
|
window.$http.delete(this.url).then(resp => {
|
|
|
|
if (typeof resp.data === 'object' && resp.data.message) {
|
|
|
|
window.$events.emit('success', resp.data.message);
|
|
|
|
}
|
|
|
|
this.row.remove();
|
2023-04-19 22:20:04 +08:00
|
|
|
}).catch(() => {
|
2020-07-01 05:12:45 +08:00
|
|
|
this.row.style.opacity = null;
|
|
|
|
this.row.style.pointerEvents = null;
|
|
|
|
});
|
|
|
|
}
|
2023-04-19 05:20:02 +08:00
|
|
|
|
|
|
|
}
|