|
|
@@ -20,23 +20,24 @@ $(function () {
|
|
|
let gljLibName = $('#gljLibSels option:selected').text();
|
|
|
let gljLibId = $('#gljLibSels option:selected').val();
|
|
|
let libName = $('#libNameTxt').val();
|
|
|
+ let libCode = $('#libCode').val().trim();
|
|
|
if(libName.trim().length === 0){
|
|
|
alert('名称不可为空!');
|
|
|
$('#libNameTxt').val('')
|
|
|
- }
|
|
|
- else if(dispNames.indexOf(libName) !== -1){
|
|
|
+ } else if (!libCode) {
|
|
|
+ alert('定额编号不可为空');
|
|
|
+ $('#libCode').val('');
|
|
|
+ } else if(dispNames.indexOf(libName) !== -1){
|
|
|
alert('此定额库已存在!');
|
|
|
$('#libNameTxt').val('')
|
|
|
- }
|
|
|
- else if(compilationName.trim().length === 0){
|
|
|
+ } else if(compilationName.trim().length === 0){
|
|
|
alert('编办不可为空!');
|
|
|
- }
|
|
|
- else if(gljLibName.trim().length === 0){
|
|
|
+ } else if(gljLibName.trim().length === 0){
|
|
|
alert("请选择工料机库!");
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else{
|
|
|
let newRationLib = {};
|
|
|
newRationLib.dispName = libName;
|
|
|
+ newRationLib.libCode = libCode; //定额编号,标准数据导出xml需要
|
|
|
newRationLib.compilationId = compilationId;
|
|
|
newRationLib.compilationName = compilationName;
|
|
|
newRationLib.gljLib = gljLibId;
|
|
|
@@ -50,23 +51,29 @@ $(function () {
|
|
|
$("#showArea").on("click", "[data-target = '#edit']", function(){
|
|
|
let renameId = $(this).parent().parent().attr("id");
|
|
|
$('#renameText').val($(this).parent().parent().find('td:first-child').text());
|
|
|
+ $('#renameCode').val($(this).parent().parent().find('td:eq(1)').text());
|
|
|
$("#renameA").attr("renameId", renameId);
|
|
|
});
|
|
|
$("#renameA").click(function(){
|
|
|
let newName = $("#renameText").val();
|
|
|
+ let newLibCode = $('#renameCode').val().trim();
|
|
|
let libId = $(this).attr("renameId");
|
|
|
let jqSel = "#" + libId + " td:first" + " a";
|
|
|
let orgName = $(jqSel).text();
|
|
|
+ let filterName = dispNameArr.filter(function (v) {
|
|
|
+ return v === newName;
|
|
|
+ });
|
|
|
if(newName.trim().length === 0){
|
|
|
alert("名称不可为空!");
|
|
|
$("#renameText").val('');
|
|
|
- }
|
|
|
- else if(dispNameArr.indexOf(newName) !== -1){
|
|
|
+ } else if (!newLibCode) {
|
|
|
+ alert('定额编号不可为空!');
|
|
|
+ $('#renameCode').val('');
|
|
|
+ } else if(filterName.length > 0 && newName !== orgName){
|
|
|
alert("该定额库已存在!");
|
|
|
$("#renameText").val('');
|
|
|
- }
|
|
|
- else{
|
|
|
- renameRationLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
|
|
|
+ } else{
|
|
|
+ renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode}, dispNameArr);
|
|
|
}
|
|
|
});
|
|
|
$('#edit').on('shown.bs.modal', function () {
|
|
|
@@ -277,12 +284,14 @@ function getAllRationLib(callback){
|
|
|
}
|
|
|
let id = result.data[i].ID;
|
|
|
let libName = result.data[i].dispName;
|
|
|
+ let libCode = result.data[i].libCode ? result.data[i].libCode : '';
|
|
|
let createDate = result.data[i].createDate.split(' ')[0];
|
|
|
let compilationName = result.data[i].compilationName;
|
|
|
dispNames.push(result.data[i].dispName);
|
|
|
$("#showArea").append(
|
|
|
"<tr id='"+id+"'>" +
|
|
|
"<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
|
|
|
+ "<td>"+libCode+"</td>" +
|
|
|
"<td>"+compilationName+" </td>" +
|
|
|
"<td>"+createDate+" </td>" +
|
|
|
"<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
|
|
|
@@ -366,10 +375,12 @@ function createRationLib(rationObj, dispNamesArr){
|
|
|
let libName = result.data.dispName;
|
|
|
let createDate = result.data.createDate.split(' ')[0];
|
|
|
let compilationName = result.data.compilationName;
|
|
|
+ let libCode = result.data.libCode ? result.data.libCode : '';
|
|
|
dispNamesArr.push(libName);
|
|
|
$("#showArea").append(
|
|
|
"<tr id='"+id+"'>" +
|
|
|
"<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
|
|
|
+ "<td>"+libCode+" </td>" +
|
|
|
"<td>"+compilationName+" </td>" +
|
|
|
"<td>"+createDate+" </td>" +
|
|
|
"<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
|
|
|
@@ -396,12 +407,14 @@ function renameRationLib(renameObj, dispNames){
|
|
|
if(!result.error){
|
|
|
let jqSel = "#" + renameObj.ID + " td:first" + " a";
|
|
|
$(jqSel).text(renameObj.newName);
|
|
|
+ $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
|
|
|
let index = dispNames.indexOf(renameObj.orgName);
|
|
|
dispNames.splice(index, 1);
|
|
|
dispNames.splice(index, 0, renameObj.newName);
|
|
|
}
|
|
|
$('#editCancelBtn').click();
|
|
|
$('#renameText').val('');
|
|
|
+ $('#renameCode').val('');
|
|
|
}
|
|
|
})
|
|
|
}
|