WorkList.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  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. })
  467. MWF.xApplication.Execution.WorkList.WorkForm = new Class({
  468. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  469. createTopNode: function(){
  470. if (!this.formTopNode) {
  471. this.formTopNode = new Element("div.formTopNode", {
  472. "styles": this.css.formTopNode
  473. }).inject(this.formNode);
  474. this.formTopImg = new Element("img.formTopImg",{
  475. "styles":this.css.formTopImg,
  476. "src":"/x_component_Execution/$Main/default/icon/Document-104.png"
  477. }).inject(this.formTopNode);
  478. this.formTopSpan = new Element("span.formTopSpan",{
  479. "styles": this.css.formTopSpan,
  480. "text":this.options.title
  481. }).inject(this.formTopNode);
  482. if( this.options.closeAction ){
  483. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  484. this.formTopCloseActionNode.addEvent("click", function () {
  485. this.close()
  486. }.bind(this))
  487. }
  488. }
  489. },
  490. _createBottomContent: function(){
  491. var html = "<span style='color:#f59353'>"+MWF.xApplication.Execution.LP.workTask.popUp.createNewTask.title+"</span>:"+MWF.xApplication.Execution.LP.workTask.popUp.createNewTask.explain
  492. html += "<br><span style='color:#f59353'>"+MWF.xApplication.Execution.LP.workTask.popUp.createAddTask.title+"</span>:"+MWF.xApplication.Execution.LP.workTask.popUp.createAddTask.explain
  493. this.createExplainDiv = new Element("div.createExplainDiv",{
  494. "styles":this.css.createExplainDiv,
  495. "html":html
  496. }).inject(this.formBottomNode);
  497. },
  498. showErrorMessage:function(xhr,text,error){
  499. var errorText = error;
  500. if (xhr) errorMessage = xhr.responseText;
  501. if(errorMessage!=""){
  502. var e = JSON.parse(errorMessage);
  503. if(e.userMessage){
  504. this.app.notice( e.userMessage,"error");
  505. }else{
  506. this.app.notice( errorText,"error");
  507. }
  508. }else{
  509. this.app.notice(errorText,"error")
  510. }
  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(json.userMessage, "success");
  632. _self.app.workList.loadCenterWorkList(this.app.workList.workNavi2)
  633. }
  634. }.bind(_self),function(xhr,text,error){
  635. _self.app.workList.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.userMessage){
  739. this.app.notice( e.userMessage,"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(json.userMessage,"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.userMessage){
  909. this.app.notice( e.userMessage,"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(json.userMessage, "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.userMessage){
  1112. this.app.notice( e.userMessage,"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. });