function PowerPackageComponent(option) {
var _el = option.el;
var _packages = option.packages;
this.app = new Vue({
el: _el,
template: `
`
,
data: {
info: {
dialogIndex: 0,
dialogOpen: false,
dialogData: {},
packages: []
},
},
mounted: function () {
var that = this
that.initPackages();
},
computed: {},
filters: {},
methods: {
initPackages: function () {
this.info.packages = _packages;
},
editPackageRule: function (obj, index) {
this.info.dialogIndex = index;
this.info.dialogOpen = true;
this.info.dialogData = $.extend(true, {}, obj);
$("body").addClass("over-hide");//避免滚动穿透,直接禁止body滚动
},
deletePackageRule: function (obj, index) {
var that = this;
var tnArray = ['取消', '确认'];
mui.confirm('确定要删除该套餐?', '温馨提示', tnArray, function (e) {
if (e.index == 0) {
} else {
//点击确认业务
that.info.packages.splice(index, 1);
}
});
},
closeRulePanel: function () {
this.info.dialogOpen = false;
$("body").removeClass("over-hide");//恢复body滚动
},
savePackageRule: function () {
var dialogData = this.info.dialogData;
if ($.trim(dialogData.power) == '') {
mui.toast("功率不能为空");
return;
}
if ($.trim(dialogData.price) === '') {
mui.toast("价格不能为空");
return;
}
if (!dialogData.time) {
mui.toast("时间不能为空");
return;
}
this.info.packages[this.info.dialogIndex] = $.extend(true, {}, this.info.dialogData);
this.info.dialogOpen = false;
$("body").removeClass("over-hide");//恢复body滚动
},
addPackageRule: function () {
this.info.dialogIndex = this.info.packages.length;
this.info.dialogOpen = true;
$("body").addClass("over-hide");//避免滚动穿透,直接禁止body滚动
this.info.dialogData = {
};
},
}
});
}
PowerPackageComponent.prototype.getPackages = function () {
return this.app.info.packages;
};