|
@@ -12,10 +12,11 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
retable: any;
|
|
|
reset = "";
|
|
|
currentTarget = null;
|
|
|
- localWindow=null;
|
|
|
- treeDatas=[];
|
|
|
- pbsSearchInputID="pbsSearchInput";
|
|
|
- searchBtnID="searchBtn";
|
|
|
+ localWindow = null;
|
|
|
+ treeDatas = [];
|
|
|
+ pbsSearchInputID = "pbsSearchInput";
|
|
|
+ searchBtnID = "searchBtn";
|
|
|
+ searchTypeSelID = "searchTypeSel";
|
|
|
|
|
|
* 启动
|
|
|
*/
|
|
@@ -45,104 +46,105 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
*/
|
|
|
getPbsTreeCallback(results) {
|
|
|
let datas = [];
|
|
|
- let num =[];
|
|
|
- if (this.checkRsults(results, true)) {
|
|
|
- let indexDatas=[];
|
|
|
- $.each(results.result, function (i, item) {
|
|
|
- var pitem={
|
|
|
- id: item.prjid+"",
|
|
|
- pId: item.prjid+"",
|
|
|
- pid: item.prjid+"",
|
|
|
- name: item.prjname,
|
|
|
- value: i,
|
|
|
- open: true,
|
|
|
- isLoad:false
|
|
|
- };
|
|
|
-
|
|
|
- let lstL=[item.prjid];
|
|
|
+ let num = [];
|
|
|
+ if (this.checkRsults(results, true)) {
|
|
|
+ let indexDatas = [];
|
|
|
+ $.each(results.result, function (i, item) {
|
|
|
+ var pitem = {
|
|
|
+ id: item.prjid + "",
|
|
|
+ pId: item.prjid + "",
|
|
|
+ pid: item.prjid + "",
|
|
|
+ name: item.prjname,
|
|
|
+ value: i,
|
|
|
+ open: true,
|
|
|
+ isLoad: false
|
|
|
+ };
|
|
|
+
|
|
|
+ let lstL = [item.prjid];
|
|
|
$.each(item.structures, function (j, info) {
|
|
|
- if(info.id!=item.prjid && lstL.indexOf(info.pid)==-1){
|
|
|
+ if (info.id != item.prjid && lstL.indexOf(info.pid) == -1) {
|
|
|
lstL.push(info.pid);
|
|
|
- }
|
|
|
- })
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- $.each(item.structures, function (j, info) {
|
|
|
- if(info.id!=item.prjid){
|
|
|
- var obj={
|
|
|
- id: info.id+"",
|
|
|
- pId: info.pid+"",
|
|
|
- pid: info.pid+"",
|
|
|
- name: info.name+"_"+ info.code,
|
|
|
+ $.each(item.structures, function (j, info) {
|
|
|
+ if (info.id != item.prjid) {
|
|
|
+ var obj = {
|
|
|
+ id: info.id + "",
|
|
|
+ pId: info.pid + "",
|
|
|
+ pid: info.pid + "",
|
|
|
+ name: info.name + "_" + info.code,
|
|
|
value: info.code,
|
|
|
- count:info.count,
|
|
|
- open:true
|
|
|
+ count: info.count,
|
|
|
+ open: true
|
|
|
};
|
|
|
- if(lstL.indexOf(info.id)==-1 && info.count>0){
|
|
|
- obj.open=false;
|
|
|
- indexDatas.push(datas.length);
|
|
|
- }
|
|
|
- datas.push(obj);
|
|
|
- }else{
|
|
|
- pitem.name+="_"+info.code;
|
|
|
- }
|
|
|
- })
|
|
|
+ if (lstL.indexOf(info.id) == -1 && info.count > 0) {
|
|
|
+ obj.open = false;
|
|
|
+ indexDatas.push(datas.length);
|
|
|
+ }
|
|
|
+ datas.push(obj);
|
|
|
+ } else {
|
|
|
+ pitem.name += "_" + info.code;
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
datas.push(pitem);
|
|
|
-
|
|
|
+
|
|
|
})
|
|
|
- var gjUrl=this.config.getPbsBjApi;
|
|
|
- this.getBjList(indexDatas,datas,gjUrl,0);
|
|
|
+ var gjUrl = this.config.getPbsBjApi;
|
|
|
+ this.getBjList(indexDatas, datas, gjUrl, 0);
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.initZtree(datas);
|
|
|
this.loadMask.hide();
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- getBjList(indexs,datas,url,index){
|
|
|
- if(index==indexs.length){
|
|
|
+ getBjList(indexs, datas, url, index) {
|
|
|
+ if (index == indexs.length) {
|
|
|
this.initZtree(datas);
|
|
|
this.loadMask.hide();
|
|
|
return;
|
|
|
}
|
|
|
- let id=datas[indexs[index]].id;
|
|
|
- let hjurl=url.replace("{0}",id);
|
|
|
- this.sendAjax({"id":id}, hjurl, "GET", function(results){
|
|
|
+ let id = datas[indexs[index]].id;
|
|
|
+ let hjurl = url.replace("{0}", id);
|
|
|
+ this.sendAjax({ "id": id }, hjurl, "GET", function (results) {
|
|
|
if (this.checkRsults(results, true)) {
|
|
|
- var infos=results.result;
|
|
|
- for(var key in infos){
|
|
|
- let items=infos[key];
|
|
|
- let item={
|
|
|
- id: key+'_'+id,
|
|
|
- name: key,
|
|
|
- value: key,
|
|
|
- pid:id,
|
|
|
- pId:id,
|
|
|
- count:items.length,
|
|
|
- open: items.length>0?false:true
|
|
|
- };
|
|
|
- datas.push(item);
|
|
|
- items.forEach(function(obj,index){
|
|
|
- datas.push({
|
|
|
- id: item.id+"_"+obj.id,
|
|
|
- name: obj.code,
|
|
|
- value: obj.code,
|
|
|
- pid:item.id,
|
|
|
- pId:item.id,
|
|
|
- count:0,
|
|
|
- open: true,
|
|
|
- layerName:obj.layerName
|
|
|
- });
|
|
|
- })
|
|
|
+ var infos = results.result;
|
|
|
+ for (var key in infos) {
|
|
|
+ let items = infos[key];
|
|
|
+ let item = {
|
|
|
+ id: key + '_' + id,
|
|
|
+ name: key,
|
|
|
+ value: key,
|
|
|
+ pid: id,
|
|
|
+ pId: id,
|
|
|
+ count: items.length,
|
|
|
+ open: items.length > 0 ? false : true
|
|
|
+ };
|
|
|
+ datas.push(item);
|
|
|
+ items.forEach(function (obj, index) {
|
|
|
+ datas.push({
|
|
|
+ id: item.id + "_" + obj.id,
|
|
|
+ name: obj.code+"("+obj.pipeId+")",
|
|
|
+ value: obj.code,
|
|
|
+ pid: item.id,
|
|
|
+ pId: item.id,
|
|
|
+ count: 0,
|
|
|
+ open: true,
|
|
|
+ pipeId: obj.pipeId,
|
|
|
+ layerName: obj.layerName
|
|
|
+ });
|
|
|
+ })
|
|
|
}
|
|
|
- this.getBjList(indexs,datas,url,index+1);
|
|
|
+ this.getBjList(indexs, datas, url, index + 1);
|
|
|
}
|
|
|
- }.bind(this), 0,true)
|
|
|
+ }.bind(this), 0, true)
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* 构建 ztree
|
|
|
* @param datas
|
|
@@ -155,51 +157,51 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
var that = this;
|
|
|
var setting = {
|
|
|
async: {
|
|
|
- enable: true
|
|
|
- },
|
|
|
- check: {
|
|
|
- enable: false
|
|
|
- },
|
|
|
- data: {
|
|
|
- simpleData: {
|
|
|
- enable: true
|
|
|
- }
|
|
|
- },
|
|
|
- view: {
|
|
|
- showLine:true,
|
|
|
- showIcon:false
|
|
|
- },
|
|
|
- callback: {
|
|
|
- onClick: function(event, treeId, treeNode){
|
|
|
- if(treeNode && treeNode.layerName){
|
|
|
- let lyName="",code=treeNode.value;
|
|
|
- if(treeNode.layerName.indexOf(',')>-1){
|
|
|
- lyName=treeNode.layerName.split(',')[1];
|
|
|
+ enable: true
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: false
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ simpleData: {
|
|
|
+ enable: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ view: {
|
|
|
+ showLine: true,
|
|
|
+ showIcon: false
|
|
|
+ },
|
|
|
+ callback: {
|
|
|
+ onClick: function (event, treeId, treeNode) {
|
|
|
+ if (treeNode && treeNode.layerName) {
|
|
|
+ let lyName = "", code = treeNode.value;
|
|
|
+ if (treeNode.layerName.indexOf(',') > -1) {
|
|
|
+ lyName = treeNode.layerName.split(',')[1];
|
|
|
}
|
|
|
- else{
|
|
|
- lyName=treeNode.layerName
|
|
|
+ else {
|
|
|
+ lyName = treeNode.layerName
|
|
|
}
|
|
|
- that.localWindow=new PipeUnitInfo({
|
|
|
- widgetPath:"widgets/PipeUnitInfo"
|
|
|
- },false,{
|
|
|
- name:lyName,
|
|
|
- id:code
|
|
|
+ that.localWindow = new PipeUnitInfo({
|
|
|
+ widgetPath: "widgets/PipeUnitInfo"
|
|
|
+ }, false, {
|
|
|
+ name: lyName,
|
|
|
+ id: code
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
- $.fn.zTree.init($("#pbsTreeDivId"), setting, zNodes);
|
|
|
+ $.fn.zTree.init($("#pbsTreeDivId"), setting, zNodes);
|
|
|
this.initTreeCheck("puchatree");
|
|
|
this.initTreeCheck("shigongtree");
|
|
|
this.initTreeCheck("shejitree");
|
|
|
- this.initTreeCheck("chengguotree");
|
|
|
+ this.initTreeCheck("chengguotree");
|
|
|
}.bind(this));
|
|
|
-
|
|
|
+
|
|
|
|
|
|
this.domObj.find("#pbsTreeDivId").on("click", "a", function (e) {
|
|
|
if (this.domObj.find("#pbsTreeDivId a").find(".active").length > 1) {
|
|
@@ -207,53 +209,72 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
}
|
|
|
$(e.currentTarget).find(".diy").addClass("active");
|
|
|
that.currentTarget = $(that.domObj.find("#pbsTreeDivId .diy.active")[1]).find(".btn_files").attr("value");
|
|
|
-
|
|
|
+
|
|
|
}.bind(this));
|
|
|
- this.domObj.find('#'+this.searchBtnID).off('click').on('click',function(){
|
|
|
- const code=this.domObj.find("#"+this.pbsSearchInputID).val().toString().trim();
|
|
|
- if(code===''){
|
|
|
+ this.domObj.find("#" + this.searchTypeSelID).off('change').on('change',function(){
|
|
|
+ this.domObj.find("#" + this.pbsSearchInputID).val('');
|
|
|
+ }.bind(this))
|
|
|
+ this.domObj.find('#' + this.searchBtnID).off('click').on('click', function () {
|
|
|
+ const code = this.domObj.find("#" + this.pbsSearchInputID).val().toString().trim();
|
|
|
+ const searchType = this.domObj.find("#" + this.searchTypeSelID).val().toString();
|
|
|
+ if (code === '') {
|
|
|
return;
|
|
|
}
|
|
|
- this.searchPBSCode(code);
|
|
|
+ switch (searchType) {
|
|
|
+ case "0":
|
|
|
+ this.searchPBSCode("name", code);
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ this.searchPBSCode("pipeId", code);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ this.searchPBSCode("name", code);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}.bind(this))
|
|
|
}
|
|
|
|
|
|
- initTreeCheck(id){
|
|
|
+ initTreeCheck(id) {
|
|
|
var setting = {
|
|
|
async: {
|
|
|
- enable: true
|
|
|
- },
|
|
|
- check: {
|
|
|
- enable: true
|
|
|
- },
|
|
|
- data: {
|
|
|
- simpleData: {
|
|
|
- enable: true
|
|
|
- }
|
|
|
- },
|
|
|
- view: {
|
|
|
- showLine:true,
|
|
|
- showIcon:false
|
|
|
- },
|
|
|
- callback: {
|
|
|
- onClick: function(event, treeId, treeNode){
|
|
|
-
|
|
|
+ enable: true
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: true
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ simpleData: {
|
|
|
+ enable: true
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ view: {
|
|
|
+ showLine: true,
|
|
|
+ showIcon: false
|
|
|
+ },
|
|
|
+ callback: {
|
|
|
+ onClick: function (event, treeId, treeNode) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
-
|
|
|
- $.fn.zTree.init($("#"+id), setting, this.config.nodedatas);
|
|
|
-
|
|
|
+
|
|
|
+ $.fn.zTree.init($("#" + id), setting, this.config.nodedatas);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
* 该方法用于搜索PBS工程结构树
|
|
|
+ * @param {string} key ztree模糊查询关键值
|
|
|
+ * @param {string} code 模糊查询字符串
|
|
|
*/
|
|
|
- searchPBSCode(code){
|
|
|
- const ztreeObj=$.fn.zTree.getZTreeObj("pbsTreeDivId");
|
|
|
- const nodes=ztreeObj.getNodesByParamFuzzy('name',code,null);
|
|
|
- nodes.forEach(node=>{
|
|
|
- ztreeObj.selectNode(node);
|
|
|
+ searchPBSCode(key: string, code: string) {
|
|
|
+
|
|
|
+ const ztreeObj = $.fn.zTree.getZTreeObj("pbsTreeDivId");
|
|
|
+ ztreeObj.cancelSelectedNode();
|
|
|
+ const nodes = ztreeObj.getNodesByParam(key, code, null);
|
|
|
+ nodes.forEach(node => {
|
|
|
+ ztreeObj.selectNode(node,false);
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -262,8 +283,8 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
* @returns 返回true或者false(true正常,false返回数据异常)
|
|
|
*/
|
|
|
checkRsults(results, colsepopup) {
|
|
|
- this.loadMask.hide();
|
|
|
- if (results.code != 1) {
|
|
|
+ this.loadMask.hide();
|
|
|
+ if (results.code != 1) {
|
|
|
console.error(results.message);
|
|
|
this.toast.show(results.message);
|
|
|
return false;
|
|
@@ -271,11 +292,11 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* 后台请求
|
|
|
*/
|
|
|
- sendAjax(data, url, ajaxtype, callBack?, type?,isasync?) {
|
|
|
+ sendAjax(data, url, ajaxtype, callBack?, type?, isasync?) {
|
|
|
let sendtype = "";
|
|
|
let senddata = null;
|
|
|
let contentType = "application/json;charset=utf-8";
|
|
@@ -295,7 +316,7 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
}
|
|
|
$.ajax({
|
|
|
headers: this.header,
|
|
|
- async:isasync,
|
|
|
+ async: isasync,
|
|
|
type: ajaxtype,
|
|
|
url: this.apiRoot + url,
|
|
|
contentType: contentType,
|
|
@@ -304,7 +325,7 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
error: function (data) {
|
|
|
console.error(data);
|
|
|
this.loadMask.hide();
|
|
|
- this.toast.show("服务端ajax出错,获取数据失败!");
|
|
|
+ this.toast.show("服务端ajax出错,获取数据失败!");
|
|
|
}.bind(this),
|
|
|
dataType: "json",
|
|
|
});
|
|
@@ -315,9 +336,9 @@ class PbsTreeManagement extends BaseWidget {
|
|
|
*/
|
|
|
destroy() {
|
|
|
if (this.localWindow && this.localWindow.infoWindow) {
|
|
|
- this.localWindow.infoWindow.remove();
|
|
|
- this.AppX.appConfig.infowindow=null;
|
|
|
- this.localWindow=null;
|
|
|
+ this.localWindow.infoWindow.remove();
|
|
|
+ this.AppX.appConfig.infowindow = null;
|
|
|
+ this.localWindow = null;
|
|
|
}
|
|
|
this.domObj.remove();
|
|
|
this.afterDestroy();
|