WorkDeploy.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  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,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),formData,file);
  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. //alert(this.uploadFileAreaNode.get("html"))
  434. fileNode.click();
  435. //this.uploadFileAreaNode.destroy();
  436. }
  437. },
  438. deleteWork:function(e){
  439. var _self = this;
  440. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnContent,300,120,function(){
  441. _self.app.createShade();
  442. _self.actions.deleteCenterWork(_self.centerWorkData.id, function(json){
  443. if(json.type && json.type=="success"){
  444. _self.app.notice(this.lp.prompt.deleteCenterWork, "success");
  445. _self.closeWork({"action":"reload"});
  446. }
  447. _self.app.destroyShade();
  448. }.bind(_self),function(xhr,text,error){
  449. _self.showErrorMessage(xhr,text,error);
  450. _self.app.destroyShade();
  451. }.bind(_self));
  452. this.close()
  453. },function(){
  454. this.close();
  455. })
  456. },
  457. deployWork:function(e){
  458. var _self = this;
  459. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnDeployContent,300,120,function(){
  460. _self.app.createShade();
  461. _self.actions.deployCenterWork(_self.centerWorkData.id, function(json){
  462. if(json.type && json.type=="success"){
  463. _self.app.notice(this.lp.prompt.deployCenterWork, "success");
  464. _self.close();
  465. _self.fireEvent("reloadView", {"action":"reload"});
  466. _self.app.destroyShade();
  467. }
  468. }.bind(_self),function(xhr,text,error){
  469. _self.showErrorMessage(xhr,text,error);
  470. _self.app.destroyShade();
  471. }.bind(_self));
  472. this.close()
  473. },function(){
  474. this.close();
  475. })
  476. },
  477. confirmWork:function(e){
  478. var _self = this;
  479. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnConfirmContent,300,120,function(){
  480. _self.actions.deployCenterWork(_self.centerWorkData.id, function(json){
  481. _self.app.createShade();
  482. if(json.type && json.type=="success"){
  483. _self.app.notice(this.lp.prompt.comfirmCenterWork, "success");
  484. _self.close();
  485. _self.fireEvent("reloadView", {"action":"reload"});
  486. _self.app.destroyShade();
  487. }
  488. }.bind(_self),function(xhr,text,error){
  489. _self.showErrorMessage(xhr,text,error);
  490. _self.app.destroyShade();
  491. }.bind(_self));
  492. this.close()
  493. },function(){
  494. this.close();
  495. })
  496. },
  497. archiveWork:function(e){
  498. var _self = this;
  499. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnArchiveContent,300,120,function(){
  500. _self.app.createShade();
  501. _self.actions.archiveMainTask(_self.centerWorkData.id, function(json){
  502. if(json.type && json.type=="success"){
  503. _self.app.notice(this.lp.prompt.archiveCenterWork, "success");
  504. _self.close();
  505. _self.fireEvent("reloadView", {"action":"reload"});
  506. _self.app.destroyShade();
  507. }
  508. }.bind(_self),function(xhr,text,error){
  509. _self.showErrorMessage(xhr,text,error);
  510. _self.app.destroyShade();
  511. }.bind(_self));
  512. this.close()
  513. },function(){
  514. this.close();
  515. })
  516. },
  517. //*************************底部按钮及方法**************************************
  518. saveCenterWork: function(data,callback){
  519. if(data.reportAuditLeaderIdentityList == ""){
  520. data.reportAuditLeaderIdentityList = [];
  521. }else{
  522. data.reportAuditLeaderIdentityList = data.reportAuditLeaderIdentityList.split(",");
  523. }
  524. this.app.restActions.saveCenterWork( data,
  525. function(json){
  526. if( callback )callback(json);
  527. }.bind(this),
  528. function(xhr,text,error){
  529. this.showErrorMessage(xhr,text,error)
  530. }.bind(this),
  531. false
  532. );
  533. },
  534. openWorkForm : function( data ){
  535. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  536. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{
  537. "centerWorkId": data.id || this.options.centerWorkId,
  538. "centerWorkTitle":data.title
  539. },{
  540. "isNew": true,
  541. "isEdited": false,
  542. "actionStatus":"save",
  543. "onPostSave" : function(){
  544. this.reloadTableContent()
  545. }.bind(this)
  546. });
  547. //alert("cccc="+this.centerWorkId)
  548. this.workform.load();
  549. }.bind(this));
  550. },
  551. showErrorMessage:function(xhr,text,error){
  552. var errorText = error;
  553. if (xhr) errorMessage = xhr.responseText;
  554. if(errorMessage!=""){
  555. var e = JSON.parse(errorMessage);
  556. if(e.message){
  557. this.app.notice( e.message,"error");
  558. }else{
  559. this.app.notice( errorText,"error");
  560. }
  561. }else{
  562. this.app.notice(errorText,"error");
  563. }
  564. }
  565. });
  566. MWF.xApplication.Execution.WorkDeploy.MyDeployWorkView = new Class({
  567. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  568. _createDocument: function(data){
  569. return new MWF.xApplication.Execution.WorkDeploy.MyDeployWorkDocument(this.viewNode, data, this.explorer, this);
  570. },
  571. _getCurrentPageData: function(callback, count){
  572. if(!this.explorer.centerWorkId) return;
  573. this.actions.getMyDeployWork(this.explorer.centerWorkId,function(json){
  574. if(json.data.length==0){
  575. this.explorer.myDeployWorkArea.destroy();
  576. }
  577. if (callback) callback(json)
  578. }.bind(this),
  579. function(xhr,text,error){
  580. this.explorer.showErrorMessage(xhr,text,error)
  581. }.bind(this),false)
  582. },
  583. _queryCreateViewNode: function(){
  584. },
  585. _postCreateViewNode: function( viewNode ){
  586. },
  587. _queryCreateViewHead:function(){
  588. },
  589. _postCreateViewHead: function( headNode ){
  590. }
  591. });
  592. MWF.xApplication.Execution.WorkDeploy.MyDeployWorkDocument = new Class({
  593. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  594. //action_edit : function(){
  595. // this.workForm = new MWF.xApplication.Execution.WorkDeploy.WorkForm(this.view.explorer, this.actions, this.data, {
  596. // "isNew": false,
  597. // "isEdited": true,
  598. // "actionStatus":"save",
  599. // "onPostSave" : function(){
  600. // this.view.explorer.contentChanged = true;
  601. // }.bind(this)
  602. // });
  603. // this.workForm.load();
  604. //},
  605. _queryCreateDocumentNode:function( itemData ){
  606. },
  607. _postCreateDocumentNode: function( itemNode, itemData ){
  608. var ftd = itemNode.getElements("td")[0];
  609. itemNode.empty();
  610. var newTd = new Element("td",{
  611. "colspan":this.view.template.items.length,
  612. "style":ftd.get("style"),
  613. "html":ftd.get("html")
  614. }).inject(itemNode);
  615. if(itemData.subWorks){
  616. itemData.subWorks.each(function(d,i){
  617. var subTrNode = new Element("tr.subTrNode",{
  618. "styles":this.css.subTrNode
  619. }).inject(this.view.viewNode);
  620. subTrNode.addEvents({
  621. "click":function(){
  622. this.action_view(d.id)
  623. }.bind(this),
  624. "mouseover":function(){
  625. subTrNode.setStyles(this.css["documentNode_over"])
  626. }.bind(this),
  627. "mouseout":function(){
  628. subTrNode.setStyles(this.css.subTrNode)
  629. }.bind(this)
  630. });
  631. this.view.template.items.each(function(dd,i){
  632. var htmlValue = dd.content.html;
  633. subTrNode.set("html",subTrNode.get("html")+htmlValue)
  634. }.bind(this));
  635. this.setLables(subTrNode,d);
  636. this.setValues(subTrNode,d);
  637. this.setStyles(subTrNode,d);
  638. this.setActions(subTrNode,d)
  639. }.bind(this))
  640. }
  641. },
  642. setLables:function(container,data){
  643. container.getElements("[lable]").each(function(el){
  644. var val = el.get("lable");
  645. if( val && this.lp[val] ){
  646. el.set("text", this.lp[val] )
  647. }
  648. }.bind(this))
  649. },
  650. setValues:function(container,data){
  651. container.getElements("[item]").each(function(el){
  652. var val = el.get("item");
  653. if(data[val]){
  654. //特殊处理人员组织的字符串
  655. //var exp = "val == 'responsibilityUnitName' || val == 'deployerUnitName'";
  656. //exp = exp + " || val == 'responsibilityEmployeeName' || val == 'deployerName'";
  657. if(val == 'responsibilityUnitName' || val == 'deployerUnitName' || val == 'responsibilityEmployeeName' || val == 'deployerName'){
  658. if(data[val]!=""){
  659. if(data[val].indexOf(",")>0){
  660. var v = data[val];
  661. var vs = v.split(",");
  662. var r = "";
  663. for(i=0;i<vs.length;i++){
  664. if(r=="") r = vs[i].split("@")[0];
  665. else r = r + ","+vs[i].split("@")[0]
  666. }
  667. data[val]=r;
  668. }else{
  669. data[val] = data[val].split("@")[0];
  670. }
  671. }
  672. }
  673. if(val == 'cooperateUnitNameList' || val == 'cooperateEmployeeNameList' ){
  674. var r = "";
  675. for(i=0;i<data[val].length;i++){
  676. if(r=="") r = data[val][i].split("@")[0];
  677. else r = r + ","+data[val][i].split("@")[0]
  678. }
  679. data[val] = r;
  680. }
  681. el.set("text", data[val].length>70 ? data[val].substr(0,70)+'...' : data[val])
  682. }
  683. }.bind(this));
  684. container.getElements("[title]").each(function(el){
  685. var val = el.get("title");
  686. if(data[val]){
  687. el.set("title", data[val] )
  688. }
  689. }.bind(this))
  690. },
  691. setStyles:function(container,data){
  692. var tdActionNode = container.getElements("td[actionTd='yes']");
  693. if(!tdActionNode) return;
  694. container.getElements("[styles]").each(function(el){
  695. var val = el.get("styles");
  696. if( val && this.css[val] ){
  697. el.setStyles(this.css[val])
  698. }
  699. }.bind(this));
  700. container.getElements("[subStyles]").each(function(el){
  701. var val = el.get("subStyles");
  702. if( val && this.css[val] ){
  703. el.setStyles(this.css[val])
  704. }
  705. }.bind(this))
  706. },
  707. setActions:function(container,data){
  708. var actionTdNode = container.getElement("td[actionTd='yes']");
  709. if(!actionTdNode) return;
  710. if(data.operation){
  711. data.operation.each(function(d,i){
  712. var actionSpan = new Element("span.actionSpan",{
  713. "styles":this.css.documentActionNode
  714. }).inject(actionTdNode);
  715. if(data.operation.length==1){
  716. if(d == "VIEW"){
  717. actionSpan.set("text",this.lp.action_view);
  718. actionSpan.addEvent("click", function (e) {
  719. this.action_view(data.id);
  720. return false;
  721. }.bind(this));
  722. }
  723. }
  724. if(d == "EDIT"){
  725. actionSpan.set("text",this.lp.action_edit);
  726. actionSpan.addEvent("click", function (e) {
  727. this.action_edit(data.id);
  728. return false;
  729. }.bind(this));
  730. }else if(d == "DELETE"){
  731. actionSpan.set("text",this.lp.action_delete);
  732. actionSpan.addEvent("click", function (e) {
  733. this.action_delete(data.id,e);
  734. return false;
  735. }.bind(this));
  736. }else if(d == "ARCHIVE"){
  737. actionSpan.set("text",this.lp.action_archive);
  738. actionSpan.addEvent("click", function (e) {
  739. this.action_archive(data.id,e);
  740. return false;
  741. }.bind(this));
  742. }
  743. }.bind(this))
  744. }
  745. },
  746. action_view:function(id){
  747. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"id": id },{
  748. "isNew": false,
  749. "isEdited": false,
  750. "actionStatus":"save",
  751. "onPostSave" : function(){
  752. this.explorer.contentChanged = true;
  753. }.bind(this)
  754. });
  755. this.workform.load();
  756. },
  757. action_edit:function(id){
  758. this.workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"id": id },{
  759. "isNew": false,
  760. "isEdited": true,
  761. "actionStatus":"save",
  762. "onPostSave" : function(){
  763. this.explorer.reloadTableContent()
  764. }.bind(this)
  765. });
  766. this.workform.load();
  767. },
  768. action_delete:function(id,e){
  769. var _self = this;
  770. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnContent,300,120,function(){
  771. _self.app.createShade();
  772. _self.actions.deleteBaseWork(id, function(json){
  773. if(json.type && json.type=="success"){
  774. this.app.notice(_self.view.explorer.lp.prompt.deleteBaseWork, "success");
  775. _self.view.explorer.reloadTableContent();
  776. _self.app.destroyShade();
  777. }
  778. }.bind(_self),function(xhr,text,error){
  779. _self.view.explorer.showErrorMessage(xhr,text,error);
  780. _self.app.destroyShade();
  781. }.bind(_self));
  782. this.close()
  783. },function(){
  784. this.close();
  785. })
  786. },
  787. action_archive:function(id,e){
  788. var _self = this;
  789. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnArchiveContent,300,120,function(){
  790. _self.app.createShade();
  791. _self.actions.archiveBaseWork(id, function(json){
  792. if(json.type && json.type=="success"){
  793. this.app.notice(_self.view.explorer.lp.prompt.archiveBaseWork, "success");
  794. _self.view.explorer.reloadTableContent();
  795. _self.app.destroyShade();
  796. }
  797. }.bind(_self),function(xhr,text,error){
  798. _self.view.explorer.showErrorMessage(xhr,text,error);
  799. _self.app.destroyShade();
  800. }.bind(_self));
  801. this.close();
  802. },function(){
  803. this.close();
  804. })
  805. }
  806. });
  807. MWF.xApplication.Execution.WorkDeploy.MyWorkView = new Class({
  808. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  809. _createDocument: function(data){
  810. return new MWF.xApplication.Execution.WorkDeploy.MyWorkDocument(this.viewNode, data, this.explorer, this);
  811. },
  812. _getCurrentPageData: function(callback, count){
  813. if(this.explorer.centerWorkId){
  814. this.actions.getMyRelativeWork( this.explorer.centerWorkId, function(json){
  815. if(json.data.length==0){
  816. this.explorer.myWorkContentArea.destroy();
  817. }
  818. if (callback) callback(json)
  819. }.bind(this),null,false);
  820. }
  821. },
  822. _openDocument: function( documentData ){
  823. this.workForm = new MWF.xApplication.Execution.WorkForm(this, this.actions, documentData, {
  824. "isNew": false,
  825. "isEdited": false
  826. });
  827. this.workForm.load();
  828. },
  829. _queryCreateViewNode: function(){
  830. },
  831. _postCreateViewNode: function( viewNode ){
  832. },
  833. _queryCreateViewHead:function(){
  834. },
  835. _postCreateViewHead: function( headNode ){
  836. }
  837. });
  838. MWF.xApplication.Execution.WorkDeploy.MyWorkDocument = new Class({
  839. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  840. viewActionReturn:function(d) {
  841. var ret = false;
  842. if(d.operation && d.operation.length==1){
  843. ret = true;
  844. }
  845. return ret;
  846. },
  847. splitActionReturn:function(d) {
  848. var ret = false;
  849. if (d.operation && d.operation.indexOf("SPLIT")>-1)ret = true;
  850. return ret;
  851. },
  852. authorizeActionReturn:function(d) {
  853. var ret = false;
  854. if (d.operation && d.operation.indexOf("AUTHORIZE")>-1)ret = true;
  855. return ret;
  856. },
  857. tackBackActionReturn:function(d){
  858. var ret = false;
  859. if (d.operation && d.operation.indexOf("TACKBACK")>-1)ret = true;
  860. return ret;
  861. },
  862. archiveActionReturn:function(d){
  863. var ret = false;
  864. if (d.operation && d.operation.indexOf("ARCHIVE")>-1)ret = true;
  865. return ret
  866. },
  867. action_view:function(){
  868. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  869. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,this.data,{
  870. "isNew": false,
  871. "isEdited": false
  872. });
  873. workform.load();
  874. }.bind(this));
  875. },
  876. action_split:function(){
  877. MWF.xDesktop.requireApp("Execution", "WorkForm", function(){
  878. var data = {
  879. title : this.data.title,
  880. centerId : this.data.centerId,
  881. centerWorkTitle: this.data.centerTitle,
  882. parentWorkId : this.data.id,
  883. //parentWorkTitle : this.data.title,
  884. workType : this.data.workType,
  885. workLevel : this.data.workLevel,
  886. completeDateLimitStr : this.data.completeDateLimitStr,
  887. completeDateLimit : this.data.completeDateLimit,
  888. reportCycle: this.data.reportCycle,
  889. reportDayInCycle: this.data.reportDayInCycle
  890. };
  891. if(this.data.id){
  892. this.actions.getBaseWorkDetails(this.data.id, function (json) {
  893. data.workSplitAndDescription = json.data.workDetail;
  894. //data.specificActionInitiatives = json.data.progressAction
  895. //data.cityCompanyDuty = json.data.dutyDescription
  896. //data.milestoneMark = json.data.landmarkDescription
  897. //data.importantMatters = json.data.majorIssuesDescription
  898. }.bind(this),null,false)
  899. }
  900. var workform = new MWF.xApplication.Execution.WorkForm(this, this.app.restActions,{"centerWorkTitle":this.data.centerTitle},{
  901. "isNew": true,
  902. "isEdited": false,
  903. "parentWorkId":this.data.id,
  904. "actionStatus":"save",
  905. "onPostSave" : function(){
  906. this.explorer.reloadTableContent()
  907. }.bind(this)
  908. });
  909. workform.load();
  910. }.bind(this));
  911. },
  912. action_authorize:function(){
  913. var data = {
  914. workId : this.data.id
  915. };
  916. var appointForm = new MWF.xApplication.Execution.WorkDeploy.Appoint(this.view.app,this.view.app.restActions,data,this.view.css,{
  917. "ieEdited": true,
  918. "onReloadView" : function( data ){
  919. this.explorer.reloadTableContent()
  920. }.bind(this)
  921. });
  922. appointForm.load();
  923. },
  924. action_tackBack: function(e){
  925. var _self = this;
  926. _self.app.confirm("warn",e,_self.lp.submitWarn.warnTitle,_self.lp.submitWarn.warnTackBackContent,300,120,function(){
  927. _self.actions.unAppointBaseWork({workId:_self.data.id}, function(json){
  928. if(json.type && json.type=="success"){
  929. _self.app.notice(_self.explorer.lp.prompt.tackbackBaseWork, "success");
  930. _self.explorer.reloadTableContent();
  931. }
  932. }.bind(_self),function(xhr,text,error){
  933. _self.explorer.showErrorMessage(xhr,text,error)
  934. }.bind(_self));
  935. this.close()
  936. },function(){
  937. this.close();
  938. })
  939. },
  940. action_archive:function(e){
  941. var _self = this;
  942. _self.view.app.confirm("warn",e,_self.view.app.lp.WorkDeploy.submitWarn.warnTitle,_self.view.app.lp.WorkDeploy.submitWarn.warnArchiveContent,300,120,function(){
  943. _self.app.createShade();
  944. _self.actions.archiveBaseWork(_self.data.id, function(json){
  945. if(json.type && json.type=="success"){
  946. this.app.notice(_self.view.explorer.lp.prompt.archiveBaseWork, "success");
  947. _self.view.explorer.reloadTableContent();
  948. _self.app.destroyShade();
  949. }
  950. }.bind(_self),function(xhr,text,error){
  951. _self.view.explorer.showErrorMessage(xhr,text,error);
  952. _self.app.destroyShade();
  953. }.bind(_self));
  954. this.close();
  955. },function(){
  956. this.close();
  957. })
  958. },
  959. _queryCreateDocumentNode:function( itemData ){
  960. },
  961. _postCreateDocumentNode: function( itemNode, itemData ){
  962. if(itemNode.getElements("div[item='workDetail']").length>0){
  963. if(itemData.hasSubWorks){
  964. itemNode.getElements("div[item='workDetail']").setStyle("color","#ec6a1a");
  965. }
  966. //this.view.actions.getBaseWorksByParentId(itemData.id,function(json){
  967. // if(json.data && json.data.length>0){
  968. // itemNode.getElements("div[item='title']").setStyle("color","#ec6a1a");
  969. // //itemNode.getElements("div[item='title']").set("title",this.view.lp.splitReady);
  970. // }
  971. //}.bind(this))
  972. }
  973. if(itemNode.getElements("div[name='appointDiv']")){
  974. if(itemData.workProcessIdentity && itemData.workProcessIdentity.indexOf("AUTHORIZE")>-1){
  975. itemNode.getElements("div[name='appointDiv']").setStyle("display","")
  976. }
  977. }
  978. if(itemNode.getElements("div[styles='documentSubject']")){
  979. itemNode.getElements("div[styles='documentSubject']").set("title",itemData.workDetail)
  980. }
  981. }
  982. });
  983. MWF.xApplication.Execution.WorkDeploy.Appoint = new Class({
  984. Extends: MPopupForm,
  985. Implements: [Options, Events],
  986. options: {
  987. "style": "default",
  988. "width": "500",
  989. "height": "300",
  990. "hasTop": true,
  991. "hasIcon": false,
  992. "hasBottom": true,
  993. "title": "",
  994. "draggable": false,
  995. "closeAction": true,
  996. "closeText" : "",
  997. "needLogout" : false,
  998. "isNew": true
  999. },
  1000. initialize: function (app, actions, data, css, options) {
  1001. this.setOptions(options);
  1002. this.app = app;
  1003. this.actions = this.app.restActions;
  1004. this.css = css;
  1005. //this.options.title = this.app.lp.idenitySelectTitle;
  1006. //
  1007. //this.identities = identities;
  1008. this.data = data || {};
  1009. this.actions = actions;
  1010. },
  1011. load: function () {
  1012. this.create();
  1013. },
  1014. createTopNode: function () {
  1015. if (!this.formTopNode) {
  1016. this.formTopNode = new Element("div.formTopNode", {
  1017. "styles": this.css.formTopNode
  1018. }).inject(this.formNode);
  1019. this.formTopIconNode = new Element("div.formTopIconNode", {
  1020. "styles": this.css.formTopIconNode
  1021. }).inject(this.formTopNode);
  1022. this.formTopTextNode = new Element("div.formTopTextNode", {
  1023. "styles": this.css.formTopTextNode,
  1024. "text": this.app.lp.workTask.appoint.appointTitle
  1025. }).inject(this.formTopNode);
  1026. if (this.options.closeAction) {
  1027. this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  1028. this.formTopCloseActionNode.addEvent("click", function () {
  1029. this.close()
  1030. }.bind(this))
  1031. }
  1032. this.formTopContentNode = new Element("div.formTopContentNode", {
  1033. "styles": this.css.formTopContentNode
  1034. }).inject(this.formTopNode);
  1035. //this._createTopContent();
  1036. }
  1037. },
  1038. _createTableContent: function () {
  1039. var table = new Element("table",{"width":"100%",border:"0",cellpadding:"5",cellspacing:"0"}).inject(this.formTableArea);
  1040. table.setStyles({"margin-top":"40px"});
  1041. var tr = new Element("tr").inject(table);
  1042. var td = new Element("td",{
  1043. text : this.app.lp.workTask.appoint.appointFor,
  1044. valign:"middle",
  1045. width:"20%"
  1046. }).inject(tr);
  1047. td = new Element("td",{width:"80%"}).inject(tr);
  1048. this.appointPerson = new MDomItem( td, {
  1049. "name" : "appointPerson", "type":"org","orgType":"identity","notEmpty":true,
  1050. "style":{"width":"90%","height":"25px","border":"1px solid #666"}
  1051. }, true, this.app );
  1052. this.appointPerson.load();
  1053. //})
  1054. tr = new Element("tr").inject(table);
  1055. td = new Element("td",{
  1056. "text" : this.app.lp.workTask.appoint.appointOpinion,
  1057. valign:"middle"
  1058. }).inject(tr);
  1059. td = new Element("td").inject(tr);
  1060. this.appointOpinion = new Element("textarea").inject(td);
  1061. this.appointOpinion.setStyles({"width":"90%","height":"50px"})
  1062. },
  1063. _createBottomContent: function () {
  1064. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1065. "styles": this.css.formCancelActionNode,
  1066. "text": this.app.lp.workTask.appoint.appointCancel
  1067. }).inject(this.formBottomNode);
  1068. this.cancelActionNode.addEvent("click", function (e) {
  1069. this.close();
  1070. }.bind(this));
  1071. this.okActionNode = new Element("div.formOkActionNode", {
  1072. "styles": this.css.formOkActionNode,
  1073. "text": this.app.lp.workTask.appoint.appointOK
  1074. }).inject(this.formBottomNode);
  1075. this.okActionNode.addEvent("click", function (e) {
  1076. this.ok(e);
  1077. }.bind(this));
  1078. },
  1079. ok:function(){
  1080. if(this.appointPerson.getValue()==""){
  1081. this.app.notice(this.app.lp.workTask.appoint.personEmpty,"error");
  1082. return false;
  1083. }
  1084. if(this.appointOpinion.get("value")==""){
  1085. this.app.notice(this.app.lp.workTask.appoint.opinionEmpty,"error");
  1086. return false;
  1087. }
  1088. var submitData = {
  1089. workId : this.data.workId,
  1090. //undertakerIdentity : this.appointPerson.get("value"),
  1091. undertakerIdentity : this.appointPerson.getValue(","),
  1092. authorizeOpinion : this.appointOpinion.get("value")
  1093. };
  1094. this.actions.appointBaseWork(submitData,function(json){
  1095. this.app.notice(this.app.lp.WorkDeploy.prompt.authorizeBaseWork,"success");
  1096. this.close();
  1097. this.fireEvent("reloadView");
  1098. }.bind(this),function(xhr,text,error){
  1099. var errorText = error;
  1100. if (xhr) errorMessage = xhr.responseText;
  1101. var e = JSON.parse(errorMessage);
  1102. if(e.message){
  1103. this.app.notice( e.message,"error");
  1104. }else{
  1105. this.app.notice( errorText,"error");
  1106. }
  1107. }.bind(this),false)
  1108. },
  1109. selectPerson: function( item, type,count ) {
  1110. MWF.xDesktop.requireApp("Selector", "package", null, false);
  1111. this.fireEvent("querySelect", this);
  1112. var value = item.get("value").split(this.valSeparator);
  1113. var options = {
  1114. "type": type,
  1115. "title": this.app.lp.workTask.appoint.appointTitle,
  1116. "count": count,
  1117. "values": value || [],
  1118. "onComplete": function (items) {
  1119. var arr = [];
  1120. items.each(function (item) {
  1121. arr.push(item.data.distinguishedName);
  1122. }.bind(this));
  1123. item.set("value", arr.join(","));
  1124. }.bind(this)
  1125. };
  1126. var selector = new MWF.O2Selector(this.app.content, options);
  1127. }
  1128. });