customervisit.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. //读取cookies
  2. function getCookie(name)
  3. {
  4. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  5. if(arr=document.cookie.match(reg))
  6. return unescape(arr[2]);
  7. else
  8. return null;
  9. }
  10. em_master = em_master || getCookie('master');//为防止从session读取数据失败
  11. //标准时间格式配置
  12. Date.prototype.format =function(format){
  13. var o = {
  14. "M+" : this.getMonth()+1, //month
  15. "d+" : this.getDate(), //day
  16. "h+" : this.getHours(), //hour
  17. "m+" : this.getMinutes(), //minute
  18. "s+" : this.getSeconds(), //second
  19. "q+" : Math.floor((this.getMonth()+3)/3), //quarter
  20. "S" : this.getMilliseconds() //millisecond
  21. }
  22. if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
  23. (this.getFullYear()+"").substr(4- RegExp.$1.length));
  24. for(var k in o)if(new RegExp("("+ k +")").test(format))
  25. format = format.replace(RegExp.$1,
  26. RegExp.$1.length==1? o[k] :
  27. ("00"+ o[k]).substr((""+ o[k]).length));
  28. return format;
  29. };
  30. var vr_id = null;
  31. var vr_class;//表单字段
  32. //根据getIdUrl获取对应的序列值
  33. function getSeqId(getIdUrl) {
  34. var id;
  35. $.ajax({
  36. async: false,
  37. type: 'GET',
  38. url: basePath + getIdUrl,
  39. dataType: 'json',
  40. success: function(data){
  41. id = data.id;
  42. }
  43. });
  44. return id;
  45. };
  46. vr_id = getSeqId('common/getId.action?seq=VISITRECORD_SEQ');
  47. //dbFind
  48. // function addDbFinf(config) {
  49. // $('#dbFindModal .modal-content .modal-title').text(config.title);
  50. // }
  51. $(document).ready(function(){
  52. //重置所有表单
  53. function resetAllForm() {
  54. $('#formStore')[0].reset();
  55. $('#pl')[0].reset();
  56. $('#cup')[0].reset();
  57. $('#pi')[0].reset();
  58. $('#fb')[0].reset();
  59. };
  60. // modal dialog
  61. var dialog = {
  62. show: function(title, content, timeout, callback){
  63. var back = $('.modal-backdrop'), modal = $('#dialog'),
  64. tt = $('.modal-title', modal), tb = $('.modal-body', modal);
  65. back.css('display', 'block');
  66. modal.css('display', 'block');
  67. tt.text(title);
  68. if(timeout && timeout > 0) {
  69. content = '<div><strong class="text-success text-xl" id="timeout">' + timeout + '</strong>&nbsp;秒后,' + content + '</div>';
  70. }
  71. tb.html(content);
  72. if(timeout) {
  73. var pre = 1000;
  74. if(timeout <=0 ) {// auto close
  75. pre = 1500;
  76. if(!callback)
  77. callback = dialog.hide;
  78. }
  79. var timer = function(t) {
  80. setTimeout(function(){
  81. if(t > -1) {
  82. $('#timeout').text(t--);
  83. timer(t);
  84. } else {
  85. callback && callback.call();
  86. }
  87. }, pre);
  88. };
  89. timer(timeout);
  90. }
  91. },
  92. hide: function() {
  93. var back = $('.modal-backdrop'), modal = $('#dialog');
  94. back.css('display', 'none');
  95. modal.css('display', 'none');
  96. }
  97. };
  98. //获取基本信息输入的JSON字符串,在拼接一些必须提交的数据
  99. function getBaseInfo () {
  100. var result = '{';
  101. result += '"vr_status":"在录入"' + ',"vr_recorder":"' + username + '"' + ',"vr_id":"' +
  102. vr_id + '"' + ',"vr_recorddate":"' + (new Date().format('yyyy-MM-dd')) +'","vr_statuscode":"ENTERING",' +
  103. '"vr_class":"' + vr_class + '"';
  104. for(var i=0;i < $('#baseinfo .form-control').length; i ++) {
  105. result += ',"';
  106. result += $($('#baseinfo .form-control').get(i)).attr('name') + '":"' +
  107. $($('#baseinfo .form-control').get(i)).val() + '"';
  108. }
  109. result += '}';
  110. return result;
  111. }
  112. //获取拜访人员输入的JSON字符串
  113. function getVisitPerpeo() {
  114. var result = '[';
  115. var visit_perpeo = $('#visit_perpeo .pl');
  116. for (var i = 0; i < visit_perpeo.length; i++) {
  117. if ($(visit_perpeo.get(i)).find('[name="pl_name"]').val()!='') {
  118. result += '{"pl_detno":' + (i+1) +',"pl_age":"0","pl_id":"0","pl_vrid":"' + vr_id + '",';
  119. result += '"pl_name":"' + $(visit_perpeo.get(i)).find('[name="pl_name"]').val() +
  120. '","pl_position":"' + $(visit_perpeo.get(i)).find('[name="pl_position"]').val()
  121. + '"}';
  122. if (i < visit_perpeo.length-1) {result += ','};
  123. };
  124. };
  125. result += ']';
  126. return result;
  127. }
  128. //获取洽谈对象输入的JSON字符串
  129. function getCustomerPerpeo () {
  130. var result = '[';
  131. var customer_perpeo = $('#customer_perpeo .cup');
  132. for (var i = 0; i < customer_perpeo.length; i++) {
  133. if ($(customer_perpeo.get(i)).find('[name="cup_name"]').val()!='') {
  134. result += '{"cup_detno":' + (i+1) +',"cup_age":"0","cup_id":"0","cup_vrid":"' + vr_id + '",';
  135. result += '"cup_name":"' + $(customer_perpeo.get(i)).find('[name="cup_name"]').val() +
  136. '","cup_position":"' + $(customer_perpeo.get(i)).find('[name="cup_position"]').val() +
  137. '","cup_tel":"' + $(customer_perpeo.get(i)).find('[name="cup_tel"]').val()
  138. + '"}';
  139. if (i < customer_perpeo.length-1) {result += ','};
  140. };
  141. };
  142. result += ']';
  143. return result;
  144. }
  145. //获取推广项目信息输入的JSON字符串
  146. function getProductInfo() {
  147. var result = '[';
  148. var productInfo = $('#productInfo .pi');
  149. for (var i = 0; i < productInfo.length; i++) {
  150. if ($(productInfo.get(i)).find('[name="pi_prodname"]').val()!='') {
  151. result += '{"pi_detno":' + (i+1) +',"pi_id":"0","pi_vrid":"' + vr_id + '",';
  152. result += '"pi_prodname":"' + $(productInfo.get(i)).find('[name="pi_prodname"]').val() +
  153. '","pi_brand":"' + $(productInfo.get(i)).find('[name="pi_brand"]').val() +
  154. '","pi_model":"' + $(productInfo.get(i)).find('[name="pi_model"]').val() +
  155. '","pi_projprogress":"' + $(productInfo.get(i)).find('[name="pi_projprogress"]').val()
  156. + '"}';
  157. if (i < productInfo.length-1) {result += ','};
  158. };
  159. };
  160. result += ']';
  161. return result;
  162. }
  163. //获取费用报销输入的JSON字符串
  164. function getFeedBack() {
  165. var result = '[';
  166. var feedBack = $('#feedBack .fb');
  167. for (var i = 0; i < feedBack.length; i++) {
  168. if ($(feedBack.get(i)).find('[name="vrd_d1"]').val()!='') {
  169. result += '{"vrd_detno":' + (i+1) +',"vrd_id":"0","vrd_vrid":"' + vr_id + '",';
  170. result += '"vrd_d1":"' + $(feedBack.get(i)).find('[name="vrd_d1"]').val() +
  171. '","vrd_n7":"' + $(feedBack.get(i)).find('[name="vrd_n7"]').val() +
  172. '","vrd_d3":"' + $(feedBack.get(i)).find('[name="vrd_d3"]').val() +
  173. '"}';
  174. if (i < feedBack.length-1) {result += ','};
  175. };
  176. };
  177. result += ']';
  178. return result;
  179. };
  180. //设置单据编号
  181. function setVrCode() {
  182. $.ajax({
  183. type: 'GET',
  184. url: basePath + 'common/getCodeString.action',
  185. dataType: 'json',
  186. data: {caller:'VisitRecord', table:'VisitRecord', type:2, _noc: 1},
  187. success: function(result){
  188. $('#vr_code').val(result.code);
  189. }
  190. });
  191. };
  192. setVrCode();
  193. //为拜访时间输入框加载时间控件
  194. $('#datetimepicker').datetimepicker({
  195. language: 'zh-CN',
  196. format: "yyyy-MM-dd hh:mm:ss"
  197. // weekStart: 1,
  198. // todayBtn: true,
  199. // autoclose: true,
  200. // todayHighlight: true,
  201. // minView: 0
  202. });
  203. //判断用户是否登录
  204. if (username && username != 'null' && username != '') {
  205. $('#username').text(username);
  206. } else {
  207. dialog.show('错误', '请先登录!&nbsp;<a href="' + basePath + '">登录</a>');
  208. };
  209. //输入当前时间
  210. $('#settime_now').click(function() {
  211. $('#vr_visittime').val(new Date().format('yyyy-MM-dd hh:mm:ss'));
  212. });
  213. //定位
  214. $('#location').click(function () {
  215. var map = new BMap.Map("location_map");
  216. var point = new BMap.Point(116.331398,39.897445);
  217. map.centerAndZoom(point,12);
  218. var geolocation = new BMap.Geolocation();
  219. geolocation.getCurrentPosition(function(r){
  220. if(this.getStatus() == BMAP_STATUS_SUCCESS){
  221. $('#vr_visitplace').val(r.address.city + r.address.district + r.address.street);
  222. }
  223. else {
  224. alert('failed'+this.getStatus());
  225. }
  226. });
  227. });
  228. //添加拜访人员输入行
  229. $('#add_visit_perpeo').click(function () {
  230. var newTr = '<tr class="pl">' +
  231. '<td width="30%"><div><input name="pl_name" class="form-control" type="text"></div></td>' +
  232. '<td width="50%"><div><input name="pl_position" class="form-control" type="text"></div></td>' +
  233. '<td with="10%"><span style="color:#FF6600;" class="glyphicon glyphicon-remove"></span></td>' +
  234. '</tr> ';
  235. $(this).parent().next().find('.table').append(newTr);
  236. $('.glyphicon-remove').click(function() {
  237. $(this).parent().parent().remove();
  238. });
  239. });
  240. //添加洽谈对象输入行
  241. $('#add_customer_perpeo').click(function () {
  242. var newTr = '<tr class="cup">' +
  243. '<td width="20%"><div><input name="cup_name" class="form-control" type="text"></div></td>' +
  244. '<td width="30%"><div><input name="cup_position" class="form-control" type="text"></div></td>' +
  245. '<td width="40%"><div><input name="cup_tel" class="form-control" type="number"></div></td>' +
  246. '<td with="10%"><span style="color:#FF6600;" class="glyphicon glyphicon-remove"></span></td>' +
  247. '</tr>';
  248. $(this).parent().next().find('.table').append(newTr);
  249. $('.glyphicon-remove').click(function() {
  250. $(this).parent().parent().remove();
  251. });
  252. });
  253. //添加推广项目信息输入行
  254. $('#add_productInfo').click(function () {
  255. var newTr = '<tr class="pi">' +
  256. '<td width="30%">' +
  257. '<div><input name="pi_prodname" class="form-control" type="text" readonly placeholder="点击选择"></div>' +
  258. '</td>' +
  259. '<td width="30%">' +
  260. '<div><input name="pi_brand" class="form-control" type="text" readonly></div>' +
  261. '</td>' +
  262. '<td width="0%" style="display:none;">' +
  263. '<div><input name="pi_model" class="form-control" type="text" readonly></div>' +
  264. '</td>' +
  265. '<td width="30%">' +
  266. '<div>' +
  267. '<select name="pi_projprogress" class="form-control" type="number">' +
  268. '<option value="初次推广">初次推广</option>' +
  269. '<option value="报价">报价</option>' +
  270. '<option value="送样">送样</option>' +
  271. '<option value="样品验证">样品验证</option>' +
  272. '<option value="量产">量产</option>' +
  273. '<option value="结案">结案</option>' +
  274. '</select>' +
  275. '</div>' +
  276. '</td>' +
  277. '<td with="10%"><span style="color:#FF6600;" class="glyphicon glyphicon-remove"></span></td>' +
  278. '</tr>';
  279. $(this).parent().next().find('.table').append(newTr);
  280. $('.glyphicon-remove').click(function() {
  281. $(this).parent().parent().remove();
  282. });
  283. prodnameDbFind();
  284. });
  285. //添加费用报销输入行
  286. $('#add_feedBack').click(function () {
  287. var newTr = '<tr class="fb">' +
  288. '<td width="35%">' +
  289. '<div><input name="vrd_d1" class="form-control" type="text" readonly placeholder="点击选择"></div>' +
  290. '</td>' +
  291. '<td width="20%">' +
  292. '<div><input name="vrd_n7" class="form-control" type="number"></div>' +
  293. '</td>' +
  294. '<td width="35%"><div><input name="vrd_d3" class="form-control" type="text"></div></td>' +
  295. '<td with="10%"><span style="color:#FF6600;" class="glyphicon glyphicon-remove"></span></td>' +
  296. '</tr>';
  297. $(this).parent().next().find('.table').append(newTr);
  298. $('.glyphicon-remove').click(function() {
  299. $(this).parent().parent().remove();
  300. });
  301. });
  302. //注册删除某一输入行事件
  303. $('.glyphicon-remove').click(function() {
  304. $(this).parent().parent().remove();
  305. });
  306. //预设单据编号 ----功能被移除
  307. // $('#vr_code_preset').click(function() {
  308. // if($(this).attr('checked')) {
  309. // $('#vr_code').attr('disabled', '');
  310. // $('#vr_code').val('');
  311. // }
  312. // else {
  313. // $('#vr_code').removeAttr('disabled');
  314. // }
  315. // });
  316. //加载下拉选项
  317. $.ajax({
  318. type: 'GET',
  319. url: basePath + 'common/singleFormItems.action',
  320. dataType: 'json',
  321. data: {caller: 'VisitRecord',condition: '',_noc: 1},
  322. success: function(result){
  323. var items = result.items;
  324. $.each(items, function(i, item){
  325. if(item.name == 'vr_type') {
  326. $.each(item.store.data, function(j, data){
  327. $('#vr_type').append('<option value="' + data.value +'">' + data.display +'</option>');
  328. });
  329. };
  330. if(item.name == 'vr_way') {
  331. $.each(item.store.data, function(j, data){
  332. $('#vr_way').append('<option value="' + data.value +'">' + data.display +'</option>');
  333. });
  334. };
  335. if (item.name == 'vr_uu') {};
  336. if (item.name == 'vr_class') {
  337. vr_class=item.value;
  338. };
  339. });
  340. }
  341. });
  342. //所属组织设为用户所在部门
  343. $('#vr_defaultorname').val(em_depart);
  344. //拜访时间设为当前的时间
  345. $('#vr_visittime').val(new Date().format('yyyy-MM-dd hh:mm:ss'));
  346. //客户编号输入提醒
  347. $('#cuuuDb').bind('click', function() {
  348. $.ajax({
  349. type: 'GET',
  350. url: basePath + 'mobile/crm/getLikeCuCode.action',
  351. data: {code: $('#vr_cuuu').val(), size: 6, page: 1},
  352. success: function(result) {
  353. $('#suggest_cuuu ul').empty();
  354. var items = result.result;
  355. var html = '';
  356. $.each(eval('('+items+')'), function(i, item){
  357. html += '<li cuname="' + item.cu_name + '">' + item.cu_code + '</li>'
  358. });
  359. $('#suggest_cuuu ul').append(html);
  360. $('#suggest_cuuu ul li').click(function() {
  361. var cu_code = $(this).text();
  362. var cu_name = $(this).attr('cuname');
  363. $('#vr_cuuu').val(cu_code);
  364. $('#vr_cuname').val(cu_name);
  365. });
  366. }
  367. });
  368. });
  369. //客户名称输入提醒
  370. $('#cunameDb').bind('click', function() {
  371. $.ajax({
  372. type: 'GET',
  373. url: basePath + 'mobile/crm/getLikeCuName.action',
  374. data: {name: encodeURI($('#vr_cuname').val()), size: 6, page: 1},
  375. success: function(result) {
  376. $('#suggest_cuname ul').empty();
  377. var items = result.result;
  378. var html = '';
  379. $.each(eval('('+items+')'), function(i, item){
  380. html += '<li cucode="' + item.cu_code + '">' + item.cu_name + '</li>'
  381. });
  382. $('#suggest_cuname ul').append(html);
  383. $('#suggest_cuname ul li').click(function() {
  384. var cu_code = $(this).attr('cucode');
  385. var cu_name = $(this).text();
  386. $('#vr_cuuu').val(cu_code);
  387. $('#vr_cuname').val(cu_name);
  388. });
  389. }
  390. });
  391. });
  392. //推广项目信息 项目名称dbFind效果
  393. function prodnameDb(input, page, size) {
  394. var count;
  395. var html = '<table class="table .table-striped text-center"><tr><th width="30%">项目名称</th>' +
  396. '<th width="30%">推广品牌</th><th width="40">推广产品型号</th></tr>';
  397. $.ajax({
  398. url: basePath + 'common/dbfind.action',
  399. type: 'POST',
  400. data: {which:'grid', caller:'Project!TG',field:'pi_prodname',
  401. condition:"upper(prj_name) like '%" + $(input).val() + "%' AND prd_emname='" + username + "' ",
  402. ob:'',page:page,pageSize:size},
  403. success: function (result) {
  404. var data = result.data;
  405. count = eval('('+data+')').length;
  406. $.each(eval('('+data+')'), function(i, item){
  407. html += '<tr><td class="pi_prodname" width="30%">' + item.prj_name +'</td>' +
  408. '<td class="pi_brand" width="30%">' + item.prj_others + '</td>' +
  409. '<td class="pi_model" width="40%">' + item.prj_producttype +'</td></tr>';
  410. });
  411. html += '</table>';
  412. $('#dbFindModal .modal-content .modal-body').html(html);
  413. $('#dbFindModal').modal('show');
  414. $('#dbFindModal .modal-content .modal-body .table td').click(function () {
  415. var td = this;
  416. var tr = $(td).parent();
  417. $(input).val(tr.find('.pi_prodname').text());
  418. $(input).parent().parent().parent().find('input[name="pi_brand"]').val(tr.find('.pi_brand').text());
  419. $(input).parent().parent().parent().find('input[name="pi_model"]').val(tr.find('.pi_model').text());
  420. $('#dbFindModal').modal('hide');
  421. });
  422. var buttonHtml = '';
  423. //添加【重置条件】
  424. buttonHtml += '<button type="button" class="btn btn-default" id="resetCondition">重置条件</button>';
  425. //添加【上一页】
  426. if(page > 1) {
  427. buttonHtml += '<button type="button" class="btn btn-default" id="prePage">上一页</button>';
  428. }
  429. //添加【下一页】
  430. if(count == size) {
  431. buttonHtml += '<button type="button" class="btn btn-default" id="nextPage">下一页</button>';
  432. }
  433. buttonHtml += '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>';
  434. $('#dbFindModal .modal-footer').html(buttonHtml);
  435. $('#resetCondition').click(function(){
  436. $(input).val('');
  437. $(input).parent().parent().parent().find('input[name="pi_brand"]').val('');
  438. $(input).parent().parent().parent().find('input[name="pi_model"]').val('');
  439. prodnameDb(input, page, size);
  440. });
  441. $('#prePage').click(function(){
  442. prodnameDb(input, page-1, size);
  443. });
  444. $('#nextPage').click(function(){
  445. prodnameDb(input, page+1, size);
  446. });
  447. }
  448. });
  449. };
  450. var prodnameDbFind = function () {
  451. $('input[name="pi_prodname"]').click(function(){
  452. prodnameDb(this, 1, 10);
  453. });
  454. };
  455. prodnameDbFind();
  456. //费用报销 费用用途dbFind效果
  457. function feedBackDb(input, page, size) {
  458. var count;
  459. var html = '<table class="table .table-striped text-center"><tr><th width="30%">费用用途</th>' +
  460. '<th width="30%">部门名称</th><th width="40">项目描述</th></tr>';
  461. $.ajax({
  462. url: basePath + 'common/dbfind.action',
  463. type: 'POST',
  464. data: {which:'grid', caller:'FeeCategorySet',field:'vrd_d1',
  465. condition: "upper(fcs_itemname) like '%" + $(input).val() + "%' AND fcs_departmentname='" +
  466. ($('#vr_defaultorname').val()?$('#vr_defaultorname').val():em_depart) + "' ",
  467. ob:'',page:1,pageSize:10},
  468. success: function (result) {
  469. var data = result.data;
  470. $.each(eval('('+data+')'), function(i, item){
  471. html += '<tr><td class="vrd_d1" width="30%">' + item.fcs_itemname +'</td>' +
  472. '<td width="30%">' + item.fcs_departmentname + '</td>' +
  473. '<td width="40%">' + item.fcs_itemdescription +'</td></tr>';
  474. });
  475. html += '</table>';
  476. $('#dbFindModal .modal-content .modal-body').html(html);
  477. $('#dbFindModal').modal('show');
  478. $('#dbFindModal .modal-content .modal-body .table td').click(function () {
  479. var td = this;
  480. var tr = $(td).parent();
  481. $(input).val(tr.find('.vrd_d1').text());
  482. $('#dbFindModal').modal('hide');
  483. });
  484. var buttonHtml = '';
  485. //添加【重置条件】
  486. buttonHtml += '<button type="button" class="btn btn-default" id="resetCondition">重置条件</button>';
  487. //添加【上一页】
  488. if(page > 1) {
  489. buttonHtml += '<button type="button" class="btn btn-default" id="prePage">上一页</button>';
  490. }
  491. //添加【下一页】
  492. if(count == size) {
  493. buttonHtml += '<button type="button" class="btn btn-default" id="nextPage">下一页</button>';
  494. }
  495. buttonHtml += '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>';
  496. $('#dbFindModal .modal-footer').html(buttonHtml);
  497. $('#resetCondition').click(function(){
  498. $(input).val('');
  499. feedBackDb(input, page, size);
  500. });
  501. $('#prePage').click(function(){
  502. feedBackDb(input, page-1, size);
  503. });
  504. $('#nextPage').click(function(){
  505. feedBackDb(input, page+1, size);
  506. });
  507. }
  508. });
  509. };
  510. var feedBackDbFind = function () {
  511. $('input[name="vrd_d1"]').click(function(){
  512. feedBackDb(this, 1, 10);
  513. });
  514. };
  515. feedBackDbFind();
  516. //保存按钮,执行提交
  517. $('#btn_save').click(function () {
  518. var cu_code = $('#vr_cuuu').val();
  519. if(! cu_code) {// 没有选择客户不可以保存
  520. dialog.show('提示,客户不能为空', '关闭提示框', 1, function() {
  521. dialog.hide();
  522. });
  523. } else {
  524. $.ajax({
  525. url: basePath + 'crm/customermgr/saveVisitRecord.action',
  526. type: 'POST',
  527. async: false,
  528. data: {
  529. formStore: getBaseInfo(),//基本信息
  530. param1: getFeedBack(),//费用报销
  531. param2: getCustomerPerpeo(),//洽谈对象
  532. param3: getVisitPerpeo(),//拜访人员
  533. param4: '',
  534. param5: getProductInfo(),//推广项目信息
  535. param6: '',
  536. param7: ''
  537. },
  538. success: function (result) {
  539. if (result.success) {
  540. dialog.show('保存成功', '正在提交单据...', 2, function() {
  541. dialog.hide();
  542. resetAllForm();
  543. $.ajax({//提交单据,将单据状态修改为已提交
  544. url: basePath + 'crm/customermgr/submitVisitRecord.action?caller=VisitRecord',
  545. data: {id: vr_id},
  546. async: false,
  547. success: function (result) {
  548. if(result.success) {
  549. dialog.show('单据提交成功', '继续...', 2, function() {
  550. dialog.hide();
  551. });
  552. } else {
  553. dialog.show('单据提交失败', result.exceptionInfo, 2, function() {
  554. dialog.hide();
  555. });
  556. }
  557. }
  558. });
  559. vr_id = getSeqId('common/getId.action?seq=VISITRECORD_SEQ');
  560. setVrCode();
  561. $('#vr_defaultorname').val(em_depart);
  562. });
  563. } else {
  564. dialog.show('保存失败', '修改数据...', 2, function() {
  565. dialog.hide();
  566. });
  567. };
  568. }
  569. });
  570. }
  571. });
  572. //重置按钮
  573. $('#btn_cancel').click(function(){
  574. resetAllForm();
  575. });
  576. });