shiori/view/js/page/base.js
Radhi Fadlillah 5232e0e2c9 Update UI
2018-05-18 14:07:15 +07:00

54 lines
No EOL
1.8 KiB
JavaScript

var Base = function () {
return {
data() {
return {
dialog: {}
}
},
methods: {
_defaultDialog() {
return {
visible: false,
loading: false,
title: '',
content: '',
fields: [],
showLabel: false,
mainText: 'Yes',
secondText: '',
mainClick: () => {
this.dialog.visible = false;
},
secondClick: () => {
this.dialog.visible = false;
}
}
},
showDialog(cfg) {
var base = this._defaultDialog();
base.visible = true;
if (cfg.loading) base.loading = cfg.loading;
if (cfg.title) base.title = cfg.title;
if (cfg.content) base.content = cfg.content;
if (cfg.fields) base.fields = cfg.fields;
if (cfg.showLabel) base.showLabel = cfg.showLabel;
if (cfg.mainText) base.mainText = cfg.mainText;
if (cfg.secondText) base.secondText = cfg.secondText;
if (cfg.mainClick) base.mainClick = cfg.mainClick;
if (cfg.secondClick) base.secondClick = cfg.secondClick;
this.dialog = base;
},
showErrorDialog(msg) {
this.showDialog({
visible: true,
title: 'Error',
content: msg,
mainText: 'OK',
mainClick: () => {
this.dialog.visible = false;
}
});
}
}
}
};