WorkList.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.Execution.WorkList = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "workNavi1" : "",
  10. "workNavi2" : ""
  11. },
  12. initialize: function (node, app, actions, options) {
  13. this.setOptions(options);
  14. this.app = app;
  15. this.lp = app.lp.workList;
  16. this.path = "/x_component_Execution/$WorkList/";
  17. this.loadCss();
  18. this.actions = actions;
  19. this.node = $(node);
  20. },
  21. loadCss: function () {
  22. this.cssPath = "/x_component_Execution/$WorkList/" + this.options.style + "/css.wcss";
  23. this._loadCss();
  24. },
  25. load: function () {
  26. if(!this.appointSwitch){
  27. var switchData = {};
  28. switchData.configCode = "WORK_AUTHORIZE";
  29. this.actions.getProfileByCode(switchData,function(json){
  30. if(json.type == "success"){
  31. if(json.data && json.data.configValue){
  32. this.appointSwitch = json.data.configValue;
  33. }
  34. }
  35. }.bind(this),null,false);
  36. }
  37. this.tabLocation = ""
  38. this.middleContent = this.app.middleContent;
  39. this.middleContent.setStyles({"margin-top":"0px","border":"0px solid #f00"});
  40. this.createNaviContent();
  41. this.createContentDiv();
  42. this.resizeWindow();
  43. this.app.addEvent("resize", function(){
  44. this.resizeWindow();
  45. }.bind(this));
  46. },
  47. resizeWindow: function(){
  48. var size = this.app.middleContent.getSize();
  49. if( this.naviDiv)this.naviDiv.setStyles({"height":(size.y-60)+"px"});
  50. if(this.naviContentDiv)this.naviContentDiv.setStyles({"height":(size.y-180)+"px"});
  51. if(this.contentDiv)this.contentDiv.setStyles({"height":(size.y-60)+"px"});
  52. if(this.rightContentDiv)this.rightContentDiv.setStyles({"height":(size.y-40-140)+"px"});
  53. },
  54. createNaviContent: function(){
  55. this.naviDiv = new Element("div.naviDiv",{
  56. "styles":this.css.naviDiv
  57. }).inject(this.middleContent);
  58. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  59. "styles":this.css.naviTitleDiv,
  60. "text":this.lp.navi.title
  61. }).inject(this.naviDiv);
  62. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  63. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  64. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv)
  65. .addEvents({
  66. "click":function(){
  67. this.app.openWorkReport()
  68. }.bind(this)
  69. })
  70. var naviContentImg = new Element("img.naviContentImg",{
  71. "styles":this.css.naviContentImg,
  72. "src":this.path+"default/icon/Prototype-100.png"
  73. }).inject(naviContentLi);
  74. var naviContentSpan = new Element("span.naviContentSpan",{
  75. "styles":this.css.naviContentSpan,
  76. "text":this.lp.navi.items.workReport
  77. }).inject(naviContentLi)
  78. },
  79. createContentDiv: function(){
  80. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleContent);
  81. this.createCategoryItemDiv();
  82. this.clickWorkListNavi( this.options.workNavi1 || "base", this.options.workNavi2 || "" );
  83. },
  84. createCategoryItemDiv: function(){
  85. this.rightCategoryDiv = new Element("div.rightCategoryDiv",{"styles":this.css.rightCategoryDiv}).inject(this.contentDiv);
  86. var isCreate = false;
  87. this.actions.createCenterWorkAuthorization(function(json){
  88. if(json.data && json.data.value){
  89. isCreate = json.data.value;
  90. }
  91. }.bind(this),null,false)
  92. if(isCreate){
  93. this.rightCategoryNewDiv = new Element("div.rightCategoryNewDiv",{
  94. "styles":this.css.rightCategoryNewDiv,
  95. "text":this.lp.createWork
  96. }).inject(this.rightCategoryDiv)
  97. .addEvents({
  98. "click":function(){
  99. MWF.xDesktop.requireApp("Execution", "WorkDeploy", function(){
  100. this.explorer = new MWF.xApplication.Execution.WorkDeploy(this, this.actions,{},{
  101. "isEdited":true,
  102. "isNew":true,
  103. "onReloadView" : function( data ){
  104. this.createRightContentDiv(this.workNavi1,this.workNavi2)
  105. }.bind(this)
  106. });
  107. this.explorer.load();
  108. }.bind(this))
  109. }.bind(this)
  110. });
  111. }
  112. this.rightCategoryItemDiv = new Element("div.rightCategoryItemDiv",{"styles":this.css.rightCategoryItemDiv}).inject(this.rightCategoryDiv);
  113. this.centerWorkLi = new Element("li.centerWorkLi",{
  114. "styles":this.css.rightCategoryItemCurrentLi,
  115. "text": this.lp.workItems.centerWork.title
  116. }).inject(this.rightCategoryItemDiv)
  117. .addEvents({
  118. "click":function(){
  119. //alert("中心工作点击");
  120. this.clickWorkListNavi("center")
  121. }.bind(this)
  122. })
  123. this.baseWorkLi = new Element("li.baseWorkLi",{
  124. "styles":this.css.rightCategoryItemLi,
  125. "text": this.lp.workItems.baseWork.title
  126. }).inject(this.rightCategoryItemDiv)
  127. .addEvents({
  128. "click":function(){
  129. //alert("具体工作点击");
  130. this.clickWorkListNavi("base");
  131. }.bind(this)
  132. })
  133. this.rightSearchDiv = new Element("div.rightSearchDiv",{"styles":this.css.rightSearchDiv}).inject(this.contentDiv);
  134. },
  135. clickWorkListNavi : function( workNavi1, workNavi2 ){
  136. this.workNavi1 = workNavi1 || "base";
  137. if(this.rightSearchDiv)this.rightSearchDiv.empty();
  138. if(this.rightContentDiv)this.rightContentDiv.destroy();
  139. if( workNavi1 == "base" ){
  140. if(this.centerWorkLi)this.centerWorkLi.setStyles({"border-bottom":""});
  141. if(this.baseWorkLi)this.baseWorkLi.setStyles({"border-bottom":"2px solid #124c93"});
  142. this.createBaseWorkSearchDiv();
  143. this.createRightContentDiv( "base" , workNavi2 || "" );
  144. }else{
  145. if(this.centerWorkLi)this.centerWorkLi.setStyles({"border-bottom":"2px solid #124c93"});
  146. if(this.baseWorkLi)this.baseWorkLi.setStyles({"border-bottom":""});
  147. this.createCenterWorkSearchDiv();
  148. this.createRightContentDiv("center", workNavi2 || "" );
  149. }
  150. },
  151. createCenterWorkSearchDiv: function(){
  152. this.rightDrafterTabLi = new Element("li.rightDrafterTabLi", {
  153. "styles": this.css.rightDrafterTabLi,
  154. "text" : MWF.xApplication.Execution.LP.workTask.centerWorkDrafter
  155. }).inject(this.rightSearchDiv)
  156. .addEvents({
  157. "click":function(){
  158. this.clickCenterWorkTaskNavi("drafter")
  159. }.bind(this)
  160. })
  161. this.rightDeployTabLi = new Element("li.rightDeployTabLi", {
  162. "styles": this.css.rightDeployTabLi,
  163. "text" :MWF.xApplication.Execution.LP.workTask.centerWorkDeploy
  164. }).inject(this.rightSearchDiv)
  165. .addEvents({
  166. "click":function(){
  167. this.clickCenterWorkTaskNavi("deploy")
  168. }.bind(this)
  169. })
  170. this.rightArchiveTabLi = new Element("li.rightArchiveTabLi", {
  171. "styles": this.css.rightArchiveTabLi,
  172. "text" :MWF.xApplication.Execution.LP.workTask.centerWorkArchive
  173. }).inject(this.rightSearchDiv)
  174. .addEvents({
  175. "click":function(){
  176. this.clickCenterWorkTaskNavi("archive")
  177. }.bind(this)
  178. })
  179. rightSearchBarSpan = new Element("span.rightSearchBarSpan",{
  180. "styles":this.css.rightSearchBarSpan
  181. }).inject(this.rightSearchDiv);
  182. this.rightSearchBarInput = new Element("input.rightSearchBarInput",{
  183. "styles":this.css.rightSearchBarInput,
  184. "type":"text"
  185. }).inject(rightSearchBarSpan)
  186. .addEvents({
  187. "keyup": function(e){
  188. if(e.code == 13){
  189. this.searchAction();
  190. }
  191. }.bind(this)
  192. })
  193. this.rightSearchBarSearch = new Element("div.rightSearchBarSearch",{
  194. "styles":this.css.rightSearchBarSearch,
  195. "text" : MWF.xApplication.Execution.LP.workTask.search
  196. }).inject(rightSearchBarSpan)
  197. .addEvents({
  198. "click":function(){
  199. this.searchAction();
  200. }.bind(this)
  201. })
  202. },
  203. clickCenterWorkTaskNavi : function( str ){
  204. if(this.rightSearchBarInput) this.rightSearchBarInput.set("value","")
  205. this.workNavi1 = "center"
  206. this.workNavi2 = str || "deploy";
  207. if( str == "drafter" ){
  208. this.rightContentDiv.empty();
  209. if(this.rightDrafterTabLi)this.rightDrafterTabLi.setStyles({"border-bottom":"2px solid #124c93"});
  210. if(this.rightDeployTabLi)this.rightDeployTabLi.setStyles({"border-bottom":""});
  211. if(this.rightArchiveTabLi)this.rightArchiveTabLi.setStyles({"border-bottom":""});
  212. this.loadCenterWorkList("drafter");
  213. }else if(str=="archive"){
  214. this.rightContentDiv.empty();
  215. if(this.rightArchiveTabLi)this.rightArchiveTabLi.setStyles({"border-bottom":"2px solid #124c93"});
  216. if(this.rightDeployTabLi)this.rightDeployTabLi.setStyles({"border-bottom":""});
  217. if(this.rightDrafterTabLi)this.rightDrafterTabLi.setStyles({"border-bottom":""});
  218. this.loadCenterWorkList("archive");
  219. }else{
  220. this.rightContentDiv.empty();
  221. if(this.rightDrafterTabLi)this.rightDrafterTabLi.setStyles({"border-bottom":""});
  222. if(this.rightArchiveTabLi)this.rightArchiveTabLi.setStyles({"border-bottom":""});
  223. if(this.rightDeployTabLi)this.rightDeployTabLi.setStyles({"border-bottom":"2px solid #124c93"});
  224. this.loadCenterWorkList("deploy");
  225. }
  226. },
  227. createBaseWorkSearchDiv:function(){
  228. //全部工作
  229. this.baseAllTabLi = new Element("li.baseAllTabLi", {
  230. "styles": this.css.baseTabLi,
  231. "text" : this.lp.baseWorkCategory.all
  232. }).inject(this.rightSearchDiv)
  233. .addEvents({
  234. "click":function(){
  235. this.clickBaseWorkTaskNavi("myAll")
  236. }.bind(this)
  237. })
  238. //草稿
  239. this.baseDrafterTabLi = new Element("li.baseDrafterTabLi", {
  240. "styles": this.css.baseTabLi,
  241. "text" : this.lp.baseWorkCategory.myDrafter
  242. }).inject(this.rightSearchDiv)
  243. .addEvents({
  244. "click":function(){
  245. this.clickBaseWorkTaskNavi("myDrafter")
  246. }.bind(this)
  247. })
  248. //我部署的
  249. this.baseDeployTabLi = new Element("li.baseDeployTabLi", {
  250. "styles": this.css.baseTabLi,
  251. "text" : this.lp.baseWorkCategory.myDeploy
  252. }).inject(this.rightSearchDiv)
  253. .addEvents({
  254. "click":function(){
  255. this.clickBaseWorkTaskNavi("myDeploy");
  256. }.bind(this)
  257. })
  258. //我负责的
  259. this.baseDoTabLi = new Element("li.baseDoTabLi", {
  260. "styles": this.css.baseTabLi,
  261. "text" : this.lp.baseWorkCategory.myDo
  262. }).inject(this.rightSearchDiv)
  263. .addEvents({
  264. "click":function(){
  265. this.clickBaseWorkTaskNavi("myDo");
  266. }.bind(this)
  267. })
  268. //我协助的
  269. this.baseAssistTabLi = new Element("li.baseAssistTabLi", {
  270. "styles": this.css.baseTabLi,
  271. "text" : this.lp.baseWorkCategory.myAssist
  272. }).inject(this.rightSearchDiv)
  273. .addEvents({
  274. "click":function(){
  275. this.clickBaseWorkTaskNavi("myAssist");
  276. }.bind(this)
  277. })
  278. //我阅知的
  279. this.baseReadTabLi = new Element("li.baseReadTabLi", {
  280. "styles": this.css.baseTabLi,
  281. "text" : this.lp.baseWorkCategory.myRead
  282. }).inject(this.rightSearchDiv)
  283. .addEvents({
  284. "click":function(){
  285. this.clickBaseWorkTaskNavi("myRead");
  286. }.bind(this)
  287. })
  288. if(this.appointSwitch && this.appointSwitch.toUpperCase() == "OPEN"){
  289. //我委派的
  290. this.baseAppointTabLi = new Element("li.baseAppointTabLi", {
  291. "styles": this.css.baseTabLi,
  292. "text" : this.lp.baseWorkCategory.myAppoint
  293. }).inject(this.rightSearchDiv)
  294. .addEvents({
  295. "click":function(){
  296. this.clickBaseWorkTaskNavi("myAppoint");
  297. }.bind(this)
  298. })
  299. }
  300. //已归档
  301. this.baseArchiveTabLi = new Element("li.baseArchiveTabLi", {
  302. "styles": this.css.baseTabLi,
  303. "text" : this.lp.baseWorkCategory.myArchive
  304. }).inject(this.rightSearchDiv)
  305. .addEvents({
  306. "click":function(){
  307. this.clickBaseWorkTaskNavi("myArchive");
  308. }.bind(this)
  309. })
  310. rightSearchBarSpan = new Element("span.rightSearchBarSpan",{
  311. "styles":this.css.rightSearchBarSpan
  312. }).inject(this.rightSearchDiv);
  313. this.rightSearchBarInput = new Element("input.input",{
  314. "styles":this.css.rightSearchBarInput,
  315. "type":"text"
  316. }).inject(rightSearchBarSpan)
  317. .addEvents({
  318. "keyup": function(e){
  319. if(e.code == 13){
  320. this.searchAction();
  321. }
  322. }.bind(this)
  323. })
  324. this.rightSearchBarSearch = new Element("div.rightSearchBarSearch",{
  325. "styles":this.css.rightSearchBarSearch,
  326. "text" : this.lp.searchButton.search
  327. }).inject(rightSearchBarSpan)
  328. .addEvents({
  329. "click":function(){
  330. this.searchAction();
  331. }.bind(this)
  332. })
  333. },
  334. clickBaseWorkTaskNavi : function( str ){
  335. if(this.rightSearchBarInput) this.rightSearchBarInput.set("value","")
  336. this.workNavi1 = "base"
  337. this.workNavi2 = str || "myDo";
  338. if( str == "myDrafter" ) {
  339. this.changeBaseWork(this.baseDrafterTabLi)
  340. this.loadBaseWorkList("myDrafter");
  341. }else if(str =="myDeploy"){
  342. this.changeBaseWork(this.baseDeployTabLi);
  343. this.loadBaseWorkList("myDeploy");
  344. }else if( str == "myDo" ){
  345. this.changeBaseWork(this.baseDoTabLi);
  346. this.loadBaseWorkList("myDo");
  347. }else if( str == "myAssist" ){
  348. this.changeBaseWork(this.baseAssistTabLi)
  349. this.loadBaseWorkList("myAssist");
  350. }else if( str == "myRead" ){
  351. this.changeBaseWork(this.baseReadTabLi)
  352. this.loadBaseWorkList("myRead");
  353. }else if( str == "myAppoint") {
  354. this.changeBaseWork(this.baseAppointTabLi)
  355. this.loadBaseWorkList("myAppoint");
  356. }else if( str == "myArchive"){
  357. this.changeBaseWork(this.baseArchiveTabLi)
  358. this.loadBaseWorkList("myArchive");
  359. }else if(str == "myAll"){
  360. this.changeBaseWork(this.baseAllTabLi)
  361. this.loadBaseWorkList("myAll");
  362. }else{
  363. this.changeBaseWork(this.baseDoTabLi)
  364. this.loadBaseWorkList("myDo");
  365. }
  366. },
  367. reloadRightContentDiv : function(){
  368. if(this.rightContentDiv)this.rightContentDiv.destroy();
  369. this.rightContentDiv = new Element("div.rightContentDiv",{
  370. "styles":this.css.rightContentDiv
  371. }).inject(this.contentDiv);
  372. },
  373. createRightContentDiv: function(workNavi1 , workNavi2 ){
  374. //alert(this.app.middleContent.getSize()-40-140+"px")
  375. if(this.rightContentDiv)this.rightContentDiv.destroy();
  376. this.rightContentDiv = new Element("div.rightContentDiv",{
  377. "styles":this.css.rightContentDiv
  378. }).inject(this.contentDiv);
  379. if(workNavi1=="base"){
  380. this.clickBaseWorkTaskNavi( workNavi2 );
  381. }else{
  382. this.clickCenterWorkTaskNavi( workNavi2 );
  383. }
  384. },
  385. createTableContent:function(json,colsJson){
  386. },
  387. loadCenterWorkList: function (str,filter) {
  388. if( this.baseView )delete this.baseView;
  389. //if(this.rightContentDiv) this.rightContentDiv.empty();
  390. this.reloadRightContentDiv();
  391. this.rightContentDiv.setStyles({"height":this.app.middleContent.getSize().y-40-140+"px"});
  392. if(this.scrollBar && this.scrollBar.scrollVAreaNode){
  393. this.scrollBar.scrollVAreaNode.destroy()
  394. }
  395. MWF.require("MWF.widget.ScrollBar", function () {
  396. this.scrollBar = new MWF.widget.ScrollBar(this.rightContentDiv, {
  397. "indent": false,
  398. "style": "xApp_TaskList",
  399. "where": "before",
  400. "distance": 100,
  401. "friction": 4,
  402. "axis": {"x": false, "y": true},
  403. "onScroll": function (y) {
  404. var scrollSize = this.rightContentDiv.getScrollSize();
  405. var clientSize = this.rightContentDiv.getSize();
  406. var scrollHeight = scrollSize.y - clientSize.y;
  407. var view = this.baseView || this.centerView;
  408. if (y + 200 > scrollHeight && view && view.loadElementList) {
  409. if (! view.isItemsLoaded) view.loadElementList()
  410. }
  411. }.bind(this)
  412. });
  413. }.bind(this),false);
  414. templateUrl = this.path+"centerWorkAll.json";
  415. this.centerView = new MWF.xApplication.Execution.WorkList.CenterWorkView(this.rightContentDiv, this.app, {explorer:this,lp : this.app.lp.centerWorkView, css : this.css, actions : this.actions }, { templateUrl : templateUrl,category:str,filterData:filter } )
  416. this.centerView.load();
  417. },
  418. loadBaseWorkList: function (str,filter) {
  419. this.workNavi2 = str || "deploy"
  420. if( this.centerView )delete this.centerView;
  421. this.reloadRightContentDiv();
  422. this.rightContentDiv.setStyles({"height":this.app.middleContent.getSize().y-40-140+"px"});
  423. templateUrl= this.path+"baseWorkAll.json";
  424. if(this.scrollBar && this.scrollBar.scrollVAreaNode){
  425. this.scrollBar.scrollVAreaNode.destroy()
  426. }
  427. MWF.require("MWF.widget.ScrollBar", function () {
  428. if(this.scrollBar) delete this.scrollBar
  429. this.scrollBar = new MWF.widget.ScrollBar(this.rightContentDiv, {
  430. "indent": false,
  431. "style": "xApp_TaskList",
  432. "where": "before",
  433. "distance": 100,
  434. "friction": 4,
  435. "axis": {"x": false, "y": true},
  436. "onScroll": function (y) {
  437. var scrollSize = this.rightContentDiv.getScrollSize();
  438. var clientSize = this.rightContentDiv.getSize();
  439. var scrollHeight = scrollSize.y - clientSize.y;
  440. var view = this.baseView || this.centerView;
  441. if (y+200 > scrollHeight && view && view.loadElementList) {
  442. if (! view.isItemsLoaded) view.loadElementList();
  443. }
  444. }.bind(this)
  445. });
  446. }.bind(this),false);
  447. this.baseView = new MWF.xApplication.Execution.WorkList.BaseWorkView(this.rightContentDiv, this.app, {lp : this.app.lp.baseWorkView, css : this.css, actions : this.actions }, { templateUrl : templateUrl,category:str,filterData:filter} )
  448. //this.baseView.options.templateUrl =
  449. this.baseView.load();
  450. },
  451. //切换具体工作tab页
  452. changeBaseWork: function(obj){
  453. var liObj = this.rightSearchDiv.getElements("li");
  454. liObj.setStyle("border-bottom","");
  455. obj.setStyle("border-bottom","2px solid #124c93");
  456. },
  457. searchAction : function(){
  458. var filterData = {}
  459. filterData.workTitle = this.rightSearchBarInput.get("value");
  460. if(this.workNavi1 == "base"){
  461. this.loadBaseWorkList(this.workNavi2,filterData)
  462. }else if(this.workNavi1 == "center"){
  463. this.loadCenterWorkList(this.workNavi2,filterData)
  464. }
  465. },
  466. showErrorMessage:function(xhr,text,error){
  467. var errorText = error;
  468. if (xhr) errorMessage = xhr.responseText;
  469. if(errorMessage!=""){
  470. var e = JSON.parse(errorMessage);
  471. if(e.message){
  472. this.app.notice( e.message,"error");
  473. }else{
  474. this.app.notice( errorText,"error");
  475. }
  476. }else{
  477. this.app.notice(errorText,"error")
  478. }
  479. }
  480. })
  481. MWF.xApplication.Execution.WorkList.WorkForm = new Class({
  482. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  483. createTopNode: function(){
  484. if (!this.formTopNode) {
  485. this.formTopNode = new Element("div.formTopNode", {
  486. "styles": this.css.formTopNode
  487. }).inject(this.formNode);
  488. this.formTopImg = new Element("img.formTopImg",{
  489. "styles":this.css.formTopImg,
  490. "src":"/x_component_Execution/$Main/default/icon/Document-104.png"
  491. }).inject(this.formTopNode);
  492. this.formTopSpan = new Element("span.formTopSpan",{
  493. "styles": this.css.formTopSpan,
  494. "text":this.options.title
  495. }).inject(this.formTopNode);
  496. if( this.options.closeAction ){
  497. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  498. this.formTopCloseActionNode.addEvent("click", function () {
  499. this.close()
  500. }.bind(this))
  501. }
  502. }
  503. },
  504. _createBottomContent: function(){
  505. var html = "<span style='color:#f59353'>"+MWF.xApplication.Execution.LP.workTask.popUp.createNewTask.title+"</span>:"+MWF.xApplication.Execution.LP.workTask.popUp.createNewTask.explain
  506. html += "<br><span style='color:#f59353'>"+MWF.xApplication.Execution.LP.workTask.popUp.createAddTask.title+"</span>:"+MWF.xApplication.Execution.LP.workTask.popUp.createAddTask.explain
  507. this.createExplainDiv = new Element("div.createExplainDiv",{
  508. "styles":this.css.createExplainDiv,
  509. "html":html
  510. }).inject(this.formBottomNode);
  511. }
  512. })
  513. MWF.xApplication.Execution.WorkList.CenterWorkView = new Class({
  514. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  515. _createDocument: function(data){
  516. return new MWF.xApplication.Execution.WorkList.CenterWorkDocument(this.viewNode, data, this.explorer, this);
  517. },
  518. _getCurrentPageData: function(callback, count){
  519. var category = this.options.category;
  520. if (!count)count = 15;
  521. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  522. //alert("this.items.length="+this.items.length)
  523. //alert("id="+id)
  524. var filter = this.options.filterData || {};
  525. filter.maxCharacterNumber = "-1"
  526. if(category=="deploy"){
  527. this.tabLocation = "centerDeploy"
  528. this.actions.getCenterWorkDeployListNext(id, count, filter, function (json) {
  529. if (callback)callback(json);
  530. }.bind(this))
  531. }else if(category=="drafter"){
  532. this.tabLocation = "centerDrafter"
  533. this.actions.getCenterWorkDrafterListNext(id, count, filter, function (json) {
  534. if (callback)callback(json);
  535. }.bind(this))
  536. }else if(category=="archive"){
  537. this.tabLocation = "centerArchive"
  538. this.actions.getCenterWorkArchiveListNext(id,count,filter,function(json){
  539. if(callback)callback(json)
  540. }.bind(this))
  541. }else{
  542. this.tabLocation = "centerDeploy"
  543. this.actions.getCenterWorkDeployListNext(id, count, filter, function (json) {
  544. if (callback)callback(json);
  545. }.bind(this),null,false)
  546. }
  547. //this.app.workList.tabLocation = this.tabLocation;
  548. },
  549. _removeDocument: function(documentData, all){
  550. this.actions.deleteCenterWork(documentData.id, function(json){
  551. if(this.tabLocation == "centerDrafter"){
  552. this.app.workList.loadCenterWorkList("drafter")
  553. }else if(this.tabLocation == "centerDeploy"){
  554. this.app.workList.loadCenterWorkList("deploy")
  555. }
  556. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  557. }.bind(this));
  558. },
  559. _create: function(){
  560. },
  561. _openDocument: function( documentData ){
  562. MWF.xDesktop.requireApp("Execution", "WorkDeploy", function(){
  563. this.workDeploy = new MWF.xApplication.Execution.WorkDeploy(this, this.actions,{"id":documentData.id},{
  564. "isEdited":false,
  565. "centerWorkId":documentData.id,
  566. "onReloadView":function(json){
  567. if(json && json.action && json.action == "reload"){
  568. this.explorer.explorer.createRightContentDiv(this.explorer.explorer.workNavi1,this.explorer.explorer.workNavi2)
  569. }
  570. }.bind(this)
  571. } );
  572. this.workDeploy.load();
  573. }.bind(this))
  574. },
  575. _queryCreateViewNode: function(){
  576. },
  577. _postCreateViewNode: function( viewNode ){
  578. },
  579. _queryCreateViewHead:function(){
  580. },
  581. _postCreateViewHead: function( headNode ){
  582. }
  583. })
  584. MWF.xApplication.Execution.WorkList.CenterWorkDocument = new Class({
  585. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  586. viewActionReturn:function(d) {
  587. var ret = false
  588. if(d.operation && d.operation.length==1){
  589. ret = true;
  590. }
  591. //if (d.operation && d.operation.indexOf("VIEW")>-1)ret = true;
  592. return ret;
  593. },
  594. editActionReturn:function(d) {
  595. var ret = false
  596. if (d.operation && d.operation.indexOf("EDIT")>-1)ret = true;
  597. return ret;
  598. },
  599. deleteActionReturn:function(d) {
  600. var ret = false
  601. if (d.operation && d.operation.indexOf("DELETE")>-1)ret = true;
  602. return ret;
  603. },
  604. action_view:function(){
  605. MWF.xDesktop.requireApp("Execution", "WorkDeploy", function(){
  606. this.workDeploy = new MWF.xApplication.Execution.WorkDeploy(this.view, this.view.app.restActions,{"id":this.data.id},{
  607. "isEdited":false,
  608. "centerWorkId":this.data.id,
  609. "onReloadView":function(json){
  610. if(json && json.action && json.action == "reload"){
  611. this.explorer.explorer.clickCenterWorkTaskNavi("drafter")
  612. }
  613. }.bind(this)
  614. });
  615. this.workDeploy.load();
  616. }.bind(this))
  617. },
  618. action_edit:function(){
  619. MWF.xDesktop.requireApp("Execution", "WorkDeploy", function(){
  620. this.workDeploy = new MWF.xApplication.Execution.WorkDeploy(this.view, this.view.app.restActions,{"id":this.data.id},{
  621. "isEdited":true,"centerWorkId":this.data.id
  622. } );
  623. this.workDeploy.load();
  624. }.bind(this))
  625. },
  626. action_delete:function(e){
  627. var _self = this;
  628. _self.view.app.confirm("warn",e,_self.view.app.lp.workList.submitWarn.warnTitle,_self.view.app.lp.workList.submitWarn.warnContent.delete,300,120,function(){
  629. _self.actions.deleteCenterWork(_self.data.id, function(json){
  630. if(json.type && json.type=="success"){
  631. this.app.notice(_self.view.app.lp.workList.prompt.deleteCenterWork, "success");
  632. _self.app.workList.loadCenterWorkList(this.app.workList.workNavi2)
  633. }
  634. }.bind(_self),function(xhr,text,error){
  635. _self.explorer.explorer.showErrorMessage(xhr,text,error)
  636. }.bind(_self));
  637. this.close()
  638. },function(){
  639. this.close();
  640. })
  641. },
  642. _postCreateDocumentNode: function( itemNode, itemData ){
  643. if(itemNode.getElements("span[icon='showIcon']")){
  644. var iconObj = itemNode.getElements("span[icon='showIcon']")
  645. var icons = itemData.workProcessIdentity;
  646. var path = this.app.workList.path+"default/icon/";
  647. var styles = "margin-left:5px";
  648. for(i=0;i<icons.length;i++){
  649. if(icons[i]=="AUTHORIZE"){
  650. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  651. }else if(icons[i]=="TACKBACK"){
  652. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  653. }else if(icons[i]=="AUTHORIZECANCEL"){
  654. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  655. }else if(icons[i]=="RESPONSIBILITY"){
  656. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"responsibility.png' style='"+styles+"' >")
  657. }else if(icons[i]=="COOPERATE"){
  658. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"cooperate.png' style='"+styles+"' >")
  659. }else if(icons[i]=="READ"){
  660. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"read.png' style='"+styles+"' >")
  661. }else if(icons[i]=="DEPLOY"){
  662. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"deploy.png' style='"+styles+"' >")
  663. }else if(icons[i]=="VIEW"){
  664. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"view.png' style='"+styles+"' >")
  665. }
  666. }
  667. }
  668. }
  669. })
  670. MWF.xApplication.Execution.WorkList.BaseWorkView = new Class({
  671. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  672. _createDocument: function(data){
  673. return new MWF.xApplication.Execution.WorkList.BaseWorkDocument(this.viewNode, data, this.explorer, this);
  674. },
  675. _getCurrentPageData: function(callback, count){
  676. var category = this.category = this.options.category;
  677. if (!count)count = 20;
  678. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  679. var filter = this.options.filterData || {};
  680. filter.maxCharacterNumber = "-1"
  681. if(category=="myDrafter"){ //我的草稿
  682. this.tabLocation = "baseDrafter"
  683. this.actions.getBaseWorkListMyDrafterNext(id, count, filter, function (json) {
  684. if (callback)callback(json);
  685. }.bind(this))
  686. }else if(category=="myDeploy"){ //我部署的
  687. this.tabLocation = "baseDeploy"
  688. this.actions.getBaseWorkListMyDeployNext(id, count, filter, function (json) {
  689. if (callback)callback(json);
  690. }.bind(this))
  691. }else if(category=="myDo"){ //我负责的
  692. this.tabLocation = "baseDo"
  693. this.actions.getBaseWorkListMyDoNext(id, count, filter, function (json) {
  694. if (callback)callback(json);
  695. }.bind(this))
  696. }else if(category=="myAssist"){ //我协助的
  697. this.tabLocation = "baseAssist"
  698. this.actions.getBaseWorkListMyAssistNext(id, count, filter, function (json) {
  699. if (callback)callback(json);
  700. }.bind(this))
  701. }else if(category=="myRead"){ //我阅知的
  702. this.tabLocation = "baseRead"
  703. this.actions.getBaseWorkListMyReadNext(id, count, filter, function (json) {
  704. if (callback)callback(json);
  705. }.bind(this))
  706. }else if(category=="myAppoint"){ //我委托的
  707. this.tabLocation = "baseAppoint"
  708. this.actions.getBaseWorkListMyAppointNext(id, count,filter,function(json){
  709. if (callback)callback(json)
  710. }.bind(this))
  711. }else if(category=="myArchive"){
  712. this.tabLocation = "baseArchive"
  713. this.actions.getBaseWorkListMyArchiveNext(id, count,filter,function(json){
  714. if (callback)callback(json)
  715. }.bind(this))
  716. }else if(category=="myAll"){
  717. this.tabLocation = "baseAll";
  718. this.actions.getBaseWorkListAllNext(id, count,filter,function(json){
  719. if (callback)callback(json)
  720. }.bind(this))
  721. }
  722. this.app.workList.tabLocation = this.tabLocation;
  723. },
  724. _removeDocument: function(documentData, all){
  725. this.actions.deleteBaseWork(documentData.id, function(json){
  726. if(json.type && json.type=="success"){
  727. if(this.tabLocation == "baseDrafter"){
  728. this.app.workList.loadBaseWorkList("myDrafter")
  729. }else if(this.tabLocation == "baseDeploy"){
  730. this.app.workList.loadBaseWorkList("myDeploy")
  731. }
  732. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  733. }
  734. }.bind(this),function(xhr,text,error){
  735. var errorText = error;
  736. if (xhr) errorMessage = xhr.responseText;
  737. var e = JSON.parse(errorMessage);
  738. if(e.message){
  739. this.app.notice( e.message,"error");
  740. }else{
  741. this.app.notice( errorText,"error");
  742. }
  743. }.bind(this));
  744. },
  745. _create: function(){
  746. },
  747. _openDocument: function( documentData ){
  748. if( documentData.workProcessStatus == this.lp.workProcessStatus.drafter ){
  749. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  750. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,documentData,{
  751. "isNew": false,
  752. "isEdited": false,
  753. "tabLocation":this.category
  754. });
  755. workform.load();
  756. }.bind(this));
  757. }else{
  758. MWF.xDesktop.requireApp("Execution", "WorkDetail", function(){
  759. var workform = new MWF.xApplication.Execution.WorkDetail(this, this.app.restActions,documentData,{
  760. "isNew": false,
  761. "isEdited": false,
  762. "tabLocation":this.category
  763. });
  764. workform.load();
  765. }.bind(this));
  766. }
  767. },
  768. _queryCreateViewNode: function(){
  769. },
  770. _postCreateViewNode: function( viewNode ){
  771. },
  772. _queryCreateViewHead:function(){
  773. },
  774. _postCreateViewHead: function( headNode ){
  775. }
  776. })
  777. MWF.xApplication.Execution.WorkList.BaseWorkDocument = new Class({
  778. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  779. viewActionReturn:function(d) {
  780. var ret = false
  781. if(d.operation && d.operation.length==1){
  782. ret = true;
  783. }
  784. //if (d.operation && d.operation.indexOf("VIEW")>-1)ret = true;
  785. return ret;
  786. },
  787. editActionReturn:function(d) {
  788. var ret = false
  789. if (d.operation && d.operation.indexOf("EDIT")>-1)ret = true;
  790. return ret;
  791. },
  792. splitActionReturn:function(d) {
  793. var ret = false
  794. if (d.operation && d.operation.indexOf("SPLIT")>-1)ret = true;
  795. return ret;
  796. },
  797. authorizeActionReturn:function(d) {
  798. var ret = false
  799. if (d.operation && d.operation.indexOf("AUTHORIZE")>-1)ret = true;
  800. return ret;
  801. },
  802. tackBackActionReturn:function(d) {
  803. var ret = false
  804. if (d.operation && d.operation.indexOf("TACKBACK")>-1)ret = true;
  805. return ret;
  806. },
  807. reportActionReturn:function(d) {
  808. var ret = false
  809. if (d.operation && d.operation.indexOf("REPORT")>-1)ret = true;
  810. return ret;
  811. },
  812. deleteActionReturn:function(d) {
  813. var ret = false
  814. if (d.operation && d.operation.indexOf("DELETE")>-1)ret = true;
  815. return ret;
  816. },
  817. action_view:function(){
  818. if( this.data.workProcessStatus == this.lp.workProcessStatus.drafter ){
  819. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  820. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,this.data,{
  821. "isNew": false,
  822. "isEdited": false,
  823. "tabLocation":this.category
  824. });
  825. workform.load();
  826. }.bind(this));
  827. }else{
  828. MWF.xDesktop.requireApp("Execution", "WorkDetail", function(){
  829. var workform = new MWF.xApplication.Execution.WorkDetail(this, this.app.restActions,this.data,{
  830. "isNew": false,
  831. "isEdited": false,
  832. "tabLocation":this.category
  833. });
  834. workform.load();
  835. }.bind(this));
  836. }
  837. },
  838. action_edit:function(){
  839. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  840. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,this.data,{
  841. "isNew": false,
  842. "isEdited": true,
  843. "tabLocation":this.view.category,
  844. "actionStatus":"save"
  845. });
  846. workform.load();
  847. }.bind(this));
  848. },
  849. action_split:function(){
  850. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  851. //var data = {
  852. // title : this.data.title,
  853. // centerId : this.data.centerId,
  854. // //centerTitle: this.data.centerTitle,
  855. // parentWorkId : this.data.id,
  856. // //parentWorkTitle : this.data.title,
  857. // workType : this.data.workType,
  858. // workLevel : this.data.workLevel,
  859. // completeDateLimitStr : this.data.completeDateLimitStr,
  860. // completeDateLimit : this.data.completeDateLimit,
  861. // reportCycle: this.data.reportCycle,
  862. // reportDayInCycle: this.data.reportDayInCycle,
  863. // workSplitAndDescription : this.data.workDetail
  864. //}
  865. //if(this.data.id){
  866. // this.actions.getBaseWorkDetails(this.data.id, function (json) {
  867. // //data.workSplitAndDescription = json.data.workDetail
  868. // //data.specificActionInitiatives = json.data.progressAction
  869. // //data.cityCompanyDuty = json.data.dutyDescription
  870. // //data.milestoneMark = json.data.landmarkDescription
  871. // //data.importantMatters = json.data.majorIssuesDescription
  872. // }.bind(this),null,false)
  873. //}
  874. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{},{
  875. "isNew": true,
  876. "isEdited": false,
  877. "parentWorkId":this.data.id,
  878. "actionStatus":"deploy"
  879. });
  880. workform.load();
  881. }.bind(this));
  882. },
  883. action_authorize:function(){
  884. data = {
  885. workId : this.data.id
  886. };
  887. var appointForm = new MWF.xApplication.Execution.WorkList.Appoint(this.view.app,this.view.app.restActions,data,this.view.css,{
  888. "ieEdited": true,
  889. "onReloadView" : function( data ){
  890. //this.view.app.workList.createRightContentDiv("base","myAppoint");
  891. this.view.app.workList.clickBaseWorkTaskNavi("myAppoint")
  892. }.bind(this)
  893. });
  894. appointForm.load();
  895. },
  896. action_tackBack:function(e){
  897. var _self = this;
  898. _self.view.app.confirm("warn",e,_self.view.app.lp.workList.submitWarn.warnTitle,_self.view.app.lp.workList.submitWarn.warnContent.tackBack,300,120,function(){
  899. data = {
  900. workId : _self.data.id
  901. };
  902. _self.actions.unAppointBaseWork(data,function(json){
  903. this.app.notice(_self.view.app.lp.workList.prompt.tackbackBaseWork,"success");
  904. }.bind(_self),function(xhr,text,error){
  905. var errorText = error;
  906. if (xhr) errorMessage = xhr.responseText;
  907. var e = JSON.parse(errorMessage);
  908. if(e.message){
  909. this.app.notice( e.message,"error");
  910. }else{
  911. this.app.notice( errorText,"error");
  912. }
  913. }.bind(_self),false)
  914. _self.view.app.workList.clickBaseWorkTaskNavi("myAppoint");
  915. this.close()
  916. },function(){
  917. this.close();
  918. })
  919. },
  920. action_report:function(){
  921. MWF.xDesktop.requireApp("Execution", "WorkReport", function(){
  922. var data = {
  923. workId : this.data.id
  924. }
  925. var workReport = new MWF.xApplication.Execution.WorkReport(this, this.app.restActions,data,{
  926. "isNew": false,
  927. "isEdited": false,
  928. "tabLocation":this.view.category,
  929. "from":"drafter"
  930. });
  931. workReport.load();
  932. }.bind(this));
  933. },
  934. action_delete:function(e){
  935. var _self = this;
  936. _self.view.app.confirm("warn",e,_self.view.app.lp.workList.submitWarn.warnTitle,_self.view.app.lp.workList.submitWarn.warnContent.delete,300,120,function(){
  937. _self.actions.deleteBaseWork(_self.data.id, function(json){
  938. if(json.type && json.type=="success"){
  939. this.app.notice(_self.view.app.lp.workList.prompt.deleteBaseWork, "success");
  940. _self.app.workList.clickBaseWorkTaskNavi(_self.app.workList.workNavi2)
  941. }
  942. }.bind(_self),function(xhr,text,error){
  943. _self.app.WorkList.showErrorMessage(xhr,text,error)
  944. }.bind(_self));
  945. this.close()
  946. },function(){
  947. this.close();
  948. })
  949. },
  950. _queryCreateDocumentNode:function( itemData ){
  951. },
  952. _postCreateDocumentNode: function( itemNode, itemData ){
  953. if(itemNode.getElements("div[name='appointDiv']")){
  954. if(itemData.okrWorkAuthorizeRecord){
  955. itemNode.getElements("div[name='appointDiv']").setStyle("display","")
  956. }
  957. }
  958. if(itemNode.getElements("div[item='workDetail']")){
  959. itemNode.getElements("div[item='workDetail']").set("title",itemData.workDetail)
  960. }
  961. if(itemNode.getElements("div[item='progressAction']")){
  962. itemNode.getElements("div[item='progressAction']").set("title",itemData.progressAction)
  963. }
  964. if(itemNode.getElements("span[icon='showIcon']")){
  965. var iconObj = itemNode.getElements("span[icon='showIcon']")
  966. var icons = itemData.workProcessIdentity;
  967. var path = this.app.workList.path+"default/icon/";
  968. var styles = "margin-left:5px";
  969. for(i=0;i<icons.length;i++){
  970. if(icons[i]=="AUTHORIZE"){
  971. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  972. }else if(icons[i]=="TACKBACK"){
  973. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  974. }else if(icons[i]=="AUTHORIZECANCEL"){
  975. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"authorize.png' style='"+styles+"' >")
  976. }else if(icons[i]=="RESPONSIBILITY"){
  977. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"responsibility.png' style='"+styles+"' >")
  978. }else if(icons[i]=="COOPERATE"){
  979. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"cooperate.png' style='"+styles+"' >")
  980. }else if(icons[i]=="READ"){
  981. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"read.png' style='"+styles+"' >")
  982. }else if(icons[i]=="DEPLOY"){
  983. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"deploy.png' style='"+styles+"' >")
  984. }else if(icons[i]=="VIEW"){
  985. iconObj.set("html",iconObj.get("html")+"<img src='"+path+"view.png' style='"+styles+"' >")
  986. }
  987. }
  988. }
  989. }
  990. })
  991. MWF.xApplication.Execution.WorkList.Appoint = new Class({
  992. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  993. Implements: [Options, Events],
  994. options: {
  995. "style": "default",
  996. "width": "500",
  997. "height": "300",
  998. "hasTop": true,
  999. "hasIcon": false,
  1000. "hasBottom": true,
  1001. "title": "",
  1002. "draggable": false,
  1003. "closeAction": true,
  1004. "closeText" : "",
  1005. "needLogout" : false,
  1006. "isNew": true
  1007. },
  1008. initialize: function (app, actions, data, css, options) {
  1009. this.setOptions(options);
  1010. this.app = app;
  1011. this.actions = this.app.restActions;
  1012. this.css = css;
  1013. //this.options.title = this.app.lp.idenitySelectTitle;
  1014. //
  1015. //this.identities = identities;
  1016. this.data = data || {};
  1017. this.actions = actions;
  1018. },
  1019. load: function () {
  1020. this.create();
  1021. },
  1022. createTopNode: function () {
  1023. if (!this.formTopNode) {
  1024. this.formTopNode = new Element("div.formTopNode", {
  1025. "styles": this.css.formTopNode
  1026. }).inject(this.formNode);
  1027. this.formTopIconNode = new Element("div.formTopIconNode", {
  1028. "styles": this.css.formTopIconNode
  1029. }).inject(this.formTopNode)
  1030. this.formTopTextNode = new Element("div.formTopTextNode", {
  1031. "styles": this.css.formTopTextNode,
  1032. "text": this.app.lp.workTask.appoint.appointTitle
  1033. }).inject(this.formTopNode)
  1034. if (this.options.closeAction) {
  1035. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1036. this.formTopCloseActionNode.addEvent("click", function () {
  1037. this.close()
  1038. }.bind(this))
  1039. }
  1040. this.formTopContentNode = new Element("div.formTopContentNode", {
  1041. "styles": this.css.formTopContentNode
  1042. }).inject(this.formTopNode)
  1043. //this._createTopContent();
  1044. }
  1045. },
  1046. _createTableContent: function () {
  1047. var table = new Element("table",{"width":"100%",border:"0",cellpadding:"5",cellspacing:"0"}).inject(this.formTableArea);
  1048. table.setStyles({"margin-top":"40px"})
  1049. var tr = new Element("tr").inject(table);
  1050. var td = new Element("td",{
  1051. text : this.app.lp.workTask.appoint.appointFor,
  1052. valign:"middle",
  1053. width:"20%"
  1054. }).inject(tr);
  1055. td = new Element("td",{width:"80%"}).inject(tr);
  1056. this.appointPerson = new Element("input",{
  1057. "readonly": true
  1058. }).inject(td);
  1059. this.appointPerson.setStyles({"width":"90%","height":"20px"})
  1060. this.appointPerson.addEvents({
  1061. "click":function(){
  1062. this.selectPerson(this.appointPerson,"identity",1)
  1063. }.bind(this)
  1064. })
  1065. tr = new Element("tr").inject(table);
  1066. td = new Element("td",{
  1067. "text" : this.app.lp.workTask.appoint.appointOpinion,
  1068. valign:"middle"
  1069. }).inject(tr);
  1070. td = new Element("td").inject(tr);
  1071. this.appointOpinion = new Element("textarea").inject(td)
  1072. this.appointOpinion.setStyles({"width":"90%","height":"50px"})
  1073. },
  1074. _createBottomContent: function () {
  1075. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1076. "styles": this.css.formCancelActionNode,
  1077. "text": this.app.lp.workTask.appoint.appointCancel
  1078. }).inject(this.formBottomNode);
  1079. this.cancelActionNode.addEvent("click", function (e) {
  1080. this.close();
  1081. }.bind(this));
  1082. this.okActionNode = new Element("div.formOkActionNode", {
  1083. "styles": this.css.formOkActionNode,
  1084. "text": this.app.lp.workTask.appoint.appointOK
  1085. }).inject(this.formBottomNode);
  1086. this.okActionNode.addEvent("click", function (e) {
  1087. this.ok(e);
  1088. }.bind(this));
  1089. },
  1090. ok:function(){
  1091. if(this.appointPerson.get("value")==""){
  1092. this.app.notice(this.app.lp.workTask.appoint.personEmpty,"error")
  1093. return false;
  1094. }
  1095. if(this.appointOpinion.get("value")==""){
  1096. this.app.notice(this.app.lp.workTask.appoint.opinionEmpty,"error")
  1097. return false;
  1098. }
  1099. var submitData = {
  1100. workId : this.data.workId,
  1101. undertakerIdentity : this.appointPerson.get("value"),
  1102. authorizeOpinion : this.appointOpinion.get("value")
  1103. }
  1104. this.actions.appointBaseWork(submitData,function(json){
  1105. this.close();
  1106. this.fireEvent("reloadView");
  1107. }.bind(this),function(xhr,text,error){
  1108. var errorText = error;
  1109. if (xhr) errorMessage = xhr.responseText;
  1110. var e = JSON.parse(errorMessage);
  1111. if(e.message){
  1112. this.app.notice( e.message,"error");
  1113. }else{
  1114. this.app.notice( errorText,"error");
  1115. }
  1116. }.bind(this),false)
  1117. },
  1118. selectPerson: function( item, type,count ) {
  1119. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  1120. this.fireEvent("querySelect", this);
  1121. var value = item.get("value").split(this.valSeparator);
  1122. var options = {
  1123. "type": type,
  1124. "title": this.app.lp.workTask.appoint.appointTitle,
  1125. "count": count,
  1126. "names": value || [],
  1127. "onComplete": function (items) {
  1128. var arr = [];
  1129. items.each(function (item) {
  1130. arr.push(item.data.name);
  1131. }.bind(this));
  1132. item.set("value", arr.join(","));
  1133. }.bind(this)
  1134. };
  1135. var selector = new MWF.OrgSelector(this.app.content, options);
  1136. }
  1137. });