|
|
@@ -3,7 +3,6 @@
|
|
|
*/
|
|
|
|
|
|
$(function () {
|
|
|
- let dispNameArr;
|
|
|
let preDeleteId = null;
|
|
|
let deleteCount = 0;
|
|
|
let selCompilationId,
|
|
|
@@ -11,121 +10,125 @@ $(function () {
|
|
|
$('#del').on('hidden.bs.modal', function () {
|
|
|
deleteCount = 0;
|
|
|
});
|
|
|
- getAllRationLib(function (dispNames) {
|
|
|
- dispNameArr = dispNames;
|
|
|
- //添加
|
|
|
- $('#addBtn').click(function () {
|
|
|
- let compilationName = $('#compilationSels option:selected').text();
|
|
|
- let compilationId = $('#compilationSels option:selected').val();
|
|
|
- let gljLibName = $('#gljLibSels option:selected').text();
|
|
|
- let gljLibId = $('#gljLibSels option:selected').val();
|
|
|
- let libName = $('#libNameTxt').val();
|
|
|
- if(libName.trim().length === 0){
|
|
|
- alert('名称不可为空!');
|
|
|
- $('#libNameTxt').val('')
|
|
|
- }
|
|
|
- else if(dispNames.indexOf(libName) !== -1){
|
|
|
- alert('此定额库已存在!');
|
|
|
- $('#libNameTxt').val('')
|
|
|
- }
|
|
|
- else if(compilationName.trim().length === 0){
|
|
|
- alert('编办不可为空!');
|
|
|
- }
|
|
|
- else if(gljLibName.trim().length === 0){
|
|
|
- alert("请选择工料机库!");
|
|
|
- }
|
|
|
- else{
|
|
|
- let newRationLib = {};
|
|
|
- newRationLib.dispName = libName;
|
|
|
- newRationLib.compilationId = compilationId;
|
|
|
- newRationLib.compilationName = compilationName;
|
|
|
- newRationLib.gljLib = gljLibId;
|
|
|
- newRationLib.creator = userAccount;
|
|
|
- newRationLib.appType = "建筑";
|
|
|
- $('#libNameTxt').val('');
|
|
|
- createRationLib(newRationLib, dispNameArr);
|
|
|
- }
|
|
|
- });
|
|
|
- //重命名
|
|
|
- $("#showArea").on("click", "[data-target = '#edit']", function(){
|
|
|
- let renameId = $(this).parent().parent().attr("id");
|
|
|
- $('#renameText').val($(this).parent().parent().find('td:first-child').text());
|
|
|
- $("#renameA").attr("renameId", renameId);
|
|
|
- });
|
|
|
- $("#renameA").click(function(){
|
|
|
- let newName = $("#renameText").val();
|
|
|
- let libId = $(this).attr("renameId");
|
|
|
- let jqSel = "#" + libId + " td:first" + " a";
|
|
|
- let orgName = $(jqSel).text();
|
|
|
- if(newName.trim().length === 0){
|
|
|
- alert("名称不可为空!");
|
|
|
- $("#renameText").val('');
|
|
|
- }
|
|
|
- else if(dispNameArr.indexOf(newName) !== -1){
|
|
|
- alert("该定额库已存在!");
|
|
|
- $("#renameText").val('');
|
|
|
- }
|
|
|
- else{
|
|
|
- renameRationLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
|
|
|
- }
|
|
|
- });
|
|
|
- $('#edit').on('shown.bs.modal', function () {
|
|
|
- setTimeout(function () {
|
|
|
- $('#renameText').focus();
|
|
|
- }, 100);
|
|
|
- });
|
|
|
-
|
|
|
- $('#add').on('shown.bs.modal', function () {
|
|
|
- setTimeout(function () {
|
|
|
- $('#libNameTxt').focus();
|
|
|
- }, 100);
|
|
|
- });
|
|
|
- $('#add').on('hidden.bs.modal', function () {
|
|
|
+ //添加
|
|
|
+ $('#addBtn').click(function () {
|
|
|
+ let compilationName = $('#compilationSels option:selected').text();
|
|
|
+ let compilationId = $('#compilationSels option:selected').val();
|
|
|
+ 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 (!libCode) {
|
|
|
+ alert('定额编号不可为空');
|
|
|
+ $('#libCode').val('');
|
|
|
+ } else if(allNames.indexOf(libName) !== -1){
|
|
|
+ alert('此定额库已存在!');
|
|
|
+ $('#libNameTxt').val('')
|
|
|
+ } else if(compilationName.trim().length === 0){
|
|
|
+ alert('编办不可为空!');
|
|
|
+ } else if(gljLibName.trim().length === 0){
|
|
|
+ alert("请选择工料机库!");
|
|
|
+ } else{
|
|
|
+ let newRationLib = {};
|
|
|
+ newRationLib.dispName = libName;
|
|
|
+ newRationLib.libCode = libCode; //定额编号,标准数据导出xml需要
|
|
|
+ newRationLib.compilationId = compilationId;
|
|
|
+ newRationLib.compilationName = compilationName;
|
|
|
+ newRationLib.gljLib = gljLibId;
|
|
|
+ newRationLib.creator = userAccount;
|
|
|
+ newRationLib.appType = "建筑";
|
|
|
$('#libNameTxt').val('');
|
|
|
+ createRationLib(newRationLib);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //重命名
|
|
|
+ $("#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 = allNames.filter(function (v) {
|
|
|
+ return v === newName;
|
|
|
});
|
|
|
- //删除
|
|
|
- $("#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(){
|
|
|
- let deleteId = $(this).attr("deleteId");
|
|
|
- if(preDeleteId && preDeleteId !== deleteId){
|
|
|
- deleteCount = 0;
|
|
|
- }
|
|
|
- preDeleteId = deleteId;
|
|
|
- deleteCount++;
|
|
|
- let jqSel = "#" + deleteId + " td:first" + " a";
|
|
|
- let libName = $(jqSel).text();
|
|
|
- if(deleteCount === 3){
|
|
|
- deleteCount = 0;
|
|
|
- removeRationLib({libId: deleteId, libName: libName}, dispNameArr);
|
|
|
- $('#del').modal('hide');
|
|
|
- }
|
|
|
- });
|
|
|
- //全部计算
|
|
|
- $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
|
|
|
- let recalcId = $(this).parent().parent().attr("id");
|
|
|
- $("#reCalcConfirm").attr("recalcId", recalcId);
|
|
|
- });
|
|
|
- $("#reCalcConfirm").click(function(){
|
|
|
- $('#reCalcConfirm').addClass('disabled');
|
|
|
- $.bootstrapLoading.start();
|
|
|
- let recalcId = $(this).attr("recalcId");
|
|
|
- CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- $('#reCalcAll').modal('hide');
|
|
|
- $('#reCalcConfirm').removeClass('disabled');
|
|
|
- }, function () {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- $('#reCalcAll').modal('hide');
|
|
|
- $('#reCalcConfirm').removeClass('disabled')
|
|
|
- });
|
|
|
- });
|
|
|
+ if(newName.trim().length === 0){
|
|
|
+ alert("名称不可为空!");
|
|
|
+ $("#renameText").val('');
|
|
|
+ } else if (!newLibCode) {
|
|
|
+ alert('定额编号不可为空!');
|
|
|
+ $('#renameCode').val('');
|
|
|
+ } else if(filterName.length > 0 && newName !== orgName){
|
|
|
+ alert("该定额库已存在!");
|
|
|
+ $("#renameText").val('');
|
|
|
+ } else{
|
|
|
+ renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#edit').on('shown.bs.modal', function () {
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#renameText').focus();
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
|
|
|
+ $('#add').on('shown.bs.modal', function () {
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#libNameTxt').focus();
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+ $('#add').on('hidden.bs.modal', function () {
|
|
|
+ $('#libNameTxt').val('');
|
|
|
+ });
|
|
|
+ //删除
|
|
|
+ $("#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(){
|
|
|
+ let deleteId = $(this).attr("deleteId");
|
|
|
+ if(preDeleteId && preDeleteId !== deleteId){
|
|
|
+ deleteCount = 0;
|
|
|
+ }
|
|
|
+ preDeleteId = deleteId;
|
|
|
+ deleteCount++;
|
|
|
+ let jqSel = "#" + deleteId + " td:first" + " a";
|
|
|
+ let libName = $(jqSel).text();
|
|
|
+ if(deleteCount === 3){
|
|
|
+ deleteCount = 0;
|
|
|
+ removeRationLib({libId: deleteId, libName: libName});
|
|
|
+ $('#del').modal('hide');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //全部计算
|
|
|
+ $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
|
|
|
+ let recalcId = $(this).parent().parent().attr("id");
|
|
|
+ $("#reCalcConfirm").attr("recalcId", recalcId);
|
|
|
+ });
|
|
|
+ $("#reCalcConfirm").click(function(){
|
|
|
+ $('#reCalcConfirm').addClass('disabled');
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ let recalcId = $(this).attr("recalcId");
|
|
|
+ CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ $('#reCalcAll').modal('hide');
|
|
|
+ $('#reCalcConfirm').removeClass('disabled');
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ $('#reCalcAll').modal('hide');
|
|
|
+ $('#reCalcConfirm').removeClass('disabled')
|
|
|
+ });
|
|
|
});
|
|
|
+
|
|
|
getCompilationList(function (data) {
|
|
|
compilationsArr = data.compilation;
|
|
|
});
|
|
|
@@ -240,7 +243,7 @@ $(function () {
|
|
|
});
|
|
|
$('#compilations').change(function () {
|
|
|
selCompilationId = $(this).select().val();
|
|
|
- CommonAjax.get(`api/sectionTemplateCount/${selCompilationId}`, function (rstData) {
|
|
|
+ CommonAjax.get(`/rationRepository/api/sectionTemplateCount/${selCompilationId}`, function (rstData) {
|
|
|
rstData.data.count > 0 ?
|
|
|
$('#templateText').text('该费用定额下已有定额章节树模板数据,是否确认覆盖数据?') :
|
|
|
$('#templateText').text('确认是否将此库的章节树设置成该费用定额下补充定额章节树模板?');
|
|
|
@@ -252,7 +255,7 @@ $(function () {
|
|
|
return false;
|
|
|
}
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post('api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
|
|
|
+ CommonAjax.post('/rationRepository/api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
|
|
|
$.bootstrapLoading.end();
|
|
|
$('#template').modal('hide');
|
|
|
}, function () {
|
|
|
@@ -262,48 +265,10 @@ $(function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-function getAllRationLib(callback){
|
|
|
- $.ajax({
|
|
|
- type: 'post',
|
|
|
- url: 'api/getRationDisplayNames',
|
|
|
- dataType: 'json',
|
|
|
- success: function (result) {
|
|
|
- let dispNames = [];
|
|
|
- if(result.data.length > 0){
|
|
|
- for(let i = 0; i < result.data.length; i++){
|
|
|
- storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data[i].ID, result.data[i].dispName);
|
|
|
- if(result.data[i].gljLib){
|
|
|
- storageUtil.setSessionCache("gljLib","repositoryID_" + result.data[i].ID, result.data[i].gljLib);
|
|
|
- }
|
|
|
- let id = result.data[i].ID;
|
|
|
- let libName = result.data[i].dispName;
|
|
|
- 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>"+compilationName+" </td>" +
|
|
|
- "<td>"+createDate+" </td>" +
|
|
|
- "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
|
|
|
- "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
|
|
|
- "<i class='fa fa-remove'></i></a>" +
|
|
|
- " <a href='javascript:void(0);' data-toggle='modal' data-target='#reCalcAll' title='全部计算'><i class='fa fa-calculator'></i></a></td>"+
|
|
|
- "<td><a class='btn btn-secondary btn-sm import-source' href='javacript:void(0);' data-id='"+ id +"' title='导入原始数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
|
|
|
- "<td><a class='btn btn-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ id +"' data-target='#emport' title='导出内部数据'><i class='fa fa-sign-out fa-rotate-270'></i>导出</a> " +
|
|
|
- "<a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入内部数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
|
|
|
- "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将章节树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
|
|
|
- "</tr>");
|
|
|
- }
|
|
|
- }
|
|
|
- callback(dispNames);
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
function getCompilationList(callback){
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
- url: 'api/getCompilationList',
|
|
|
+ url: '/rationRepository/api/getCompilationList',
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
//addoptions
|
|
|
@@ -350,74 +315,52 @@ function getGljLibOps(compilationId, gljLibs){
|
|
|
return rst;
|
|
|
}
|
|
|
|
|
|
-function createRationLib(rationObj, dispNamesArr){
|
|
|
+function createRationLib(rationObj){
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
- url: 'api/addRationRepository',
|
|
|
+ url: '/rationRepository/api/addRationRepository',
|
|
|
data: {rationRepObj: JSON.stringify(rationObj)},
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
- if(result.data){
|
|
|
- storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data.ID, result.data.dispName);
|
|
|
- if(result.data.gljLib){
|
|
|
- storageUtil.setSessionCache("gljLib","repositoryID_" + result.data.ID, result.data.gljLib);
|
|
|
- }
|
|
|
- let id = result.data.ID;
|
|
|
- let libName = result.data.dispName;
|
|
|
- let createDate = result.data.createDate.split(' ')[0];
|
|
|
- let compilationName = result.data.compilationName;
|
|
|
- dispNamesArr.push(libName);
|
|
|
- $("#showArea").append(
|
|
|
- "<tr id='"+id+"'>" +
|
|
|
- "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
|
|
|
- "<td>"+compilationName+" </td>" +
|
|
|
- "<td>"+createDate+" </td>" +
|
|
|
- "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
|
|
|
- "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
|
|
|
- "<i class='fa fa-remove'></i></a>" +
|
|
|
- " <a href='javascript:void(0);' data-toggle='modal' data-target='#reCalcAll' title='全部计算'><i class='fa fa-calculator'></i></a>"+
|
|
|
- "<td><a class='btn btn-secondary btn-sm import-source' href='javacript:void(0);' data-id='"+ id +"' title='导入原始数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
|
|
|
- "<td><a class='btn btn-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ id +"' data-target='#emport' title='导出内部数据'><i class='fa fa-sign-out fa-rotate-270'></i>导出</a> " +
|
|
|
- "<a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入内部数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
|
|
|
- "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将章节树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
|
|
|
- "</tr>");
|
|
|
- }
|
|
|
+ window.location.href = location.href;
|
|
|
$('#cancelBtn').click();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-function renameRationLib(renameObj, dispNames){
|
|
|
+function renameRationLib(renameObj){
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
- url: 'api/editRationLibs',
|
|
|
+ url: '/rationRepository/api/editRationLibs',
|
|
|
data: {oprtor: userAccount, renameObj: JSON.stringify(renameObj)},
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
if(!result.error){
|
|
|
let jqSel = "#" + renameObj.ID + " td:first" + " a";
|
|
|
$(jqSel).text(renameObj.newName);
|
|
|
- let index = dispNames.indexOf(renameObj.orgName);
|
|
|
- dispNames.splice(index, 1);
|
|
|
- dispNames.splice(index, 0, renameObj.newName);
|
|
|
+ $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
|
|
|
+ let index = allNames.indexOf(renameObj.orgName);
|
|
|
+ allNames.splice(index, 1);
|
|
|
+ allNames.splice(index, 0, renameObj.newName);
|
|
|
}
|
|
|
$('#editCancelBtn').click();
|
|
|
$('#renameText').val('');
|
|
|
+ $('#renameCode').val('');
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-function removeRationLib(delObj, dispNames){
|
|
|
+function removeRationLib(delObj){
|
|
|
$.bootstrapLoading.start();
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
- url: 'api/deleteRationLibs',
|
|
|
+ url: '/rationRepository/api/deleteRationLibs',
|
|
|
data: {oprtor: userAccount, libId: delObj.libId},
|
|
|
dataType: 'json',
|
|
|
success: function (result) {
|
|
|
if(!result.error){
|
|
|
var jqSel = "#"+ delObj.libId;
|
|
|
$(jqSel).remove();
|
|
|
- let index = dispNames.indexOf(delObj.libName);
|
|
|
- dispNames.splice(index, 1);
|
|
|
+ let index = allNames.indexOf(delObj.libName);
|
|
|
+ allNames.splice(index, 1);
|
|
|
$('#delCancelBtn').click();
|
|
|
}
|
|
|
$.bootstrapLoading.end();
|