|
|
|
|
@ -19,8 +19,9 @@
|
|
|
|
|
minRow: 8,
|
|
|
|
|
acceptWidgets: true,
|
|
|
|
|
float: true,
|
|
|
|
|
removable: '#trash',
|
|
|
|
|
});
|
|
|
|
|
GridStack.setupDragIn('#components-panel > .component-item', undefined, [
|
|
|
|
|
GridStack.setupDragIn('#components-panel .component-item', undefined, [
|
|
|
|
|
{
|
|
|
|
|
w: 12,
|
|
|
|
|
h: 2,
|
|
|
|
|
@ -70,6 +71,13 @@
|
|
|
|
|
handleAddComponent(item);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
grid.on('removed', function (_event, itemArray) {
|
|
|
|
|
console.log(itemArray, '这里触发了移除removed事件');
|
|
|
|
|
itemArray.forEach((item) => {
|
|
|
|
|
handleRemoveComponent(item);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 处理添加组件之后的操作
|
|
|
|
|
@ -83,15 +91,27 @@
|
|
|
|
|
}
|
|
|
|
|
currentComponent = component;
|
|
|
|
|
// 右侧显示组件属性列表
|
|
|
|
|
if (!$('#props-panel').find('form').hasClass('show')) {
|
|
|
|
|
$('#props-panel').find('.wait-box').addClass('hidden');
|
|
|
|
|
$('#props-panel').find('form').attr('class', 'show');
|
|
|
|
|
if (!$('#props-panel').find('form').is(':visible')) {
|
|
|
|
|
$('#props-panel').find('.wait-box').hide();
|
|
|
|
|
$('#props-panel').find('form').show();
|
|
|
|
|
}
|
|
|
|
|
// 将当前选中组件的属性显示在右侧列表中
|
|
|
|
|
setCurrentComponentProps(currentComponent);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var handleRemoveComponent = (component) => {
|
|
|
|
|
if (currentComponent && currentComponent.id === component.id) {
|
|
|
|
|
currentComponent = null;
|
|
|
|
|
// 右侧显示请选择组件
|
|
|
|
|
if (!$('#props-panel').find('wait-box').is(':visible')) {
|
|
|
|
|
console.log('111');
|
|
|
|
|
$('#props-panel').find('.wait-box').show();
|
|
|
|
|
$('#props-panel').find('form').hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//将当前选中组件的属性显示在右侧列表中
|
|
|
|
|
var setCurrentComponentProps = function (component) {
|
|
|
|
|
const form = $('#props-panel').find('form');
|
|
|
|
|
@ -168,8 +188,8 @@
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$('.global-save-button').click(function () {
|
|
|
|
|
grid.addWidget({ w: 2, content: 'item 1' });
|
|
|
|
|
$('.save-container').click(function () {
|
|
|
|
|
// grid.addWidget({ w: 2, content: 'item 1' });
|
|
|
|
|
console.log(grid.save());
|
|
|
|
|
console.log(grid);
|
|
|
|
|
});
|
|
|
|
|
|