yoqw/web/cms/app/services/dialog.js
2020-07-01 15:22:07 +08:00

67 lines
1.7 KiB
JavaScript

import Service from '@ember/service';
import $ from 'jquery'
import isEmpty from '../utils/is-empty'
export default Service.extend({
alert(msg) {
bootbox.alert(msg);
},
error(msg, fnClose) {
bootbox.dialog({
message: msg,
buttons: {
danger: {
label: '关闭',
className: 'btn-danger',
callback: fnClose || $.noop
}
}
});
},
confirm(msg, fnYes, fnNo) {
bootbox.dialog({
message: msg,
buttons: {
success: {
label: '确定',
className: 'btn-success',
callback: fnYes
},
danger: {
label: '取消',
className: 'btn-danger',
callback: fnNo || $.noop
}
}
});
},
prompt(title,fnYes, fnNo) {
bootbox.prompt({
title: title,
inputType: "textarea",
callback: reason => {
if(isEmpty(reason)){
bootbox.alert('已取消');
}else{
fnYes(reason);
}
},
buttons: {
confirm: {
label: '确定',
className: 'btn-success',
callback: fnYes
},
cancel: {
label: '取消',
className: 'btn-danger',
callback: fnNo || $.noop
}
}
});
},
dialog(config) {
bootbox.dialog(config);
}
});