41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
import BasicComponent from './basic-component';
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
export default BasicComponent.extend({
|
|
tagName: 'a',
|
|
attributeBindings: ['title', 'href', 'role', 'rel'],
|
|
role: 'button',
|
|
rel: 'tooltip',
|
|
href: 'javascript:;',
|
|
enabled: alias('model.active'),
|
|
title: '删除',
|
|
'icon-size-class': 'bigger-120',
|
|
'data-rel': 'tooltip',
|
|
'data-original-title': alias('title'),
|
|
'icon-only': alias('iconOnly'),
|
|
didReceiveAttrs() {
|
|
const me = this;
|
|
if (me.get('icon-only')) {
|
|
me.set('icon-size-class', 'bigger-130');
|
|
me.set('classNameBindings', ['red']);
|
|
}
|
|
else {
|
|
me.set('classNameBindings',
|
|
['icon-only::btn',
|
|
'icon-only::btn-xs']);
|
|
me.set('classNames', ['btn-danger']);
|
|
}
|
|
},
|
|
click() {
|
|
const me = this;
|
|
me.get('dialog').confirm('确认要删除吗?', () => {
|
|
const model = me.get('model');
|
|
me.get('service').del(model).then(() => {
|
|
me.get('route.controller.model.data').removeObject(model);
|
|
me.decrementProperty('route.controller.model.total');
|
|
me.get('message').alert('删除成功');
|
|
});
|
|
});
|
|
}
|
|
});
|