|
@@ -18,20 +18,21 @@ $(function () {
|
|
|
let gljLibId = $('#gljLibSels option:selected').val();
|
|
|
let libName = $('#libNameTxt').val();
|
|
|
let libCode = $('#libCode').val().trim();
|
|
|
- if(libName.trim().length === 0){
|
|
|
+ const serialNo = +$('#serialNo').val();
|
|
|
+ if (libName.trim().length === 0) {
|
|
|
alert('名称不可为空!');
|
|
|
$('#libNameTxt').val('')
|
|
|
} else if (!libCode) {
|
|
|
alert('定额库编码不可为空');
|
|
|
$('#libCode').val('');
|
|
|
- } else if(allNames.indexOf(libName) !== -1){
|
|
|
+ } else if (allNames.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需要
|
|
@@ -40,37 +41,40 @@ $(function () {
|
|
|
newRationLib.gljLib = gljLibId;
|
|
|
newRationLib.creator = userAccount;
|
|
|
newRationLib.appType = "建筑";
|
|
|
+ newRationLib.serialNo = serialNo;
|
|
|
$('#libNameTxt').val('');
|
|
|
createRationLib(newRationLib);
|
|
|
}
|
|
|
});
|
|
|
//重命名
|
|
|
- $("#showArea").on("click", "[data-target = '#edit']", 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());
|
|
|
+ $('#renameSerialNo').val($(this).parent().parent().find('td:eq(1)').text());
|
|
|
+ $('#renameCode').val($(this).parent().parent().find('td:eq(2)').text());
|
|
|
$("#renameA").attr("renameId", renameId);
|
|
|
});
|
|
|
- $("#renameA").click(function(){
|
|
|
+ $("#renameA").click(function () {
|
|
|
let newName = $("#renameText").val();
|
|
|
let newLibCode = $('#renameCode').val().trim();
|
|
|
+ let newSerialNo = +$('#renameSerialNo').val();
|
|
|
let libId = $(this).attr("renameId");
|
|
|
let jqSel = "#" + libId + " td:first" + " a";
|
|
|
let orgName = $(jqSel).text();
|
|
|
let filterName = allNames.filter(function (v) {
|
|
|
return v === newName;
|
|
|
});
|
|
|
- if(newName.trim().length === 0){
|
|
|
+ if (newName.trim().length === 0) {
|
|
|
alert("名称不可为空!");
|
|
|
$("#renameText").val('');
|
|
|
} else if (!newLibCode) {
|
|
|
alert('定额库编码不可为空!');
|
|
|
$('#renameCode').val('');
|
|
|
- } else if(filterName.length > 0 && newName !== orgName){
|
|
|
+ } else if (filterName.length > 0 && newName !== orgName) {
|
|
|
alert("该定额库已存在!");
|
|
|
$("#renameText").val('');
|
|
|
- } else{
|
|
|
- renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode});
|
|
|
+ } else {
|
|
|
+ renameRationLib({ ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode, newSerialNo });
|
|
|
}
|
|
|
});
|
|
|
$('#edit').on('shown.bs.modal', function () {
|
|
@@ -88,37 +92,37 @@ $(function () {
|
|
|
$('#libNameTxt').val('');
|
|
|
});
|
|
|
//删除
|
|
|
- $("#showArea").on("click", "[data-target = '#del']", function(){
|
|
|
+ $("#showArea").on("click", "[data-target = '#del']", function () {
|
|
|
let deleteId = $(this).parent().parent().attr("id");
|
|
|
$("#deleteA").attr("deleteId", deleteId);
|
|
|
let delLibName = $(`#${deleteId}`).find('td:first').text();
|
|
|
$('#del').find('.modal-body h5').text(`准备删除 “${delLibName}”,会导致已引用此库的地方出错,确定要删除吗?`);
|
|
|
});
|
|
|
- $("#deleteA").click(function(){
|
|
|
+ $("#deleteA").click(function () {
|
|
|
let deleteId = $(this).attr("deleteId");
|
|
|
- if(preDeleteId && preDeleteId !== deleteId){
|
|
|
+ if (preDeleteId && preDeleteId !== deleteId) {
|
|
|
deleteCount = 0;
|
|
|
}
|
|
|
preDeleteId = deleteId;
|
|
|
deleteCount++;
|
|
|
let jqSel = "#" + deleteId + " td:first" + " a";
|
|
|
let libName = $(jqSel).text();
|
|
|
- if(deleteCount === 3){
|
|
|
+ if (deleteCount === 3) {
|
|
|
deleteCount = 0;
|
|
|
- removeRationLib({libId: deleteId, libName: libName});
|
|
|
+ removeRationLib({ libId: deleteId, libName: libName });
|
|
|
$('#del').modal('hide');
|
|
|
}
|
|
|
});
|
|
|
//全部计算
|
|
|
- $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
|
|
|
+ $("#showArea").on("click", "[data-target = '#reCalcAll']", function () {
|
|
|
let recalcId = $(this).parent().parent().attr("id");
|
|
|
$("#reCalcConfirm").attr("recalcId", recalcId);
|
|
|
});
|
|
|
- $("#reCalcConfirm").click(function(){
|
|
|
+ $("#reCalcConfirm").click(function () {
|
|
|
$('#reCalcConfirm').addClass('disabled');
|
|
|
$.bootstrapLoading.start();
|
|
|
let recalcId = $(this).attr("recalcId");
|
|
|
- CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
|
|
|
+ CommonAjax.post('/rationRepository/api/reCalcAll', { rationRepId: recalcId }, function (rstData) {
|
|
|
$.bootstrapLoading.end();
|
|
|
$('#reCalcAll').modal('hide');
|
|
|
$('#reCalcConfirm').removeClass('disabled');
|
|
@@ -168,14 +172,14 @@ $(function () {
|
|
|
});
|
|
|
|
|
|
// 导入原始数据确认
|
|
|
- $("#source-import,#data-import").click(function() {
|
|
|
+ $("#source-import,#data-import").click(function () {
|
|
|
$.bootstrapLoading.start();
|
|
|
const self = $(this);
|
|
|
const type = self.is("#source-import") ? 'source_file' : 'import_data';
|
|
|
const dialog = type === 'source_file' ? $("#import") : $("#import2");
|
|
|
try {
|
|
|
let formData = new FormData();
|
|
|
- let file = $("input[name='"+ type +"']")[0];
|
|
|
+ let file = $("input[name='" + type + "']")[0];
|
|
|
if (file.files.length <= 0) {
|
|
|
throw '请选择文件!';
|
|
|
}
|
|
@@ -193,11 +197,11 @@ $(function () {
|
|
|
cache: false,
|
|
|
contentType: false,
|
|
|
processData: false,
|
|
|
- beforeSend: function() {
|
|
|
+ beforeSend: function () {
|
|
|
self.attr('disabled', 'disabled');
|
|
|
self.text('上传中...');
|
|
|
},
|
|
|
- success: function(response){
|
|
|
+ success: function (response) {
|
|
|
self.removeAttr('disabled');
|
|
|
self.text('确定导入');
|
|
|
if (response.err === 0) {
|
|
@@ -214,19 +218,19 @@ $(function () {
|
|
|
alert(message);
|
|
|
}
|
|
|
},
|
|
|
- error: function(){
|
|
|
+ error: function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
alert("与服务器通信发生错误");
|
|
|
self.removeAttr('disabled');
|
|
|
self.text('确定导入');
|
|
|
}
|
|
|
});
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
alert(error);
|
|
|
}
|
|
|
});
|
|
|
// 导入章节数据确认
|
|
|
- $('#import-section-confirm').click(function() {
|
|
|
+ $('#import-section-confirm').click(function () {
|
|
|
$.bootstrapLoading.start();
|
|
|
const self = $(this);
|
|
|
const dialog = $('#section');
|
|
@@ -250,11 +254,11 @@ $(function () {
|
|
|
cache: false,
|
|
|
contentType: false,
|
|
|
processData: false,
|
|
|
- beforeSend: function() {
|
|
|
+ beforeSend: function () {
|
|
|
self.attr('disabled', 'disabled');
|
|
|
self.text('上传中...');
|
|
|
},
|
|
|
- success: function(response){
|
|
|
+ success: function (response) {
|
|
|
self.removeAttr('disabled');
|
|
|
self.text('确定导入');
|
|
|
if (response.err === 0) {
|
|
@@ -271,14 +275,14 @@ $(function () {
|
|
|
alert(message);
|
|
|
}
|
|
|
},
|
|
|
- error: function(){
|
|
|
+ error: function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
alert("与服务器通信发生错误");
|
|
|
self.removeAttr('disabled');
|
|
|
self.text('确定导入');
|
|
|
}
|
|
|
});
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
alert(error);
|
|
|
}
|
|
|
});
|
|
@@ -323,7 +327,7 @@ $(function () {
|
|
|
return false;
|
|
|
}
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/rationRepository/api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
|
|
|
+ CommonAjax.post('/rationRepository/api/initSectionTemplate', { rationLibId: rationRepId, compilationId: selCompilationId }, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
$('#template').modal('hide');
|
|
|
}, function () {
|
|
@@ -333,25 +337,25 @@ $(function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-function getCompilationList(callback){
|
|
|
+function getCompilationList(callback) {
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/rationRepository/api/getCompilationList',
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
//addoptions
|
|
|
- for(let i = 0; i < result.data.compilation.length; i++){
|
|
|
- let $option = $("<option >"+ result.data.compilation[i].name +"</option>");
|
|
|
- $option.val( result.data.compilation[i]._id);
|
|
|
+ for (let i = 0; i < result.data.compilation.length; i++) {
|
|
|
+ let $option = $("<option >" + result.data.compilation[i].name + "</option>");
|
|
|
+ $option.val(result.data.compilation[i]._id);
|
|
|
$('#compilationSels').append($option);
|
|
|
}
|
|
|
//初始工料机库选项
|
|
|
- if(result.data.compilation.length > 0 && result.data.gljLibs.length > 0){
|
|
|
+ if (result.data.compilation.length > 0 && result.data.gljLibs.length > 0) {
|
|
|
let compilationId = result.data.compilation[0]._id;
|
|
|
//console.log(compilationId);
|
|
|
let gljLibOps = getGljLibOps(compilationId, result.data.gljLibs);
|
|
|
- for(let i = 0; i < gljLibOps.length; i++){
|
|
|
- let $option = $("<option >"+ gljLibOps[i].dispName +"</option>");
|
|
|
+ for (let i = 0; i < gljLibOps.length; i++) {
|
|
|
+ let $option = $("<option >" + gljLibOps[i].dispName + "</option>");
|
|
|
$option.val(gljLibOps[i].ID);
|
|
|
$('#gljLibSels').append($option);
|
|
|
}
|
|
@@ -361,8 +365,8 @@ function getCompilationList(callback){
|
|
|
//刷新工料机库选项
|
|
|
$('#gljLibSels').children().remove();
|
|
|
let newGljLibOps = getGljLibOps(this.selectedOptions[0].value, result.data.gljLibs);
|
|
|
- for(let i = 0; i < newGljLibOps.length; i++){
|
|
|
- let $option = $("<option >"+ newGljLibOps[i].dispName +"</option>");
|
|
|
+ for (let i = 0; i < newGljLibOps.length; i++) {
|
|
|
+ let $option = $("<option >" + newGljLibOps[i].dispName + "</option>");
|
|
|
$option.val(newGljLibOps[i].ID);
|
|
|
$('#gljLibSels').append($option);
|
|
|
}
|
|
@@ -371,11 +375,11 @@ function getCompilationList(callback){
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-function getGljLibOps(compilationId, gljLibs){
|
|
|
+function getGljLibOps(compilationId, gljLibs) {
|
|
|
let rst = [];
|
|
|
- for(let i = 0; i < gljLibs.length; i++){
|
|
|
- if(gljLibs[i]){
|
|
|
- if(compilationId === gljLibs[i].compilationId){
|
|
|
+ for (let i = 0; i < gljLibs.length; i++) {
|
|
|
+ if (gljLibs[i]) {
|
|
|
+ if (compilationId === gljLibs[i].compilationId) {
|
|
|
rst.push(gljLibs[i]);
|
|
|
}
|
|
|
}
|
|
@@ -383,11 +387,11 @@ function getGljLibOps(compilationId, gljLibs){
|
|
|
return rst;
|
|
|
}
|
|
|
|
|
|
-function createRationLib(rationObj){
|
|
|
+function createRationLib(rationObj) {
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/rationRepository/api/addRationRepository',
|
|
|
- data: {rationRepObj: JSON.stringify(rationObj)},
|
|
|
+ data: { rationRepObj: JSON.stringify(rationObj) },
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
window.location.href = location.href;
|
|
@@ -395,17 +399,18 @@ function createRationLib(rationObj){
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-function renameRationLib(renameObj){
|
|
|
+function renameRationLib(renameObj) {
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/rationRepository/api/editRationLibs',
|
|
|
- data: {oprtor: userAccount, renameObj: JSON.stringify(renameObj)},
|
|
|
+ data: { oprtor: userAccount, renameObj: JSON.stringify(renameObj) },
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
- if(!result.error){
|
|
|
+ if (!result.error) {
|
|
|
let jqSel = "#" + renameObj.ID + " td:first" + " a";
|
|
|
$(jqSel).text(renameObj.newName);
|
|
|
- $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
|
|
|
+ $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newSerialNo);
|
|
|
+ $(`#${renameObj.ID} td:eq(2)`).text(renameObj.newLibCode);
|
|
|
let index = allNames.indexOf(renameObj.orgName);
|
|
|
allNames.splice(index, 1);
|
|
|
allNames.splice(index, 0, renameObj.newName);
|
|
@@ -413,19 +418,20 @@ function renameRationLib(renameObj){
|
|
|
$('#editCancelBtn').click();
|
|
|
$('#renameText').val('');
|
|
|
$('#renameCode').val('');
|
|
|
+ $('#renameSerialNo').val('');
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-function removeRationLib(delObj){
|
|
|
+function removeRationLib(delObj) {
|
|
|
$.bootstrapLoading.start();
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: '/rationRepository/api/deleteRationLibs',
|
|
|
- data: {oprtor: userAccount, libId: delObj.libId},
|
|
|
+ data: { oprtor: userAccount, libId: delObj.libId },
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
- if(!result.error){
|
|
|
- var jqSel = "#"+ delObj.libId;
|
|
|
+ if (!result.error) {
|
|
|
+ var jqSel = "#" + delObj.libId;
|
|
|
$(jqSel).remove();
|
|
|
let index = allNames.indexOf(delObj.libName);
|
|
|
allNames.splice(index, 1);
|