我相信,很多人已经恨死了“该死的代码就是注释”,因为那些没有注释的代码大大降低了代码的可读性,当我们对一个方法进行重用时,我们需要浪费好多时间来验证这代码是否是我们所需要的。于是,我们将那些不写注释的代码的程序猿骂的狗血淋头。
- /**
- * @function 加载tree
- * @author xxxx
- *
- * @date 2012-03-26
- *
- * treeType应当有以下类型
- * 1.all 公司+公司领导+部门+部门领导
- * 2.corpL 公司级部门+领导
- * 3.corpNL 公司级部门(无领导)
- * 4.deptL 部门级科室+部门领导
- * 5.deptNL 部门级科室(无部门领导)
- * 6.siteT 站点
- * 7.plantT 场站
- * 8.corpL-B站点下公司+部门,非当前公司只显示到公司
- */
- loadTreeAdvance:function (params) {
- console.dir(["params", params]);
- var siteName = "";
- var plantName = "";
- var showLevels = 2;
- var type = "3";
- var withLeaderType = "";
- var withPeopleType = "";
- var treeType = "", orgDN = "", orgLabel = "";
- if (params) {
- siteName = params.site.siteName;
- plantName = params.plant.plantName;
- showLevels = params.showLevels; //显示层数
- treeType = params.treeType; //组织机构树类型
- type = params.defaultType; //TODO 待移除
- this.type = params.defaultType;
- withLeaderType = params.withLeaderType; //带领导?
- withPeopleType = params.withPeopleType; //带个人?
- this.withoutSelfPlant = params.withoutSelfPlant; //带自家电场?
- orgDN = params.orgDN; //root DN
- orgLabel = params.orgLabel; //root Label
- }
- var createFolderTree = function (result) {
- console.dir([ "loadTree:result", result ]);
- var _items = result.get("itemJSON");
- var _temp = [];
- var _item = null;
- if (treeType == "sites") {
- _item = this._getItemsObject(_items);
- for (var i = 0; i < _item.length; i++) {
- _temp.push({
- "treeId":_item[i].id,
- "DN":_item[i].id,
- "name":_item[i].label,
- "displayName" : _item[i].label,
- "subOrgsBrief":[]
- });
- }
- if(params.isStandardRuleDist){
- //XX下发申请中,发往单位树中不包括总部节点
- //by xxxx 2012-12-1 17:29:20
- //by yyy 增加isSite 项 2012-12-25 16:06:27
- var _tempArr = dojo.clone(_temp);
- _temp = [];
- for ( var k = 0; k < _tempArr.length; k++) {
- if(_tempArr[k].name != "总部"){
- _temp.push({
- "treeId":_tempArr[k].treeId,
- "DN":_tempArr[k].DN,
- "isSite":true,
- "displayName" : _tempArr[k].displayName,
- "subOrgsBrief":[]
- });
- }
- }
- }
- }else {
- for (var j = 0; j < _items.length; j++) {
- _items[j].treeId = _items[j].DN;
- _items[j].orgPath= _items[j].name,
- _items[j].displayName=_items[j].name,
- _temp.push(_items[j]);
- }
- }
- var data = {
- identifier:"treeId",
- label:"name",
- items:_temp
- };
- console.dir([ "loadTree:data", data ]);
- this.departmentInfo = data;
- this.workStore = new dojo.data.ItemFileWriteStore({
- "data":data
- });
- this.workModel = new dijit.tree.ForestStoreModel({
- store:this.workStore,
- query:{},
- rootId:this._rootDN,
- rootLabel:this._rootLabel,
- childrenAttrs:[ "subOrgsBrief" ]
- });
- console.dir([ "loadTree : workModel", this.workModel ]);
- this.workTree = new dijit.Tree({
- model:this.workModel,
- openOnClick:false,
- persist:false // persist==true is too hard to test
- });
- this.workTree.placeAt(this.containerNode);
- console.dir(["workTree", this.workTree]);
- };
- var postPayload = {
- "desiredPageIndex":"",
- "pageSize":1000,
- "criterias":{
- "type":type,
- "siteName":siteName,
- "plantName":plantName,
- "prefixName":"",
- "orgDN":this._rootDN
- }
- };
- this.get("model").retrieveDepartment(postPayload, dojo.hitch(this, createFolderTree));
- },
- /**
- * treeType应当有以下类型
- * 1.all 公司+公司领导+部门+部门领导
- * 2.corpL 公司级部门+领导
- * 3.corpNL 公司级部门(无领导)
- * 4.deptL 部门级科室+部门领导
- * 5.deptNL 部门级科室(无部门领导)
- * 6.siteT 站点
- * 7.plantT 场站
- * 8.corpL-B站点下公司+部门,非当前公司只显示到公司
- */
- loadTreeAdvance:function (params) {
- withLeaderType = params.withLeaderType; //带领导?
- withPeopleType = params.withPeopleType; //带个人?
- type = params.defaultType; //TODO 待移除
- /XX制度下发申请中,发往单位树中不包括总部节点
- //by xxxx 2012-12-1 17:29:20
- //by yyyy 增加isSite 项 2012-12-25 16:06:27
- persist:false // persist==true is too hard to test