WorkDeploy.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. MWF.xApplication.Execution = MWF.xApplication.Execution || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  4. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  5. MWF.xDesktop.requireApp("Execution", "WorkForm", null, false);
  6. MWF.xApplication.Execution.WorkDeploy = new Class({
  7. Extends: MPopupForm,
  8. Implements: [Options, Events],
  9. options: {
  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. this.getCenterWorkInfo();
  37. if (this.options.isNew) {
  38. this.create();
  39. } else if (this.options.isEdited) {
  40. this.edit();
  41. } else {
  42. this.open();
  43. }
  44. },
  45. getCenterWorkInfo:function(centerId){
  46. var id = "(0)";
  47. if(arguments.length==1){
  48. id = centerId;
  49. }else{
  50. if(this.data.id){
  51. id = this.data.id;
  52. }
  53. }
  54. this.actions.getCenterWorkInfo(id,function(json){
  55. if(json.type = "success"){
  56. this.centerWorkData = json.data;
  57. this.centerWorkId = this.centerWorkData.id
  58. }
  59. }.bind(this),function(xhr,error,text){
  60. this.showErrorMessage(xhr,error,text)
  61. }.bind(this),false)
  62. },
  63. createTopNode: function () {
  64. if (!this.formTopNode) {
  65. this.formTopNode = new Element("div.formTopNode", {
  66. "styles": this.css.formTopNode
  67. }).inject(this.formNode);
  68. this.formTopIconNode = new Element("div", {
  69. "styles": this.css.formTopIconNode
  70. }).inject(this.formTopNode);
  71. this.formTopTextNode = new Element("div", {
  72. "styles": this.css.formTopTextNode,
  73. "text": this.options.title
  74. }).inject(this.formTopNode);
  75. if (this.options.closeAction) {
  76. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  77. this.formTopCloseActionNode.addEvent("click", function () {
  78. this.close();
  79. }.bind(this))
  80. }
  81. this.formTopContentNode = new Element("div", {
  82. "styles": this.css.formTopContentNode
  83. }).inject(this.formTopNode);
  84. this._createTopContent();
  85. }
  86. },
  87. _createTopContent: function () {
  88. if(this.formTopContentNode) this.formTopContentNode.empty();
  89. var html = "<span styles='formTopContentTitle' lable='drafter'></span>" +
  90. " <span styles='formTopContentValue' item='drafter'></span>" +
  91. "<span styles='formTopContentTitle' lable='draftDepartment'></span>" +
  92. " <span styles='formTopContentValue' item='draftDepartment'></span>" +
  93. "<span styles='formTopContentTitle' lable='draftDate'></span>" +
  94. " <span styles='formTopContentValue' item='draftDate'></span>";
  95. this.formTopContentNode.set("html", html);
  96. var form = new MForm(this.formTopContentNode, this.centerWorkData, {
  97. isEdited: false,
  98. itemTemplate: {
  99. drafter: {
  100. text: this.lp.drafter + ":",
  101. value:this.centerWorkData.creatorName.split("@")[0],
  102. type: "innertext"
  103. },
  104. draftDepartment: {
  105. text: this.lp.draftDepartment + ":",
  106. value:this.centerWorkData.creatorUnitName.split("@")[0],
  107. type: "innertext"
  108. },
  109. draftDate: {text: this.lp.draftDate + ":",name:"createTime", type: "innertext"}
  110. }
  111. }, this.app, this.css);
  112. form.load();
  113. },
  114. reloadTableContent:function(id){
  115. if(arguments.length==0){
  116. if(this.centerWorkData){
  117. id = this.centerWorkData.id
  118. }else if(this.data.id){
  119. id = this.data.id
  120. }else if(this.options.centerWorkId){
  121. id = this.options.centerWorkId
  122. }
  123. }
  124. this.getCenterWorkInfo(id);
  125. this._createTopContent();
  126. this._createTableContent(this.centerWorkData);
  127. this._createBottomContent();
  128. },
  129. _createTableContent: function () {
  130. if(this.formTableArea) this.formTableArea.empty();
  131. //alert(this.centerWorkData)
  132. this.createCenterWorkInfor(this.centerWorkData);
  133. this.createImportContent();
  134. this.createMyWorkList();
  135. this.creataMyDeployWorkList();
  136. },
  137. createCenterWorkInfor: function(data) {
  138. this.centerWorkContentArea = new Element("div.centerWorkContentArea", {
  139. "styles": this.css.workContentArea
  140. }).inject(this.formTableArea);
  141. var workContentTitleNode = new Element("div.workContentTitleNode", {
  142. "styles": this.css.workContentTitleNode,
  143. "text": this.lp.centerWorkInfor
  144. }).inject(this.centerWorkContentArea);
  145. this.centerWorkContentNode = new Element("div.centerWorkContentNode", {
  146. "styles": this.css.workContentNode
  147. }).inject(this.centerWorkContentArea);
  148. this.loadCenterWorkInfor(data)
  149. },
  150. loadCenterWorkInfor: function(data){
  151. this.centerWorkContentNode.empty();
  152. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='centerWorkInforTable'>" +
  153. "<tr><td styles='centerWorkInforTitle' lable='centerWorkTitle'></td>" +
  154. " <td styles='centerWorkInforValue' item='centerWorkTitle'></td></tr>" +
  155. "<tr><td colspan='2'>" +
  156. " <div styles='centerWorkInforTitleDiv' lable='reportAuditLeader'></div>" +
  157. " <div styles='centerWorkInforValueDiv' item='reportAuditLeader'></div>" +
  158. " <div styles='centerWorkInforTitleDiv' lable='defaultWorkType'></div>" +
  159. " <div styles='centerWorkInforValueDiv' item='defaultWorkType'></div>" +
  160. " <div styles='centerWorkInforTitleDiv' lable='workCompletedLimit'></div>" +
  161. " <div styles='centerWorkInforValueDiv' item='workCompletedLimit'></div>" +
  162. "</td></tr>" +
  163. "<tr><td styles='centerWorkInforTitle' lable='centerWorkMemo'></td>" +
  164. " <td styles='centerWorkInforValue' item='centerWorkMemo'></td></tr>" +
  165. "</table>";
  166. this.centerWorkContentNode.set("html", html);
  167. var resultWorkType = [];
  168. var resultWorkTypeTxt = "";
  169. if(data.workTypes){
  170. data.workTypes.each(function(d,i){
  171. if(d.workTypeName) resultWorkType.push(d.workTypeName)
  172. })
  173. }
  174. resultWorkTypeTxt = resultWorkType.join(",");
  175. if(resultWorkType.length>0){
  176. resultWorkTypeTxt = ","+resultWorkTypeTxt
  177. }
  178. var form = this.centerForm = new MForm(this.centerWorkContentNode, data, {
  179. isEdited: this.isEdited || this.isNew,
  180. itemTemplate: {
  181. centerWorkTitle: {
  182. text: this.lp.centerWorkTitle + ":", name : "title", type: "text",
  183. notEmpty:true
  184. },
  185. defaultWorkType: {
  186. text: this.lp.defaultWorkType + ":", name : "defaultWorkType", type: "select",
  187. selectValue : resultWorkTypeTxt,
  188. selectText : resultWorkTypeTxt,
  189. notEmpty:true,
  190. style : {"width":"100px","height":"30px","border-radius":"1px"}
  191. },
  192. defaultWorkLevel: {
  193. text: this.lp.defaultWorkLevel + ":", name:"defaultWorkLevel", type: "select",selectValue : this.lp.defaultWorkTypeValue,
  194. notEmpty:true,
  195. style : {"width":"200px","height":"30px","color":"#999999","border-radius":"1px","box-shadow": "0px 0px 1px #CCC"}
  196. },
  197. reportAuditLeader: {
  198. text: this.lp.reportAuditLeader + ":",
  199. name:"reportAuditLeaderIdentityList",
  200. type:"org",
  201. orgType:"identity",
  202. attr:{"readonly":true},
  203. notEmpty:false,
  204. count: 0,
  205. value: this.reportAuditLeaderList?this.reportAuditLeaderList.join(","):"",
  206. style : {"width":"400px"}
  207. },
  208. workCompletedLimit: {
  209. text: this.lp.workCompletedLimit + ":", name:"defaultCompleteDateLimitStr", type: "text",
  210. tType:"date",
  211. attr:{"readonly":true},
  212. notEmpty:true
  213. },
  214. centerWorkMemo: {
  215. text: this.lp.centerWorkMemo + ":",
  216. name: "description",
  217. type: "textarea"
  218. }
  219. }
  220. }, this.app);
  221. form.load();
  222. },
  223. createImportContent: function(){
  224. if(this.centerWorkData && this.centerWorkData.operation){
  225. if(this.centerWorkData.operation.indexOf("IMPORTWORK")>-1){
  226. this.importDiv = new Element("div.importDiv",{
  227. "styles" : this.css.importDiv
  228. }).inject(this.formTableArea);
  229. this.importTemplateDiv = new Element("div.importTemplateDiv",{
  230. "styles": this.css.importTemplateDiv,
  231. "text":this.lp.importTemplate
  232. }).inject(this.importDiv);
  233. this.importTemplateDiv.addEvents({
  234. "click":function(){
  235. window.open("../x_component_Execution/baseWork.xls")
  236. }.bind(this)
  237. });
  238. this.importTitleDiv = new Element("div.importTitleDiv",{
  239. "styles": this.css.importTitleDiv,
  240. "text":this.lp.importTemplateTitle
  241. }).inject(this.importDiv);
  242. }
  243. }
  244. },
  245. createMyWorkList : function(){
  246. if(this.myWorkContentArea) this.myWorkContentArea.destroy();
  247. var workContentArea = this.myWorkContentArea = new Element("div.workContentArea", {
  248. "styles": this.css.workContentArea
  249. }).inject(this.formTableArea);
  250. var workContentTitleNode = new Element("div", {
  251. "styles": this.css.workContentTitleNode,
  252. "text": this.lp.myWorkInfor
  253. }).inject(workContentArea);
  254. workContentNode = new Element("div", {
  255. "styles": this.css.workContentNode
  256. }).inject(workContentArea);
  257. //this.createSplitWorkList();
  258. var list = this.myWorkView = new MWF.xApplication.Execution.WorkDeploy.MyWorkView(workContentNode, this.app, this, { templateUrl : this.path+"myWork.json" });
  259. list.load();
  260. },
  261. creataMyDeployWorkList : function(){
  262. var workContentArea = this.myDeployWorkArea = new Element("div.myDeployWorkArea", {
  263. "styles": this.css.workContentArea
  264. }).inject(this.formTableArea);
  265. var myDeployWorkTitleNode = new Element("div.myDeployWorkTitleNode", {
  266. "styles": this.css.workContentTitleNode,
  267. "text": this.lp.deployWorkInfor
  268. }).inject(workContentArea);
  269. var list = this.myDeployWorkView = new MWF.xApplication.Execution.WorkDeploy.MyDeployWorkView(workContentArea, this.app, this, { templateUrl : this.path+"myDeployWork.json" });
  270. list.load();
  271. },
  272. //*************************底部按钮及方法**************************************
  273. _createBottomContent: function () {
  274. if(this.formBottomNode) this.formBottomNode.empty();
  275. if(this.centerWorkData && this.centerWorkData.operation){
  276. this.centerWorkData.operation.each(function(d,i){
  277. if(d == "CLOSE"){
  278. this.closeBotton = new Element("div.closeBotton", {
  279. "styles": this.css.formActionNode,
  280. "text": this.lp.botton.close
  281. }).inject(this.formBottomNode);
  282. this.closeBotton.addEvent("click", function (e) {
  283. this.closeWork(e);
  284. }.bind(this));
  285. }else if(d == "CREATEWORK"){
  286. this.newBotton = new Element("div.newBotton", {
  287. "styles": this.css.formActionNode,
  288. "text": this.lp.botton.new
  289. }).inject(this.formBottomNode);
  290. this.newBotton.addEvent("click", function (e) {
  291. this.createWork(e);
  292. }.bind(this));
  293. }else if(d == "IMPORTWORK"){
  294. this.importBotton = new Element("div.importBotton", {
  295. "styles": this.css.formActionNode,
  296. "text": this.lp.botton.import
  297. }).inject(this.formBottomNode);
  298. this.importBotton.addEvent("click", function (e) {
  299. this.importWork(e);
  300. }.bind(this));
  301. }else if(d == "DELETE"){
  302. this.deleteBotton = new Element("div.deleteBotton", {
  303. "styles": this.css.formActionNode,
  304. "text": this.lp.botton.delete
  305. }).inject(this.formBottomNode);
  306. this.deleteBotton.addEvent("click", function (e) {
  307. this.deleteWork(e);
  308. }.bind(this));
  309. }else if(d == "DEPLOY"){
  310. this.deployBotton = new Element("div.deployBotton", {
  311. "styles": this.css.formActionNode,
  312. "text": this.lp.botton.deploy
  313. }).inject(this.formBottomNode);
  314. this.deployBotton.addEvent("click", function (e) {
  315. this.deployWork(e);
  316. }.bind(this));
  317. }else if(d == "ARCHIVE"){
  318. this.archiveBotton = new Element("div.archiveBotton", {
  319. "styles": this.css.formActionNode,
  320. "text": this.lp.botton.archive
  321. }).inject(this.formBottomNode);
  322. this.archiveBotton.addEvent("click", function (e) {
  323. this.archiveWork(e);
  324. }.bind(this));
  325. } if(d == "CONFIRM"){
  326. this.confirmBotton = new Element("div.confirmBotton", {
  327. "styles": this.css.formActionNode,
  328. "text": this.lp.botton.confirm
  329. }).inject(this.formBottomNode);
  330. this.confirmBotton.addEvent("click", function (e) {
  331. this.confirmWork(e);
  332. }.bind(this));
  333. }
  334. }.bind(this))
  335. }
  336. },
  337. closeWork:function(data){
  338. this.close();
  339. //this.fireEvent("reloadView", data);
  340. this.fireEvent("reloadView", {"action":"reload"});
  341. },
  342. createWork:function(){
  343. var r = this.centerForm.getResult(true,",",true,false,true);
  344. if( !r ){
  345. return
  346. }
  347. if(this.options.isNew || this.options.isEdited){
  348. this.saveCenterWork(r,function(json){
  349. if(json.type && json.type == "error"){
  350. this.app.notice(json.message, "error")
  351. }else{
  352. if(json.data && json.data.id)this.reloadTableContent(json.data.id);
  353. if(this.centerWorkData)this.openWorkForm(this.centerWorkData)
  354. }
  355. }.bind(this))
  356. }else{
  357. if(this.centerWorkData)this.openWorkForm(this.centerWorkData)
  358. }
  359. },
  360. importWork:function(){
  361. var centerId;
  362. var r = this.centerForm.getResult(true,",",true,false,true);
  363. if( !r ){
  364. return false;
  365. }
  366. //if(r.reportAuditLeaderIdentityList == ""){
  367. // r.reportAuditLeaderIdentityList = [];
  368. //}else{
  369. // r.reportAuditLeaderIdentityList = r.reportAuditLeaderIdentityList.split(",");
  370. //}
  371. if(this.options.isNew || this.options.isEdited){
  372. this.saveCenterWork(r,function(json){
  373. if(json.type && json.type == "error"){
  374. this.app.notice(json.message, "error")
  375. }else{
  376. if(this.centerWorkData){
  377. centerId = this.centerWorkData.id;
  378. this.createUpload(centerId);
  379. this.reloadTableContent(centerId)
  380. }
  381. //if(json.data && json.data.id){
  382. // centerId = json.data.id;alert(centerId)
  383. // this.reloadTableContent(json.data.id)
  384. //}
  385. }
  386. }.bind(this))
  387. }else{
  388. if(this.centerWorkData) centerId = this.centerWorkData.id;
  389. this.createUpload(centerId);
  390. }
  391. //this.createUpload(centerId);
  392. },
  393. createUpload:function(centerId){
  394. if (centerId){
  395. if(this.uploadFileAreaNode) this.uploadFileAreaNode.destroy();
  396. this.uploadFileAreaNode = new Element("div");
  397. var html = "<input name=\"file\" type=\"file\" />";
  398. this.uploadFileAreaNode.set("html", html);
  399. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  400. this.fileUploadNode.addEvent("change", function(){
  401. var files = fileNode.files;
  402. if (files.length){
  403. for (var i = 0; i < files.length; i++) {
  404. var file = files.item(i);
  405. var tmp = file.name.split(".");
  406. this.uploadFileName = file.name;
  407. if( tmp[tmp.length-1].toLowerCase() != "xls" && tmp[tmp.length-1].toLowerCase() != "xlsx" ){
  408. this.app.notice("请导入excel文件!","error");
  409. return;
  410. }
  411. var formData = new FormData();
  412. formData.append('file', file);
  413. this.app.createShade(null,"正在导入,请稍后.....");
  414. this.actions.importBaseWork(centerId,formData,file,function(json){
  415. this.reloadTableContent(centerId);
  416. this.app.destroyShade()
  417. }.bind(this),function(xhr,text,error){
  418. this.showErrorMessage(xhr,text,error);
  419. this.app.destroyShade()
  420. }.bind(this));
  421. //this.actions.importBaseWork(centerId,function(json){
  422. // this.reloadTableContent(centerId);
  423. // this.app.destroyShade()
  424. //}.bind(this),function(xhr,text,error){
  425. // this.showErrorMessage(xhr,text,error);
  426. // this.app.destroyShade()
  427. //}.bind(this),formData,file)
  428. }
  429. }
  430. }.bind(this));
  431. var fileNode = this.uploadFileAreaNode.getFirst();
  432. //alert(13)
  433. debugger;
  434. //alert(this.uploadFileAreaNode.get("html"))
  435. fileNode.click();
  436. //this.uploadFileAreaNode.destroy();
  437. }
  438. },
  439. deleteWork:function(e){
  440. var _self = this;
  441. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnContent,300,120,function(){
  442. _self.app.createShade();
  443. _self.actions.deleteCenterWork(_self.centerWorkData.id, function(json){
  444. if(json.type && json.type=="success"){
  445. _self.app.notice(this.lp.prompt.deleteCenterWork, "success");
  446. _self.closeWork({"action":"reload"});
  447. }
  448. _self.app.destroyShade();
  449. }.bind(_self),function(xhr,text,error){
  450. _self.showErrorMessage(xhr,text,error);
  451. _self.app.destroyShade();
  452. }.bind(_self));
  453. this.close()
  454. },function(){
  455. this.close();
  456. })
  457. },
  458. deployWork:function(e){
  459. var _self = this;
  460. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnDeployContent,300,120,function(){
  461. _self.app.createShade();
  462. _self.actions.deployCenterWork(_self.centerWorkData.id, function(json){
  463. if(json.type && json.type=="success"){
  464. _self.app.notice(this.lp.prompt.deployCenterWork, "success");
  465. _self.close();
  466. _self.fireEvent("reloadView", {"action":"reload"});
  467. _self.app.destroyShade();
  468. }
  469. }.bind(_self),function(xhr,text,error){
  470. _self.showErrorMessage(xhr,text,error);
  471. _self.app.destroyShade();
  472. }.bind(_self));
  473. this.close()
  474. },function(){
  475. this.close();
  476. })
  477. },
  478. confirmWork:function(e){
  479. var _self = this;
  480. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnConfirmContent,300,120,function(){
  481. _self.actions.deployCenterWork(_self.centerWorkData.id, function(json){
  482. _self.app.createShade();
  483. if(json.type && json.type=="success"){
  484. _self.app.notice(this.lp.prompt.comfirmCenterWork, "success");
  485. _self.close();
  486. _self.fireEvent("reloadView", {"action":"reload"});
  487. _self.app.destroyShade();
  488. }
  489. }.bind(_self),function(xhr,text,error){
  490. _self.showErrorMessage(xhr,text,error);
  491. _self.app.destroyShade();
  492. }.bind(_self));
  493. this.close()
  494. },function(){
  495. this.close();
  496. })
  497. },
  498. archiveWork:function(e){
  499. var _self = this;
  500. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnArchiveContent,300,120,function(){
  501. _self.app.createShade();
  502. _self.actions.archiveMainTask(_self.centerWorkData.id, function(json){
  503. if(json.type && json.type=="success"){
  504. _self.app.notice(this.lp.prompt.archiveCenterWork, "success");
  505. _self.close();
  506. _self.fireEvent("reloadView", {"action":"reload"});
  507. _self.app.destroyShade();
  508. }
  509. }.bind(_self),function(xhr,text,error){
  510. _self.showErrorMessage(xhr,text,error);
  511. _self.app.destroyShade();
  512. }.bind(_self));
  513. this.close()
  514. },function(){
  515. this.close();
  516. })
  517. },
  518. //*************************底部按钮及方法**************************************
  519. saveCenterWork: function(data,callback){
  520. if(data.reportAuditLeaderIdentityList == ""){
  521. data.reportAuditLeaderIdentityList = [];
  522. }else{
  523. data.reportAuditLeaderIdentityList = data.reportAuditLeaderIdentityList.split(",");
  524. }
  525. this.app.restActions.saveCenterWork( data,
  526. function(json){
  527. if( callback )callback(json);
  528. }.bind(this),
  529. function(xhr,text,error){
  530. this.showErrorMessage(xhr,text,error)
  531. }.bind(this),
  532. false
  533. );
  534. },
  535. openWorkForm : function( data ){
  536. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  537. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{
  538. "centerWorkId": data.id || this.options.centerWorkId,
  539. "centerWorkTitle":data.title
  540. },{
  541. "isNew": true,
  542. "isEdited": false,
  543. "actionStatus":"save",
  544. "onPostSave" : function(){
  545. this.reloadTableContent()
  546. }.bind(this)
  547. });
  548. //alert("cccc="+this.centerWorkId)
  549. this.workform.load();
  550. }.bind(this));
  551. },
  552. showErrorMessage:function(xhr,text,error){
  553. var errorText = error;
  554. if (xhr) errorMessage = xhr.responseText;
  555. if(errorMessage!=""){
  556. var e = JSON.parse(errorMessage);
  557. if(e.message){
  558. this.app.notice( e.message,"error");
  559. }else{
  560. this.app.notice( errorText,"error");
  561. }
  562. }else{
  563. this.app.notice(errorText,"error");
  564. }
  565. }
  566. });
  567. MWF.xApplication.Execution.WorkDeploy.MyDeployWorkView = new Class({
  568. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  569. _createDocument: function(data){
  570. return new MWF.xApplication.Execution.WorkDeploy.MyDeployWorkDocument(this.viewNode, data, this.explorer, this);
  571. },
  572. _getCurrentPageData: function(callback, count){
  573. if(!this.explorer.centerWorkId) return;
  574. this.actions.getMyDeployWork(this.explorer.centerWorkId,function(json){
  575. if(json.data.length==0){
  576. this.explorer.myDeployWorkArea.destroy();
  577. }
  578. if (callback) callback(json)
  579. }.bind(this),
  580. function(xhr,text,error){
  581. this.explorer.showErrorMessage(xhr,text,error)
  582. }.bind(this),false)
  583. },
  584. _queryCreateViewNode: function(){
  585. },
  586. _postCreateViewNode: function( viewNode ){
  587. },
  588. _queryCreateViewHead:function(){
  589. },
  590. _postCreateViewHead: function( headNode ){
  591. }
  592. });
  593. MWF.xApplication.Execution.WorkDeploy.MyDeployWorkDocument = new Class({
  594. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  595. //action_edit : function(){
  596. // this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.view.explorer, this.actions, this.data, {
  597. // "isNew": false,
  598. // "isEdited": true,
  599. // "actionStatus":"save",
  600. // "onPostSave" : function(){
  601. // this.view.explorer.contentChanged = true;
  602. // }.bind(this)
  603. // });
  604. // this.workForm.load();
  605. //},
  606. _queryCreateDocumentNode:function( itemData ){
  607. },
  608. _postCreateDocumentNode: function( itemNode, itemData ){
  609. var ftd = itemNode.getElements("td")[0];
  610. itemNode.empty();
  611. var newTd = new Element("td",{
  612. "colspan":this.view.template.items.length,
  613. "style":ftd.get("style"),
  614. "html":ftd.get("html")
  615. }).inject(itemNode);
  616. if(itemData.subWorks){
  617. itemData.subWorks.each(function(d,i){
  618. var subTrNode = new Element("tr.subTrNode",{
  619. "styles":this.css.subTrNode
  620. }).inject(this.view.viewNode);
  621. subTrNode.addEvents({
  622. "click":function(){
  623. this.action_view(d.id)
  624. }.bind(this),
  625. "mouseover":function(){
  626. subTrNode.setStyles(this.css["documentNode_over"])
  627. }.bind(this),
  628. "mouseout":function(){
  629. subTrNode.setStyles(this.css.subTrNode)
  630. }.bind(this)
  631. });
  632. this.view.template.items.each(function(dd,i){
  633. var htmlValue = dd.content.html;
  634. subTrNode.set("html",subTrNode.get("html")+htmlValue)
  635. }.bind(this));
  636. this.setLables(subTrNode,d);
  637. this.setValues(subTrNode,d);
  638. this.setStyles(subTrNode,d);
  639. this.setActions(subTrNode,d)
  640. }.bind(this))
  641. }
  642. },
  643. setLables:function(container,data){
  644. container.getElements("[lable]").each(function(el){
  645. var val = el.get("lable");
  646. if( val && this.lp[val] ){
  647. el.set("text", this.lp[val] )
  648. }
  649. }.bind(this))
  650. },
  651. setValues:function(container,data){
  652. container.getElements("[item]").each(function(el){
  653. var val = el.get("item");
  654. if(data[val]){
  655. //特殊处理人员组织的字符串
  656. //var exp = "val == 'responsibilityUnitName' || val == 'deployerUnitName'";
  657. //exp = exp + " || val == 'responsibilityEmployeeName' || val == 'deployerName'";
  658. if(val == 'responsibilityUnitName' || val == 'deployerUnitName' || val == 'responsibilityEmployeeName' || val == 'deployerName'){
  659. if(data[val]!=""){
  660. if(data[val].indexOf(",")>0){
  661. var v = data[val];
  662. var vs = v.split(",");
  663. var r = "";
  664. for(i=0;i<vs.length;i++){
  665. if(r=="") r = vs[i].split("@")[0];
  666. else r = r + ","+vs[i].split("@")[0]
  667. }
  668. data[val]=r;
  669. }else{
  670. data[val] = data[val].split("@")[0];
  671. }
  672. }
  673. }
  674. if(val == 'cooperateUnitNameList' || val == 'cooperateEmployeeNameList' ){
  675. var r = "";
  676. for(i=0;i<data[val].length;i++){
  677. if(r=="") r = data[val][i].split("@")[0];
  678. else r = r + ","+data[val][i].split("@")[0]
  679. }
  680. data[val] = r;
  681. }
  682. el.set("text", data[val].length>70 ? data[val].substr(0,70)+'...' : data[val])
  683. }
  684. }.bind(this));
  685. container.getElements("[title]").each(function(el){
  686. var val = el.get("title");
  687. if(data[val]){
  688. el.set("title", data[val] )
  689. }
  690. }.bind(this))
  691. },
  692. setStyles:function(container,data){
  693. var tdActionNode = container.getElements("td[actionTd='yes']");
  694. if(!tdActionNode) return;
  695. container.getElements("[styles]").each(function(el){
  696. var val = el.get("styles");
  697. if( val && this.css[val] ){
  698. el.setStyles(this.css[val])
  699. }
  700. }.bind(this));
  701. container.getElements("[subStyles]").each(function(el){
  702. var val = el.get("subStyles");
  703. if( val && this.css[val] ){
  704. el.setStyles(this.css[val])
  705. }
  706. }.bind(this))
  707. },
  708. setActions:function(container,data){
  709. var actionTdNode = container.getElement("td[actionTd='yes']");
  710. if(!actionTdNode) return;
  711. if(data.operation){
  712. data.operation.each(function(d,i){
  713. var actionSpan = new Element("span.actionSpan",{
  714. "styles":this.css.documentActionNode
  715. }).inject(actionTdNode);
  716. if(data.operation.length==1){
  717. if(d == "VIEW"){
  718. actionSpan.set("text",this.lp.action_view);
  719. actionSpan.addEvent("click", function (e) {
  720. this.action_view(data.id);
  721. return false;
  722. }.bind(this));
  723. }
  724. }
  725. if(d == "EDIT"){
  726. actionSpan.set("text",this.lp.action_edit);
  727. actionSpan.addEvent("click", function (e) {
  728. this.action_edit(data.id);
  729. return false;
  730. }.bind(this));
  731. }else if(d == "DELETE"){
  732. actionSpan.set("text",this.lp.action_delete);
  733. actionSpan.addEvent("click", function (e) {
  734. this.action_delete(data.id,e);
  735. return false;
  736. }.bind(this));
  737. }else if(d == "ARCHIVE"){
  738. actionSpan.set("text",this.lp.action_archive);
  739. actionSpan.addEvent("click", function (e) {
  740. this.action_archive(data.id,e);
  741. return false;
  742. }.bind(this));
  743. }
  744. }.bind(this))
  745. }
  746. },
  747. action_view:function(id){
  748. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"id": id },{
  749. "isNew": false,
  750. "isEdited": false,
  751. "actionStatus":"save",
  752. "onPostSave" : function(){
  753. this.explorer.contentChanged = true;
  754. }.bind(this)
  755. });
  756. this.workform.load();
  757. },
  758. action_edit:function(id){
  759. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"id": id },{
  760. "isNew": false,
  761. "isEdited": true,
  762. "actionStatus":"save",
  763. "onPostSave" : function(){
  764. this.explorer.reloadTableContent()
  765. }.bind(this)
  766. });
  767. this.workform.load();
  768. },
  769. action_delete:function(id,e){
  770. var _self = this;
  771. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnContent,300,120,function(){
  772. _self.app.createShade();
  773. _self.actions.deleteBaseWork(id, function(json){
  774. if(json.type && json.type=="success"){
  775. this.app.notice(_self.view.explorer.lp.prompt.deleteBaseWork, "success");
  776. _self.view.explorer.reloadTableContent();
  777. _self.app.destroyShade();
  778. }
  779. }.bind(_self),function(xhr,text,error){
  780. _self.view.explorer.showErrorMessage(xhr,text,error);
  781. _self.app.destroyShade();
  782. }.bind(_self));
  783. this.close()
  784. },function(){
  785. this.close();
  786. })
  787. },
  788. action_archive:function(id,e){
  789. var _self = this;
  790. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnArchiveContent,300,120,function(){
  791. _self.app.createShade();
  792. _self.actions.archiveBaseWork(id, function(json){
  793. if(json.type && json.type=="success"){
  794. this.app.notice(_self.view.explorer.lp.prompt.archiveBaseWork, "success");
  795. _self.view.explorer.reloadTableContent();
  796. _self.app.destroyShade();
  797. }
  798. }.bind(_self),function(xhr,text,error){
  799. _self.view.explorer.showErrorMessage(xhr,text,error);
  800. _self.app.destroyShade();
  801. }.bind(_self));
  802. this.close();
  803. },function(){
  804. this.close();
  805. })
  806. }
  807. });
  808. MWF.xApplication.Execution.WorkDeploy.MyWorkView = new Class({
  809. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  810. _createDocument: function(data){
  811. return new MWF.xApplication.Execution.WorkDeploy.MyWorkDocument(this.viewNode, data, this.explorer, this);
  812. },
  813. _getCurrentPageData: function(callback, count){
  814. if(this.explorer.centerWorkId){
  815. this.actions.getMyRelativeWork( this.explorer.centerWorkId, function(json){
  816. if(json.data.length==0){
  817. this.explorer.myWorkContentArea.destroy();
  818. }
  819. if (callback) callback(json)
  820. }.bind(this),null,false);
  821. }
  822. },
  823. _openDocument: function( documentData ){
  824. this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, documentData, {
  825. "isNew": false,
  826. "isEdited": false
  827. });
  828. this.workForm.load();
  829. },
  830. _queryCreateViewNode: function(){
  831. },
  832. _postCreateViewNode: function( viewNode ){
  833. },
  834. _queryCreateViewHead:function(){
  835. },
  836. _postCreateViewHead: function( headNode ){
  837. }
  838. });
  839. MWF.xApplication.Execution.WorkDeploy.MyWorkDocument = new Class({
  840. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  841. viewActionReturn:function(d) {
  842. var ret = false;
  843. if(d.operation && d.operation.length==1){
  844. ret = true;
  845. }
  846. return ret;
  847. },
  848. splitActionReturn:function(d) {
  849. var ret = false;
  850. if (d.operation && d.operation.indexOf("SPLIT")>-1)ret = true;
  851. return ret;
  852. },
  853. authorizeActionReturn:function(d) {
  854. var ret = false;
  855. if (d.operation && d.operation.indexOf("AUTHORIZE")>-1)ret = true;
  856. return ret;
  857. },
  858. tackBackActionReturn:function(d){
  859. var ret = false;
  860. if (d.operation && d.operation.indexOf("TACKBACK")>-1)ret = true;
  861. return ret;
  862. },
  863. archiveActionReturn:function(d){
  864. var ret = false;
  865. if (d.operation && d.operation.indexOf("ARCHIVE")>-1)ret = true;
  866. return ret
  867. },
  868. action_view:function(){
  869. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  870. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,this.data,{
  871. "isNew": false,
  872. "isEdited": false
  873. });
  874. workform.load();
  875. }.bind(this));
  876. },
  877. action_split:function(){
  878. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  879. var data = {
  880. title : this.data.title,
  881. centerId : this.data.centerId,
  882. centerWorkTitle: this.data.centerTitle,
  883. parentWorkId : this.data.id,
  884. //parentWorkTitle : this.data.title,
  885. workType : this.data.workType,
  886. workLevel : this.data.workLevel,
  887. completeDateLimitStr : this.data.completeDateLimitStr,
  888. completeDateLimit : this.data.completeDateLimit,
  889. reportCycle: this.data.reportCycle,
  890. reportDayInCycle: this.data.reportDayInCycle
  891. };
  892. if(this.data.id){
  893. this.actions.getBaseWorkDetails(this.data.id, function (json) {
  894. data.workSplitAndDescription = json.data.workDetail;
  895. //data.specificActionInitiatives = json.data.progressAction
  896. //data.cityCompanyDuty = json.data.dutyDescription
  897. //data.milestoneMark = json.data.landmarkDescription
  898. //data.importantMatters = json.data.majorIssuesDescription
  899. }.bind(this),null,false)
  900. }
  901. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"centerWorkTitle":this.data.centerTitle},{
  902. "isNew": true,
  903. "isEdited": false,
  904. "parentWorkId":this.data.id,
  905. "actionStatus":"save",
  906. "onPostSave" : function(){
  907. this.explorer.reloadTableContent()
  908. }.bind(this)
  909. });
  910. workform.load();
  911. }.bind(this));
  912. },
  913. action_authorize:function(){
  914. var data = {
  915. workId : this.data.id
  916. };
  917. var appointForm = new MWF.xApplication.Execution.WorkDeploy.Appoint(this.view.app,this.view.app.restActions,data,this.view.css,{
  918. "ieEdited": true,
  919. "onReloadView" : function( data ){
  920. this.explorer.reloadTableContent()
  921. }.bind(this)
  922. });
  923. appointForm.load();
  924. },
  925. action_tackBack: function(e){
  926. var _self = this;
  927. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnTackBackContent,300,120,function(){
  928. _self.actions.unAppointBaseWork({workId:_self.data.id}, function(json){
  929. if(json.type && json.type=="success"){
  930. _self.app.notice(_self.explorer.lp.prompt.tackbackBaseWork, "success");
  931. _self.explorer.reloadTableContent();
  932. }
  933. }.bind(_self),function(xhr,text,error){
  934. _self.explorer.showErrorMessage(xhr,text,error)
  935. }.bind(_self));
  936. this.close()
  937. },function(){
  938. this.close();
  939. })
  940. },
  941. action_archive:function(e){
  942. var _self = this;
  943. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnArchiveContent,300,120,function(){
  944. _self.app.createShade();
  945. _self.actions.archiveBaseWork(_self.data.id, function(json){
  946. if(json.type && json.type=="success"){
  947. this.app.notice(_self.view.explorer.lp.prompt.archiveBaseWork, "success");
  948. _self.view.explorer.reloadTableContent();
  949. _self.app.destroyShade();
  950. }
  951. }.bind(_self),function(xhr,text,error){
  952. _self.view.explorer.showErrorMessage(xhr,text,error);
  953. _self.app.destroyShade();
  954. }.bind(_self));
  955. this.close();
  956. },function(){
  957. this.close();
  958. })
  959. },
  960. _queryCreateDocumentNode:function( itemData ){
  961. },
  962. _postCreateDocumentNode: function( itemNode, itemData ){
  963. if(itemNode.getElements("div[item='workDetail']").length>0){
  964. if(itemData.hasSubWorks){
  965. itemNode.getElements("div[item='workDetail']").setStyle("color","#ec6a1a");
  966. }
  967. //this.view.actions.getBaseWorksByParentId(itemData.id,function(json){
  968. // if(json.data && json.data.length>0){
  969. // itemNode.getElements("div[item='title']").setStyle("color","#ec6a1a");
  970. // //itemNode.getElements("div[item='title']").set("title",this.view.lp.splitReady);
  971. // }
  972. //}.bind(this))
  973. }
  974. if(itemNode.getElements("div[name='appointDiv']")){
  975. if(itemData.workProcessIdentity && itemData.workProcessIdentity.indexOf("AUTHORIZE")>-1){
  976. itemNode.getElements("div[name='appointDiv']").setStyle("display","")
  977. }
  978. }
  979. if(itemNode.getElements("div[styles='documentSubject']")){
  980. itemNode.getElements("div[styles='documentSubject']").set("title",itemData.workDetail)
  981. }
  982. }
  983. });
  984. MWF.xApplication.Execution.WorkDeploy.Appoint = new Class({
  985. Extends: MPopupForm,
  986. Implements: [Options, Events],
  987. options: {
  988. "style": "default",
  989. "width": "500",
  990. "height": "300",
  991. "hasTop": true,
  992. "hasIcon": false,
  993. "hasBottom": true,
  994. "title": "",
  995. "draggable": false,
  996. "closeAction": true,
  997. "closeText" : "",
  998. "needLogout" : false,
  999. "isNew": true
  1000. },
  1001. initialize: function (app, actions, data, css, options) {
  1002. this.setOptions(options);
  1003. this.app = app;
  1004. this.actions = this.app.restActions;
  1005. this.css = css;
  1006. //this.options.title = this.app.lp.idenitySelectTitle;
  1007. //
  1008. //this.identities = identities;
  1009. this.data = data || {};
  1010. this.actions = actions;
  1011. },
  1012. load: function () {
  1013. this.create();
  1014. },
  1015. createTopNode: function () {
  1016. if (!this.formTopNode) {
  1017. this.formTopNode = new Element("div.formTopNode", {
  1018. "styles": this.css.formTopNode
  1019. }).inject(this.formNode);
  1020. this.formTopIconNode = new Element("div.formTopIconNode", {
  1021. "styles": this.css.formTopIconNode
  1022. }).inject(this.formTopNode);
  1023. this.formTopTextNode = new Element("div.formTopTextNode", {
  1024. "styles": this.css.formTopTextNode,
  1025. "text": this.app.lp.workTask.appoint.appointTitle
  1026. }).inject(this.formTopNode);
  1027. if (this.options.closeAction) {
  1028. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1029. this.formTopCloseActionNode.addEvent("click", function () {
  1030. this.close()
  1031. }.bind(this))
  1032. }
  1033. this.formTopContentNode = new Element("div.formTopContentNode", {
  1034. "styles": this.css.formTopContentNode
  1035. }).inject(this.formTopNode);
  1036. //this._createTopContent();
  1037. }
  1038. },
  1039. _createTableContent: function () {
  1040. var table = new Element("table",{"width":"100%",border:"0",cellpadding:"5",cellspacing:"0"}).inject(this.formTableArea);
  1041. table.setStyles({"margin-top":"40px"});
  1042. var tr = new Element("tr").inject(table);
  1043. var td = new Element("td",{
  1044. text : this.app.lp.workTask.appoint.appointFor,
  1045. valign:"middle",
  1046. width:"20%"
  1047. }).inject(tr);
  1048. td = new Element("td",{width:"80%"}).inject(tr);
  1049. this.appointPerson = new MDomItem( td, {
  1050. "name" : "appointPerson", "type":"org","orgType":"identity","notEmpty":true,
  1051. "style":{"width":"90%","height":"25px","border":"1px solid #666"}
  1052. }, true, this.app );
  1053. this.appointPerson.load();
  1054. //})
  1055. tr = new Element("tr").inject(table);
  1056. td = new Element("td",{
  1057. "text" : this.app.lp.workTask.appoint.appointOpinion,
  1058. valign:"middle"
  1059. }).inject(tr);
  1060. td = new Element("td").inject(tr);
  1061. this.appointOpinion = new Element("textarea").inject(td);
  1062. this.appointOpinion.setStyles({"width":"90%","height":"50px"})
  1063. },
  1064. _createBottomContent: function () {
  1065. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1066. "styles": this.css.formCancelActionNode,
  1067. "text": this.app.lp.workTask.appoint.appointCancel
  1068. }).inject(this.formBottomNode);
  1069. this.cancelActionNode.addEvent("click", function (e) {
  1070. this.close();
  1071. }.bind(this));
  1072. this.okActionNode = new Element("div.formOkActionNode", {
  1073. "styles": this.css.formOkActionNode,
  1074. "text": this.app.lp.workTask.appoint.appointOK
  1075. }).inject(this.formBottomNode);
  1076. this.okActionNode.addEvent("click", function (e) {
  1077. this.ok(e);
  1078. }.bind(this));
  1079. },
  1080. ok:function(){
  1081. if(this.appointPerson.getValue()==""){
  1082. this.app.notice(this.app.lp.workTask.appoint.personEmpty,"error");
  1083. return false;
  1084. }
  1085. if(this.appointOpinion.get("value")==""){
  1086. this.app.notice(this.app.lp.workTask.appoint.opinionEmpty,"error");
  1087. return false;
  1088. }
  1089. var submitData = {
  1090. workId : this.data.workId,
  1091. //undertakerIdentity : this.appointPerson.get("value"),
  1092. undertakerIdentity : this.appointPerson.getValue(","),
  1093. authorizeOpinion : this.appointOpinion.get("value")
  1094. };
  1095. this.actions.appointBaseWork(submitData,function(json){
  1096. this.app.notice(this.app.lp.WorkDeploy.prompt.authorizeBaseWork,"success");
  1097. this.close();
  1098. this.fireEvent("reloadView");
  1099. }.bind(this),function(xhr,text,error){
  1100. var errorText = error;
  1101. if (xhr) errorMessage = xhr.responseText;
  1102. var e = JSON.parse(errorMessage);
  1103. if(e.message){
  1104. this.app.notice( e.message,"error");
  1105. }else{
  1106. this.app.notice( errorText,"error");
  1107. }
  1108. }.bind(this),false)
  1109. },
  1110. selectPerson: function( item, type,count ) {
  1111. MWF.xDesktop.requireApp("Selector", "package", null, false);
  1112. this.fireEvent("querySelect", this);
  1113. var value = item.get("value").split(this.valSeparator);
  1114. var options = {
  1115. "type": type,
  1116. "title": this.app.lp.workTask.appoint.appointTitle,
  1117. "count": count,
  1118. "values": value || [],
  1119. "onComplete": function (items) {
  1120. var arr = [];
  1121. items.each(function (item) {
  1122. arr.push(item.data.distinguishedName);
  1123. }.bind(this));
  1124. item.set("value", arr.join(","));
  1125. }.bind(this)
  1126. };
  1127. var selector = new MWF.O2Selector(this.app.content, options);
  1128. }
  1129. });