miniUI——弹出框的数据绑定

通用代码片段

function addEditFill(config) {

mini.open({
targetWindow: window,
url: config.url,
title: config.title,
width: "860",
height: "500",
allowResize: false,
showModal: true,
allowDrag: false,
onload: function () {    // 弹出界面加载完成
var iframe = this.getIFrameEl();
var data = config.data;
iframe.contentWindow.editPage.setData(data);    // 调用弹出界面进行初始化
},
ondestroy: function (message) {   //  弹出界面关闭前
if (message == "ok")
fillManageMsg.load();
}



          ondestroy: function () { // 弹出页面关闭前
                var iframe = this.getIFrameEl();
                //获取选中、编辑的结果
                var data = iframe.contentWindow.editPage.getData();
                data = mini.clone(data); // 必须克隆数据
                putawayMsg.updateRow(curRow, data);
                // putawayMsg.reload();
            }



});
}

// 新增

$('#jk-add-fill').on('click', function () {
addEditFill({
title: '新增计划',
url: 'fill_edit.html',
data: ''
});
});

// 双击编辑

fillManageMsg.on('rowdblclick', function (e) {
var rowRecord = e.record;
addEditFill({
title: '修改计划',
url: 'edit.html',
data: rowRecord
});
})

// 编辑

$("#jk-edit-fill").on("click", function () {
var rows = fillManageMsg.getSelecteds();
if (rows.length == 1) {
var fillManageList = rows[0];

addEditFill({
title: '修改计划',
url: 'edit.html',
data: fillManageList
});

} else
mini.alert("请勾选单一数据");
});

// 删除

$("#jk-del-fill").on('click', function () {
var rows = fillManageMsg.getSelecteds();
var ids = rows.map(function (value) {
var output = {};
output._uid = value._uid;
return output;
});
if (rows.length == 0)
mini.alert('未勾选数据');
else {
mini.confirm("确定删除记录?", "确定?",
function (action) {
if (action == "ok") {
var obj = {};
obj.selecteds = ids;
console.log(obj.selecteds)

/**
$.ajax({
url: '',
data: ,
type: 'post',
}).done(result => {
mini.alert(result.msg, '', function () {
gridWaveList.load();
});

}).fail(error => {
mini.alert(error.message);
})
.always(() => {
mini.unmask(document.body);
});
*/
}
}
);
}
});

你可能感兴趣的:(miniUI)