|
@@ -135,19 +135,26 @@ $(document).ready(function() {
|
|
|
|
|
|
//新增定额库
|
|
|
$("#add-ration").click(function () {
|
|
|
- let rationLib = $("select[name='ration_lib']").children("option:selected").val();
|
|
|
- let rationLibString = $("select[name='ration_lib']").children("option:selected").text();
|
|
|
- if (rationLib == undefined || rationLib == '') {
|
|
|
- alert("请选择定额库");
|
|
|
- return;
|
|
|
- }
|
|
|
- if ($("input:hidden[name=ration_lib][data-id = " + rationLib + "]").length <= 0) {
|
|
|
- let tem = {
|
|
|
+ const options = $("select[name='ration_lib']").children("option:selected");
|
|
|
+ let alertArr = [];
|
|
|
+ let htmlString = '';
|
|
|
+ for (const option of options) {
|
|
|
+ const rationLib = $(option).val();
|
|
|
+ const rationLibString = $(option).text();
|
|
|
+ if (!rationLib) {
|
|
|
+ alertString.push(`“${rationLibString}”为无效定额库`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ($("input:hidden[name=ration_lib][data-id = " + rationLib + "]").length > 0) {
|
|
|
+ alertArr.push(`“${rationLibString}”已存在`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ const tem = {
|
|
|
id: rationLib,
|
|
|
name: rationLibString,
|
|
|
isDefault: false
|
|
|
};
|
|
|
- let htmlString = `
|
|
|
+ htmlString += `
|
|
|
<tr class='ration_tr' draggable="true">
|
|
|
<td><span class="cursor-default">${tem.name}</span></td>
|
|
|
<td><label class="form-check-label"> <input class="form-check-input" name="ration_isDefault" value="${tem.id}" type="radio"></td>
|
|
@@ -155,14 +162,28 @@ $(document).ready(function() {
|
|
|
<a class='btn btn-link btn-sm ' style="padding: 0px" onclick='deleteTableTr(this,"ration_tr")'>删除</a>
|
|
|
<input type="hidden" name="ration_lib" data-id="${tem.id}" value='${JSON.stringify(tem)}'>
|
|
|
</td>
|
|
|
- </tr>`
|
|
|
- $("#ration_tbody").append(htmlString);
|
|
|
+ </tr>`;
|
|
|
+ }
|
|
|
+ if (alertArr.length) {
|
|
|
+ alert(alertArr.join('\n'));
|
|
|
} else {
|
|
|
- alert('已存在相同的定额库')
|
|
|
+ $("#ration_tbody").append(htmlString);
|
|
|
+ $("#addRation").modal('hide');
|
|
|
}
|
|
|
- $("#addRation").modal('hide');
|
|
|
});
|
|
|
|
|
|
+ // 复制定额库
|
|
|
+ $('#copy-lib-confirm').click(async function () {
|
|
|
+ try {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ const [valuationID, engineeringID] = window.location.pathname.split('/').slice(-2);
|
|
|
+ await ajaxPost('/compilation/copyRationLibs', { valuationID, engineeringID });
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ } finally {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }
|
|
|
+ });
|
|
|
// 拖动排序
|
|
|
const dragSelector = '.ration_tr[draggable=true]';
|
|
|
const rationBodySelector = '#ration_tbody';
|
|
@@ -550,7 +571,7 @@ function initCompilation() {
|
|
|
let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
|
|
|
html += tmpHtml;
|
|
|
}
|
|
|
- $("select[name='ration_lib']").children("option").first().after(html);
|
|
|
+ $("select[name='ration_lib']").html(html);
|
|
|
|
|
|
// 工料机库
|
|
|
html = '';
|