This commit is contained in:
wangyidong
2024-05-30 14:58:02 +08:00
parent 71c7e40397
commit 8a3d4b61db
+36 -6
View File
@@ -39,12 +39,14 @@ function syncModule()
let $copy = $('.form-row.copy').last();
let $branch = $copy.find('.picker-box');
$copy.find('input[id^=modules]').val(module.name);
$copy.find('input[id^=shorts]').val(module.short);
if($branch.length > 0) new zui.Picker($branch, $branchPicker.options);
$copy.find('input[id^=modules]').attr('id', 'modules[]').attr('name', 'modules[]').val(module.name);
$copy.find('input[id^=shorts]').attr('id', 'shorts[]').attr('name', 'shorts[]').val(module.short);
$copy.find('.add-btn').on('click', addItem);
$copy.find('.del-btn').on('click', removeItem);
if($branch.length > 0) new zui.Picker($branch, $.extend({'name': 'branch[]'}, $branchPicker.options));
}
})
})
});
});
}
function syncProduct(obj)
@@ -61,7 +63,35 @@ function syncProduct(obj)
$picker.render({items: items})
$picker.$.setValue('');
})
});
}
window.addItem = function(e)
{
const obj = e.target
const thisRow = $(obj).closest('.form-row');
const newItem = thisRow.clone();
newItem.find('.add-btn').on('click', addItem);
newItem.find('.del-btn').on('click', removeItem);
$newBranch = newItem.find('.picker-box [name^=branch]');
$pickerBox = null;
if($newBranch.length > 0)
{
$pickerBox = $newBranch.closest('.picker-box');
$pickerBox.removeAttr('id').removeAttr('data-zui-picker').empty();
}
$(obj).closest('.form-row').after(newItem);
newItem.find('input[id^=modules]').attr('id', 'modules[]').attr('name', 'modules[]').val('');
newItem.find('input[id^=shorts]').attr('id', 'shorts[]').attr('name', 'shorts[]').val('');
if($pickerBox)
{
$options = thisRow.find('.picker-box [name^=branch]').zui('picker').options;
$pickerBox.picker($.extend({'name': 'branch[]'}, options));
}
}
window.toggleCopy = function()