|
@@ -1,11 +1,6 @@
|
|
|
/**
|
|
|
* Created by Syusuke on 2017/3/17.
|
|
|
*/
|
|
|
-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(){
|
|
@@ -14,234 +9,54 @@ $("#dinge").click(function(){
|
|
|
$("#gongliao").click(function(){
|
|
|
$(this).attr('href', "/rationLibEditor/gongliao" + "?params=" + JSON.stringify(params))
|
|
|
});
|
|
|
-//----------------------------------------------------页面初始化
|
|
|
-$(document).ready(function(){
|
|
|
- rationOprObj.initParam();
|
|
|
- mkRationItemSpread();
|
|
|
-});
|
|
|
|
|
|
var rationOprObj = {
|
|
|
- initParam : function() {
|
|
|
- var me = this, rationLibName = getQueryString("repository");//获取定额库参数
|
|
|
- if (rationLibName) {
|
|
|
- params.realLibName = rationLibName;
|
|
|
- me.getRationTree();
|
|
|
- } else{
|
|
|
- params = JSON.parse(getQueryString("params"));
|
|
|
- me.getRationTree();
|
|
|
+ rationSpread : null,
|
|
|
+ rationGLJSpread: null,
|
|
|
+ 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}
|
|
|
+ ],
|
|
|
+ lockedCells:[
|
|
|
+ {row:-1,col:3,rowCount:-1, colCount:1}
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
- getRationTree: function(){
|
|
|
- var me = this;
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"api/getRationTree",
|
|
|
- data:{"rationLibName": params.realLibName},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:20000,
|
|
|
- success:function(result,textStatus,status){
|
|
|
- if(status.status == 200) {
|
|
|
- me.createRationTree(result.data);
|
|
|
- }
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- alert(err.responseText.error)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- createRationTree: function(sourceData){
|
|
|
- var treeArr = tree_Data_Helper.buildTreeNodeDirectly(sourceData);
|
|
|
- treeObj = $.fn.zTree.init($("#treeDemo"), setting, treeArr);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-var zTreeOprObj = {
|
|
|
- addRootNode: function() {
|
|
|
- var me = this, rawNode = {ParentID: -1, NextSiblingID: -1, name: "新增节点"};
|
|
|
- me.addNewNode(rawNode, function(err, rst){
|
|
|
- if (!(err)) {
|
|
|
- var newNodes = [], isSilent = false;
|
|
|
- newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:true, items:[]});
|
|
|
- if (treeObj) {
|
|
|
- treeObj.addNodes(null, -1, newNodes, isSilent);
|
|
|
- } else {
|
|
|
- treeObj = $.fn.zTree.init($("#treeDemo"), setting, newNodes);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- addNewNode : function(rawNode, callback){
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"api/createNewNode",
|
|
|
- data:{"rationLibName":params.realLibName,"rawNodeData": JSON.stringify(rawNode)},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:1000,
|
|
|
- success: function(result,textStatus,status){
|
|
|
- callback(false, result);
|
|
|
- },
|
|
|
- error:function(err){
|
|
|
- callback(err);
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- onRename : function(e, treeId, treeNode, isCancel) {
|
|
|
- var nodes = [];
|
|
|
- nodes.push(treeNode);
|
|
|
- zTreeOprObj.updateNodes(nodes);
|
|
|
- },
|
|
|
- onBeforeRemove: function(treeId, treeNode){
|
|
|
- var nodeIds = [], preNode = treeNode.getPreNode(), preNodeId = -1;
|
|
|
- if (preNode) {
|
|
|
- preNodeId = preNode.ID;
|
|
|
- }
|
|
|
- nodeIds.push(treeNode.ID);
|
|
|
- for (var i = 0; i < treeNode.items.length; i++) {
|
|
|
- nodeIds.push(treeNode.items[i].ID);
|
|
|
+ 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:[
|
|
|
+ {row:-1,col:1,rowCount:-1, colCount:1},
|
|
|
+ {row:-1,col:2,rowCount:-1, colCount:1},
|
|
|
+ {row:-1,col:3,rowCount:-1, colCount:1},
|
|
|
+ {row:-1,col:5,rowCount:-1, colCount:1},
|
|
|
+ {row:-1,col:6,rowCount:-1, colCount:1}
|
|
|
+ ]
|
|
|
}
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"api/deleteNodes",
|
|
|
- data:{"nodes": JSON.stringify(nodeIds), "preNodeId": preNodeId, "preNodeNextId": treeNode.NextSiblingID},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:5000,
|
|
|
- success:function(result,textStatus,status){
|
|
|
- //if(result){
|
|
|
- // caseDeleteTreeNode(result.data)
|
|
|
- //}
|
|
|
- },
|
|
|
- error:function(){
|
|
|
- }
|
|
|
- });
|
|
|
- return true;
|
|
|
},
|
|
|
- updateNodes: function(nodes){
|
|
|
- if (nodes && nodes.length > 0) {
|
|
|
- var reqData = []
|
|
|
- for (var i = 0; i < nodes.length; i++) {
|
|
|
- var node = {};
|
|
|
- node.rationRepId = nodes[i].rationRepId;
|
|
|
- node.ID = nodes[i].ID;
|
|
|
- node.ParentID = nodes[i].ParentID;
|
|
|
- node.NextSiblingID = nodes[i].NextSiblingID;
|
|
|
- node.name = nodes[i].name;
|
|
|
- node.__v = nodes[i].__v + 1;
|
|
|
- reqData.push(node);
|
|
|
- }
|
|
|
- $.ajax({
|
|
|
- type:"POST",
|
|
|
- url:"api/updateNodes",
|
|
|
- data:{"nodes": JSON.stringify(reqData)},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:5000,
|
|
|
- success:function(result,textStatus,status){
|
|
|
- console.log(status + ' : ' + result);
|
|
|
- },
|
|
|
- error:function(){
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-};
|
|
|
-//--------------------------------------------------------树处理事件
|
|
|
-var newCount = 13;
|
|
|
-//新增树节点
|
|
|
-function addHoverDom(treeId, treeNode) {
|
|
|
- var sObj = $("#" + treeNode.tId + "_span");
|
|
|
- if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0||(treeNode.level==2)) return;
|
|
|
- var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
|
|
|
- + "' title='add node' onfocus='this.blur();'></span>";
|
|
|
- sObj.after(addStr);
|
|
|
- var btn = $("#addBtn_"+treeNode.tId);
|
|
|
- if (btn) btn.bind("click", function(){
|
|
|
- var zTree = $.fn.zTree.getZTreeObj("treeDemo");
|
|
|
- if((treeNode.level==0)){
|
|
|
- var newNode = zTree.addNodes(treeNode, {id:(++newCount), pId:treeNode.id,nId:-1,isParent:true, name:"请输入章节名称",items:[]});
|
|
|
-
|
|
|
- }
|
|
|
- else{
|
|
|
- var newNode = zTree.addNodes(treeNode, {id:(++newCount), pId:treeNode.id,nId:-1,isParent:false, name:"请输入章节名称"});
|
|
|
-
|
|
|
- }
|
|
|
- saveNewSection(newNode[0]);
|
|
|
- var pnode = newNode[0].getPreNode()
|
|
|
- if(pnode){
|
|
|
- pnode.nId = newNode[0].id;
|
|
|
- saveNewSection(pnode);
|
|
|
- }
|
|
|
- return false;
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
-//保存新增的节点
|
|
|
-function saveNewSection(n){
|
|
|
- var sec={};
|
|
|
- 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:"api/addSection",
|
|
|
- data:{"rationLibName":params.realLibName,"rationSection":section},
|
|
|
- dataType:"json",
|
|
|
- cache:false,
|
|
|
- timeout:1000,
|
|
|
- success:function(result,textStatus,status){
|
|
|
- },
|
|
|
- error:function(){
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-//--------------------------------------------------------定额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}
|
|
|
- ],
|
|
|
- lockedCells:[
|
|
|
- {row:-1,col:3,rowCount:-1, colCount:1}
|
|
|
- ]
|
|
|
- }
|
|
|
-};
|
|
|
-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:[
|
|
|
- {row:-1,col:1,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:2,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:3,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:5,rowCount:-1, colCount:1},
|
|
|
- {row:-1,col:6,rowCount:-1, colCount:1}
|
|
|
- ]
|
|
|
+ mkRationItemSpread: function() {
|
|
|
+ var me = this;
|
|
|
+ me.rationSpread = $.fn.Spread.init($("#rationItemsSheet"), me.spSetting_ration);
|
|
|
+ me.rationGLJSpread = $.fn.Spread.init($("#rationGLJSheet"), me.spSetting_rationGLJ);
|
|
|
}
|
|
|
-};
|
|
|
-function mkRationItemSpread(){
|
|
|
- var rationSpread = $.fn.Spread.init($("#rationItemsSheet"),spSetting_ration);
|
|
|
- var rationGLJSpread = $.fn.Spread.init($("#rationGLJSheet"),spSetting_rationGLJ);
|
|
|
}
|