ViewExplorer.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "Explorer", null, false);
  2. MWF.xApplication.cms.ColumnManager.ViewExplorer = new Class({
  3. Extends: MWF.xApplication.cms.ColumnManager.Explorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "style" : "default",
  7. "create": MWF.CMSCM.LP.view.create,
  8. "search": MWF.CMSCM.LP.view.search,
  9. "searchText": MWF.CMSCM.LP.view.searchText,
  10. "noElement": MWF.CMSCM.LP.view.noViewNoticeText
  11. },
  12. //_createElement: function(e){
  13. // var _self = this;
  14. // var options = {
  15. // "onQueryLoad": function(){
  16. // this.actions = _self.app.restActions;
  17. // this.application = _self.app.options.column;
  18. // this.column = _self.app.options.column;
  19. // }
  20. // };
  21. // this.app.desktop.openApplication(e, "cms.ViewDesigner", options);
  22. //},
  23. createCreateElementNode: function(){
  24. // this.createElementNode = new Element("div", {
  25. // "styles": this.css.createElementNode,
  26. // "title": this.options.tooltip.create
  27. // }).inject(this.toolbarNode);
  28. // this.createElementNode.addEvents({
  29. // "click": function(e){ this._createElement(e); }.bind(this),
  30. // "mouseover" : function(e){
  31. // this.createElementNode.setStyles(this.css.createElementNode_over);
  32. // }.bind(this),
  33. // "mouseout" : function(ev){
  34. // this.createElementNode.setStyles(this.css.createElementNode);
  35. // }.bind(this)
  36. // });
  37. },
  38. _createElement: function(e){
  39. var _self = this;
  40. var createView = function(e, form){
  41. layout.desktop.getFormDesignerStyle(function(){
  42. var options = {
  43. "style": layout.desktop.formDesignerStyle,
  44. "onQueryLoad": function(){
  45. this.actions = _self.app.restActions;
  46. this.column = _self.app.options.column;
  47. this.application = _self.app.options.column;
  48. this.relativeForm = form;
  49. },
  50. "onPostSave" : function(){
  51. _self.reload();
  52. }
  53. };
  54. layout.desktop.openApplication(e, "cms.ViewDesigner", options);
  55. }.bind(this));
  56. };
  57. this.loadSelectFormDialog( createView );
  58. },
  59. loadSelectFormDialog : function(callback, title, appId){
  60. var _self = this;
  61. var selectFormMaskNode = new Element("div", {"styles": this.css.selectFormMaskNode}).inject(this.app.content);
  62. var selectFormAreaNode = new Element("div", {"styles": this.css.selectFormTemplateAreaNode}).inject(this.app.content);
  63. selectFormAreaNode.fade("in");
  64. var selectFormTitleNode = new Element("div",{
  65. "styles":this.css.createTemplateFormTitleNode,
  66. "text":title || this.app.lp.view.selectRelativeForm
  67. }).inject(selectFormAreaNode);
  68. var selectFormScrollNode = new Element("div", {"styles": this.css.selectFormScrollNode}).inject(selectFormAreaNode);
  69. var selectFormContentNode = new Element("div", {"styles": this.css.selectFormContentNode}).inject(selectFormScrollNode);
  70. MWF.require("MWF.widget.ScrollBar", function(){
  71. new MWF.widget.ScrollBar(selectFormScrollNode, {"indent": false});
  72. }.bind(this));
  73. var _self = this;
  74. this.app.restActions.listForm( appId || this.app.options.column.id, function(json){
  75. json.data.each(function(form){
  76. var formNode = new Element("div", {
  77. "styles": this.css.formNode
  78. }).inject(selectFormContentNode);
  79. var x = "process_icon_" + (Math.random()*33).toInt() + ".png";
  80. var iconUrl = this.path+this.options.style+"/processIcon/"+x;
  81. var formIconNode = new Element("div", {
  82. "styles": this.css.formIconNode
  83. }).inject(formNode);
  84. formIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  85. new Element("div", {
  86. "styles": this.css.formTitleNode,
  87. "text": form.name
  88. }).inject(formNode);
  89. new Element("div", {
  90. "styles": this.css.formDescriptionNode,
  91. "text": form.description || "",
  92. "title": form.description || ""
  93. }).inject(formNode);
  94. new Element("div", {
  95. "styles": this.css.formDateNode,
  96. "text": (form.updateTime || "")
  97. }).inject(formNode);
  98. formNode.store("form", {"name":form.name, "id":form.id});
  99. formNode.addEvents({
  100. "mouseover": function(){this.setStyles(_self.css.formNode_over)},
  101. "mouseout": function(){this.setStyles(_self.css.formNode)},
  102. "mousedown": function(){this.setStyles(_self.css.formNode_down)},
  103. "mouseup": function(){this.setStyles(_self.css.formNode_over)},
  104. "click": function(e){
  105. //createView(e, this.retrieve("form"));
  106. if(callback)callback(e, this.retrieve("form"));
  107. selectFormAreaNode.destroy();
  108. selectFormMaskNode.destroy();
  109. }
  110. });
  111. }.bind(this));
  112. var size = this.app.content.getSize();
  113. var nodeSize = selectFormAreaNode.getSize();
  114. var y = (size.y - nodeSize.y)/2;
  115. var x = (size.x - nodeSize.x)/2;
  116. if (y<0) y=0;
  117. if (x<0) x=0;
  118. selectFormAreaNode.setStyles({
  119. "top": ""+y+"px",
  120. "left": ""+x+"px"
  121. });
  122. }.bind(this));
  123. selectFormMaskNode.addEvent("click", function(){
  124. selectFormAreaNode.destroy();
  125. selectFormMaskNode.destroy();
  126. });
  127. },
  128. _loadItemDataList: function(callback){
  129. this.actions.listView(this.app.options.column.id,callback);
  130. },
  131. _getItemObject: function(item, index){
  132. return new MWF.xApplication.cms.ColumnManager.ViewExplorer.View(this, item, {index:index})
  133. },
  134. setTooltip: function(){
  135. this.options.tooltip = {
  136. "create": MWF.CMSCM.LP.view.create,
  137. "search": MWF.CMSCM.LP.view.search,
  138. "searchText": MWF.CMSCM.LP.view.searchText,
  139. "noElement": MWF.CMSCM.LP.view.noViewNoticeText
  140. };
  141. },
  142. loadElementList: function(){
  143. this._loadItemDataList(function(json){
  144. json.data = json.data || [];
  145. if (json.data.length){
  146. json.data.each(function(item){
  147. var itemObj = this._getItemObject(item, this.itemArray.length+1);
  148. itemObj.load();
  149. this.itemObject[ item.id ] = itemObj;
  150. this.itemArray.push( itemObj );
  151. }.bind(this));
  152. }else{
  153. var noElementNode = new Element("div", {
  154. "styles": this.css.noElementNode,
  155. "text": (this.options.noCreate) ? MWF.CMSCM.LP.view.noViewNoCreateNoticeText : this.options.tooltip.noElement
  156. }).inject(this.elementContentListNode);
  157. // if (!this.options.noCreate){
  158. // noElementNode.addEvent("click", function(e){
  159. // this._createElement(e);
  160. // }.bind(this));
  161. // }
  162. }
  163. }.bind(this));
  164. },
  165. deleteItems: function(){
  166. while (this.deleteMarkItems.length){
  167. var item = this.deleteMarkItems.shift();
  168. if (this.deleteMarkItems.length){
  169. item.deleteView();
  170. }else{
  171. item.deleteView(function(){
  172. // this.reloadItems();
  173. this.hideDeleteAction();
  174. this.reload();
  175. }.bind(this));
  176. }
  177. }
  178. },
  179. keyCopy: function(e){
  180. if (this.selectMarkItems.length){
  181. var items = [];
  182. var i = 0;
  183. var checkItems = function(e){
  184. if (i>=this.selectMarkItems.length){
  185. if (items.length){
  186. var str = JSON.encode(items);
  187. if (e){
  188. e.clipboardData.setData('text/plain', str);
  189. }else {
  190. window.clipboardData.setData("Text", str);
  191. }
  192. this.app.notice(this.app.lp.copyed, "success");
  193. }
  194. }
  195. }.bind(this);
  196. this.selectMarkItems.each(function(item){
  197. this.app.restActions.getView(item.data.id, function(json){
  198. json.data.elementType = "view";
  199. items.push(json.data);
  200. i++;
  201. checkItems(e);
  202. }.bind(this), null, false)
  203. }.bind(this));
  204. }
  205. },
  206. keyPaste: function(e){
  207. var dataStr = "";
  208. if (e){
  209. dataStr = e.clipboardData.getData('text/plain');
  210. }else{
  211. dataStr = window.clipboardData.getData("Text");
  212. }
  213. var data = JSON.decode(dataStr);
  214. this.loadSelectFormDialog( function( e, form ){
  215. this.pasteItem(data, 0, form);
  216. }.bind(this), MWF.CMSCM.LP.view.selectRelativeFormNoticeText ); //"请选择需粘贴视图的关联表单"
  217. },
  218. pasteItem: function(data, i, form){
  219. if (i<data.length){
  220. var item = data[i];
  221. if (item.elementType==="view"){
  222. this.saveItemAs(item, function(){
  223. i++;
  224. this.pasteItem(data, i, form);
  225. }.bind(this), function(){
  226. i++;
  227. this.pasteItem(data, i, form);
  228. }.bind(this), function(){
  229. this.reload();
  230. }.bind(this), form );
  231. }else{
  232. i++;
  233. this.pasteItem(data, i, form);
  234. }
  235. }else{
  236. this.reload();
  237. }
  238. },
  239. saveItemAs: function(data, success, failure, cancel, form){
  240. this.app.restActions.listView(this.app.options.application.id, function(dJson){
  241. dJson.data = dJson.data || [];
  242. var i=1;
  243. var someItems = dJson.data.filter(function(d){ return d.id===data.id });
  244. if (someItems.length){
  245. var someItem = someItems[0];
  246. var lp = this.app.lp;
  247. var _self = this;
  248. var d1 = new Date().parse(data.updateTime);
  249. var d2 = new Date().parse(someItem.updateTime);
  250. var html = "<div>"+lp.copyConfirmInfor+"</div>";
  251. html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='font-weight: bold; font-size:14px;'>"+lp.copySource+" "+someItem.name+"</div>";
  252. html += "<div style='font-size:12px; color: #666666; float: left'>"+someItem.updateTime+"</div>" +
  253. "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'></div>" +
  254. "<div style='color: red; float: right;'>"+((d1>=d2) ? "": lp.copynew)+"</div></div>";
  255. html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.name+"</div>";
  256. html += "<div style='font-size:12px; color: #666666; float: left;'>"+data.updateTime+"</div>" +
  257. "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'></div>" +
  258. "<div style='color: red; float: right;'>"+((d1<=d2) ? "": lp.copynew)+"</div></div>";
  259. // html += "<>"
  260. this.app.dlg("inofr", null, this.app.lp.copyConfirmTitle, {"html": html}, 500, 290, [
  261. {
  262. "text": lp.copyConfirm_overwrite,
  263. "action": function(){_self.saveItemAsUpdate(someItem, data, success, failure);this.close();}
  264. },
  265. {
  266. "text": lp.copyConfirm_new,
  267. "action": function(){_self.saveItemAsNew(dJson, data, success, failure);this.close();}
  268. },
  269. {
  270. "text": lp.copyConfirm_skip,
  271. "action": function(){/*nothing*/ this.close(); if (success) success();}
  272. },
  273. {
  274. "text": lp.copyConfirm_cancel,
  275. "action": function(){this.close(); if (cancel) cancel();}
  276. }
  277. ]);
  278. }else{
  279. this.saveItemAsNew(dJson, data, success, failure, form)
  280. }
  281. }.bind(this), function(){if (failure) failure();}.bind(this));
  282. },
  283. saveItemAsUpdate: function(someItem, data, success, failure, form){
  284. data.isNew = false;
  285. data.id = someItem.id;
  286. data.application = someItem.appId || someItem.application;
  287. data.applicationName = someItem.appName || someItem.applicationName;
  288. data.appId = data.application;
  289. data.appName = data.applicationName;
  290. data.name = someItem.name;
  291. data.alias = someItem.alias;
  292. data.formId = form.id;
  293. var content = JSON.parse( data.content );
  294. content.application = data.application;
  295. content.applicationName = data.applicationName;
  296. content.relativeForm = form;
  297. content.id = data.id;
  298. content.name = someItem.name;
  299. content.alias = someItem.alias;
  300. var fields = [];
  301. content.columns.each( function( c ){
  302. c.id = this.app.restActions.getUUID();
  303. c.isNew = false;
  304. var field = {};
  305. field.id = c.id;
  306. field.isNew = true;
  307. field.viewId = data.id;
  308. field.fieldTitle = c.title;
  309. field.fieldName = c.value;
  310. field.xshowSequence = form.id;
  311. fields.push( field )
  312. }.bind(this));
  313. //data.fields.each( function(field){
  314. // var list = content.columns.filter(function(d){ return d.id===field.id });
  315. // field.xshowSequence = form.id;
  316. // field.viewId = data.id;
  317. // field.id = this.app.restActions.getUUID();
  318. // if(list.length > 0 ){
  319. // list[0].id = field.id;
  320. // }
  321. //}.bind(this));
  322. data.content = JSON.stringify( content );
  323. this.app.restActions.saveView(data, function(){
  324. if (success) success();
  325. }.bind(this), function(){
  326. if (failure) failure();
  327. }.bind(this));
  328. },
  329. saveItemAsNew: function(dJson, data, success, failure, form){
  330. var item = this.app.options.application;
  331. var id = item.id;
  332. var name = item.name;
  333. var oldName = data.name;
  334. var i=1;
  335. while (dJson.data.some(function(d){ return d.name==data.name || d.alias==data.name })){
  336. data.name = oldName+"_copy"+i;
  337. data.alias = oldName+"_copy"+i;
  338. i++;
  339. }
  340. data.isNew = true;
  341. data.id = this.app.restActions.getUUID();
  342. data.application = id;
  343. data.applicationName = name;
  344. data.appId = id;
  345. data.appName = name;
  346. data.formId = form.id;
  347. var content = JSON.parse( data.content );
  348. content.application = data.application;
  349. content.applicationName = data.applicationName;
  350. content.relativeForm = form;
  351. content.id = data.id;
  352. content.name = data.name;
  353. content.alias = data.alias;
  354. var fields = [];
  355. content.columns.each( function( c ){
  356. c.id = this.app.restActions.getUUID();
  357. c.isNew = false;
  358. var field = {};
  359. field.id = c.id;
  360. field.isNew = true;
  361. field.viewId = data.id;
  362. field.fieldTitle = c.title;
  363. field.fieldName = c.value;
  364. field.xshowSequence = form.id;
  365. fields.push( field )
  366. }.bind(this));
  367. data.content = JSON.stringify( content );
  368. delete data.createTime;
  369. delete data.updateTime;
  370. delete data.elementType;
  371. this.app.restActions.saveView(data, function(){
  372. if (success) success();
  373. }.bind(this), function(){
  374. if (failure) failure();
  375. }.bind(this));
  376. }
  377. });
  378. MWF.xApplication.cms.ColumnManager.ViewExplorer.View = new Class({
  379. Extends: MWF.xApplication.cms.ColumnManager.Explorer.Item,
  380. load_bak: function(){
  381. if( this.options.index % 2 == 0 ){
  382. this.itemNodeCss = this.explorer.css.itemNode_even
  383. }else{
  384. this.itemNodeCss = this.explorer.css.itemNode
  385. }
  386. this.node = new Element("div", {
  387. "styles": this.itemNodeCss,
  388. "events": {
  389. "click": function(e){this._open(e);e.stopPropagation();}.bind(this),
  390. "mouseover": function(){
  391. this.node.setStyles( this.explorer.css.itemNode_over )
  392. }.bind(this),
  393. "mouseout": function(){
  394. this.node.setStyles( this.itemNodeCss )
  395. }.bind(this)
  396. }
  397. }).inject(this.container,this.options.where);
  398. if (this.data.name.icon) this.icon = this.data.name.icon;
  399. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  400. var itemIconNode = new Element("div", {
  401. "styles": this.explorer.css.itemIconNode
  402. }).inject(this.node);
  403. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  404. //new Element("img", {
  405. // "src": iconUrl, "border": "0"
  406. //}).inject(itemIconNode);
  407. itemIconNode.makeLnk({
  408. "par": this._getLnkPar()
  409. });
  410. this.actionsArea = new Element("div.actionsArea",{
  411. styles : this.explorer.css.actionsArea
  412. }).inject(this.node);
  413. if (!this.explorer.options.noDelete){
  414. this.deleteActionNode = new Element("div.deleteAction", {
  415. "styles": this.explorer.css.deleteAction
  416. }).inject(this.actionsArea);
  417. this.deleteActionNode.addEvent("click", function(e){
  418. this.deleteItem(e);
  419. e.stopPropagation();
  420. }.bind(this));
  421. this.deleteActionNode.addEvents({
  422. "mouseover" : function(ev){
  423. this.deleteActionNode.setStyles( this.explorer.css.deleteAction_over )
  424. }.bind(this),
  425. "mouseout" : function(ev){
  426. this.deleteActionNode.setStyles( this.explorer.css.deleteAction )
  427. }.bind(this)
  428. })
  429. }
  430. var inforNode = new Element("div.itemInforNode", {
  431. "styles": this.explorer.css.itemInforNode
  432. }).inject(this.node);
  433. var inforBaseNode = new Element("div.itemInforBaseNode", {
  434. "styles": this.explorer.css.itemInforBaseNode
  435. }).inject(inforNode);
  436. new Element("div.itemTextTitleNode", {
  437. "styles": this.explorer.css.itemTextTitleNode,
  438. "text": this.data.name,
  439. "title": this.data.name
  440. }).inject(inforBaseNode);
  441. new Element("div.itemTextAliasNode", {
  442. "styles": this.explorer.css.itemTextAliasNode,
  443. "text": this.data.alias,
  444. "title": this.data.alias
  445. }).inject(inforBaseNode);
  446. new Element("div.itemTextDateNode", {
  447. "styles": this.explorer.css.itemTextDateNode,
  448. "text": (this.data.updateTime || "")
  449. }).inject(inforBaseNode);
  450. new Element("div.itemTextDescriptionNode", {
  451. "styles": this.explorer.css.itemTextDescriptionNode,
  452. "text": this.data.description || "",
  453. "title": this.data.description || ""
  454. }).inject(inforBaseNode);
  455. this._customNodes();
  456. //this._isNew();
  457. },
  458. _customNodes: function(){},
  459. _open: function(e){
  460. var _self = this;
  461. var options = {
  462. "appId": "cms.ViewDesigner"+_self.data.id,
  463. "id": _self.data.id,
  464. "application":_self.explorer.app.options.column.id,
  465. "onQueryLoad": function(){
  466. this.actions = _self.explorer.actions;
  467. this.category = _self;
  468. this.options.id = _self.data.id;
  469. this.column = _self.explorer.app.options.column;
  470. this.application = _self.explorer.app.options.column;
  471. this.options.noModifyName = _self.explorer.options.noModifyName;
  472. this.options.readMode = _self.explorer.options.readMode,
  473. this.options.formId = _self.data.formId;
  474. }
  475. };
  476. this.explorer.app.desktop.openApplication(e, "cms.ViewDesigner", options);
  477. },
  478. _getIcon: function(){
  479. var x = (Math.random()*33).toInt();
  480. return "process_icon_"+x+".png";
  481. },
  482. _getLnkPar: function(){
  483. return {
  484. "icon": this.explorer.path+this.explorer.options.style+"/viewIcon/lnk.png",
  485. "title": this.data.name,
  486. "par": "cms.ViewDesigner#{\"id\": \""+this.data.id+"\", \"application\": "+JSON.stringify( this.explorer.app.options.application )+"}"
  487. };
  488. },
  489. // deleteItem: function(e){
  490. // var _self = this;
  491. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  492. // _self.deleteForm();
  493. // this.close();
  494. // },function(){
  495. // this.close();
  496. // });
  497. // },
  498. deleteView: function(callback){
  499. this.explorer.app.restActions.deleteView(this.data.id, function(){
  500. this.node.destroy();
  501. if (callback) callback();
  502. }.bind(this));
  503. },
  504. saveas: function(){
  505. MWF.xDesktop.requireApp("Selector", "package", function(){
  506. var app = this.explorer.app.options.application;
  507. app.name = app.appName;
  508. var selector = new MWF.O2Selector(this.explorer.app.content, {
  509. "title": this.explorer.app.lp.copyto,
  510. "type": "CMSApplication",
  511. "count" : 1,
  512. "values": [app],
  513. "onComplete": function(items){
  514. items.each(function(item){
  515. this.saveItemAs(item.data);
  516. }.bind(this));
  517. }.bind(this)
  518. });
  519. }.bind(this));
  520. },
  521. saveItemAs: function(item){
  522. //var selectForm = function(){
  523. // this.explorer.loadSelectFormDialog( function( e, form ){
  524. // this._saveItemAs(item, form);
  525. // }.bind(this), "请选择需粘贴视图的关联表单", item.id);
  526. //}.bind(this);
  527. //this.explorer.app.restActions.getForm(item.formId, function( json ){
  528. // if( json && json.data && json.data.id ){
  529. // this._saveItemAs(item, form);
  530. // }else{
  531. // selectForm();
  532. // }
  533. //}.bind(this), function(){
  534. // selectForm();
  535. //}.bind(this));
  536. var text = MWF.xApplication.cms.ColumnManager.LP.selectRelateFormNotice;
  537. this.explorer.loadSelectFormDialog( function( e, form ){
  538. this._saveItemAs(item, form);
  539. }.bind(this), text, item.id);
  540. },
  541. _saveItemAs: function(item, form){
  542. this.app = this.app || this.explorer.app;
  543. var id = item.id;
  544. var name = item.name || item.appName;
  545. this.explorer.app.restActions.getView(this.data.id, function(json){
  546. var data = json.data;
  547. var oldName = data.name;
  548. this.explorer.app.restActions.listView(id, function(dJson){
  549. dJson.data = dJson.data || [];
  550. var i=1;
  551. while (dJson.data.some(function(d){ return d.name==data.name || d.alias==data.name })){
  552. data.name = oldName+"_copy"+i;
  553. data.alias = oldName+"_copy"+i;
  554. i++;
  555. }
  556. data.isNew = true;
  557. data.id = this.app.restActions.getUUID();
  558. data.application = id;
  559. data.applicationName = name;
  560. data.appId = id;
  561. data.appName = name;
  562. data.formId = form.id;
  563. var content = JSON.parse( data.content );
  564. content.application = data.application;
  565. content.applicationName = data.applicationName;
  566. content.relativeForm = form;
  567. content.id = data.id;
  568. content.name = data.name;
  569. content.alias = data.alias;
  570. var fields = [];
  571. content.columns.each( function( c ){
  572. c.id = this.app.restActions.getUUID();
  573. c.isNew = false;
  574. var field = {};
  575. field.id = c.id;
  576. field.isNew = true;
  577. field.viewId = data.id;
  578. field.fieldTitle = c.title;
  579. field.fieldName = c.value;
  580. field.xshowSequence = form.id;
  581. fields.push( field )
  582. }.bind(this));
  583. data.content = JSON.stringify( content );
  584. delete data.createTime;
  585. delete data.updateTime;
  586. delete data.elementType;
  587. this.explorer.app.restActions.saveView(data, function(){
  588. if (id == this.explorer.app.options.application.id) this.explorer.reload();
  589. }.bind(this));
  590. }.bind(this));
  591. }.bind(this));
  592. }
  593. });