|
@@ -1,45 +1,58 @@
|
|
|
/**
|
|
|
* Created by Syusuke on 2017/3/17.
|
|
|
*/
|
|
|
-var rationLibName = getQueryString("rationname");//获取定额库参数
|
|
|
function getQueryString(key){
|
|
|
var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)");
|
|
|
var result = window.location.search.substr(1).match(reg);
|
|
|
return result?decodeURIComponent(result[2]):null;
|
|
|
}
|
|
|
+//---------------------------------------------------页面跳转
|
|
|
+var params = {}
|
|
|
+$("#dinge").click(function(){
|
|
|
+ $(this).attr('href', "/rationLibEditor/rationLib" + "?params=" + JSON.stringify(params))
|
|
|
+})
|
|
|
+$("#gongliao").click(function(){
|
|
|
+ $(this).attr('href', "/rationLibEditor/gongliao" + "?params=" + JSON.stringify(params))
|
|
|
+});
|
|
|
//----------------------------------------------------页面初始化
|
|
|
-var properties = {};//综合属性
|
|
|
-properties.sectionSelected = "";//选择的章节
|
|
|
-properties.rationSelected = "";//选择的定额
|
|
|
-function getRealLib(){
|
|
|
+$(document).ready(function(){
|
|
|
+ initParam();
|
|
|
+ mkRationItemSpread();
|
|
|
+});
|
|
|
+function initParam(){
|
|
|
+ var rationLibName = getQueryString("rationname");//获取定额库参数
|
|
|
+ if(rationLibName)
|
|
|
+ getRealLib(rationLibName);
|
|
|
+ else{
|
|
|
+ params = JSON.parse(getQueryString("params"));
|
|
|
+ getRationTree();
|
|
|
+ }
|
|
|
+}
|
|
|
+function getRealLib(LibName){
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url:"http://localhost:6060/rationLibEditor/getRealLibName",
|
|
|
- data:{"rationName":rationLibName},
|
|
|
+ data:{"rationName":LibName},
|
|
|
async:false,
|
|
|
dataType:"json",
|
|
|
cache:false,
|
|
|
timeout:1000,
|
|
|
success:function(result){
|
|
|
- properties.realLibName = result.data[0].DBName
|
|
|
+ params.realLibName = result.data[0].dbName
|
|
|
+ getRationTree();
|
|
|
},
|
|
|
error:function(){}
|
|
|
})
|
|
|
}
|
|
|
-$(document).ready(function(){
|
|
|
- getRealLib();
|
|
|
- getRationTree();
|
|
|
- mkRationItemSpread();
|
|
|
-});
|
|
|
//---------------------------------------------------初始化章节树界面
|
|
|
function getRationTree(){
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url:"http://localhost:6060/rationLibEditor/getRationTree",
|
|
|
- data:{"rationLibName": properties.realLibName},
|
|
|
+ data:{"rationLibName": params.realLibName},
|
|
|
dataType:"json",
|
|
|
cache:false,
|
|
|
- timeout:500000,
|
|
|
+ timeout:20000,
|
|
|
success:function(result,textStatus,status){
|
|
|
if(status.status == 200) createRationTree(result.data);//根据返回的全部定额章节对象,构架树。
|
|
|
else{
|
|
@@ -47,8 +60,8 @@ function getRationTree(){
|
|
|
saveTempTree();
|
|
|
}
|
|
|
},
|
|
|
- error:function(){
|
|
|
- alert("caonima")
|
|
|
+ error:function(err){
|
|
|
+ alert(err.responseText.error)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -65,13 +78,13 @@ function createRationTree(obj){
|
|
|
function makeNodes(obj){
|
|
|
var arr=[];
|
|
|
arr = obj.filter(function(x){
|
|
|
- return x.ParentID==0
|
|
|
+ return x.parentId==0
|
|
|
})
|
|
|
arr.forEach(function(x){
|
|
|
- x.id = x.SectionID;
|
|
|
- x.pId = x.ParentID;
|
|
|
- x.nId = x.NextSiblingID;
|
|
|
- x.name = x.Name;
|
|
|
+ x.id = x.sectionId;
|
|
|
+ x.pId = x.parentId;
|
|
|
+ x.nId = x.nextSiblingId;
|
|
|
+ x.name = x.name;
|
|
|
x.isParent = true
|
|
|
x.lev = 0
|
|
|
});
|
|
@@ -79,13 +92,13 @@ function makeNodes(obj){
|
|
|
for(var i=0;i<arr.length;i++){
|
|
|
var L1 = [];
|
|
|
L1 = obj.filter(function(x){
|
|
|
- return x.ParentID ==arr[i].id;
|
|
|
+ return x.parentId ==arr[i].id;
|
|
|
});
|
|
|
L1.forEach(function(x){
|
|
|
- x.id = x.SectionID;
|
|
|
- x.pId = x.ParentID;
|
|
|
- x.nId = x.NextSiblingID;
|
|
|
- x.name = x.Name;
|
|
|
+ x.id = x.sectionId;
|
|
|
+ x.pId = x.parentId;
|
|
|
+ x.nId = x.nextSiblingId;
|
|
|
+ x.name = x.name;
|
|
|
x.isParent = true
|
|
|
x.lev = 1
|
|
|
});
|
|
@@ -93,13 +106,13 @@ function makeNodes(obj){
|
|
|
for(var j=0; j<L1.length;j++){
|
|
|
var L2 = [];
|
|
|
L2 =obj.filter(function(x){
|
|
|
- return x.ParentID == L1[j].id;
|
|
|
+ return x.parentId == L1[j].id;
|
|
|
})
|
|
|
L2.forEach(function(x){
|
|
|
- x.id = x.SectionID;
|
|
|
- x.pId = x.ParentID;
|
|
|
- x.nId = x.NextSiblingID;
|
|
|
- x.name = x.Name;
|
|
|
+ x.id = x.sectionId;
|
|
|
+ x.pId = x.parentId;
|
|
|
+ x.nId = x.nextSiblingId;
|
|
|
+ x.name = x.name;
|
|
|
x.isParent = false;
|
|
|
x.lev = 2
|
|
|
})
|
|
@@ -113,11 +126,11 @@ function makeNodes(obj){
|
|
|
function sortArray(arr){
|
|
|
var a = [];
|
|
|
for(var i=0;i<arr.length;i++)
|
|
|
- if (arr[i].NextSiblingID == -1)
|
|
|
+ if (arr[i].nextSiblingId == -1)
|
|
|
a.push(arr[i])
|
|
|
for(; a.length < arr.length;){
|
|
|
for(var j=0;j<arr.length;j++) {
|
|
|
- if (arr[j].NextSiblingID == a[0].SectionID)
|
|
|
+ if (arr[j].nextSiblingId == a[0].sectionId)
|
|
|
{a.unshift(arr[j]); break;}
|
|
|
}
|
|
|
}
|
|
@@ -128,11 +141,11 @@ function saveTempTree(){
|
|
|
var N = []
|
|
|
for(i=0;i<zNodes.length;i++){
|
|
|
var node ={}
|
|
|
- node.SectionID = zNodes[i].id;
|
|
|
- node.ParentID = zNodes[i].pId;
|
|
|
+ node.sectionId = zNodes[i].id;
|
|
|
+ node.parentId = zNodes[i].pId;
|
|
|
|
|
|
- node.NextSiblingID = zNodes[i].nId;
|
|
|
- node.Name =zNodes[i].name;
|
|
|
+ node.nextSiblingId = zNodes[i].nId;
|
|
|
+ node.name =zNodes[i].name;
|
|
|
N.push(node);
|
|
|
}
|
|
|
var rationTempTree = JSON.stringify(N)
|
|
@@ -143,12 +156,8 @@ function saveTempTree(){
|
|
|
dataType:"json",
|
|
|
cache:false,
|
|
|
timeout:1000,
|
|
|
- success:function(result){
|
|
|
-
|
|
|
- },
|
|
|
- error:function(){
|
|
|
-
|
|
|
- }
|
|
|
+ success:function(result,textStatus,status){},
|
|
|
+ error:function(){}
|
|
|
})
|
|
|
}
|
|
|
//--------------------------------------------------------树处理事件
|
|
@@ -183,19 +192,19 @@ function addHoverDom(treeId, treeNode) {
|
|
|
//保存新增的节点
|
|
|
function saveNewSection(n){
|
|
|
var sec={};
|
|
|
- sec.SectionID = n.id;
|
|
|
- sec.ParentID = n.pId;
|
|
|
- sec.NextSiblingID = n.nId;
|
|
|
- sec.Name = n.name;
|
|
|
+ sec.sectionId = n.id;
|
|
|
+ sec.parentId = n.pId;
|
|
|
+ sec.nextSiblingId = n.nId;
|
|
|
+ sec.name = n.name;
|
|
|
var section = JSON.stringify(sec);
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url:"http://localhost:6060/rationLibEditor/addSection",
|
|
|
- data:{"rationLibName":properties.realLibName,"rationSection":section},
|
|
|
+ data:{"rationLibName":params.realLibName,"rationSection":section},
|
|
|
dataType:"json",
|
|
|
cache:false,
|
|
|
timeout:1000,
|
|
|
- success:function(result){
|
|
|
+ success:function(result,textStatus,status){
|
|
|
},
|
|
|
error:function(){
|
|
|
}
|
|
@@ -217,11 +226,11 @@ function onRemove(e, treeId, treeNode) {
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url:"http://localhost:6060/rationLibEditor/deleteSection",
|
|
|
- data:{"rationLibName":properties.realLibName,"sectionID": treeNode.id},
|
|
|
+ data:{"rationLibName":params.realLibName,"sectionID": treeNode.id},
|
|
|
dataType:"json",
|
|
|
cache:false,
|
|
|
timeout:1000,
|
|
|
- success:function(result){
|
|
|
+ success:function(result,textStatus,status){
|
|
|
//if(result){
|
|
|
// caseDeleteTreeNode(result.data)
|
|
|
//}
|
|
@@ -236,6 +245,14 @@ function onRemove(e, treeId, treeNode) {
|
|
|
//--------------------------------------------------------定额spreadjs
|
|
|
var spSetting_ration = {
|
|
|
spType:"Ration",
|
|
|
+ header:[
|
|
|
+ {headerName:"编码",headerWidth:120,data:"rationCode"},
|
|
|
+ {headerName:"名称",headerWidth:400,data:"rationName"},
|
|
|
+ {headerName:"单位",headerWidth:120,data:"unit"},
|
|
|
+ {headerName:"基价",headerWidth:120,data:"basePrice"},
|
|
|
+ {headerName:"显示名称(以%s表示参数)",headerWidth:450,data:"caption"},
|
|
|
+ {headerName:"取费专业",headerWidth:120,data:"feeType"}
|
|
|
+ ],
|
|
|
view:{
|
|
|
comboBox:[
|
|
|
{row:-1,col:2,rowCount:-1,colCount:1}
|
|
@@ -247,6 +264,15 @@ var spSetting_ration = {
|
|
|
};
|
|
|
var spSetting_rationGLJ = {
|
|
|
spType:"RationGLJ",
|
|
|
+ header:[
|
|
|
+ {headerName:"编码",headerWidth:160},
|
|
|
+ {headerName:"名称",headerWidth:400},
|
|
|
+ {headerName:"单位",headerWidth:160},
|
|
|
+ {headerName:"单位基价",headerWidth:160},
|
|
|
+ {headerName:"定额消耗",headerWidth:160},
|
|
|
+ {headerName:"类型",headerWidth:160},
|
|
|
+ {headerName:"操作",headerWidth:130}
|
|
|
+ ],
|
|
|
view:{
|
|
|
comboBox:[],
|
|
|
lockedCells:[
|
|
@@ -258,90 +284,7 @@ var spSetting_rationGLJ = {
|
|
|
]
|
|
|
}
|
|
|
};
|
|
|
-var ration_header = [
|
|
|
- {headerName:"编码",headerWidth:120},
|
|
|
- {headerName:"名称",headerWidth:400},
|
|
|
- {headerName:"单位",headerWidth:120},
|
|
|
- {headerName:"基价",headerWidth:120},
|
|
|
- {headerName:"显示名称(以%s表示参数)",headerWidth:450},
|
|
|
- {headerName:"取费专业",headerWidth:120}
|
|
|
-]
|
|
|
-var rationGLJ_header = [
|
|
|
- {headerName:"编码",headerWidth:160},
|
|
|
- {headerName:"名称",headerWidth:400},
|
|
|
- {headerName:"单位",headerWidth:160},
|
|
|
- {headerName:"单位基价",headerWidth:160},
|
|
|
- {headerName:"定额消耗",headerWidth:160},
|
|
|
- {headerName:"类型",headerWidth:160},
|
|
|
- {headerName:"操作",headerWidth:130}
|
|
|
-]
|
|
|
-function editRationStarting(spread_setting,args){
|
|
|
- properties.rationSelected = args.editingText;
|
|
|
-}
|
|
|
-function editRationEnding(spread,spread_setting,args){
|
|
|
- if(spread_setting.event.remove)
|
|
|
- Remove(spread_setting,args);
|
|
|
- else{
|
|
|
- var ActiveSheet = spread.getActiveSheet();
|
|
|
- var rationItem = {}
|
|
|
- // rationItem.RationCode = ActiveSheet.getValue(args.row,0);
|
|
|
- rationItem.RationCode = args.editingText;
|
|
|
- rationItem.RationName = ActiveSheet.getValue(args.row,1);
|
|
|
- rationItem.Unit = ActiveSheet.getValue(args.row,2);
|
|
|
- rationItem.BasePrice = Number(ActiveSheet.getValue(args.row,3));
|
|
|
- if(properties.sectionSelected = "")
|
|
|
- {
|
|
|
- alert("请选择章节点")
|
|
|
- return;
|
|
|
- }
|
|
|
- else
|
|
|
- rationItem.SectionID = properties.sectionSelected;
|
|
|
- rationItem.ContentID = 0;
|
|
|
- rationItem.Caption = ActiveSheet.getValue(args.row,4);
|
|
|
- rationItem.FeeType = Number(ActiveSheet.getValue(args.row,5))
|
|
|
- upsert(spread_setting,rationItem);
|
|
|
- }
|
|
|
-}
|
|
|
-//通用remove
|
|
|
-function Remove(spread_setting,args){
|
|
|
- AjaxRemove(spread_setting);
|
|
|
-}
|
|
|
-//通用upsert
|
|
|
-function upsert(spread_setting,data){
|
|
|
- AjaxUpsert(spread_setting,data)
|
|
|
-}
|
|
|
-function AjaxRemove(spread_setting){
|
|
|
- var pro = JSON.stringify(properties);
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"http://localhost:6060/rationLibEditor/remove"+spread_setting.name,
|
|
|
- data:{"setting":spread_setting,"properties":pro},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:1000,
|
|
|
- success:function(result){
|
|
|
- spread_setting.event.remove = false;
|
|
|
- },
|
|
|
- error:function(){}
|
|
|
- })
|
|
|
-}
|
|
|
-function AjaxUpsert(spread_setting,data){
|
|
|
- var pro = JSON.stringify(spread_setting.properties);
|
|
|
- var dataStr = JSON.stringify(data);
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"http://localhost:6060/rationLibEditor/upsert"+spread_setting.name,
|
|
|
- data:{"properties":pro,"data":dataStr},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:1000,
|
|
|
- success:function(result){
|
|
|
- spread_setting.event.upsert = false;
|
|
|
- },
|
|
|
- error:function(){}
|
|
|
- })
|
|
|
-}
|
|
|
function mkRationItemSpread(){
|
|
|
- var rationSpread = $.fn.Spread.init($("#rationItemsSheet"),spSetting_ration,ration_header);
|
|
|
- var rationGLJSpread = $.fn.Spread.init($("#rationGLJSheet"),spSetting_rationGLJ,rationGLJ_header);
|
|
|
+ var rationSpread = $.fn.Spread.init($("#rationItemsSheet"),spSetting_ration);
|
|
|
+ var rationGLJSpread = $.fn.Spread.init($("#rationGLJSheet"),spSetting_rationGLJ);
|
|
|
}
|