PublicseasEdit.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. MWF.xApplication.CRM.AddressExplorer={};
  2. MWF.xApplication.CRM.PublicseasEdit = new Class({
  3. Extends: MWF.xApplication.CRM.Template.PopupForm,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "width": "800",
  8. "height": "100%",
  9. "top" : 0,
  10. "left" : 0,
  11. "hasTop": true,
  12. "hasIcon": false,
  13. "hasBottom": true,
  14. "title": "",
  15. "draggable": false,
  16. "closeAction": true
  17. },
  18. initialize: function (explorer, actions, data, options) {
  19. this.setOptions(options);
  20. this.explorer = explorer;
  21. this.app = explorer.app;
  22. this.lp = this.app.lp.publicseas.publicseasEdit;
  23. this.path = "../x_component_CRM/$PublicseasEdit/";
  24. this.cssPath = this.path + this.options.style + "/css.wcss";
  25. this._loadCss();
  26. this.options.title = this.lp.title;
  27. this.data = data || {};
  28. this.actions = actions;
  29. },
  30. load: function () {
  31. this.loadResource(function(){
  32. this.appArea = jQuery("body").children(":first");
  33. this.createForm();
  34. debugger
  35. }.bind(this))
  36. },
  37. loadResource: function ( callback ) {
  38. if(callback)callback();
  39. /*var baseUrls = [
  40. "../x_component_CRM/$Template/assets/js/jquery.min.js",
  41. ];
  42. var fullcalendarUrl = "../x_component_CRM/$Template/assets/js/notifyme.js";
  43. var confirmUrl = "../x_component_CRM/$Template/assets/js/showBo.js";
  44. //var confirmUrl = "../x_component_CRM/$Main/laydate/laydate.js";
  45. COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/assets/css/notifyme.css",function(){
  46. COMMON.AjaxModule.load(baseUrls, function(){
  47. jQuery.noConflict();
  48. COMMON.AjaxModule.load(fullcalendarUrl, function(){
  49. COMMON.AjaxModule.load(confirmUrl, function(){
  50. if(callback)callback();
  51. }.bind(this))
  52. }.bind(this));
  53. }.bind(this))
  54. }.bind(this));
  55. COMMON.AjaxModule.loadCss("../x_component_CRM/$Template/date/css/jquery-ui.css",function(){
  56. COMMON.AjaxModule.load(baseUrls, function(){
  57. jQuery.noConflict();
  58. COMMON.AjaxModule.load("../x_component_CRM/$Template/date/jquery-ym-datePlugin-0.1.js", function(){
  59. //if(callback)callback();
  60. /!* COMMON.AjaxModule.load("../x_component_CRM/$Template/date/js/datepicker.all.js", function(){
  61. if(callback)callback();
  62. }.bind(this))*!/
  63. }.bind(this));
  64. }.bind(this))
  65. }.bind(this));*/
  66. },
  67. createForm:function(){
  68. debugger
  69. _self = this;
  70. jQuery(_self.appArea).next().attr("style","");
  71. jQuery(_self.appArea).next().attr("class","mask");
  72. var section_header = '<div class="section-header"><div class="section-mark" style="border-left-color: rgb(70, 205, 207);"></div> '+
  73. '<div data-v-ec8f8850="" class="section-title">基本信息</div></div>';
  74. var itemTemplateObject = _self.getItemTemplate(_self.lp );
  75. var section_conent = '<div class="section-conent">';
  76. debugger
  77. for ( i in itemTemplateObject){
  78. var stype = itemTemplateObject[i].type;
  79. var innerHtml = '<input type="text" class="inline-input" name="'+i+'" id="'+i+'" stype="'+stype+'">';
  80. if(stype=="textarea"){
  81. innerHtml = '<textarea rows="6" class="el-textarea__inner" id="'+i+'" stype="'+stype+'" style="resize: none; min-height: 30.6px;"></textarea>';
  82. }
  83. if(stype=="select" || stype=="hide"){
  84. innerHtml = '<div class="inline-input" style="display: inline-block;cursor:pointer;" id="'+i+'" stype="'+stype+'" ></div><div class="el-icon-arrow-down el-icon--right" style="margin-left: -20px; display: inline-block;"><img src="../x_component_CRM/$Clue/default/icons/arrow.png"></div>';
  85. }
  86. if(stype=="map"){
  87. innerHtml = '<div class="setMap" id="setMap"' +' stype="'+stype+'"></div>';
  88. }
  89. section_conent = section_conent+'<div class="conent-inline"><div class="conent-title" lable="'+i+'">'+itemTemplateObject[i].text+'</div>' +
  90. '<div class="conent-value">'+innerHtml+'</div></div>';
  91. }
  92. section_conent = section_conent + '</div>';
  93. var section_button = '<div class="section_button"><div><button class="el-button handle-button el-button-cancle"><span>取消</span></button>'+
  94. '<button class="el-button handle-button el-button-primary"><span>保存</span></button></div></div>';
  95. var htmlstr = section_header+section_conent+section_button;
  96. jQuery(".headMoreImg").notifyMe(
  97. 'left',
  98. 'default',
  99. _self.options.title,
  100. '',
  101. '',
  102. htmlstr,
  103. 'notifyEdit',
  104. 50
  105. );
  106. jQuery(".conent-value").each(function(index,element){
  107. var cobj = jQuery(element).children().eq(0)
  108. var stype = jQuery(cobj).attr("stype");
  109. if(stype=="datetime"){
  110. _self.loadTimeContainer(jQuery(cobj).attr("id"));
  111. }
  112. if(stype=="select" || stype=="hide"){
  113. var selectObjects = _self.app.lp.publicseas;
  114. for ( j in selectObjects){
  115. if(j==jQuery(cobj).attr("id")){
  116. var clp = itemTemplateObject[j];
  117. var valueList = clp.value;
  118. var valueArr = valueList.split(",");
  119. if(valueArr.length>0){
  120. var selectHtml = '<ul class="el-dropdown-type" style="display: none;" tid="'+jQuery(cobj).attr("id")+'">'
  121. for(var n=0;n<valueArr.length;n++){
  122. selectHtml = selectHtml+'<li class="el-dropdown-menu__item">'+valueArr[n]+'</li>'
  123. }
  124. jQuery(".notify-content").append(selectHtml+'<div class="popper__arrow"></div></ul>');
  125. jQuery(cobj).click(function(){
  126. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").css({"left":jQuery(cobj).offset().left-50,"top":jQuery(cobj).offset().top+30,"width":282})
  127. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  128. });
  129. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").children().click(function(){
  130. debugger
  131. jQuery(cobj).text(jQuery(this).text());
  132. jQuery("[tid='"+jQuery(cobj).attr("id")+"']").toggle(100);
  133. });
  134. }
  135. }
  136. }
  137. }
  138. if(stype=="map"){
  139. _self.loadMap();
  140. }
  141. }
  142. );
  143. jQuery('.el-button-cancle').click(function(){
  144. setTimeout(function(){
  145. jQuery("#notifyEdit").remove();
  146. if(jQuery(".mask").length>0){
  147. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  148. jQuery(".mask").attr("class","");
  149. }
  150. },200);
  151. });
  152. jQuery('.el-button-primary').click(function(){
  153. var filter = {};
  154. filter = {
  155. customername:jQuery('div[lable="customername"]').next().children().eq(0).val(),
  156. level:jQuery('div[lable="level"]').next().children().eq(0).text(),
  157. industry:jQuery('div[lable="industry"]').next().children().eq(0).text(),
  158. source:jQuery('div[lable="source"]').next().children().eq(0).text(),
  159. dealstatus:jQuery('div[lable="dealstatus"]').next().children().eq(0).text(),
  160. telephone:jQuery('div[lable="telephone"]').next().children().eq(0).val(),
  161. cellphone:jQuery('div[lable="cellphone"]').next().children().eq(0).val(),
  162. website:jQuery('div[lable="website"]').next().children().eq(0).val(),
  163. location:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("location"),
  164. detailaddress:jQuery('div[lable="detailaddress"]').next().children().eq(0).val(),
  165. lng:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lng"),
  166. lat:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("lat"),
  167. province:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("province"),
  168. city:jQuery('div[lable="detailaddress"]').next().children().eq(0).attr("city"),
  169. nexttime:jQuery('div[lable="nexttime"]').next().children().eq(0).val(),
  170. remark:jQuery('div[lable="remark"]').next().children().eq(0).val(),
  171. };
  172. debugger
  173. _self.actions.saveCustomer( filter, function (json) {
  174. debugger
  175. if(json.type=="success"){
  176. Showbo.Msg.alert('保存成功!');
  177. }
  178. setTimeout(function(){
  179. jQuery("#notifyEdit").remove();
  180. if(jQuery(".mask").length>0){
  181. jQuery(".mask").attr("style",'left: 0px; top: 0px; width: 100%; overflow: hidden; position: absolute; z-index: 500000; background-color: rgb(255, 255, 255)');
  182. jQuery(".mask").attr("class","");
  183. }
  184. },200);
  185. }.bind(_self));
  186. });
  187. },
  188. loadTimeContainer: function(stime){
  189. jQuery("#"+stime).ymdateplugin({
  190. showTimePanel: true
  191. });
  192. },
  193. loadMap: function(){
  194. _self = this;
  195. this.mapDiv = jQuery("#setMap")[0];
  196. jQuery(".section-conent").css("height","700px");
  197. if(this.mapDiv)this.mapDiv.empty();
  198. if(this.addressModule) delete this.addressModule;
  199. MWF.xDesktop.requireApp("CRM", "AddressExplorer", function(){
  200. this.addressModule = new MWF.xApplication.CRM.AddressExplorer(this.mapDiv,this,this.actions,{});
  201. this.addressModule.load();
  202. }.bind(this))
  203. },
  204. getItemTemplate: function( lp ){
  205. _self = this;
  206. return {
  207. Publicseasname: {
  208. text: lp.publicseasname,
  209. type: "text",
  210. //attr : {placeholder:lp.name},
  211. notEmpty:true,
  212. value:this.publicseasData && this.publicseasData.customername?this.publicseasData.customername:""
  213. },
  214. level:{
  215. type: "select",
  216. text: lp.level,
  217. value:this.app.lp.customer.level.value
  218. },
  219. industry: {
  220. type: "select",
  221. text: lp.industry,
  222. value:this.app.lp.customer.industry.value
  223. },
  224. source: {
  225. type: "select",
  226. text: lp.source,
  227. value:this.app.lp.customer.source.value
  228. },
  229. /*dealstatus:{
  230. type: "hide",
  231. text: lp.dealstatus,
  232. value:this.app.lp.customer.dealstatus.value
  233. },*/
  234. telephone:{
  235. type: "text",
  236. text: lp.telephone,
  237. value:this.app.lp.clue.level.value
  238. },
  239. website: {
  240. text:lp.website,
  241. type: "text"
  242. },
  243. nexttime: {
  244. text:lp.nexttime,
  245. attr : {id:"nexttime"},
  246. type: "datetime"
  247. },
  248. cellphone: {
  249. text:lp.cellphone,
  250. type: "text"
  251. },
  252. detailaddress: {
  253. text:lp.detailaddress,
  254. type: "text"
  255. },
  256. remark: {
  257. text:lp.remark,
  258. type: "textarea"
  259. },
  260. location: {
  261. text:lp.location,
  262. type: "map"
  263. }
  264. }
  265. }
  266. });