WorkDeploy-bak.js 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xDesktop.requireApp("Execution", "WorkForm", null, false);
  5. MWF.xApplication.Execution.WorkDeploy = new Class({
  6. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  7. Implements: [Options, Events],
  8. options: {
  9. //"centerWorkId" : "fc44be47-7271-469f-8f04-deebdb71d3e6",
  10. "style": "default",
  11. "width": "90%",
  12. "height": "90%",
  13. "hasTop": true,
  14. "hasIcon": false,
  15. "hasBottom": true,
  16. "title": "",
  17. "draggable": false,
  18. "closeAction": true,
  19. "isNew": false,
  20. "isEdited": true
  21. },
  22. initialize: function (explorer, actions, data, options) {
  23. this.setOptions(options);
  24. this.explorer = explorer;
  25. this.app = explorer.app;
  26. this.lp = this.app.lp.WorkDeploy;
  27. this.actions = this.app.restActions;
  28. this.path = "/x_component_Execution/$WorkDeploy/";
  29. this.cssPath = this.path + this.options.style + "/css.wcss";
  30. this._loadCss();
  31. this.options.title = this.lp.title;
  32. this.data = data || {};
  33. this.actions = actions;
  34. },
  35. load: function () {
  36. if(!this.appointSwitch){
  37. var switchData = {};
  38. switchData.configCode = "WORK_AUTHORIZE";
  39. this.actions.getProfileByCode(switchData,function(json){
  40. if(json.type == "success"){
  41. if(json.data && json.data.configValue){
  42. this.appointSwitch = json.data.configValue;
  43. }
  44. }
  45. }.bind(this),null,false);
  46. }
  47. if(!this.splitSwitch){
  48. var switchData = {};
  49. switchData.configCode = "WORK_DISMANTLING";
  50. this.actions.getProfileByCode(switchData,function(json){
  51. if(json.type == "success"){
  52. if(json.data && json.data.configValue){
  53. this.splitSwitch = json.data.configValue;
  54. }
  55. }
  56. }.bind(this),null,false);
  57. }
  58. if(!this.archiveSwitch){
  59. var switchData = {};
  60. switchData.configCode = "ARCHIVEMANAGER";
  61. this.actions.getProfileByCode(switchData,function(json){
  62. if(json.type == "success"){
  63. if(json.data && json.data.configValue){
  64. if(json.data.configValue.indexOf(this.app.identity)>-1)
  65. this.archiveSwitch = true;
  66. }
  67. }
  68. }.bind(this),null,false);
  69. }
  70. //alert(JSON.stringify(this.data))
  71. if (this.options.isNew) {
  72. this.create();
  73. } else if (this.options.isEdited) {
  74. this.edit();
  75. } else {
  76. this.open();
  77. }
  78. },
  79. createShade: function(txt){
  80. if(this.shadeDiv){ this.shadeDiv.destroy()}
  81. if(this.shadeTxtDiv) this.shadeTxtDiv.destroy()
  82. this.shadeDiv = new Element("div.shadeDiv").inject(this.formNode)
  83. this.shadeTxtDiv = new Element("div.shadeTxtDiv").inject(this.shadeDiv);
  84. this.shadeTxtDiv.set("text",txt)
  85. this.shadeDiv.setStyles({
  86. "left":"0px","top":"40px","width":"100%","height":"100%","position":"absolute","opacity":"0.6","background-color":"#999999","z-index":"999",
  87. "text-align":"center"
  88. })
  89. this.shadeTxtDiv.setStyles({"color":"#ffffff","font-size":"30px","margin-top":"300px"})
  90. },
  91. destroyShade : function(){
  92. if(this.shadeDiv) this.shadeDiv.destroy()
  93. if(this.shadeDiv) this.shadeDiv.destroy()
  94. },
  95. createTopNode: function () {
  96. if (!this.formTopNode) {
  97. this.formTopNode = new Element("div.formTopNode", {
  98. "styles": this.css.formTopNode
  99. }).inject(this.formNode);
  100. this.formTopIconNode = new Element("div", {
  101. "styles": this.css.formTopIconNode
  102. }).inject(this.formTopNode)
  103. this.formTopTextNode = new Element("div", {
  104. "styles": this.css.formTopTextNode,
  105. "text": this.options.title
  106. }).inject(this.formTopNode)
  107. if (this.options.closeAction) {
  108. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  109. this.formTopCloseActionNode.addEvent("click", function () {
  110. this.close()
  111. }.bind(this))
  112. }
  113. this.formTopContentNode = new Element("div", {
  114. "styles": this.css.formTopContentNode
  115. }).inject(this.formTopNode)
  116. this._createTopContent();
  117. }
  118. },
  119. _createTopContent: function () {
  120. var html = "<span styles='formTopContentTitle' lable='drafter'></span>" +
  121. " <span styles='formTopContentValue' item='drafter'></span>" +
  122. "<span styles='formTopContentTitle' lable='draftDepartment'></span>" +
  123. " <span styles='formTopContentValue' item='draftDepartment'></span>" +
  124. "<span styles='formTopContentTitle' lable='draftDate'></span>" +
  125. " <span styles='formTopContentValue' item='draftDate'></span>"
  126. this.formTopContentNode.set("html", html);
  127. this.getCenterWorkInfor( function( json ){
  128. if(!json.data){
  129. json.data = {};
  130. json.data.creatorName = this.app.user;
  131. json.data.creatorOrganizationName = this.app.department;
  132. json.data.createTime = json.date;
  133. }
  134. var form = new MForm(this.formTopContentNode, json.data, {
  135. isEdited: this.isEdited || this.isNew,
  136. itemTemplate: {
  137. drafter: {text: this.lp.drafter + ":", name:"creatorName", type: "innertext"},
  138. draftDepartment: {text: this.lp.draftDepartment + ":", name:"creatorOrganizationName", type: "innertext"},
  139. draftDate: {text: this.lp.draftDate + ":",name:"createTime", type: "innertext"}
  140. }
  141. }, this.app, this.css);
  142. form.load();
  143. }.bind(this) )
  144. },
  145. getCenterWorkInfor: function( callback ){
  146. var auditData = {};
  147. this.reportAuditLeader = "";
  148. auditData.configCode = "REPORT_AUDIT_LEADER";
  149. this.actions.getProfileByCode(auditData,function(json){
  150. if(json.type == "success"){
  151. if(json.data && json.data.configValue){
  152. this.reportAuditLeader = json.data.configValue
  153. }
  154. }
  155. //this.reportAuditLeader
  156. }.bind(this),null,false);
  157. if( this.centerWorkInforData ){
  158. if(callback)callback(this.centerWorkInforData);
  159. }else{
  160. this.actions.getMainTask( this.options.centerWorkId,function( json ){
  161. this.centerWorkInforData = json.data;
  162. if(callback)callback(json);
  163. }.bind(this),null,false)
  164. }
  165. },
  166. reloadContent: function(data){
  167. this.formTableArea.empty();
  168. this._createTableContent(data);
  169. },
  170. _createTableContent: function (data) {
  171. data = data || {
  172. processIdentity : this.app.identity,
  173. deployerName : this.app.user,
  174. creatorName : this.app.user
  175. }
  176. if(data.id){
  177. this.centerWorkId = data.id;
  178. }
  179. if(this.data.id){
  180. this.centerWorkId = this.data.id;
  181. }
  182. if(this.centerWorkId){
  183. this.getMainTask(this.centerWorkId, function( json ){
  184. data = json.data;
  185. this.centerWorkData = json.data;
  186. }.bind(this));
  187. }
  188. this.createCenterWorkInfor(data);
  189. this.importBaseWork();
  190. this.createMyWorkList();
  191. //this.createSplitWorkList();
  192. this.creataDeployWorkList();
  193. },
  194. importBaseWork: function(){
  195. this.importDiv = new Element("div.importDiv",{
  196. "styles" : this.css.importDiv
  197. }).inject(this.formTableArea);
  198. this.importTemplateDiv = new Element("div.importTemplateDiv",{
  199. "styles": this.css.importTemplateDiv,
  200. "text":this.lp.importTemplate
  201. }).inject(this.importDiv)
  202. this.importTemplateDiv.addEvents({
  203. "click":function(){
  204. window.open("/x_component_Execution/baseWork.xls")
  205. }.bind(this)
  206. })
  207. this.importTitleDiv = new Element("div.importTitleDiv",{
  208. "styles": this.css.importTitleDiv,
  209. "text":this.lp.importTemplateTitle
  210. }).inject(this.importDiv);
  211. //拟稿环节有导入操作,其他环节只有拟稿人才有导入操作
  212. if(this.centerWorkData==undefined || (this.centerWorkData && this.centerWorkData.processStatus==this.lp.statusDraft) || this.centerWorkData.deployerIdentity == this.app.identity ){
  213. }else{
  214. if(this.importDiv) {
  215. this.importDiv.destroy();
  216. }
  217. }
  218. },
  219. upload : function(){
  220. var r = this.centerForm.getResult(true,",",true,false,true);
  221. if( !r ){
  222. return false;
  223. }
  224. if(this.centerWorkData==undefined || (this.centerWorkData && this.centerWorkData.processStatus==this.lp.statusDraft)){
  225. this.saveMainTask( r, function( json ){
  226. this.getMainTask(json.userMessage, function( data ){
  227. this.centerWorkInforData = data.data;
  228. this.loadCenterWorkInfor(data.data)
  229. }.bind(this))
  230. }.bind(this) )
  231. }
  232. if (!this.uploadFileAreaNode){
  233. this.uploadFileAreaNode = new Element("div");
  234. var html = "<input name=\"file\" type=\"file\" />";
  235. this.uploadFileAreaNode.set("html", html);
  236. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  237. this.fileUploadNode.addEvent("change", function(){
  238. var files = fileNode.files;
  239. if (files.length){
  240. for (var i = 0; i < files.length; i++) {
  241. var file = files.item(i);
  242. var tmp = file.name.split(".");
  243. this.uploadFileName = file.name;
  244. if( tmp[tmp.length-1].toLowerCase() != "xls" && tmp[tmp.length-1].toLowerCase() != "xlsx" ){
  245. this.app.notice("请导入excel文件!","error");
  246. return;
  247. }
  248. var formData = new FormData();
  249. formData.append('file', file);
  250. this.createShade("正在导入,请稍后.....")
  251. this.actions.importBaseWork(this.centerWorkId,function(json){
  252. this.reloadContent(this.centerWorkInforData)
  253. this.destroyShade()
  254. }.bind(this),function(xhr,text,error){
  255. var errorText = error;
  256. if (xhr) errorMessage = xhr.responseText;
  257. var e = JSON.parse(errorMessage);
  258. if(e.userMessage){
  259. this.app.notice( e.userMessage,"error");
  260. }else{
  261. this.app.notice( errorText,"error");
  262. }
  263. this.destroyShade()
  264. }.bind(this),formData,file)
  265. }
  266. }
  267. }.bind(this));
  268. }
  269. var fileNode = this.uploadFileAreaNode.getFirst();
  270. fileNode.click();
  271. },
  272. createCenterWorkInfor: function(data) {
  273. this.centerWorkContentArea = new Element("div.centerWorkContentArea", {
  274. "styles": this.css.workContentArea
  275. }).inject(this.formTableArea);
  276. var workContentTitleNode = new Element("div", {
  277. "styles": this.css.workContentTitleNode,
  278. "text": this.lp.centerWorkInfor
  279. }).inject(this.centerWorkContentArea);
  280. this.centerWorkContentNode = new Element("div.centerWorkContentNode", {
  281. "styles": this.css.workContentNode
  282. }).inject(this.centerWorkContentArea);
  283. this.loadCenterWorkInfor(data)
  284. },
  285. loadCenterWorkInfor: function(data){
  286. this.centerWorkId = data.id
  287. this.centerWorkContentNode.empty();
  288. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='centerWorkInforTable'>" +
  289. "<tr><td styles='centerWorkInforTitle' lable='centerWorkTitle'></td>" +
  290. " <td styles='centerWorkInforValue' item='centerWorkTitle'></td></tr>" +
  291. "<tr><td colspan='2'>" +
  292. //"<div styles='centerWorkInforTitleDiv' lable='defaultWorkType'></div>" +
  293. //" <div styles='centerWorkInforValueDiv' item='defaultWorkType'></div>" +
  294. //" <div styles='centerWorkInforTitleDiv' lable='defaultWorkLevel'></div>" +
  295. //" <div styles='centerWorkInforValueDiv' item='defaultWorkLevel'></div>" +
  296. " <div styles='centerWorkInforTitleDiv' lable='reportAuditLeader'></div>" +
  297. " <div styles='centerWorkInforValueDiv' item='reportAuditLeader'></div>" +
  298. " <div styles='centerWorkInforTitleDiv' lable='defaultWorkType'></div>" +
  299. " <div styles='centerWorkInforValueDiv' item='defaultWorkType'></div>" +
  300. " <div styles='centerWorkInforTitleDiv' lable='workCompletedLimit'></div>" +
  301. " <div styles='centerWorkInforValueDiv' item='workCompletedLimit'></div>" +
  302. "</td></tr>" +
  303. "<tr><td styles='centerWorkInforTitle' lable='centerWorkMemo'></td>" +
  304. " <td styles='centerWorkInforValue' item='centerWorkMemo'></td></tr>" +
  305. "</table>"
  306. this.centerWorkContentNode.set("html", html);
  307. //this.getCenterWorkInfor( function( json ){
  308. var resultWorkType = []
  309. var resultWorkTypeTxt = ""
  310. this.actions.listCategoryAll(function(json){
  311. if(json.data){
  312. for(i=0;i<json.data.length;i++){
  313. if(json.data[i].workTypeName){
  314. resultWorkType.push(json.data[i].workTypeName)
  315. }
  316. }
  317. }
  318. }.bind(this),null,false
  319. )
  320. resultWorkTypeTxt = resultWorkType.join(",")
  321. if(resultWorkType.length>0){
  322. resultWorkTypeTxt = ","+resultWorkTypeTxt
  323. }
  324. var form = this.centerForm = new MForm(this.centerWorkContentNode, data, {
  325. isEdited: this.isEdited || this.isNew,
  326. itemTemplate: {
  327. centerWorkTitle: {
  328. text: this.lp.centerWorkTitle + ":", name : "title", type: "text",
  329. notEmpty:true,
  330. },
  331. defaultWorkType: {
  332. text: this.lp.defaultWorkType + ":", name : "defaultWorkType", type: "select",
  333. selectValue : resultWorkTypeTxt,
  334. selectText : resultWorkTypeTxt,
  335. notEmpty:true,
  336. style : {"width":"100px","height":"30px","color":"#999999","border-radius":"1px","box-shadow": "0px 0px 1px #CCC"}
  337. },
  338. defaultWorkLevel: {
  339. text: this.lp.defaultWorkLevel + ":", name:"defaultWorkLevel", type: "select",selectValue : this.lp.defaultWorkTypeValue,
  340. notEmpty:true,
  341. style : {"width":"200px","height":"30px","color":"#999999","border-radius":"1px","box-shadow": "0px 0px 1px #CCC"}
  342. },
  343. reportAuditLeader: {
  344. text: this.lp.reportAuditLeader + ":", name:"reportAuditLeaderIdentity",
  345. tType:"identity",
  346. attr:{"readonly":true},
  347. notEmpty:false,
  348. count: 0,
  349. value: this.reportAuditLeader?this.reportAuditLeader:"",
  350. style : {"width":"300px"}
  351. },
  352. workCompletedLimit: {
  353. text: this.lp.workCompletedLimit + ":", name:"defaultCompleteDateLimitStr", type: "text",
  354. tType:"date",
  355. attr:{"readonly":true},
  356. notEmpty:true
  357. },
  358. centerWorkMemo: {
  359. text: this.lp.centerWorkMemo + ":",
  360. name: "description",
  361. type: "textarea"
  362. }
  363. }
  364. }, this.app);
  365. form.load();
  366. //}.bind(this))
  367. },
  368. reloadList : function(){
  369. this.splitWorkContentArea.destroy();
  370. this.myWorkContentArea.destroy();
  371. this.createMyWorkList();
  372. //this.createSplitWorkList();
  373. this.creataDeployWorkList();
  374. },
  375. createMyWorkList : function(){
  376. if(this.myWorkContentArea) this.myWorkContentArea.destroy();
  377. var workContentArea = this.myWorkContentArea = new Element("div.workContentArea", {
  378. "styles": this.css.workContentArea
  379. }).inject(this.formTableArea);
  380. var workContentTitleNode = new Element("div", {
  381. "styles": this.css.workContentTitleNode,
  382. "text": this.lp.myWorkInfor
  383. }).inject(workContentArea);
  384. var workContentNode = new Element("div", {
  385. "styles": this.css.workContentNode
  386. }).inject(workContentArea);
  387. //this.createSplitWorkList();
  388. var list = this.myWorkView = new MWF.xApplication.Execution.WorkDeploy.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"listItem.json" })
  389. list.load();
  390. ////subList权限控制
  391. //if(this.centerWorkData==undefined || (this.centerWorkData && this.centerWorkData.processStatus==this.lp.statusDraft)){
  392. // //拟稿环节不需要显示拆分list
  393. // this.splitWorkContentArea.setStyle("display","none");
  394. //}else if(this.centerWorkData.deployerIdentity == this.app.identity){
  395. // //不是拟稿状态,如果当前身份等于中心工作身份 1、如果具体工作没有当前身份负责的工作,不需要显示拆分list 2、如果有显示拆分list
  396. // var subListFlag = false;
  397. // this.myWorkView.myWorkJson.data.each(function(d){
  398. // if(d.subWrapOutOkrWorkBaseInfos){
  399. // d.subWrapOutOkrWorkBaseInfos.each(function(d1){
  400. // if(d1.deployerIdentity == this.app.identity){
  401. // subListFlag = true
  402. // }
  403. // }.bind(this))
  404. // }
  405. // }.bind(this))
  406. // if(!subListFlag){
  407. // //this.splitWorkContentArea.setStyle("display","none");
  408. // }
  409. //}
  410. },
  411. createSplitWorkList : function(){
  412. var workContentArea = this.splitWorkContentArea = new Element("div.splitWorkContentArea", {
  413. "styles": this.css.workContentArea
  414. }).inject(this.formTableArea);
  415. var workContentTitleNode = new Element("div", {
  416. "styles": this.css.workContentTitleNode,
  417. "text": this.lp.deployWorkInfor
  418. }).inject(workContentArea);
  419. this.subWorkContentNode = new Element("div.subWorkContentNode", {
  420. "styles": this.css.workContentNode
  421. }).inject(workContentArea);
  422. //var list = new MWF.xApplication.Execution.CenterWorkDeployer.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"listItem.json" })
  423. //list.load();
  424. },
  425. creataDeployWorkList : function(){
  426. var workContentArea = this.deployWorkContentArea = new Element("div.deployWorkContentArea", {
  427. "styles": this.css.workContentArea
  428. }).inject(this.formTableArea);
  429. var workContentTitleNode = new Element("div", {
  430. "styles": this.css.workContentTitleNode,
  431. "text": "hidden"
  432. }).inject(workContentArea);
  433. this.deployWorkContentNode = new Element("div.deployWorkContentNode", {
  434. "styles": this.css.workContentNode
  435. }).inject(workContentArea);
  436. this.createSplitWorkList();
  437. var list = this.myDeployView = new MWF.xApplication.Execution.WorkDeploy.MyDeployView(this.deployWorkContentNode, this.app, this, { templateUrl : this.path+"listItem_deploy.json" })
  438. list.load();
  439. //this.deployWorkContentArea.setStyle("display","none")
  440. this.deployWorkContentArea.destroy();
  441. },
  442. _createBottomContent: function () {
  443. if(this.formBottomNode) this.formBottomNode.empty();
  444. this.newWorkActionNode = new Element("div.newWorkActionNode", {
  445. "styles": this.css.formActionNode,
  446. "text": this.lp.newWork
  447. }).inject(this.formBottomNode);
  448. this.newWorkActionNode.addEvents({
  449. "click":function(){
  450. var r = this.centerForm.getResult(true,",",true,false,true);
  451. if( !r ){
  452. return
  453. }
  454. if(this.centerWorkData==undefined || (this.centerWorkData && this.centerWorkData.processStatus==this.lp.statusDraft)){
  455. this.saveMainTask( r, function( json ){
  456. if( json.type && json.type === "error"){
  457. this.app.notice(json.userMessage, "error")
  458. }else{
  459. this.getMainTask(json.userMessage, function( data ){
  460. //this.reloadMainTask( data.data )
  461. this.centerWorkInforData = data.data;
  462. this.centerWorkData = data.data;
  463. this.loadCenterWorkInfor(data.data)
  464. //this.reloadContent(this.centerWorkInforData)
  465. this.openWorkForm( data.data );
  466. this._createBottomContent();
  467. }.bind(this))
  468. }
  469. }.bind(this))
  470. }else{
  471. this.openWorkForm( this.centerWorkData );
  472. }
  473. }.bind(this)
  474. })
  475. //只有拟稿状态才有删除按钮
  476. if(this.centerWorkData && this.centerWorkData.processStatus && this.centerWorkData.processStatus == this.lp.statusDraft){
  477. this.deleteActionNode = new Element("div.deleteActionNode",{
  478. "styles" : this.css.formActionNode,
  479. "text" : this.lp.remove
  480. }).inject(this.formBottomNode);
  481. var _self = this;
  482. this.deleteActionNode.addEvents({
  483. "click": function(e){
  484. this.app.confirm("warn",e,this.lp.submitWarn.warnTitle,this.lp.submitWarn.warnContent,300,120,function(){
  485. _self.actions.deleteCenterWork(_self.centerWorkData.id,function(json){
  486. _self.app.notice(json.userMessage,"success");
  487. _self.close();
  488. _self.fireEvent("reloadView",{"tab":"drafter"});
  489. }.bind(_self),function(xhr,text,error){
  490. var errorText = error;
  491. if (xhr) errorMessage = xhr.responseText;
  492. var e = JSON.parse(errorMessage);
  493. if(e.userMessage){
  494. _self.app.notice( e.userMessage,"error");
  495. }else{
  496. _self.app.notice( errorText,"error");
  497. }
  498. }.bind(_self),false)
  499. this.close();
  500. },function(){
  501. this.close();
  502. })
  503. }.bind(this)
  504. })
  505. }
  506. this.importActionNode = new Element("div.newWorkActionNode",{
  507. "styles": this.css.formActionNode,
  508. "text" :this.lp.import
  509. }).inject(this.formBottomNode);
  510. this.importActionNode.addEvents({
  511. "click":function(){
  512. this.upload();
  513. }.bind(this)
  514. })
  515. this.deployActionNode = new Element("div.formActionNode", {
  516. "styles": this.css.formActionNode,
  517. "text": this.lp.goonDeploy
  518. }).inject(this.formBottomNode);
  519. this.deployActionNode.addEvent("click", function (e) {
  520. this.deploy(e);
  521. }.bind(this));
  522. if (this.centerWorkData && this.centerWorkData.status != this.lp.statuArchive) {
  523. if(this.archiveSwitch){
  524. this.archiveActionNode = new Element("div.formActionNode", {
  525. "styles": this.css.formActionNode,
  526. "text": this.lp.actionArchive
  527. }).inject(this.formBottomNode);
  528. this.archiveActionNode.addEvent("click", function (e) {
  529. this.archive(e)
  530. }.bind(this));
  531. }
  532. }
  533. this.cancelActionNode = new Element("div.formActionNode", {
  534. "styles": this.css.formActionNode,
  535. "text": this.lp.close
  536. }).inject(this.formBottomNode);
  537. this.cancelActionNode.addEvent("click", function (e) {
  538. this.close(e);
  539. }.bind(this));
  540. //底部按钮控制
  541. //拟稿环节有创建按钮,其他环节只有拟稿人才有创建按钮
  542. //拟稿环节有导入操作,其他环节只有拟稿人才有导入
  543. if(this.centerWorkData==undefined || (this.centerWorkData && this.centerWorkData.processStatus==this.lp.statusDraft) || this.centerWorkData.deployerIdentity == this.app.identity ){
  544. }else{
  545. if(this.newWorkActionNode) {
  546. this.newWorkActionNode.destroy();
  547. }
  548. if(this.importActionNode){
  549. this.importActionNode.destroy();
  550. }
  551. }
  552. //如果已归档 所有按钮删除
  553. if (this.centerWorkData && this.centerWorkData.status == this.lp.statuArchive) {
  554. if(this.newWorkActionNode)this.newWorkActionNode.destroy();
  555. if(this.deleteActionNode)this.deleteActionNode.destroy();
  556. if(this.importActionNode)this.importActionNode.destroy();
  557. if(this.deployActionNode)this.deployActionNode.destroy();
  558. if(this.archiveActionNode)this.archiveActionNode.destroy();
  559. }
  560. },
  561. saveMainTask: function(data, callback){
  562. this.app.restActions.saveMainTask( data,
  563. function(json){
  564. if( callback )callback(json);
  565. }.bind(this),
  566. function(xhr,text,error){
  567. var errorText = error;
  568. if (xhr) errorMessage = xhr.responseText;
  569. var e = JSON.parse(errorMessage);
  570. if(e.userMessage){
  571. this.app.notice( e.userMessage,"error");
  572. }else{
  573. this.app.notice( errorText,"error");
  574. }
  575. }.bind(this),
  576. false
  577. );
  578. },
  579. getMainTask: function(id, callback){
  580. this.app.restActions.getMainTask( id, function(json){
  581. if( callback )callback(json);
  582. }.bind(this),null,false);
  583. },
  584. openWorkForm : function( data ){
  585. this.myWorkView._create( data );
  586. },
  587. //loadBaseWork:function(){
  588. // //alert("id="+this.centerWorkId);
  589. //
  590. // this.subTaskContentDiv.empty();
  591. //
  592. // //if(this.centerWorkId && this.centerWorkId!=""){
  593. //
  594. // var list = new MWF.xApplication.Execution.WorkDeploy.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"listItem.json" })
  595. // list.load();
  596. //
  597. //
  598. //},
  599. archive:function(){
  600. this.actions.archiveMainTask(this.centerWorkData.id,function(){
  601. this.app.notice(this.lp.statuArchive,"success");
  602. this.close();
  603. }.bind(this),function(xhr,text,error){
  604. var errorText = error;
  605. if (xhr) errorMessage = xhr.responseText;
  606. var e = JSON.parse(errorMessage);
  607. if(e.userMessage){
  608. this.app.notice( e.userMessage,"error");
  609. }else{
  610. this.app.notice( errorText,"error");
  611. }
  612. }.bind(this),false)
  613. },
  614. deploy: function(){
  615. if(this.centerWorkData==undefined){
  616. this.app.notice(this.lp.warnIng.baseWorkNotEmpty, "ok");
  617. return false;
  618. }
  619. if(this.centerWorkData.processStatus==this.lp.statusDraft){
  620. var dataLen = 0
  621. this.actions.getUserDeployBaseWork( this.centerWorkData.id, function(json){
  622. if(json.data){
  623. dataLen = json.data.length
  624. }
  625. }.bind(this),null,false);
  626. if(dataLen==0){
  627. this.app.notice(this.lp.warnIng.baseWorkNotEmpty, "ok");
  628. return false;
  629. }
  630. }
  631. var ids = [];
  632. this.actions.getUserDeployBaseWork( this.centerWorkId, function(json){
  633. if(this.centerWorkInforData){
  634. if(this.centerWorkInforData.processStatus == this.lp.statusDraft){ //中心工作草稿环节,
  635. json.data.each(function(d){
  636. if(d.workProcessStatus == this.lp.statusDraft){
  637. ids.push(d.id)
  638. }
  639. }.bind(this))
  640. }else{ //其他环节,其他环节也有可能拟稿人追加
  641. json.data.each(function( d ){
  642. if( d.subWrapOutOkrWorkBaseInfos ){
  643. d.subWrapOutOkrWorkBaseInfos.each(function( infor ){
  644. if( infor.workProcessStatus == this.lp.statusDraft ){
  645. ids.push( infor.id )
  646. }
  647. }.bind(this))
  648. }
  649. if(d.workProcessStatus == this.lp.statusDraft){
  650. ids.push(d.id)
  651. }
  652. }.bind(this))
  653. }
  654. }
  655. //if( ids.length > 0 ){
  656. var data = {};
  657. data.centerId = this.centerWorkId;
  658. data.workIds = ids;
  659. this.createShade("正在部署,请稍等...");
  660. this.actions.deployBaseWork( data, function( j ){
  661. if(j.type && j.type=="success"){
  662. this.destroyShade();
  663. this.app.notice(this.lp.deployeSuccess, "ok");
  664. //this.reloadContent();
  665. this.close();
  666. this.fireEvent("reloadView");
  667. //if(this.app.workTask && this.app.workTask.contentDiv){ alert("load worktask")
  668. // this.app.workTask.contentDiv.destroy()
  669. // this.app.workTask.createContentDiv();
  670. //}
  671. //if(this.app){ alert("load main")
  672. // this.app.createTodoList();
  673. //}
  674. }else{
  675. this.app.notice(j.data.message, "error")
  676. this.destroyShade();
  677. }
  678. }.bind(this),function(xhr,text,error){
  679. var errorText = error;
  680. if (xhr) errorMessage = xhr.responseText;
  681. var e = JSON.parse(errorMessage);
  682. if(e.userMessage){
  683. this.app.notice( e.userMessage,"error");
  684. }else{
  685. this.app.notice( errorText,"error");
  686. }
  687. this.destroyShade();
  688. }.bind(this),true);
  689. //}else{
  690. // this.app.notice(this.lp.noWordNeedDeployed, "ok");
  691. //}
  692. //this.destroyShade();
  693. }.bind(this),function(xhr,text,error){}.bind(this),false);
  694. }
  695. })
  696. MWF.xApplication.Execution.WorkDeploy.MyWorkView = new Class({
  697. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  698. _createDocument: function(data){
  699. return new MWF.xApplication.Execution.WorkDeploy.MyWorkDocument(this.viewNode, data, this.explorer, this);
  700. },
  701. _getCurrentPageData: function(callback, count){
  702. //var tmpArr = [];
  703. if(this.explorer.centerWorkId){
  704. this.actions.getUserProcessBaseWork( this.explorer.centerWorkId, function(json){ //alert("process=length="+json.data.length+"="+JSON.stringify(json))
  705. if(json.data.length==0){
  706. this.explorer.myWorkContentArea.destroy();
  707. }
  708. //this.myWorkJson = json
  709. if (callback) callback(json)
  710. }.bind(this),null,false);
  711. }
  712. },
  713. _removeDocument: function(documentData, all){
  714. this.actions.deleteBaseWork(documentData.id, function(json){
  715. if(json.type && json.type=="success"){
  716. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  717. this.reload();
  718. this.explorer.contentChanged = true;
  719. }
  720. }.bind(this),function(xhr,text,error){
  721. var errorText = error;
  722. if (xhr) errorMessage = xhr.responseText;
  723. var e = JSON.parse(errorMessage);
  724. if(e.userMessage){
  725. this.app.notice( e.userMessage,"error");
  726. }else{
  727. this.app.notice( errorText,"error");
  728. }
  729. }.bind(this));
  730. },
  731. _create: function(data){
  732. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  733. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"centerWorkId": data.id || this.options.centerWorkId },{
  734. "isNew": true,
  735. "isEdited": false,
  736. "actionStatus":"save",
  737. "onPostSave" : function(){
  738. this.explorer.contentChanged = true;
  739. }.bind(this)
  740. });
  741. //alert("cccc="+this.centerWorkId)
  742. this.workform.load();
  743. }.bind(this));
  744. },
  745. _openDocument: function( documentData ){
  746. this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, documentData, {
  747. "isNew": false,
  748. "isEdited": false
  749. })
  750. this.workForm.load();
  751. },
  752. _queryCreateViewNode: function(){
  753. },
  754. _postCreateViewNode: function( viewNode ){
  755. },
  756. _queryCreateViewHead:function(){
  757. },
  758. _postCreateViewHead: function( headNode ){
  759. }
  760. })
  761. MWF.xApplication.Execution.WorkDeploy.MyWorkDocument = new Class({
  762. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  763. action_comfirm : function(){
  764. },
  765. action_edit : function(){
  766. this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.explorer, this.actions, this.data, {
  767. "isNew": false,
  768. "isEdited": true,
  769. "actionStatus":"save",
  770. "onPostSave" : function(){
  771. this.view.explorer.contentChanged = true;
  772. }.bind(this)
  773. })
  774. this.workForm.load();
  775. },
  776. action_remove : function(){
  777. this.view.app.restActions.deleteBaseWork( this.data.id, function(json){
  778. if(json.type && json.type=="success"){
  779. this.view.app.notice(this.app.lp.deleteDocumentOK, "success");
  780. this.view.reload();
  781. this.view.explorer.contentChanged = true;
  782. }
  783. }.bind(this),function(xhr,text,error){
  784. var errorText = error;
  785. if (xhr) errorMessage = xhr.responseText;
  786. var e = JSON.parse(errorMessage);
  787. if(e.userMessage){
  788. this.app.notice( e.userMessage,"error");
  789. }else{
  790. this.app.notice( errorText,"error");
  791. }
  792. }.bind(this));
  793. },
  794. action_split:function(){
  795. var data = {
  796. title : this.data.title,
  797. centerId : this.data.centerId,
  798. //centerTitle: this.data.centerTitle,
  799. parentWorkId : this.data.id,
  800. //parentWorkTitle : this.data.title,
  801. workType : this.data.workType,
  802. workLevel : this.data.workLevel,
  803. completeDateLimitStr : this.data.completeDateLimitStr,
  804. completeDateLimit : this.data.completeDateLimit,
  805. reportCycle: this.data.reportCycle,
  806. reportDayInCycle: this.data.reportDayInCycle
  807. }
  808. if(this.data.id){
  809. this.actions.getBaseWorkDetails(this.data.id, function (json) {
  810. data.workSplitAndDescription = json.data.workDetail
  811. data.specificActionInitiatives = json.data.progressAction
  812. data.cityCompanyDuty = json.data.dutyDescription
  813. data.milestoneMark = json.data.landmarkDescription
  814. data.importantMatters = json.data.majorIssuesDescription
  815. }.bind(this),null,false)
  816. }
  817. var workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.view.explorer, this.actions, data, {
  818. "isNew": true,
  819. "isEdited": false,
  820. "actionStatus":"save",
  821. "onPostSave" : function(){
  822. this.view.explorer.contentChanged = true;
  823. }.bind(this)
  824. })
  825. workForm.load();
  826. },
  827. action_appoint:function(){
  828. var flag = true;
  829. this.view.actions.getBaseWorksByParentId(this.data.id,function(json){
  830. if(json.data){
  831. json.data.each(function(n,i){
  832. if(n.workProcessStatus && n.workProcessStatus == this.view.lp.statusDraft){
  833. flag = false
  834. }
  835. }.bind(this))
  836. }
  837. }.bind(this),function(){
  838. flag = false
  839. }.bind(this),false)
  840. if(!flag){
  841. this.view.app.notice(this.view.explorer.lp.cannotAppoint,"error")
  842. return false
  843. }
  844. var data = {
  845. workId : this.data.id
  846. };
  847. var appointForm = new MWF.xApplication.Execution.WorkDeploy.Appoint(this.view.app,this.view.app.restActions,data,this.view.css,{
  848. "ieEdited": true,
  849. "onReloadView" : function( data ){
  850. //判断如果只有一个可以拆解的 则关掉本窗口,刷新父窗口,如果还有则刷新本窗口
  851. //alret("刷新或关闭");
  852. this.checkFlag = false;
  853. this.view.explorer.actions.getUserProcessBaseWork( this.data.centerId, function(json){
  854. this.checkFlag = false;
  855. json.data.each(function(o,i){
  856. if(o.responsibilityIdentity == this.view.app.identity){
  857. this.checkFlag = true;
  858. }
  859. }.bind(this))
  860. }.bind(this),null,false);
  861. if(this.checkFlag){
  862. this.view.explorer.reloadList()
  863. }else{
  864. this.view.explorer.close();
  865. this.view.explorer.fireEvent("reloadView")
  866. }
  867. }.bind(this)
  868. });
  869. appointForm.load();
  870. },
  871. _queryCreateDocumentNode:function( itemData ){
  872. },
  873. _postCreateDocumentNode: function( itemNode, itemData ){
  874. if(itemNode.getElements("div[item='title']").length>0){
  875. this.view.actions.getBaseWorksByParentId(itemData.id,function(json){
  876. if(json.data && json.data.length>0){
  877. itemNode.getElements("div[item='title']").setStyle("color","#ec6a1a");
  878. //itemNode.getElements("div[item='title']").set("title",this.view.lp.splitReady);
  879. }
  880. }.bind(this))
  881. }
  882. if(itemNode.getElements("div[name='appointDiv']")){
  883. if(itemData.okrWorkAuthorizeRecord){
  884. itemNode.getElements("div[name='appointDiv']").setStyle("display","")
  885. }
  886. }
  887. if(itemNode.getElements("div[styles='documentSubject']")){
  888. itemNode.getElements("div[styles='documentSubject']").set("title",itemData.shortWorkDetail)
  889. }
  890. },
  891. editActionReturn : function(d){
  892. if(d.status == this.lp.statuArchive){
  893. return false;
  894. }
  895. if(d.workProcessStatus == this.lp.statusDraft){
  896. return true;
  897. }
  898. return false;
  899. },
  900. appointActionReturn : function(d){
  901. if(d.status == this.lp.statuArchive){
  902. return false;
  903. }
  904. var flag = false;
  905. if(this.view.explorer.appointSwitch && this.view.explorer.appointSwitch.toUpperCase() == "OPEN"){
  906. flag = true;
  907. this.view.actions.getBaseWorksByParentId(d.id,function(json){
  908. if(json.data){
  909. json.data.each(function(n,i){
  910. if(n.workProcessStatus && n.workProcessStatus == this.view.lp.statusDraft){
  911. flag = false
  912. }
  913. }.bind(this))
  914. }
  915. }.bind(this),function(){
  916. flag = false
  917. }.bind(this),false)
  918. if(true){
  919. if(d.responsibilityIdentity != this.view.app.identity){
  920. flag = false;
  921. }
  922. }
  923. }else{
  924. flag = false;
  925. }
  926. return flag
  927. },
  928. removeActionReturn : function(d){
  929. if(d.status == this.lp.statuArchive){
  930. return false;
  931. }
  932. if(d.workProcessStatus == this.lp.statusDraft){
  933. return true;
  934. }
  935. return false;
  936. },
  937. splitActionReturn : function(d){
  938. if(d.status == this.lp.statuArchive){
  939. return false;
  940. }
  941. if(this.view.explorer.splitSwitch && this.view.explorer.splitSwitch.toUpperCase() == "OPEN"){
  942. //如果不等于草稿并且身份相同 显示拆分
  943. if(d.workProcessStatus != this.lp.statusDraft && d.responsibilityIdentity == this.app.identity){
  944. return true;
  945. }
  946. }
  947. return false;
  948. }
  949. })
  950. MWF.xApplication.Execution.WorkDeploy.SubWorkView = new Class({
  951. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  952. _createDocument: function(data){
  953. return new MWF.xApplication.Execution.WorkDeploy.SubWorkDocument(this.viewNode, data, this.explorer, this);
  954. },
  955. _getCurrentPageData: function(callback, count){
  956. var json = {
  957. data : this.parentWorkData.subWrapOutOkrWorkBaseInfos,
  958. count : this.parentWorkData.subWrapOutOkrWorkBaseInfos.length,
  959. size : this.parentWorkData.subWrapOutOkrWorkBaseInfos.length
  960. }
  961. if (callback) callback(json);
  962. },
  963. _removeDocument: function(documentData, all){
  964. this.actions.deleteBaseWork(documentData.id, function(json){
  965. if(json.type && json.type=="success"){
  966. this.app.notice(json.userMessage, "success");
  967. }
  968. //alert("subview")
  969. this.explorer.reloadContent();
  970. this.explorer.contentChanged = true;
  971. }.bind(this),function(xhr,text,error){
  972. var errorText = error;
  973. if (xhr) errorMessage = xhr.responseText;
  974. var e = JSON.parse(errorMessage);
  975. if(e.userMessage){
  976. this.app.notice( e.userMessage,"error");
  977. }else{
  978. this.app.notice( errorText,"error");
  979. }
  980. }.bind(this));
  981. },
  982. _create: function(){
  983. },
  984. _openDocument: function( documentData ){
  985. this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this, this.actions, documentData, {
  986. "isNew": false,
  987. "isEdited": false
  988. })
  989. this.workForm.load();
  990. },
  991. _queryCreateViewNode: function(){
  992. },
  993. _postCreateViewNode: function( viewNode ){
  994. },
  995. _queryCreateViewHead:function(){
  996. },
  997. _postCreateViewHead: function( headNode ){
  998. }
  999. })
  1000. MWF.xApplication.Execution.WorkDeploy.SubWorkDocument = new Class({
  1001. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1002. action_edit : function(){
  1003. this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.view.explorer, this.actions, this.data, {
  1004. "isNew": false,
  1005. "isEdited": true,
  1006. "actionStatus":"save",
  1007. "onPostSave" : function(){
  1008. this.view.explorer.contentChanged = true;
  1009. }.bind(this)
  1010. })
  1011. this.workForm.load();
  1012. },
  1013. _queryCreateDocumentNode:function( itemData ){
  1014. if( !this.view.titleLoaded ){
  1015. var titleNode = new Element("tr").inject(this.view.viewNode)
  1016. tdNode = new Element("td",{
  1017. text : this.view.parentWorkData.title,
  1018. colspan : this.view.template.items.length,
  1019. styles : this.css.titleTdNode
  1020. }).inject(titleNode)
  1021. this.view.titleLoaded = true;
  1022. }
  1023. },
  1024. _postCreateDocumentNode: function( itemNode, itemData ){
  1025. if(itemNode.getElements("div[styles='documentSubject']")){
  1026. itemNode.getElements("div[styles='documentSubject']").set("title",itemData.shortWorkDetail)
  1027. }
  1028. },
  1029. editActionReturn: function(d){
  1030. if(d.status == this.lp.statuArchive){
  1031. return false;
  1032. }
  1033. //alert(JSON.stringify(d))
  1034. if(d.workProcessStatus == this.lp.statusDraft){
  1035. return true;
  1036. }
  1037. return false;
  1038. },
  1039. removeActionReturn: function(d){
  1040. if(d.status == this.lp.statuArchive){
  1041. return false;
  1042. }
  1043. return true;
  1044. }
  1045. })
  1046. MWF.xApplication.Execution.WorkDeploy.MyDeployView = new Class({
  1047. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1048. _createDocument: function(data){
  1049. return new MWF.xApplication.Execution.WorkDeploy.MyDeployDocument(this.viewNode, data, this.explorer, this);
  1050. },
  1051. _getCurrentPageData: function(callback, count){
  1052. //var json = {
  1053. // data : this.parentWorkData.subWrapOutOkrWorkBaseInfos,
  1054. // count : this.parentWorkData.subWrapOutOkrWorkBaseInfos.length,
  1055. // size : this.parentWorkData.subWrapOutOkrWorkBaseInfos.length
  1056. //}
  1057. //if (callback) callback(json);
  1058. this.actions.getUserDeployBaseWork( this.explorer.centerWorkId, function(json){ //alert("deploy="+JSON.stringify(json))
  1059. var formatJson = {};
  1060. var formatData = [];
  1061. var centerData = [];
  1062. var centerJson = {};
  1063. if(json.type=="success"){
  1064. if(json.data){
  1065. json.data.each(function(d){
  1066. if(d.subWrapOutOkrWorkBaseInfos){
  1067. //如果有subWrapOutOkrWorkBaseInfos对象 说明是层次关系
  1068. formatData.push(d)
  1069. }else{
  1070. //把中心工作的头放到对象中,本身对象作为subWrapOutOkrWorkBaseInfos的值
  1071. centerData.push(d)
  1072. }
  1073. }.bind(this))
  1074. }
  1075. }
  1076. if(centerData.length>0){
  1077. if(this.explorer.centerWorkData){
  1078. this.explorer.centerWorkData.subWrapOutOkrWorkBaseInfos = centerData;
  1079. }else{
  1080. this.explorer.getMainTask(this.explorer.centerWorkId, function( json ){
  1081. data = json.data;
  1082. this.explorer.centerWorkData = json.data;
  1083. }.bind(this),null,false);
  1084. this.explorer.centerWorkData.subWrapOutOkrWorkBaseInfos = centerData;
  1085. }
  1086. formatData.push(this.explorer.centerWorkData)
  1087. }
  1088. formatJson.data = formatData;
  1089. if(formatJson.data.length==0){
  1090. this.explorer.splitWorkContentArea.destroy();
  1091. }
  1092. //this.myWorkJson = json
  1093. if (callback) callback(formatJson)
  1094. }.bind(this),null,false);
  1095. },
  1096. _removeDocument: function(documentData, all){
  1097. this.actions.deleteBaseWork(documentData.id, function(json){
  1098. this.explorer.reloadContent();
  1099. this.explorer.contentChanged = true;
  1100. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  1101. }.bind(this));
  1102. },
  1103. _create: function(data){
  1104. },
  1105. _openDocument: function( documentData ){
  1106. this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this, this.actions, documentData, {
  1107. "isNew": false,
  1108. "isEdited": false
  1109. })
  1110. this.workForm.load();
  1111. },
  1112. _queryCreateViewNode: function(){
  1113. },
  1114. _postCreateViewNode: function( viewNode ){
  1115. },
  1116. _queryCreateViewHead:function(){
  1117. },
  1118. _postCreateViewHead: function( headNode ){
  1119. }
  1120. })
  1121. MWF.xApplication.Execution.WorkDeploy.MyDeployDocument = new Class({
  1122. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1123. action_edit : function(){
  1124. this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.view.explorer, this.actions, this.data, {
  1125. "isNew": false,
  1126. "isEdited": true,
  1127. "actionStatus":"save",
  1128. "onPostSave" : function(){
  1129. this.view.explorer.contentChanged = true;
  1130. }.bind(this)
  1131. })
  1132. this.workForm.load();
  1133. },
  1134. _queryCreateDocumentNode:function( itemData ){
  1135. //if( !this.view.titleLoaded ){
  1136. // var titleNode = new Element("tr").inject(this.view.viewNode)
  1137. // tdNode = new Element("td",{
  1138. // //text : this.view.parentWorkData.title,
  1139. // //colspan : this.view.template.items.length,
  1140. // //styles : this.css.titleTdNode
  1141. // text :"biaottttttttttt"
  1142. // }).inject(titleNode)
  1143. // this.view.titleLoaded = true;
  1144. //}
  1145. },
  1146. _postCreateDocumentNode: function( itemNode, itemData ){
  1147. if( itemData.subWrapOutOkrWorkBaseInfos ){
  1148. var list = new MWF.xApplication.Execution.WorkDeploy.SubWorkView( this.view.explorer.subWorkContentNode,
  1149. this.view.explorer.app,
  1150. this.view.explorer, {
  1151. templateUrl : this.view.explorer.path+"listItem_sub.json",
  1152. hasHead : !this.view.subViewHeadLoaded //头部只建一次
  1153. })
  1154. list.parentWorkData = itemData;
  1155. list.load();
  1156. this.view.subViewHeadLoaded = true;
  1157. }
  1158. if(itemNode.getElements("div[styles='documentSubject']")){
  1159. itemNode.getElements("div[styles='documentSubject']").set("title",itemData.shortWorkDetail)
  1160. }
  1161. },
  1162. editActionReturn: function(d){
  1163. //alert(JSON.stringify(d))
  1164. if(d.workProcessStatus == this.lp.statusDraft){
  1165. return true;
  1166. }
  1167. return false;
  1168. },
  1169. removeActionReturn : function(d){
  1170. if(d.status == this.lp.statuArchive){
  1171. return false;
  1172. }
  1173. if(d.workProcessStatus == this.lp.statusDraft){
  1174. return true;
  1175. }
  1176. return false;
  1177. },
  1178. splitActionReturn : function(d){
  1179. if(d.status == this.lp.statuArchive){
  1180. return false;
  1181. }
  1182. //如果不等于草稿并且身份相同 显示拆分
  1183. if(d.workProcessStatus != this.lp.statusDraft && d.responsibilityIdentity == this.app.identity){
  1184. return true;
  1185. }
  1186. return false;
  1187. },
  1188. appointActionReturn : function(d){
  1189. if(d.status == this.lp.statuArchive){
  1190. return false;
  1191. }
  1192. return true;
  1193. }
  1194. })
  1195. MWF.xApplication.Execution.WorkDeploy.WorkForm = new Class({
  1196. Extends: MWF.xApplication.Execution.WorkForm,
  1197. _ok: function (data, callback) {
  1198. data.title = data.workDetail;
  1199. if(this.options.isNew){
  1200. data.deployerName = this.app.user;
  1201. data.creatorName = this.app.user;
  1202. }
  1203. this.app.restActions.saveTask(data,function(json){
  1204. if(json.type && json.type=="success"){
  1205. this.app.notice(this.lp.submitSuccess, "ok");
  1206. this.explorer.reloadContent();
  1207. this.close();
  1208. }
  1209. this.fireEvent("postSave", json);
  1210. }.bind(this),function(xhr,text,error){
  1211. var errorText = error;
  1212. if (xhr) errorMessage = xhr.responseText;
  1213. var e = JSON.parse(errorMessage);
  1214. if(e.userMessage){
  1215. this.app.notice( e.userMessage,"error");
  1216. }else{
  1217. this.app.notice( errorText,"error");
  1218. }
  1219. }.bind(this));
  1220. }
  1221. })
  1222. MWF.xApplication.Execution.WorkDeploy.Appoint = new Class({
  1223. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1224. Implements: [Options, Events],
  1225. options: {
  1226. "style": "default",
  1227. "width": "500",
  1228. "height": "300",
  1229. "hasTop": true,
  1230. "hasIcon": false,
  1231. "hasBottom": true,
  1232. "title": "",
  1233. "draggable": false,
  1234. "closeAction": true,
  1235. "closeText" : "",
  1236. "needLogout" : false,
  1237. "isNew": true
  1238. },
  1239. initialize: function (app, actions, data, css, options) {
  1240. this.setOptions(options);
  1241. this.app = app;
  1242. this.actions = this.app.restActions;
  1243. this.css = css;
  1244. //this.options.title = this.app.lp.idenitySelectTitle;
  1245. //
  1246. //this.identities = identities;
  1247. this.data = data || {};
  1248. this.actions = actions;
  1249. },
  1250. load: function () {
  1251. this.create();
  1252. },
  1253. createTopNode: function () {
  1254. if (!this.formTopNode) {
  1255. this.formTopNode = new Element("div.formTopNode", {
  1256. "styles": this.css.formTopNode
  1257. }).inject(this.formNode);
  1258. this.formTopIconNode = new Element("div.formTopIconNode", {
  1259. "styles": this.css.formTopIconNode
  1260. }).inject(this.formTopNode)
  1261. this.formTopTextNode = new Element("div.formTopTextNode", {
  1262. "styles": this.css.formTopTextNode,
  1263. "text": this.app.lp.workTask.appoint.appointTitle
  1264. }).inject(this.formTopNode)
  1265. if (this.options.closeAction) {
  1266. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1267. this.formTopCloseActionNode.addEvent("click", function () {
  1268. this.close()
  1269. }.bind(this))
  1270. }
  1271. this.formTopContentNode = new Element("div.formTopContentNode", {
  1272. "styles": this.css.formTopContentNode
  1273. }).inject(this.formTopNode)
  1274. //this._createTopContent();
  1275. }
  1276. },
  1277. _createTableContent: function () {
  1278. var table = new Element("table",{"width":"100%",border:"0",cellpadding:"5",cellspacing:"0"}).inject(this.formTableArea);
  1279. table.setStyles({"margin-top":"40px"})
  1280. var tr = new Element("tr").inject(table);
  1281. var td = new Element("td",{
  1282. text : this.app.lp.workTask.appoint.appointFor,
  1283. valign:"middle",
  1284. width:"20%"
  1285. }).inject(tr);
  1286. td = new Element("td",{width:"80%"}).inject(tr);
  1287. this.appointPerson = new Element("input",{
  1288. "readonly": true
  1289. }).inject(td);
  1290. this.appointPerson.setStyles({"width":"90%","height":"20px"})
  1291. this.appointPerson.addEvents({
  1292. "click":function(){
  1293. this.selectPerson(this.appointPerson,"identity",1)
  1294. }.bind(this)
  1295. })
  1296. tr = new Element("tr").inject(table);
  1297. td = new Element("td",{
  1298. "text" : this.app.lp.workTask.appoint.appointOpinion,
  1299. valign:"middle"
  1300. }).inject(tr);
  1301. td = new Element("td").inject(tr);
  1302. this.appointOpinion = new Element("textarea").inject(td)
  1303. this.appointOpinion.setStyles({"width":"90%","height":"50px"})
  1304. },
  1305. _createBottomContent: function () {
  1306. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1307. "styles": this.css.formCancelActionNode,
  1308. "text": this.app.lp.workTask.appoint.appointCancel
  1309. }).inject(this.formBottomNode);
  1310. this.cancelActionNode.addEvent("click", function (e) {
  1311. this.close();
  1312. }.bind(this));
  1313. this.okActionNode = new Element("div.formOkActionNode", {
  1314. "styles": this.css.formOkActionNode,
  1315. "text": this.app.lp.workTask.appoint.appointOK
  1316. }).inject(this.formBottomNode);
  1317. this.okActionNode.addEvent("click", function (e) {
  1318. this.ok(e);
  1319. }.bind(this));
  1320. },
  1321. ok:function(){
  1322. if(this.appointPerson.get("value")==""){
  1323. this.app.notice(this.app.lp.workTask.appoint.personEmpty,"error")
  1324. return false;
  1325. }
  1326. if(this.appointOpinion.get("value")==""){
  1327. this.app.notice(this.app.lp.workTask.appoint.opinionEmpty,"error")
  1328. return false;
  1329. }
  1330. var submitData = {
  1331. workId : this.data.workId,
  1332. undertakerIdentity : this.appointPerson.get("value"),
  1333. authorizeOpinion : this.appointOpinion.get("value")
  1334. }
  1335. this.actions.appointBaseWork(submitData,function(json){
  1336. this.close();
  1337. this.fireEvent("reloadView");
  1338. }.bind(this),function(xhr,text,error){
  1339. var errorText = error;
  1340. if (xhr) errorMessage = xhr.responseText;
  1341. var e = JSON.parse(errorMessage);
  1342. if(e.userMessage){
  1343. this.app.notice( e.userMessage,"error");
  1344. }else{
  1345. this.app.notice( errorText,"error");
  1346. }
  1347. }.bind(this),false)
  1348. },
  1349. selectPerson: function( item, type,count ) {
  1350. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  1351. this.fireEvent("querySelect", this);
  1352. var value = item.get("value").split(this.valSeparator);
  1353. var options = {
  1354. "type": type,
  1355. "title": this.app.lp.workTask.appoint.appointTitle,
  1356. "count": count,
  1357. "names": value || [],
  1358. "onComplete": function (items) {
  1359. var arr = [];
  1360. items.each(function (item) {
  1361. arr.push(item.data.name);
  1362. }.bind(this));
  1363. item.set("value", arr.join(","));
  1364. }.bind(this)
  1365. };
  1366. var selector = new MWF.OrgSelector(this.app.content, options);
  1367. }
  1368. });