| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920 |
- MWF.require("MWF.widget.Tree", null, false);
- MWF.xApplication.Organization.OrgExplorer = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
-
- initialize: function(node, actions, options){
- this.setOptions(options);
-
- this.path = "/x_component_Organization/$OrgExplorer/";
- this.cssPath = "/x_component_Organization/$OrgExplorer/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.deleteElements = [];
- this.actions = actions;
- this.node = $(node);
- },
- load: function(){
- MWF.AC.getCompanyList();
- this.loadLayout();
- this.loadChart();
- },
- loadLayout: function(){
- this.chartAreaNode = new Element("div", {"styles": this.css.chartAreaNode}).inject(this.node);
- this.propertyAreaNode = new Element("div", {"styles": this.css.propertyAreaNode}).inject(this.node);
-
- this.resizeBarNode = new Element("div", {"styles": this.css.resizeBarNode}).inject(this.propertyAreaNode);
- this.propertyNode = new Element("div", {"styles": this.css.propertyNode}).inject(this.propertyAreaNode);
-
- this.propertyTitleNode = new Element("div", {"styles": this.css.propertyTitleNode}).inject(this.propertyNode);
- this.propertyContentNode = new Element("div", {"styles": this.css.propertyContentNode}).inject(this.propertyNode);
-
- this.loadToolbar();
- this.chartScrollNode = new Element("div", {"styles": this.css.chartScrollNode}).inject(this.chartAreaNode);
- this.chartNode = new Element("div", {"styles": this.css.chartNode}).inject(this.chartScrollNode);
-
- this.resizePropertyContentNode();
- this.app.addEvent("resize", function(){this.resizePropertyContentNode();}.bind(this));
-
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(this.chartScrollNode, {
- "style":"xApp_Organization_Explorer", "where": "before", "distance": 20, "friction": 4, "axis": {"x": false, "y": true},
- "onScroll": function(y){this.checkDeleteMasks();}.bind(this)
- });
- new MWF.widget.ScrollBar(this.propertyContentNode, {
- "style":"xApp_Organization_Explorer", "where": "before", "distance": 20, "friction": 4, "axis": {"x": false, "y": true}
- });
- }.bind(this));
-
- this.propertyResize = new Drag(this.resizeBarNode,{
- "snap": 1,
- "onStart": function(el, e){
- var x = e.event.clientX;
- var y = e.event.clientY;
- el.store("position", {"x": x, "y": y});
-
- var size = this.chartAreaNode.getSize();
- el.store("initialWidth", size.x);
- }.bind(this),
- "onDrag": function(el, e){
- var x = e.event.clientX;
- // var y = e.event.y;
- var bodySize = this.node.getSize();
- var position = el.retrieve("position");
- var initialWidth = el.retrieve("initialWidth").toFloat();
- var dx = position.x.toFloat()-x.toFloat();
-
- var width = initialWidth-dx;
- if (width> bodySize.x/1.5) width = bodySize.x/1.5;
- if (width<400) width = 400;
- this.chartAreaNode.setStyle("width", width+1);
- this.propertyAreaNode.setStyle("margin-left", width);
- }.bind(this)
- });
- },
- resizePropertyContentNode: function(){
- var size = this.node.getSize();
- var tSize = this.propertyTitleNode.getSize();
- var mtt = this.propertyTitleNode.getStyle("margin-top").toFloat();
- var mbt = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
- var mtc = this.propertyContentNode.getStyle("margin-top").toFloat();
- var mbc = this.propertyContentNode.getStyle("margin-bottom").toFloat();
- var height = size.y-tSize.y-mtt-mbt-mtc-mbc;
- this.propertyContentNode.setStyle("height", height);
-
- tSize = this.toolbarNode.getSize();
- mtt = this.toolbarNode.getStyle("margin-top").toFloat();
- mbt = this.toolbarNode.getStyle("margin-bottom").toFloat();
- mtc = this.toolbarNode.getStyle("margin-top").toFloat();
- mbc = this.toolbarNode.getStyle("margin-bottom").toFloat();
- height = size.y-tSize.y-mtt-mbt-mtc-mbc;
- this.chartScrollNode.setStyle("height", height);
- },
-
- loadToolbar: function(){
- this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode}).inject(this.chartAreaNode);
- if (MWF.AC.isCompanyCreator()){
- this.addTopCompanyNode = new Element("div", {"styles": this.css.addTopCompanyNode}).inject(this.toolbarNode);
- this.addTopCompanyNode.addEvent("click", function(){
- this.addTopCompany();
- }.bind(this));
- }
- //this.createSearchNode();
- },
- createSearchNode: function(){
- this.searchNode = new Element("div", {"styles": this.css.searchNode}).inject(this.toolbarNode);
-
- this.searchButtonNode = new Element("div", {
- "styles": this.css.searchButtonNode,
- "title": this.app.lp.search
- }).inject(this.searchNode);
-
- this.searchInputAreaNode = new Element("div", {
- "styles": this.css.searchInputAreaNode
- }).inject(this.searchNode);
-
- this.searchInputBoxNode = new Element("div", {
- "styles": this.css.searchInputBoxNode
- }).inject(this.searchInputAreaNode);
-
- this.searchInputNode = new Element("input", {
- "type": "text",
- "value": this.app.lp.searchText,
- "styles": this.css.searchInputNode,
- "x-webkit-speech": "1"
- }).inject(this.searchInputBoxNode);
- var _self = this;
- this.searchInputNode.addEvents({
- "focus": function(){
- if (this.value==_self.app.lp.searchText) this.set("value", "");
- },
- "blur": function(){if (!this.value) this.set("value", _self.app.lp.searchText);},
- "keydown": function(e){
- if (e.code==13){
- this.searchOrg();
- e.preventDefault();
- }
- }.bind(this),
- "selectstart": function(e){
- e.preventDefault();
- }
- });
- this.searchButtonNode.addEvent("click", function(){this.searchOrg();}.bind(this));
- },
- addTopCompany: function(){
- var isNewElement = true;
- if (this.currentItem) isNewElement = this.currentItem.unSelected();
- if (isNewElement){
- var newElementData = this._getAddCompanyData();
- var item = this._newElement(newElementData, this);
- item.load();
- item.selected();
- item.editBaseInfor();
- (new Fx.Scroll(this.chartScrollNode)).toElementCenter(item.node);
- }else{
- this.app.notice(this.app.lp.organizationSave, "error", this.propertyContentNode);
- }
- },
- _newElement: function(data, explorer){
- return new MWF.xApplication.Organization.OrgExplorer.Company(data, explorer);
- },
- _getAddCompanyData: function(){
- return {
- "name": "",
- "superior": ""
- };
- },
- _getAddDepartmentData: function(){
- return {
- "name": "",
- "superior": "",
- "company": ""
- };
- },
- searchOrg: function(){
- alert("--- search ---");
- },
- loadChart: function(){
- this.actions.listTopCompany(function(json){
- this.loadChartContent(json.data, "Company", null);
- }.bind(this));
- },
- loadChartContent: function(data, type, pitem){
- data.each(function(itemData){
- var item = new MWF.xApplication.Organization.OrgExplorer[type](itemData, this);
- if (pitem) item.parentItem = pitem;
- item.load();
-
- if (type=="Company"){
- this.loadChildCompanyNodes(item);
- this.loadChildDepartmentNodes(item);
- }else{
- this.loadChildSubDepartmentNodes(item);
- }
-
- }.bind(this));
- },
- loadChildCompanyNodes: function(item, callback){
- this.actions.listSubCompany(function(json){
- this.loadChartContent(json.data, "Company", item);
- }.bind(this), null, item.data.id);
- },
- loadChildDepartmentNodes: function(item){
- this.actions.listDepartment(function(json){
- this.loadChartContent(json.data, "Department", item);
- }.bind(this), null, item.data.id);
- },
- loadChildSubDepartmentNodes: function(item){
- this.actions.listSubDepartment(function(json){
- this.loadChartContent(json.data, "Department", item);
- }.bind(this), null, item.data.id);
- },
- checkDeleteMasks: function(y) {
- this.deleteElements.each(function(item){
- var maskNode = this.chartScrollNode.getElementById("mask"+item.data.id);
- if (maskNode){
- maskNode.position({
- relativeTo: item.childNode,
- position: 'upperLeft',
- edge: 'upperLeft'
- });
- }
- }.bind(this));
- },
- checkDeleteElements: function(){
- if (this.deleteElements.length){
- if (!this.deleteElementsNode){
- this.deleteElementsNode = new Element("div", {
- "styles": this.css.deleteGroupsNode,
- "text": this.app.lp.deleteOrganization
- }).inject(this.node);
- this.deleteElementsNode.position({
- relativeTo: this.chartScrollNode,
- position: "centerTop",
- edge: "centerTop"
- });
- this.deleteElementsNode.addEvent("click", function(e){
- this.deleteSelectedElements(e);
- }.bind(this));
- }
- }else{
- if (this.deleteElementsNode){
- this.deleteElementsNode.destroy();
- this.deleteElementsNode = null;
- delete this.deleteElementsNode;
- }
- }
- },
- checkDeleteElementsConfirm: function(){
- var confirmText = this.app.lp.deleteOrganizationConfirm;
- var size = {"x": 300, "y": 120};
- for (var i=0; i<this.deleteElements.length; i++){
- var item = this.deleteElements[i];
- if (item.childNode.getFirst()){
- confirmText = this.app.lp.deleteOrganizationSubConfirm;
- size = {"x": 450, "y": 230};
- break;
- }
- if (item.getDutyCount()>0){
- confirmText = this.app.lp.deleteOrganizationAllConfirm;
- size = {"x": 450, "y": 180};
- break;
- }
- if (item.getAttributeCount()>0){
- confirmText = this.app.lp.deleteOrganizationAllConfirm;
- size = {"x": 450, "y": 180};
- break;
- }
- if (item.getMemberCount()>0){
- confirmText = this.app.lp.deleteOrganizationAllConfirm;
- size = {"x": 450, "y": 180};
- break;
- }
- }
- return {"text": confirmText, "size": size};
- },
- deleteSelectedElements: function(e){
- var _self = this;
- confirm = this.checkDeleteElementsConfirm();
- this.app.confirm("infor", e, this.app.lp.deleteOrganizationTitle, {"html": confirm.text}, confirm.size.x, confirm.size.y, function(){
- var deleted = [];
- var doCount = 0;
- var readyCount = _self.deleteElements.length;
- var errorText = "";
- var complete = function(){
- if (doCount == readyCount){
- if (errorText){
- _self.app.notice(errorText, "error", _self.propertyContentNode, {x: "left", y:"top"});
- }
- }
- }
- _self.deleteElements.each(function(item){
- item["delete"](function(){
- deleted.push(item);
- doCount++;
- if (_self.deleteElements.length==doCount){
- _self.deleteElements = _self.deleteElements.filter(function(item, index){
- return !deleted.contains(item);
- });
- _self.checkDeleteElements();
- }
- complete();
- }, function(error){
- errorText = (errorText) ? errorText+"<br/><br/>"+error : error;
- doCount++;
- if (_self.deleteElements.length==doCount){
- _self.deleteElements = _self.deleteElements.filter(function(item, index){
- return !deleted.contains(item);
- });
- _self.checkDeleteElements();
- }
- complete();
- });
- });
- this.close();
- }, function(){
- this.close();
- });
- },
- });
- MWF.xApplication.Organization.OrgExplorer.Item = new Class({
- initialize: function(data, explorer){
- this.data = data;
- this.explorer = explorer;
- this.chartNode = this.explorer.chartNode;
-
- this.prevItem = null;
- this.nextItem = null;
- this.parentItem = null;
- this.children = [];
- this.selectedDutys = [];
- this.selectedAttributes = [];
- this.isEdit = false;
- this.isEditor = false;
- this.deleteSelected = false;
-
- this.initStyle();
- }, initStyle: function(){
- this.style = this.explorer.css.companyItem;
- },
- load: function(){
- this.node = new Element("div", {"styles": this.style.node}).inject(this.chartNode);
- this.contentNode = new Element("div", {"styles": this.style.contentNode}).inject(this.node);
- this.childNode = new Element("div", {"styles": this.style.childNode}).inject(this.node);
- this.childTween = new Fx.Tween(this.childNode, {
- "duration": 200,
- "transition": Fx.Transitions.Quint.easeOut,
- "onComplete": function(){
- var y = this.childNode.getSize().y;
- if (y>0)this.childNode.setStyle("height", "auto");
- }.bind(this)
- });
- this.flagNode = new Element("div", {"styles": this.style.flagNode}).inject(this.contentNode);
- this.flagIconNode = new Element("div", {"styles": this.style.flagIconNode}).inject(this.flagNode);
- this.iconNode = new Element("div", {"styles": this.style.iconNode}).inject(this.contentNode);
- this.actionNode = new Element("div", {"styles": this.style.actionNode}).inject(this.contentNode);
-
- this.textNode = new Element("div", {"styles": this.style.textNode}).inject(this.contentNode);
- this.textNode.set({
- "text": this.data.name
- });
- // var indent = this.getIndent();
- // this.indentNode.setStyle("width", ""+indent+"px");
- this.setNewItem();
- if (this.parentItem){
- this.parentItem.children.push(this);
- this.parentItem.flagIconNode.setStyles(this.style.flagIconNode_e);
- this.node.inject(this.parentItem.childNode);
- }else{
- this.node.inject(this.chartNode);
- }
- this.addActions();
- this.setEvent();
- },
- setNewItem: function(){
- if (!this.created){
- if (!this.data.id){
- this.created = false;
- this.contentNode.setStyles(this.style.contentNodeNew);
- }else {
- this.created = true;
- this.contentNode.setStyles(this.style.contentNode);
- }
- }
- },
- getIndent: function(){
- return (this.data.level.toFloat()-1)*20;
- },
- addActions: function(){
- MWF.AC.isCompanyEditor({
- "id": this.data.id,
- "yes": function(){
- this.isEditor = true;
- this.deleteNode = new Element("div", {"styles": this.style.actionDeleteNode}).inject(this.actionNode);
- this.addDepartmentNode = new Element("div", {"styles": this.style.actionAddDepartmentNode, "title": this.explorer.app.lp.createSubDepartment}).inject(this.actionNode);
- this.addCompanyNode = new Element("div", {"styles": this.style.actionAddCompanyNode, "title": this.explorer.app.lp.createSubCompany}).inject(this.actionNode);
- this.actionConfigNode = new Element("div", {"styles": this.style.actionConfigNode, "title": this.explorer.app.lp.configCompany}).inject(this.actionNode);
- this.deleteNode.addEvent("click", function(e){
- this.deleteButton();
- e.stopPropagation();
- }.bind(this));
- this.addDepartmentNode.addEvent("click", function(e){
- if (!this.checkDelete()) if (this.data.id) this.addDepartment();
- e.stopPropagation();
- }.bind(this));
- this.addCompanyNode.addEvent("click", function(e){
- if (!this.checkDelete()) if (this.data.id) this.addCompany();
- e.stopPropagation();
- }.bind(this));
- this.actionConfigNode.addEvent("click", function(e){
- if (!this.checkDelete()) if (this.data.id) this.configCompany(e);
- e.stopPropagation();
- }.bind(this));
- }.bind(this)
- });
- },
- deleteButton: function(){
- if (!this.deleteSelected){
- this.deleteNode.setStyles(this.style.actionDeleteNode_selected);
- this.contentNode.setStyles(this.style.contentNode_selected);
- this.node.setStyles(this.style.node_forDelete);
- //this.node.setStyles(this.style.node_forDelete);
- if (this.addDepartmentNode) this.addDepartmentNode.setStyle("display", "none");
- if (this.addCompanyNode) this.addCompanyNode.setStyle("display", "none");
- if (this.actionConfigNode) this.actionConfigNode.setStyle("display", "none");
- //this.childNode.mask({
- // "id": "mask"+this.data.id,
- // "inject": this.node,
- // "style": this.style.nodeMask
- //});
- var removeItems = [];
- this.explorer.deleteElements.each(function(item){
- if (this.childNode.contains(item.node)){
- item.deleteNode.setStyles(item.style.actionDeleteNode);
- item.contentNode.setStyles(item.style.contentNode);
- item.node.setStyles(this.style.node);
- if (item.addDepartmentNode) item.addDepartmentNode.setStyle("display", "block");
- if (item.addCompanyNode) item.addCompanyNode.setStyle("display", "block");
- if (item.actionConfigNode) item.actionConfigNode.setStyle("display", "block");
- item.actionNode.setStyle("opacity", "0");
- // item.childNode.unmask();
- item.deleteSelected = false;
- removeItems.push(item);
- }
- }.bind(this));
- removeItems.each(function(item){
- this.explorer.deleteElements.erase(item);
- }.bind(this));
- this.explorer.deleteElements.push(this);
- this.deleteSelected = true;
- this.explorer.checkDeleteElements();
- }else{
- this.deleteNode.setStyles(this.style.actionDeleteNode);
- this.contentNode.setStyles(this.style.contentNode);
- this.node.setStyles(this.style.node);
- if (this.addDepartmentNode) this.addDepartmentNode.setStyle("display", "block");
- if (this.addCompanyNode) this.addCompanyNode.setStyle("display", "block");
- if (this.actionConfigNode) this.actionConfigNode.setStyle("display", "block");
- // this.actionNode.setStyle("opacity", "0");
- // this.childNode.unmask();
- this.explorer.deleteElements.erase(this);
- this.deleteSelected = false;
- this.explorer.checkDeleteElements();
- }
- },
- addCompany: function(){
- var isNewElement = true;
- if (this.explorer.currentItem) isNewElement = this.explorer.currentItem.unSelected();
- if (isNewElement){
- var newElementData = this.explorer._getAddCompanyData();
- newElementData.superior = this.data.id;
- var item = new MWF.xApplication.Organization.OrgExplorer.Company(newElementData, this.explorer);
- item.parentItem = this;
- item.load();
- item.selected();
- item.editBaseInfor();
- (new Fx.Scroll(this.explorer.chartScrollNode)).toElementCenter(item.node);
- }else{
- this.app.notice(this.explorer.app.lp.organizationSave, "error", this.propertyContentNode);
- }
- },
- addDepartment: function(){
- var isNewElement = true;
- if (this.explorer.currentItem) isNewElement = this.explorer.currentItem.unSelected();
- if (isNewElement){
- var newElementData = this.explorer._getAddDepartmentData();
- newElementData.company = this.data.id;
- var item = new MWF.xApplication.Organization.OrgExplorer.Department(newElementData, this.explorer);
- item.parentItem = this;
- item.load();
- item.selected();
- item.editBaseInfor();
- (new Fx.Scroll(this.explorer.chartScrollNode)).toElementCenter(item.node);
- }else{
- this.app.notice(this.explorer.app.lp.organizationSave, "error", this.propertyContentNode);
- }
- },
- configCompany: function(e) {
- var controllerList = this.data.controllerList || [];
- var options = {
- "title": this.explorer.app.lp.configCompany,
- "type": "person",
- "values": controllerList,
- "onComplete": function(items){
- var ids = [];
- items.each(function(item){
- ids.push(item.data.id);
- });
- if (!ids.length){
- var _self = this;
- this.explorer.app.confirm("warn", e, this.explorer.app.lp.configCompanyNullTitle, {"html": this.explorer.app.lp.configCompanyNull}, 400, 160, function(){
- _self.data.controllerList = ids;
- _self.explorer.actions.saveCompany(_self.data, function(json){
- this.explorer.app.notice(this.explorer.app.lp.configCompanyOk, "success");
- }.bind(_self));
- this.close();
- }, function(){
- this.close();
- });
- }else{
- this.data.controllerList = ids;
- this.explorer.actions.saveCompany(this.data, function(json){
- this.explorer.app.notice(this.explorer.app.lp.configCompanyOk, "success");
- }.bind(this));
- }
- }.bind(this)
- }
- var selector = new MWF.OrgSelector(this.explorer.app.content, options)
- },
- checkDelete: function(){
- //if (this.deleteSelected) reutrn true;
- var item = this;
- while (item){
- if (item.deleteSelected) return true;
- var item = item.parentItem
- }
- return false;
- },
- setEvent: function(){
- // this.node.addEvents({
- // "mouseover": function(e){
- // this.node.setStyles(this.style.nodeOver);
- // e.stopPropagation();
- // }.bind(this),
- // "mouseout": function(e){
- // this.node.setStyles(this.style.node);
- // }.bind(this)
- // });
- this.contentNode.addEvents({
- "mouseover": function(e){
- if (this.explorer.currentItem!=this){
- this.flagNode.setStyles(this.style.flagNodeOver);
- }
- if (!this.checkDelete()) if (this.data.id) this.actionNode.fade("in");
- }.bind(this),
- "mouseout": function(e){
- if (this.explorer.currentItem!=this){
- this.flagNode.setStyles(this.style.flagNode);
- }
- if (!this.checkDelete()) if (this.data.id) this.actionNode.fade("out");
- }.bind(this),
- "click": function(e){
- this.itemClick();
- }.bind(this)
- });
- this.flagNode.addEvents({
- "click": function(e){
- if (!this.childTween.isRunning()){
- var oy = this.childNode.retrieve("c-height", 0);
- var cy = this.childNode.getSize().y;
- if (cy>0){
- this.childNode.store("c-height", cy);
- this.childTween.start("height", cy, 0);
- this.flagIconNode.setStyles(this.style.flagIconNode_c);
- }else{
- this.childTween.start("height", 0, oy);
- this.flagIconNode.setStyles(this.style.flagIconNode_e);
- }
- }
- }.bind(this)
- });
- },
- itemClick: function(){
- if (this.explorer.currentItem){
- if (this.explorer.currentItem.unSelected()){
- this.selected();
- }else{
- this.explorer.app.notice(this.explorer.app.lp.organizationSave, "error", this.propertyContentNode);
- }
- }else{
- this.selected();
- }
- },
- selected: function(){
- this.explorer.currentItem = this;
- this.flagNode.setStyles(this.style.flagNodeSelected);
- this.showItemProperty();
- },
- unSelected: function(){
- if (this.isEdit) return false;
- this.explorer.currentItem = null;
- this.flagNode.setStyles(this.style.flagNode);
- this.clearItemProperty();
- return true;
- },
- showItemProperty: function(){
- this.explorer.propertyTitleNode.set("text", this.data.name);
- this.showItemPropertyBase();
- this.showItemPropertyDuty();
- this.showItemPropertyAttribute();
- },
- showItemPropertyBase: function(){
- this.propertyBaseNode = new Element("div", {
- "styles": this.style.propertyInforNode
- }).inject(this.explorer.propertyContentNode);
-
- this.baseActionNode = new Element("div", {
- "styles": this.style.propertyInforActionNode
- }).inject(this.propertyBaseNode);
- this.propertyBaseTextNode = new Element("div", {
- "styles": this.style.propertyInforTextNode,
- "text": this.explorer.app.lp.companyBaseText
- }).inject(this.propertyBaseNode);
- if (this.isEditor) this.createEditBaseNode();
-
- this.propertyBaseContentNode = new Element("div", {
- "styles": this.style.propertyInforContentNode
- }).inject(this.propertyBaseNode);
-
- var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center'>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.companyName+"</td><td id='formCompanyName'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.companyNumber+"</td><td id='formCompanyNumber'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.companyAddress+"</td><td id='formCompanyAddress'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.companyShortname+"</td><td id='formCompanyShortname'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.orderNumber+"</td><td id='formOrderNumber'></td><tr>";
- html += "</table>";
-
- this.propertyBaseContentNode.set("html", html);
- // this.propertyBaseContentNode.getElements("td").setStyles({
- // "border-bottom": "1px solid #c9c9c9"
- // });
- this.propertyBaseContentNode.getElements("td.formTitle").setStyles(this.style.propertyBaseContentTdTitle);
-
- this.companyNameInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formCompanyName"), this.data.name, this.explorer.css.formInput);
- this.companyNumberInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formCompanyNumber"), this.data.number, this.explorer.css.formInput);
- this.companyAddressInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formCompanyAddress"), this.data.address, this.explorer.css.formInput);
- this.companyShortnameInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formCompanyShortname"), this.data.shortname, this.explorer.css.formInput);
- this.orderNumberInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formOrderNumber"), this.data.orderNumber, this.explorer.css.formInput);;
- },
- createEditBaseNode: function(){
- this.editBaseNode = new Element("button", {
- "styles": this.style.editBaseNode,
- "text": this.explorer.app.lp.edit,
- "events": {"click": this.editBaseInfor.bind(this)}
- }).inject(this.baseActionNode);
- },
- createCancelBaseNode: function(){
- this.cancelBaseNode = new Element("button", {
- "styles": this.style.cancelBaseNode,
- "text": this.explorer.app.lp.cancel,
- "events": {"click": this.cancelBaseInfor.bind(this)}
- }).inject(this.baseActionNode);
- },
- createSaveBaseNode: function(){
- this.saveBaseNode = new Element("button", {
- "styles": this.style.saveBaseNode,
- "text": this.explorer.app.lp.save,
- "events": {"click": this.saveBaseInfor.bind(this)}
- }).inject(this.baseActionNode);
- },
- editBaseInfor: function(){
- this.baseActionNode.empty();
- this.editBaseNode = null;
- this.createCancelBaseNode();
- this.createSaveBaseNode();
-
- this.editMode();
- },
- cancelBaseInfor: function(){
- if (this.data.name){
- this.baseActionNode.empty();
- this.cancelBaseNode = null;
- this.saveBaseNode = null;
- this.createEditBaseNode();
- this.readMode();
- }else{
- this.destroy();
- }
- },
- destroy: function(){
- if (this.parentItem) this.parentItem.children.erase(this);
- this.explorer.currentItem = null;
- this.clearItemProperty();
- this.node.destroy();
- delete this;
- },
- saveBaseInfor: function(callback){
- if (!this.companyNameInput.input.get("value")){
- this.explorer.app.notice(this.explorer.app.lp.inputOrganizationInfor, "error", this.explorer.propertyContentNode);
- return false;
- }
- this.propertyBaseNode.mask({
- "style": {
- "opacity": 0.7,
- "background-color": "#999"
- }
- });
- this.save(function(){
- this.baseActionNode.empty();
- this.cancelBaseNode = null;
- this.saveBaseNode = null;
- this.createEditBaseNode();
-
- this.readMode();
- this.setNewItem();
- this.propertyBaseNode.unmask();
- if (callback) callback();
- }.bind(this), function(xhr, text, error){
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.explorer.app.notice("request json error: "+errorText, "error");
- this.propertyBaseNode.unmask();
- }.bind(this));
- },
-
- clearItemProperty: function(){
- this.explorer.propertyTitleNode.empty();
- this.explorer.propertyContentNode.empty();
- },
- editMode: function(){
- this.companyNameInput.editMode();
- this.companyNumberInput.editMode();
- this.companyAddressInput.editMode();
- this.companyShortnameInput.editMode();
- this.orderNumberInput.editMode();
- this.isEdit = true;
- },
- readMode: function(){
- this.companyNameInput.readMode();
- this.companyNumberInput.readMode();
- this.companyAddressInput.readMode();
- this.companyShortnameInput.readMode();
- this.orderNumberInput.readMode();
- this.isEdit = false;
- },
- save: function(callback, cancel){
- this.data.name = this.companyNameInput.save();
- this.data.number = this.companyNumberInput.save();
- this.data.address = this.companyAddressInput.save();
- this.data.shortname = this.companyShortnameInput.save();
- this.data.orderNumber = this.orderNumberInput.save();
-
- this.explorer.actions.saveCompany(this.data, function(json){
- if (!this.data.id) this.data.id = json.data.id;
- this.textNode.set("text", this.data.name);
- if (callback) callback();
- }.bind(this), function(xhr, text, error){
- if (cancel) cancel(xhr, text, error);
- }.bind(this));
- },
-
- showItemPropertyDuty: function(){
- this.propertyDutyNode = new Element("div", {
- "styles": this.style.propertyInforNode
- }).inject(this.explorer.propertyContentNode);
-
- this.dutyActionNode = new Element("div", {
- "styles": this.style.propertyInforActionNode
- }).inject(this.propertyDutyNode);
- this.propertyDutyTextNode = new Element("div", {
- "styles": this.style.propertyInforTextNode,
- "text": this.explorer.app.lp.companyDutyText
- }).inject(this.propertyDutyNode);
- // this.createEditBaseNode();
-
- this.propertyDutyContentNode = new Element("div", {
- "styles": this.style.propertyInforContentNode
- }).inject(this.propertyDutyNode);
- if (this.isEditor) {
- this.createDeleteDutyNode();
- this.createAddDutyNode();
- }
- this.listDuty();
- },
- createAddDutyNode: function(){
- this.addDutyNode = new Element("button", {
- "styles": this.style.addDutyNode,
- "text": this.explorer.app.lp.add,
- "events": {"click": this.addDuty.bind(this)}
- }).inject(this.dutyActionNode);
- },
- createDeleteDutyNode: function(){
- this.deleteDutyNode = new Element("button", {
- "styles": this.style.deleteDutyNode_desable,
- "text": this.explorer.app.lp["delete"],
- "disable": true
- }).inject(this.dutyActionNode);
- },
- addDuty: function(){
- var data = this.getNewDutyData();
- if (!this.created){
- this.saveBaseInfor(function(){
- new MWF.xApplication.Organization.CompanyDuty(this.propertyDutyContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }.bind(this));
- }else{
- new MWF.xApplication.Organization.CompanyDuty(this.propertyDutyContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }
- },
- getNewDutyData: function(){
- return {
- "company": this.data.id,
- "name": "",
- };
- },
- checkDeleteDutyAction: function(){
- if (this.selectedDutys.length){
- if (this.deleteDutyNode.get("disable")){
- this.deleteDutyNode.set({
- "styles": this.style.deleteDutyNode
- });
- this.deleteDutyNode.removeProperty("disable");
- this.deleteDutyNode.addEvent("click", function(e){this.deleteDuty(e);}.bind(this));
- }
- }else{
- if (!this.deleteDutyNode.get("disable")){
- this.deleteDutyNode.set({
- "styles": this.style.deleteDutyNode_desable,
- "disable": true
- });
- this.deleteDutyNode.removeEvents("click");
- }
- }
- },
- deleteDuty: function(e){
- var _self = this;
- this.explorer.app.confirm("infor", e, this.explorer.app.lp.deleteDutyTitle, this.explorer.app.lp.deleteDuty, 300, 120, function(){
- this.close();
- _self.selectedDutys.each(function(duty){
- duty.remove();
- });
- delete _self.selectedDutys;
- _self.selectedDutys = [];
- _self.checkDeleteDutyAction();
- }, function(){this.close();});
- },
-
- listDuty: function(){
- var html = "<table cellspacing='0' cellpadding='5' border='0' width='95%' align='center' style='line-height:normal'>";
- html += "<tr><th style='width:20px'></th>";
- html += "<th style='width: 30%; border-right: 1px solid #FFF'>"+this.explorer.app.lp.dutyName+"</th>";
- html += "<th>"+this.explorer.app.lp.dutyMember+"</th><th style='width:20px'></th></tr>";
- html += "</table>";
- this.propertyDutyContentNode.set("html", html);
- this.propertyDutyContentNode.getElements("th").setStyles(this.style.propertyDutyContentTdTitle);
- if (this.data.id){
- this.explorer.actions.listCompanyDuty(function(json){
- json.data.each(function(item){
- new MWF.xApplication.Organization.CompanyDuty(this.propertyDutyContentNode.getElement("table").getFirst(), item, this, this.explorer.css.map);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }
- },
- getDutyCount: function(){
- if (this.data.id){
- var count = 0;
- this.explorer.actions.listCompanyDuty(function(json){
- count = json.data.length;
- }.bind(this), null, this.data.id, false);
- return count;
- }
- return 0;
- },
-
-
- showItemPropertyAttribute: function(){
- this.propertyAttributeNode = new Element("div", {
- "styles": this.style.propertyInforNode
- }).inject(this.explorer.propertyContentNode);
-
- this.attributeActionNode = new Element("div", {
- "styles": this.style.propertyInforActionNode
- }).inject(this.propertyAttributeNode);
- this.propertyAttributeTextNode = new Element("div", {
- "styles": this.style.propertyInforTextNode,
- "text": this.explorer.app.lp.companyAttributeText
- }).inject(this.propertyAttributeNode);
- // this.createEditBaseNode();
-
- this.propertyAttributeContentNode = new Element("div", {
- "styles": this.style.propertyInforContentNode
- }).inject(this.propertyAttributeNode);
- if (this.isEditor) {
- this.createDeleteAttributeNode();
- this.createAddAttributeNode();
- }
- this.listAttribute();
- },
- createAddAttributeNode: function(){
- this.addAttributeNode = new Element("button", {
- "styles": this.style.addDutyNode,
- "text": this.explorer.app.lp.add,
- "events": {"click": this.addAttribute.bind(this)}
- }).inject(this.attributeActionNode);
- },
- createDeleteAttributeNode: function(){
- this.deleteAttributeNode = new Element("button", {
- "styles": this.style.deleteDutyNode_desable,
- "text": this.explorer.app.lp["delete"],
- "disable": true
- }).inject(this.attributeActionNode);
- },
- addAttribute: function(){
- var data = this.getNewAttributeData();
- if (!this.created){
- this.saveBaseInfor(function(){
- new MWF.xApplication.Organization.CompanyAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }.bind(this));
- }else{
- new MWF.xApplication.Organization.CompanyAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }
- },
- getNewAttributeData: function(){
- return {
- "company": this.data.id,
- "name": "",
- "attributeList":[]
- };
- },
- checkDeleteAttributeAction: function(){
- if (this.selectedAttributes.length){
- if (this.deleteAttributeNode.get("disable")){
- this.deleteAttributeNode.set({
- "styles": this.style.deleteDutyNode
- });
- this.deleteAttributeNode.removeProperty("disable");
- this.deleteAttributeNode.addEvent("click", function(e){this.deleteAttribute(e);}.bind(this));
- }
- }else{
- if (!this.deleteAttributeNode.get("disable")){
- this.deleteAttributeNode.set({
- "styles": this.style.deleteDutyNode_desable,
- "disable": true
- });
- this.deleteAttributeNode.removeEvents("click");
- }
- }
- },
- deleteAttribute: function(e){
- var _self = this;
- this.explorer.app.confirm("infor", e, this.explorer.app.lp.deleteAttributeTitle, this.explorer.app.lp.deleteAttribute, 300, 120, function(){
- this.close();
- _self.selectedAttributes.each(function(attribute){
- attribute.remove();
- });
- delete _self.selectedAttributes;
- _self.selectedAttribute = [];
- _self.checkDeleteAttributeAction();
- }, function(){this.close();});
- },
- listAttribute: function(){
- var html = "<table cellspacing='0' cellpadding='5' border='0' width='95%' align='center' style='line-height:normal'>";
- html += "<tr><th style='width:20px'></th>";
- html += "<th style='width: 30%; border-right: 1px solid #FFF'>"+this.explorer.app.lp.attributeName+"</th>";
- html += "<th>"+this.explorer.app.lp.attributeValue+"</th><th style='width:20px'></th></tr>";
- html += "</table>";
- this.propertyAttributeContentNode.set("html", html);
- this.propertyAttributeContentNode.getElements("th").setStyles(this.style.propertyDutyContentTdTitle);
- if (this.data.id){
- this.explorer.actions.listCompanyAttribute(function(json){
- json.data.each(function(item){
- new MWF.xApplication.Organization.CompanyAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), item, this, this.explorer.css.map);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }
- },
- getAttributeCount: function(){
- if (this.data.id){
- var count = 0;
- this.explorer.actions.listCompanyAttribute(function(json){
- count = json.data.length;
- }.bind(this), null, this.data.id, false);
- return count;
- }
- return 0;
- },
- getMemberCount: function(){return 0;},
- "delete": function(success, failure){
- this.children.each(function(item){
- item["delete"]();
- });
- this._deleteDutys();
- this._deleteAttributes();
- this._deleteMembers();
- this._deleteItem(this.data.id, function(){
- this.destroy();
- if (success) success();
- }.bind(this), function(xhr, text, error){
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- if (failure) failure(errorText);
- }.bind(this));
- },
- _deleteItem: function(id, success, failure){
- this.explorer.actions.deleteCompany(id, success, failure, false);
- },
- _deleteDutys: function(){
- this._listDutys(function(json){
- json.data.each(function(duty){
- this.explorer.actions.deleteCompanyDuty(duty.id, null, null, false);
- }.bind(this));
- }.bind(this));
- },
- _listDutys: function(success){
- this.explorer.actions.listCompanyDuty(function(json){
- if (success) success(json);
- }.bind(this), null, this.data.id, false);
- },
- _deleteAttributes: function(){
- this._listAttributes(function(json){
- json.data.each(function(att){
- this.explorer.actions.deleteCompanyAttribute(att.id, null, null, false);
- }.bind(this));
- }.bind(this));
- },
- _listAttributes: function(success){
- this.explorer.actions.listCompanyAttribute(function(json){
- if (success) success(json);
- }.bind(this), null, this.data.id, false);
- },
- _deleteMembers: function(){
- return true;
- }
-
- });
- MWF.xApplication.Organization.OrgExplorer.Company = new Class({
- Extends: MWF.xApplication.Organization.OrgExplorer.Item
- });
- MWF.xApplication.Organization.OrgExplorer.Department = new Class({
- Extends: MWF.xApplication.Organization.OrgExplorer.Item,
- initStyle: function(){
- this.style = this.explorer.css.departmentItem;
- },
- addActions: function(){
- MWF.AC.isDepartmentEditor({
- "id": this.data.company,
- "yes": function(){
- this.isEditor = true;
- this.deleteNode = new Element("div", {"styles": this.style.actionDeleteNode}).inject(this.actionNode);
- this.addDepartmentNode = new Element("div", {"styles": this.style.actionAddDepartmentNode, "title": this.explorer.app.lp.createSubDepartment}).inject(this.actionNode);
- this.deleteNode.addEvent("click", function(e){
- this.deleteButton();
- e.stopPropagation();
- }.bind(this));
- this.addDepartmentNode.addEvent("click", function(e){
- if (!this.checkDelete()) if (this.data.id) this.addDepartment();
- e.stopPropagation();
- }.bind(this));
- }.bind(this)
- });
- },
- addDepartment: function(){
- var isNewElement = true;
- if (this.explorer.currentItem) isNewElement = this.explorer.currentItem.unSelected();
- if (isNewElement){
- var newElementData = this.explorer._getAddDepartmentData();
- newElementData.superior = this.data.id;
- var item = new MWF.xApplication.Organization.OrgExplorer.Department(newElementData, this.explorer);
- item.parentItem = this;
- item.load();
- item.selected();
- item.editBaseInfor();
- (new Fx.Scroll(this.explorer.chartScrollNode)).toElementCenter(item.node, "y");
- }else{
- this.app.notice(this.explorer.app.lp.organizationSave, "error", this.propertyContentNode);
- }
- },
- saveBaseInfor: function(callback){
- if (!this.departmentNameInput.input.get("value")){
- this.explorer.app.notice(this.explorer.app.lp.inputOrganizationInfor, "error", this.explorer.propertyContentNode);
- return false;
- }
- this.propertyBaseNode.mask({
- "style": {
- "opacity": 0.7,
- "background-color": "#999"
- }
- });
- this.save(function(){
- this.baseActionNode.empty();
- this.cancelBaseNode = null;
- this.saveBaseNode = null;
- this.createEditBaseNode();
- this.readMode();
- this.setNewItem();
- this.propertyBaseNode.unmask();
- if (callback) callback();
- }.bind(this), function(xhr, text, error){
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.explorer.app.notice("request json error: "+errorText, "error");
- this.propertyBaseNode.unmask();
- }.bind(this));
- },
- showItemProperty: function(){
- this.explorer.propertyTitleNode.set("text", this.data.name);
- this.showItemPropertyBase();
- this.showItemPropertyDuty();
- this.showItemPropertyAttribute();
-
- this.showItemMembers();
- },
-
- showItemPropertyBase: function(){
- this.propertyBaseNode = new Element("div", {
- "styles": this.style.propertyInforNode
- }).inject(this.explorer.propertyContentNode);
-
- this.baseActionNode = new Element("div", {
- "styles": this.style.propertyInforActionNode
- }).inject(this.propertyBaseNode);
- this.propertyBaseTextNode = new Element("div", {
- "styles": this.style.propertyInforTextNode,
- "text": this.explorer.app.lp.departmentBaseText
- }).inject(this.propertyBaseNode);
- if (this.isEditor) this.createEditBaseNode();
-
- this.propertyBaseContentNode = new Element("div", {
- "styles": this.style.propertyInforContentNode
- }).inject(this.propertyBaseNode);
-
- var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center'>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.departmentName+"</td><td id='formDepartmentName'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.departmentNumber+"</td><td id='formDepartmentNumber'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.departmentShortname+"</td><td id='formDepartmentShortname'></td></tr>";
- html += "<tr><td class='formTitle'>"+this.explorer.app.lp.orderNumber+"</td><td id='formOrderNumber'></td></tr>";
- html += "</table>";
-
- this.propertyBaseContentNode.set("html", html);
- // this.propertyBaseContentNode.getElements("td").setStyles({
- // "border-bottom": "1px solid #c9c9c9"
- // });
- this.propertyBaseContentNode.getElements("td.formTitle").setStyles(this.style.propertyBaseContentTdTitle);
-
- this.departmentNameInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formDepartmentName"), this.data.name, this.explorer.css.formInput);
- this.departmentNumberInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formDepartmentNumber"), this.data.number, this.explorer.css.formInput);
- this.departmentShortnameInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formDepartmentShortname"), this.data.shortname, this.explorer.css.formInput);
- this.orderNumberInput = new MWF.xApplication.Organization.Input(this.propertyBaseContentNode.getElement("#formOrderNumber"), this.data.orderNumber, this.explorer.css.formInput);;
- },
- editMode: function(){
- this.departmentNameInput.editMode();
- this.departmentNumberInput.editMode();
- this.departmentShortnameInput.editMode();
- this.orderNumberInput.editMode();
- this.isEdit = true;
- },
- readMode: function(){
- this.departmentNameInput.readMode();
- this.departmentNumberInput.readMode();
- this.departmentShortnameInput.readMode();
- this.orderNumberInput.readMode();
- this.isEdit = false;
- },
- save: function(callback){
- this.data.name = this.departmentNameInput.save();
- this.data.number = this.departmentNumberInput.save();
- this.data.shortname = this.departmentShortnameInput.save();
- this.data.orderNumber = this.orderNumberInput.save();
-
- this.explorer.actions.saveDepartment(this.data, function(json){
- if (!this.data.id) this.data.id = json.data.id;
- this.textNode.set("text", this.data.name);
- if (callback) callback();
- }.bind(this));
- },
- getNewDutyData: function(){
- return {
- "department": this.data.id,
- "name": ""
- };
- },
- getNewAttributeData: function(){
- return {
- "department": this.data.id,
- "name": "",
- "attributeList":[]
- };
- },
- listDuty: function(){
- this.propertyDutyTextNode.set("text", this.explorer.app.lp.departmentDutyText);
- var html = "<table cellspacing='0' cellpadding='5' border='0' width='95%' align='center' style='line-height:normal'>";
- html += "<tr><th style='width:20px'></th>";
- html += "<th style='width: 30%; border-right: 1px solid #FFF'>"+this.explorer.app.lp.dutyName+"</th>";
- html += "<th>"+this.explorer.app.lp.dutyMember+"</th><th style='width:20px'></th></tr>";
- html += "</table>";
- this.propertyDutyContentNode.set("html", html);
- this.propertyDutyContentNode.getElements("th").setStyles(this.style.propertyDutyContentTdTitle);
- if (this.data.id){
- this.explorer.actions.listDepartmentDuty(function(json){
- json.data.each(function(item){
- new MWF.xApplication.Organization.DepartmentDuty(this.propertyDutyContentNode.getElement("table").getFirst(), item, this, this.explorer.css.map);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }
- },
- getDutyCount: function(){
- if (this.data.id){
- var count = 0;
- this.explorer.actions.listDepartmentDuty(function(json){
- count = json.data.length;
- }.bind(this), null, this.data.id, false);
- return count;
- }
- return 0;
- },
- addDuty: function(){
- var data = this.getNewDutyData();
- if (!this.created){
- this.saveBaseInfor(function(){
- new MWF.xApplication.Organization.DepartmentDuty(this.propertyDutyContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }.bind(this));
- }else{
- new MWF.xApplication.Organization.DepartmentDuty(this.propertyDutyContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }
- },
- listAttribute: function(){
- this.propertyAttributeTextNode.set("text", this.explorer.app.lp.departmentAttributeText);
- var html = "<table cellspacing='0' cellpadding='5' border='0' width='95%' align='center' style='line-height:normal'>";
- html += "<tr><th style='width:20px'></th>";
- html += "<th style='width: 30%; border-right: 1px solid #FFF'>"+this.explorer.app.lp.attributeName+"</th>";
- html += "<th>"+this.explorer.app.lp.attributeValue+"</th><th style='width:20px'></th></tr>";
- html += "</table>";
- this.propertyAttributeContentNode.set("html", html);
- this.propertyAttributeContentNode.getElements("th").setStyles(this.style.propertyDutyContentTdTitle);
- if (this.data.id){
- this.explorer.actions.listDepartmentAttribute(function(json){
- json.data.each(function(item){
- new MWF.xApplication.Organization.DepartmentAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), item, this, this.explorer.css.map);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }
- },
- getAttributeCount: function(){
- if (this.data.id){
- var count = 0;
- this.explorer.actions.listDepartmentAttribute(function(json){
- count = json.data.length;
- }.bind(this), null, this.data.id, false);
- return count;
- }
- return 0;
- },
- addAttribute: function(){
- var data = this.getNewAttributeData();
- if (!this.created){
- this.saveBaseInfor(function(){
- new MWF.xApplication.Organization.DepartmentAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }.bind(this));
- }else{
- new MWF.xApplication.Organization.DepartmentAttribute(this.propertyAttributeContentNode.getElement("table").getFirst(), data, this, this.explorer.css.map);
- }
- },
- showItemMembers: function(){
- this.propertyMembersNode = new Element("div", {
- "styles": this.style.propertyInforNode
- }).inject(this.explorer.propertyContentNode);
-
- this.membersActionNode = new Element("div", {
- "styles": this.style.propertyInforActionNode
- }).inject(this.propertyMembersNode);
- this.propertyMembersTextNode = new Element("div", {
- "styles": this.style.propertyInforTextNode,
- "text": this.explorer.app.lp.departmentMemberText
- }).inject(this.propertyMembersNode);
-
- this.propertyMemberContentNode = new Element("div", {
- "styles": this.style.propertyInforContentNode
- }).inject(this.propertyMembersNode);
-
- // this.createDeleteMemberNode();
- if (this.isEditor) this.createAddMemberNode();
-
- this.listMembers();
- },
- createAddMemberNode: function(){
- this.addMemberNode = new Element("button", {
- "styles": this.style.addDutyNode,
- "text": this.explorer.app.lp.add,
- "events": {"click": this.addMember.bind(this)}
- }).inject(this.membersActionNode);
- },
- createDeleteMemberNode: function(){
- this.deleteMemberNode = new Element("button", {
- "styles": this.style.deleteDutyNode_desable,
- "text": this.explorer.app.lp["delete"],
- "disable": true
- }).inject(this.membersActionNode);
- },
- checkSaveBaseInfor: function(callback){
- if (!this.created){
- this.saveBaseInfor(function(){
- if (callback) callback();
- }.bind(this));
- }else{
- if (callback) callback();
- }
- },
- addMember: function(){
- this.checkSaveBaseInfor(function(){
- MWF.xDesktop.requireApp("Organization", "Selector.Person", function(){
- var selector = new MWF.xApplication.Organization.Selector.Person(this.explorer.app.content,{
- "values": [],
- "onComplete": function(items){
- var ids = 0;
- items.each(function(item){
- var newIData = {
- "person": item.data.id,
- "department": this.data.id,
- "name": item.data.name+"("+this.data.name+")"
- };
- this.explorer.actions.saveIdentity(newIData, function(json){
- newIData.id = json.data.id;
- this.createIdentity(newIData);
- }.bind(this));
- }.bind(this));
- }.bind(this)
- });
- selector.load();
- }.bind(this));
- }.bind(this));
- },
- listMembers: function(){
- if (this.data.id) {
- this.explorer.actions.listIdentity(function (json) {
- json.data.each(function (item) {
- var _department = this;
- this.createIdentity(item);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }
- },
- getMemberCount: function(){
- if (this.data.id){
- var count = 0;
- this.explorer.actions.listIdentity(function(json){
- count = json.data.length;
- }.bind(this), null, this.data.id, false);
- return count;
- }
- return 0;
- },
- createIdentity: function(item){
- _department = this;
- MWF.require("MWF.widget.Identity", function(){
- new MWF.widget.Identity(item, this.propertyMemberContentNode, this.explorer, this.isEditor, function(e){
- var _self = this;
- var text = this.explorer.app.lp.deleteIdentityInDepartment;
- text = text.replace("{depart}", _department.data.name);
- text = text.replace("{identity}", this.data.name);
- _self.explorer.app.confirm("warn", e, this.explorer.app.lp.deleteIdentityInDepartmentTitle, text, 400, 140, function(){
- _self.explorer.actions.deleteIdentity(_self.data.id, function(){
- _self.node.destroy();
- delete _self;
- // _department.
- });
- this.close();
- }, function(){
- this.close();
- });
- });
- }.bind(this));
- },
- _deleteItem: function(id, success, failure){
- this.explorer.actions.deleteDepartment(id, success, failure, false);
- },
- _deleteDutys: function(){
- this._listDutys(function(json){
- json.data.each(function(duty){
- this.explorer.actions.deleteDepartmentDuty(duty.id, null, null, false);
- }.bind(this));
- }.bind(this));
- },
- _listDutys: function(success){
- this.explorer.actions.listDepartmentDuty(function(json){
- if (success) success(json);
- }.bind(this), null, this.data.id, false);
- },
- _deleteAttributes: function(){
- this._listAttributes(function(json){
- json.data.each(function(att){
- this.explorer.actions.deleteDepartmentAttribute(att.id, null, null, false);
- }.bind(this));
- }.bind(this));
- },
- _listAttributes: function(success){
- this.explorer.actions.listDepartmentAttribute(function(json){
- if (success) success(json);
- }.bind(this), null, this.data.id, false);
- },
- _deleteMembers: function(){
- this.explorer.actions.listIdentity(function(json){
- json.data.each(function(i){
- this.explorer.actions.deleteIdentity(i.id, null, null, false);
- }.bind(this));
- }.bind(this), null, this.data.id, false);
- }
- });
- MWF.xApplication.Organization.Input = new Class({
- Implements: [Events],
- initialize: function(node, value, style){
- this.node = $(node);
- this.value = value || "";
- this.style = style;
- this.load();
- },
- load: function(){
- this.content = new Element("div", {
- "styles": this.style.content,
- "text": this.value
- }).inject(this.node);
- },
- editMode: function(){
- this.content.empty();
- this.input = new Element("input",{
- "styles": this.style.input,
- "value": this.value
- }).inject(this.content);
-
- this.input.addEvents({
- "focus": function(){
- this.input.setStyles(this.style.input_focus);
- }.bind(this),
- "blur": function(){
- this.input.setStyles(this.style.input);
- }.bind(this)
- });
-
- },
- readMode: function(){
- this.content.empty();
- this.input = null;
- this.content.set("text", this.value);
- },
- save: function(){
- if (this.input) this.value = this.input.get("value");
- return this.value;
- }
- });
- MWF.xApplication.Organization.CompanyDuty = new Class({
- initialize: function(container, data, item, style){
- this.container = $(container);
- this.data = data;
- if (this.data.identityList) this.data.identityList = data.identityList.filter(function(item){return item;});
- this.style = style;
- this.item = item;
- this.identitys = [];
- this.selected = false;
- this.load();
- },
- load: function(){
- this.node = new Element("tr", {
- "styles": this.style.contentNode
- }).inject(this.container);
-
- this.selectNode = new Element("td", {
- "styles": this.style.selectNode
- }).inject(this.node);
-
- this.nameNode = new Element("td", {
- "styles": this.style.nameNode,
- "html": (this.data.name) ? this.data.name : "<input type='text'/>"
- }).inject(this.node);
- this.input = this.nameNode.getFirst("input");
- if (this.input) this.setEditNameInput();
-
- this.valueNode = new Element("td", {
- "styles": this.style.valueNode
- }).inject(this.node);
-
- this.createActionNode();
- this.setEvent();
- this.loadValue();
- },
- createActionNode: function(){
- this.actionNode = new Element("td", {
- "styles": this.style.actionNode
- }).inject(this.node);
- if (this.item.isEditor) {
- this.actionNode.addEvent("click", function () {
- this.addIdentitys();
- }.bind(this));
- }else{
- this.actionNode.setStyle("background", "transparent");
- }
- },
- setEvent: function(){
- this.selectNode.addEvent("click", function(){
- this.selectNodeClick();
- }.bind(this));
-
- this.nameNode.addEvent("click", function(){
- if (!this.input){
- this.nameNode.empty();
- this.input = new Element("input", {"type": "text", "value": this.data.name}).inject(this.nameNode);
- this.setEditNameInput();
- }
- }.bind(this));
-
- this.valueNodeClick();
- },
- selectNodeClick: function(){
- if (!this.selected){
- this.selected = true;
- this.selectNode.setStyles(this.style.selectNode_selected);
- this.node.setStyles(this.style.contentNode_selected);
- this.item.selectedDutys.push(this);
- this.item.checkDeleteDutyAction();
- }else{
- this.selected = false;
- this.selectNode.setStyles(this.style.selectNode);
- this.node.setStyles(this.style.contentNode);
- this.item.selectedDutys.erase(this);
- this.item.checkDeleteDutyAction();
- }
- },
- valueNodeClick: function(){
-
- },
- setEditNameInput: function(){
- this.input.setStyles(this.style.nameInputNode);
- this.input.focus();
- this.input.addEvents({
- "blur": function(){
- var name = this.input.get("value");
- if (name){
- if (name != this.data.name){
- this.save(name);
- }else{
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name);
- }
- }else{
- if (!this.data.id){
- this.node.destroy();
- delete this;
- }else{
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name);
- }
- }
- }.bind(this)
- });
- },
- save: function(name){
- var oldName = this.data.name;
- if (name) this.data.name = name;
- this.item.explorer.actions.saveCompanyDuty(this.data, function(json){
- this.data.id = json.data.id;
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name)
- this.loadValue();
- }.bind(this), function(xhr, text, error){
- this.data.name = oldName;
- this.input.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- loadValue: function(){
- this.identitys = [];
- this.valueNode.empty();
- if (this.data.identityList){
- this.data.identityList.each(function(id){
- if (id){
- this.item.explorer.actions.getIdentity(function(identity){
- MWF.require("MWF.widget.Identity", function(){
- this.identitys.push(new MWF.widget.Identity(identity.data, this.valueNode, this.item.explorer));
- }.bind(this));
- }.bind(this), null, id, false);
- }
- }.bind(this));
- }
- },
- addIdentitys: function(){
- var selector = new MWF.OrgSelector(this.item.explorer.app.content, {
- "type": "Identity",
- "values": this.data.identityList || [],
- "onComplete": function(items){
- var ids = [];
- items.each(function(item){ids.push(item.data.id);});
- this.data.identityList = ids;
- this.save();
- }.bind(this)
- });
- //selector.load();
- },
- remove: function(){
- this.item.explorer.actions.deleteCompanyDuty(this.data.id, function(){
- this.node.destroy();
- delete this;
- }.bind(this));
- }
- });
- MWF.xApplication.Organization.DepartmentDuty = new Class({
- Extends: MWF.xApplication.Organization.CompanyDuty,
- save: function(name){
- var oldName = this.data.name;
- if (name) this.data.name = name;
- this.item.explorer.actions.saveDepartmentDuty(this.data, function(json){
- this.data.id = json.data.id;
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name);
- this.loadValue();
- }.bind(this), function(xhr, text, error){
- this.data.name = oldName;
- this.input.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- remove: function(){
- this.item.explorer.actions.deleteDepartmentDuty(this.data.id, function(){
- this.node.destroy();
- delete this;
- }.bind(this));
- }
- });
- MWF.xApplication.Organization.CompanyAttribute = new Class({
- Extends: MWF.xApplication.Organization.CompanyDuty,
-
- createActionNode: function(){
- this.actionNode = new Element("td", {"styles": this.style.actionAttributeNode}).inject(this.node);
- },
- selectNodeClick: function(){
- if (!this.selected){
- this.selected = true;
- this.selectNode.setStyles(this.style.selectNode_selected);
- this.node.setStyles(this.style.contentNode_selected);
- this.item.selectedAttributes.push(this);
- this.item.checkDeleteAttributeAction();
- }else{
- this.selected = false;
- this.selectNode.setStyles(this.style.selectNode);
- this.node.setStyles(this.style.contentNode);
- this.item.selectedAttributes.erase(this);
- this.item.checkDeleteAttributeAction();
- }
- },
- valueNodeClick: function(){
- this.valueNode.addEvent("click", function(){
- if (!this.valueInput){
- this.valueNode.empty();
- this.valueInput = new Element("input", {"type": "text", "value": (this.data.attributeList) ? this.data.attributeList.join(",") : ""}).inject(this.valueNode);
- this.setEditValueInput();
- }
- }.bind(this));
- },
- setEditValueInput: function(){
- this.valueInput.setStyles(this.style.nameInputNode);
- this.valueInput.focus();
- this.valueInput.addEvents({
- "blur": function(){
- var value = this.valueInput.get("value");
- if (value){
- if (value != this.data.attributeList.join(",")){
- this.saveValue(value);
- }else{
- this.valueNode.empty();
- this.valueInput = null;
- this.valueNode.set("text", this.data.attributeList.join(","));
- }
- }else{
- if (!this.data.id){
- this.node.destroy();
- delete this;
- }else{
- this.valueNode.empty();
- this.valueInput = null;
- this.valueNode.set("text", this.data.attributeList.join(","));
- }
- }
- }.bind(this)
- });
- },
- saveValue: function(value){
- var oldValue = this.data.attributeList;
- this.data.attributeList = value.split("/,\s*/");
- this.item.explorer.actions.saveCompanyAttribute(this.data, function(json){
- this.data.id = json.data.id;
- this.valueNode.empty();
- this.valueInput = null;
- this.valueNode.set("text", this.data.attributeList.join(","));
- }.bind(this), function(xhr, text, error){
- this.data.attributeList = oldValue;
- this.valueInput.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- loadValue: function(){
- if (this.data.attributeList) this.valueNode.set("text", this.data.attributeList.join(","));
- },
- save: function(name){
- var oldName = this.data.name;
- this.data.name = name;
- this.item.explorer.actions.saveCompanyAttribute(this.data, function(json){
- this.data.id = json.data.id;
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name);
- }.bind(this), function(xhr, text, error){
- this.data.name = oldName;
- this.input.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- remove: function(){
- this.item.explorer.actions.deleteCompanyAttribute(this.data.id, function(){
- this.node.destroy();
- delete this;
- }.bind(this));
- }
- });
- MWF.xApplication.Organization.DepartmentAttribute = new Class({
- Extends: MWF.xApplication.Organization.CompanyAttribute,
- saveValue: function(value){
- var oldValue = this.data.attributeList;
- this.data.attributeList = value.split("/,\s*/");
- this.item.explorer.actions.saveDepartmentAttribute(this.data, function(json){
- this.data.id = json.data.id;
- this.valueNode.empty();
- this.valueInput = null;
- this.valueNode.set("text", this.data.attributeList.join(","));
- }.bind(this), function(xhr, text, error){
- this.data.attributeList = oldValue;
- this.valueInput.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- save: function(name){
- var oldName = this.data.name;
- this.data.name = name;
- this.item.explorer.actions.saveDepartmentAttribute(this.data, function(json){
- this.data.id = json.data.id;
- this.nameNode.empty();
- this.input = null;
- this.nameNode.set("text", this.data.name);
- }.bind(this), function(xhr, text, error){
- this.data.name = oldName;
- this.input.focus();
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- this.item.explorer.app.notice("request json error: "+errorText, "error");
- }.bind(this));
- },
- remove: function(){
- this.item.explorer.actions.deleteDepartmentAttribute(this.data.id, function(){
- this.node.destroy();
- delete this;
- }.bind(this));
- }
- });
- //MWF.xApplication.Organization.Identity = new Class({
- // initialize: function(data, container, explorer, style, canRemove, removeAction){
- // this.container = $(container);
- // this.data = data;
- // this.style = style;
- // this.explorer = explorer;
- // this.canRemove = canRemove || false;
- // this.removeAction = removeAction;
- // this.load();
- // },
- // load: function(){
- // this.node = new Element("div", {
- // "styles": this.style.identityNode,
- // "text": this.data.name
- // }).inject(this.container);
- //
- // if (this.canRemove){
- // this.removeNode = new Element("div", {
- // "styles": this.style.identityRemoveNode
- // }).inject(this.node);
- // if (this.removeAction) this.removeNode.addEvent("click", this.removeAction.bind(this));
- //// var pr = this.node.getStyle("padding-right").toFloat();
- //// pr = pr+this.removeNode.getSize().x;
- //// this.node.setStyle("padding-right", ""+pr+"px");
- // }
- //
- // this.explorer.actions.getPerson(function(person){
- // this.inforNode = new Element("div", {
- // "styles": this.style.identityInforNode
- // });
- // var nameNode = new Element("div", {
- // "styles": this.style.identityInforNameNode
- // }).inject(this.inforNode);
- // var picNode = new Element("div", {
- // "styles": this.style.identityInforPicNode,
- // "html": "<img width='50' height='50' border='0' src='"+"/x_component_Organization/$OrgExplorer/default/icon/head.png'></img>"
- // }).inject(nameNode);
- // var nameTextNode = new Element("div", {
- // "styles": this.style.identityInforNameTextNode,
- // "text": person.data.display
- // }).inject(nameNode);
- //
- // var phoneNode = new Element("div", {
- // "styles": this.style.identityInforPhoneNode,
- // "html": "<div style='width:30px; float:left'>"+this.explorer.app.lp.phone+": </div><div style='width:90px; float:left; margin-left:10px'>"+person.data.mobile+"</div>"
- // }).inject(this.inforNode);
- // var mailNode = new Element("div", {
- // "styles": this.style.identityInforPhoneNode,
- // "html": "<div style='width:30px; float:left'>"+this.explorer.app.lp.mail+": </div><div style='width:90px; float:left; margin-left:10px'>"+person.data.mail+"</div>"
- // }).inject(this.inforNode);
- //
- //
- // new mBox.Tooltip({
- // content: this.inforNode,
- // setStyles: {content: {padding: 15, lineHeight: 20}},
- // attach: this.node,
- // transition: 'flyin'
- // });
- //
- // }.bind(this), null, this.data.person);
- //
- //
- // this.node.addEvents({
- // "mouseover": function(){
- // this.node.setStyles(this.style.identityNode_over);
- // // this.showPersonInfor();
- // }.bind(this),
- // "mouseout": function(){
- // this.node.setStyles(this.style.identityNode);
- // // this.hidePersonInfor();
- // }.bind(this)
- // });
- // }
- //});
|