阜外心血管项目前端

addOrEditCustomer.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /**
  2. * 修改增加客户信息
  3. * */
  4. $(function() {
  5. var user_Id = helper.request.queryString("eid");
  6. var pid = helper.request.queryString("pid");
  7. //判断是否是添加住户
  8. if(pid){
  9. $('#purchase_info').hide();//隐藏购房信息
  10. }else{
  11. $('#purchase_info').show();//显购房信息
  12. }
  13. //出生年月
  14. laydate.render({
  15. elem: '#customer_birthday',
  16. theme: '#1ab394',
  17. //type: 'month',
  18. calendar: true
  19. });
  20. //获取 区域 项目 期号下拉
  21. helper.getDropList.getProLocations($('#head_form_rengin'), $('#head_form_pro'), $('#head_form_floor'));
  22. //获取房主关系
  23. helper.getDropList.getlistDropByDic($('#ower_relationship'), 'FZGX');
  24. //getProLists(); //项目下拉
  25. if(user_Id) {
  26. user_Id = '' + user_Id;
  27. user_Id = user_Id.indexOf('_') === -1 ? user_Id : user_Id.split('_')[0];
  28. getCustomer(user_Id);
  29. }
  30. //绑定验证(所有 input.form-control)
  31. $('#tab_user_contents').find("input[class='form-control']").on('blur keyup', valideInput);
  32. /*
  33. $('#customer_scaleResume').on('focus click', function() {
  34. $('#reginsTreeView').removeClass('hidden').addClass('show');
  35. });
  36. $('#customer_scaleResume').on('keyup', function() {
  37. if($(this).val() == '') {
  38. $('reginsTreeView').treeview('uncheckAll', {
  39. silent: true
  40. });
  41. $(this).attr('data-id', '0');
  42. }
  43. });
  44. $('#customer_scaleResume + .caret').on('click', function() {
  45. $('#reginsTreeView').removeClass('hidden').addClass('show');
  46. });
  47. $('#reginsTreeView').mouseleave(function() {
  48. $(this).removeClass('show').addClass('hidden');
  49. });*/
  50. });
  51. //获取单个用户
  52. function getCustomer(ids) {
  53. $.getJSON(huayi.config.callcenter_url + "Customer/GetCustomer", {
  54. cid: ids,
  55. token: $.cookie("token")
  56. }, function(data) {
  57. if(data.state.toLowerCase() == "success") {
  58. data = data.data;
  59. if(data) {
  60. //基本信息
  61. $('#customer_name').val(data.F_CustomerName); //是 string 姓名/联系人
  62. $('#customer_code').val(data.F_CustomerCode); //是 string 客户工作单位
  63. if(data.F_CustomerEName) {
  64. $('#customer_sex').find("input[type='radio'][value= " + data.F_CustomerEName + "]").prop("checked", true); //性别
  65. }
  66. $('#customer_birthday').val(data.F_CustomerPym); //否 string 出生年月
  67. $('#customer_card').val(data.F_LegalRepresentativeCardID); //否 string 身份证号
  68. $('#customer_education').val(data.F_CustomerLayer); //否 int 学历
  69. $('#customer_postCode').val(data.F_PostCode); //否 string 收入层次
  70. $('#customer_business').val(data.F_BusinessProfile); //否 string 客户职业
  71. $('#customer_openingBank').val(data.F_OpeningBank); //否 string 职务
  72. $('#customer_website').val(data.F_Website); //否 string 兴趣爱好
  73. $('#customer_brand').val(data.F_Url); //否 string 车辆品牌
  74. $('#customer_kind').val(data.F_Kind); //否 string 车牌号码
  75. //联系信息
  76. $('#customer_mobile').val(data.F_Mobile); //否 string 手机号码
  77. // $('#customer_tel').val(data.F_Telephone); //否 string 电话
  78. // $('#customer_fax').val(data.F_Fax); //否 string 传真
  79. // $('#customer_email').val(data.F_Email); //否 string 邮箱
  80. $('#customer_address').val(data.F_Address); //否 string 通讯住址
  81. $('#customer_nature').val(data.F_Nature); //否 string 籍贯(精准到县)
  82. //购房信息
  83. // if(data.F_ScaleResume && data.F_CategoryId) {
  84. // $('#customer_scaleResume').val(data.F_ScaleResume); //否 string 所购项目
  85. // $('#customer_scaleResume').attr('data-id', data.F_CategoryId); //否 string 所购项目id
  86. //// $('#customer_scaleResume').on('focus',function(){
  87. //// $('#btn-select-node').trigger('click');
  88. //// });
  89. // } else {
  90. // $('#customer_scaleResume').val('请选择所购项目');
  91. // $('#customer_scaleResume').attr('data-id', 0);
  92. // }
  93. $('#head_form_rengin').selectpicker('val', data.F_Layer).trigger('change'); //区域 待修改
  94. $('#head_form_pro').selectpicker('val', data.F_CategoryId).trigger('change'); //项目
  95. $('#head_form_floor').selectpicker('val', data.F_CustomerType).trigger('change'); //期号
  96. $('#customer_natures').val(data.F_CustomerNature);// 否 string 楼号
  97. $('#customer_class').val(data.F_CustomerClass); // 否 string 单元号
  98. $('#customer_floor').val(data.F_BusinessLicenseID); //否 string 所购楼层信息
  99. $('#ower_relationship').selectpicker('val', data.F_CustomerNatureID).trigger('change'); //房主关系
  100. $('#customer_trade').val(data.F_TradeId); //否 int 总房款
  101. $('#customer_regionId').val(data.F_RegionId); //否 int 老带新套数
  102. $('#customer_bankAccount').val(data.F_BankAccount); //否 string 老带新项目
  103. $('#customer_legalRepresentative').val(data.F_LegalRepresentative); //否 string 置业顾问
  104. //家庭情况
  105. if(data.F_TaxID) {
  106. $('#customer_merrige').find("input[type='radio'][value= " + data.F_TaxID + "]").prop("checked", true); //性别
  107. }
  108. $('#customer_mainProduct').val(data.F_MainProduct); //否 string 家庭人口
  109. $('#customer_spouse').val(data.F_CustomerFrom); //否 string 客户配偶情况
  110. $('#customer_children').val(data.F_TrackInfo); //否 string 客户子女情况
  111. $('#customer_parent').val(data.F_TrackState); //否 string 客户父母情况
  112. $('#customer_consumption').val(data.F_ImportDegree); //否 string 客户消费偏好
  113. $('#customer_notes').val(data.F_Notes); //否 string 其他备注
  114. //基本信息
  115. if(data.Sex) {
  116. $('#accountSex').find("input[type='radio'][value= " + data.Sex + "]").prop("checked", true); //性别
  117. }
  118. if(data.Birthday) {
  119. $('#accountBirthday').val(data.Birthday.split(' ')[0].substring(0, 7)); //出生年月
  120. }
  121. $('#customer_name').trigger('blur');
  122. }
  123. }
  124. });
  125. }
  126. //保存项目
  127. function saveCustomer() {
  128. var user_Id = helper.request.queryString("eid");
  129. var pid = helper.request.queryString("pid");
  130. var eID;
  131. var house;
  132. //判断是否是添加住户
  133. if(pid){
  134. if(!$.trim($('#customer_name').val()) ||
  135. !$.trim($('#customer_card').val()) ||
  136. ($.trim($('#ower_relationship').val()) === "0") ||
  137. !$.trim($('#customer_mobile').val())
  138. ) {
  139. layer.msg('带红色星号的是必填项,请填写或选择后再保存!');
  140. return;
  141. }
  142. }else{
  143. if(!$.trim($('#customer_name').val()) ||
  144. !$.trim($('#customer_card').val()) ||
  145. ($.trim($('#ower_relationship').val()) === "0") ||
  146. !$.trim($('#customer_mobile').val()) ||
  147. ($.trim($('#head_form_rengin').val()) === "0") ||
  148. ($.trim($('#head_form_pro').val()) === "0") ||
  149. ($.trim($('#head_form_floor').val()) === "0") ||
  150. !$.trim($('#customer_floor').val())
  151. ) {
  152. layer.msg('带红色星号的是必填项,请填写或选择后再保存!');
  153. return;
  154. }
  155. }
  156. if(user_Id) {
  157. webURL = 'Customer/Update';
  158. user_Id = '' + user_Id;
  159. if(user_Id.indexOf('_') > -1) {
  160. eID = user_Id.split('_')[0];
  161. house = user_Id.split('_')[1];
  162. } else {
  163. eID = user_Id;
  164. }
  165. } else {
  166. webURL = 'Customer/Add';
  167. pid = pid === "" ? 0 : helper.request.queryString("pid");
  168. }
  169. $.post(huayi.config.callcenter_url + webURL, {
  170. F_CustomerId: eID, //F_UserId为0是添加,>0修改
  171. //基本信息
  172. F_CustomerName: $('#customer_name').val(), //是 string 姓名/联系人
  173. F_CustomerCode: $('#customer_code').val(), //是 string 客户工作单位
  174. F_CustomerEName: $('#customer_sex').find("input[type='radio']:checked").val(), //否 string 性别(男,女)
  175. F_CustomerPym: $('#customer_birthday').val(), //否 string 出生年月
  176. F_LegalRepresentativeCardID: $('#customer_card').val(), //否 string 身份证号
  177. F_CustomerLayer: $('#customer_education').val(), //否 int 学历
  178. F_PostCode: $('#customer_postCode').val(), //否 string 收入层次
  179. F_BusinessProfile: $('#customer_business').val(), //否 string 客户职业
  180. F_OpeningBank: $('#customer_openingBank').val(), //否 string 职务
  181. F_Website: $('#customer_website').val(), //否 string 兴趣爱好
  182. F_Url: $('#customer_brand').val(), //否 string 车辆品牌
  183. F_Kind: $('#customer_kind').val(), //否 string 车牌号码
  184. //联系信息
  185. F_Mobile: $('#customer_mobile').val(), //否 string 手机号码
  186. // F_Telephone: $('#customer_tel').val(), //否 string 电话
  187. // F_Fax: $('#customer_fax').val(), //否 string 传真
  188. // F_Email: $('#customer_email').val(), //否 string 邮箱
  189. F_Address: $('#customer_address').val(), //否 string 通讯住址
  190. F_Nature: $('#customer_nature').val(), //否 string 籍贯(精准到县)
  191. //购房信息
  192. //F_ScaleResume: $('#customer_scaleResume').val(), //否 string 所购项目
  193. //F_CategoryId: $('#customer_scaleResume').attr('data-id'), //否 string 所购项目id
  194. F_Layer: $('#head_form_rengin').val(), // 否 int 区域id
  195. F_CustomerNatureID: $('#ower_relationship').val(), //否 int 房主关系
  196. F_ScaleResume: $('#head_form_pro').find('option:selected').text(), // 否 string 所购项目
  197. F_CategoryId: $('#head_form_pro').val(), // 否 string 所购项目id
  198. F_CustomerType: $('#head_form_floor').val(), // 否 string 期号id
  199. F_CustomerNature: $('#customer_natures').val(), // 否 string 楼号
  200. F_CustomerClass: $('#customer_class').val(), // 否 string 单元号
  201. F_BusinessLicenseID: $('#customer_floor').val(), //否 string 所购楼层信息(房间号)
  202. F_TradeId: $('#customer_trade').val(), //否 int 总房款
  203. F_RegionId: $('#customer_regionId').val(), //否 int 老带新套数
  204. F_BankAccount: $('#customer_bankAccount').val(), //否 string 老带新项目
  205. F_LegalRepresentative: $('#customer_legalRepresentative').val(), //否 string 置业顾问
  206. //家庭情况
  207. F_TaxID: $('#customer_merrige').find("input[type='radio']:checked").val(), //否 string 婚姻状况
  208. F_MainProduct: $('#customer_mainProduct').val(), //否 string 家庭人口
  209. F_CustomerFrom: $('#customer_spouse').val(), //否 string 客户配偶情况
  210. F_TrackInfo: $('#customer_children').val(), //否 string 客户子女情况
  211. F_TrackState: $('#customer_parent').val(), //否 string 客户父母情况
  212. F_ImportDegree: $('#customer_consumption').val(), //否 string 客户消费偏好
  213. F_Notes: $('#customer_notes').val(), //否 string 其他备注
  214. parentid: pid, //否 int 用户级别 父级子级 修改的时候不传
  215. token: $.cookie("token")
  216. }, function(data) {
  217. data = JSON.parse(data);
  218. if(data.state.toLowerCase() == "success") {
  219. var index = parent.layer.getFrameIndex(window.name);
  220. parent.layer.close(index);
  221. if(pid === 0 || house != "house") {
  222. parent.table.reload('t_callTotal');
  223. } else {
  224. parent.table.reload('t_callTotal1');
  225. }
  226. parent.layer.msg("保存成功");
  227. }
  228. });
  229. }
  230. //验证(所有 input.form-control)的方法
  231. function valideInput() {
  232. var _that = $(this);
  233. //console.log($(this).attr('id'));
  234. switch($(this).attr('id')) {
  235. case 'customer_name': //验证姓名
  236. valideMethods(_that, regexs.userNameReg, '格式不正确(只能输入2-20位汉字可以包含·•)!', false);
  237. break;
  238. case 'customer_code': //验证客户单位
  239. valideMethods(_that, regexs.proTitle, '格式不正确(2-30位,只能输入中英文数字 空格 + - 中文标点)!', true);
  240. break;
  241. case 'customer_card': //验证身份证号码
  242. valideMethods(_that, regexs.identityCard, '身份证号码格式不正确!', false);
  243. break;
  244. case 'customer_postCode': //验证收入层次
  245. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  246. break;
  247. case 'customer_business': //验证客户职业
  248. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  249. break;
  250. case 'customer_openingBank': //验证职务
  251. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  252. break;
  253. case 'customer_website': //兴趣爱好
  254. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  255. break;
  256. case 'customer_brand': //验证车辆品牌
  257. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  258. break;
  259. case 'customer_kind': //验证车牌号码
  260. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  261. break;
  262. case 'customer_mobile': //验证手机号码
  263. valideMethods(_that, regexs.phone, '您输入的手机号码格式不正确!', false);
  264. break;
  265. case 'customer_tel': //验证电话
  266. valideMethods(_that, regexs.fax, '您输入的电话格式不正确!', true);
  267. break;
  268. case 'customer_fax': //验证传真
  269. valideMethods(_that, regexs.fax, '您输入的传真格式不正确!', true);
  270. break;
  271. case 'customer_email': //验证email
  272. valideMethods(_that, regexs.email, '您输入的邮箱格式不正确!', true);
  273. break;
  274. case 'customer_address': //验证通讯住址
  275. valideMethods(_that, regexs.address, '格式不正确(只能包含中文、英文、数字、下划线、中英文逗号、中英文句号)!', true);
  276. break;
  277. case 'customer_nature': //验证籍贯(精准到县)
  278. valideMethods(_that, regexs.address, '格式不正确(只能包含中文、英文、数字、下划线、中英文逗号、中英文句号)!', true);
  279. break;
  280. case 'customer_floor': //验证所购楼层信息
  281. valideMethods(_that, regexs.roomNum, '格式不正确(只能输入匹配中文、英文、数字、下划线 和 \ - —— #)!', false);
  282. break;
  283. case 'customer_trade': //总房款
  284. valideMethods(_that, regexs.nums, '格式不正确(只能包含数字)!', true);
  285. break;
  286. case 'customer_regionId': //老带新套数
  287. valideMethods(_that, regexs.nums, '格式不正确(只能包含数字)!', true);
  288. break;
  289. case 'customer_bankAccount': //老带新项目
  290. valideMethods(_that, regexs.chOrnum, '格式不正确(只能包含数字、文字)!', true);
  291. break;
  292. case 'customer_legalRepresentative': //置业顾问
  293. valideMethods(_that, regexs.chOren, '格式不正确(只能输入汉字或字母)!', true);
  294. break;
  295. case 'customer_mainProduct': //验证家庭人口
  296. valideMethods(_that, regexs.chOrnum, '格式不正确(只能包含数字、文字)!', true);
  297. break;
  298. }
  299. if($('#tab_user_contents').find('.has-error').length > 0) {
  300. $('.project_save').attr('disabled', true);
  301. $('#btn_save').off('click', saveCustomer);
  302. } else {
  303. $('.project_save').attr('disabled', false);
  304. $('#btn_save').off('click', saveCustomer);
  305. $('#btn_save').on('click', saveCustomer);
  306. }
  307. }
  308. /**
  309. * 验证方法
  310. * _this :传递的this
  311. * regRlues: 验证的规则
  312. * msg: 提示信息
  313. * isRes:boolean 是否允许验证的内容为空,true:允许为空,false:不允许为空
  314. * */
  315. function valideMethods(_this, regRlues, msg, isRes) {
  316. var txtTpips = _this.parent().parent().find('.text-tips');
  317. if(txtTpips) {
  318. txtTpips.parent().remove();
  319. }
  320. if(!isRes) {
  321. //不为空
  322. if(!regRlues.test($.trim(_this.val()))) {
  323. _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
  324. _this.parent().find('.glyphicon').remove();
  325. $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  326. $('<div class="col-md-5"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent().parent());
  327. $('.project_save').attr('disabled', true);
  328. } else {
  329. _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
  330. _this.parent().find('.glyphicon').remove();
  331. $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  332. }
  333. } else {
  334. //为空不验证;但是有内容就验证;
  335. if($.trim(_this.val())) {
  336. if(!regRlues.test($.trim(_this.val()))) {
  337. _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
  338. _this.parent().find('.glyphicon').remove();
  339. $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  340. $('<div class="col-md-5"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent().parent());
  341. $('.project_save').attr('disabled', true);
  342. } else {
  343. _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
  344. _this.parent().find('.glyphicon').remove();
  345. $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  346. }
  347. } else {
  348. _this.parent().find('.glyphicon').remove();
  349. _this.parent().parent().removeClass('has-error has-success has-feedback');
  350. }
  351. }
  352. }
  353. ////项目下拉(树形下拉)
  354. //function getProLists() {
  355. // $.getJSON(huayi.config.callcenter_url + 'CusRegionCategory/GetRegionListTree2', {
  356. // token: $.cookie("token")
  357. // }, function(result) {
  358. // if(result.state.toLowerCase() == "success") {
  359. // result = result.data;
  360. // if(result) {
  361. // var defaultDatas = [];
  362. // var childrenObj = [];
  363. // for(var i = 0, resultLength = result.length; i < resultLength; i++) {
  364. // if(result[i].ParentId === 0) {
  365. // defaultDatas.push({
  366. // id: result[i].id,
  367. // ParentId: result[i].ParentId,
  368. // text: result[i].text,
  369. // children: []
  370. // });
  371. // } else {
  372. // childrenObj.push({
  373. // id: result[i].id,
  374. // ParentId: result[i].ParentId,
  375. // text: result[i].text,
  376. // });
  377. // }
  378. // }
  379. //
  380. // for(var k = 0, defaultDatasLength = defaultDatas.length; k < defaultDatasLength; k++) {
  381. // for(var j = 0, childrenLength = childrenObj.length; j < childrenLength; j++) {
  382. // if(defaultDatas[k].id === childrenObj[j].ParentId) {
  383. // defaultDatas[k].children.push({
  384. // id: childrenObj[j].id,
  385. // ParentId: childrenObj[j].ParentId,
  386. // text: childrenObj[j].text,
  387. // children: null
  388. // });
  389. // }
  390. // }
  391. // }
  392. // var $sTree = $('#reginsTreeView').treeview({
  393. // color: "#428bca",
  394. // expandIcon: 'glyphicon glyphicon-chevron-right',
  395. // collapseIcon: 'glyphicon glyphicon-chevron-down',
  396. // nodeIcon: 'fa fa-folder-o',
  397. // //selectedIcon: "glyphicon glyphicon-stop",
  398. // //icon: "glyphicon glyphicon-stop",
  399. // //emptyIcon: 'glyphicon',
  400. // //showCheckbox: true,
  401. // selectable: true,
  402. // state: {
  403. // selected: true
  404. // },
  405. // data: defaultDatas,
  406. // onNodeSelected: function(event, node) {
  407. //// $('#customer_scaleResume').off('focus',function(){
  408. //// $('#btn-select-node').trigger('click');
  409. //// });
  410. // $sTree.treeview('clearSearch');
  411. // $('#customer_scaleResume').val(node.text);
  412. // $('#customer_scaleResume').attr('data-id', node.id);
  413. // $('#reginsTreeView').removeClass('show').addClass('hidden');
  414. // },
  415. // onNodeUnselected: function(event, node) {
  416. //// $('#customer_scaleResume').off('focus',function(){
  417. //// $('#btn-select-node').trigger('click');
  418. //// });
  419. // $('#customer_scaleResume').val('请选择所购项目');
  420. // $('#customer_scaleResume').attr('data-id', 0);
  421. // }
  422. // });
  423. // $('#reginsTreeView').treeview('collapseAll', {
  424. // silent: true
  425. // });
  426. // var findSNodes = function() {
  427. // return $sTree.treeview('search', [$('#customer_scaleResume').val(), {
  428. // ignoreCase: false,
  429. // exactMatch: false
  430. // }]);
  431. // };
  432. //
  433. // var selectableNodes = findSNodes();
  434. //
  435. // $('#customer_scaleResume').on('keyup focus', function(e) {
  436. // selectableNodes = findSNodes();
  437. // });
  438. //// $('#btn-select-node').on('click', function (e) {
  439. //// $sTree.treeview('selectNode', [ selectableNodes[0], { silent: true}]);
  440. //// });
  441. //
  442. // }
  443. //
  444. // }
  445. // })
  446. //}