三元财务UI

addOrEditCusInfo.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /**
  2. * 修改增加客户信息
  3. * */
  4. var indexNum = 0;
  5. $(function() {
  6. //获取所属部门
  7. getDepts('customerTreeView', 'customer_bedept')
  8. .then(function(){
  9. var edit_id = helper.request.queryString("edit_id");
  10. if (edit_id) {
  11. getCustomer(edit_id);
  12. }
  13. //绑定验证(所有 input.form-control)
  14. $('#tab_user_contents').find("input[class='form-control']").on('blur keyup', valideInput);
  15. });
  16. });
  17. //获取客户详情
  18. function getCustomer(ids) {
  19. $.getJSON(huayi.config.callcenter_url + "CustomerNew/GetCustomer", {
  20. cusid: ids, //客户id
  21. token: $.cookie("token")
  22. }, function(data) {
  23. if (data.state.toLowerCase() == "success") {
  24. var cusBase = data.data.CustomerBase;
  25. if (cusBase) {
  26. $('#customer_key').val(cusBase.F_KeyWords); //string 关键词
  27. $('#customer_code').val(cusBase.F_CustomerCode); //string 客户编号
  28. $('#customer_companyname').val(cusBase.F_CompanyName); //string 公司名称
  29. $('#customer_comaddress').val(cusBase.F_CompanyAddress); //string 公司地址
  30. $('#customer_legalName').val(cusBase.F_LegalName); //string 法人姓名
  31. $('#customer_lehalTel').val(cusBase.F_LegalTel); //string 法人电话
  32. $('#customer_subtrade').val(cusBase.F_SubTrade); // int 所属行业
  33. $('#customer_taxCategory').val(cusBase.F_TaxCategory); // int 税务类别
  34. $('#customer_taxPointDes').val(cusBase.F_TaxPointDes); //string 税点描述
  35. $('#customer_invoiceRange').val(cusBase.F_InvoiceRange); //string 开票范围
  36. $('#customer_layer').val(cusBase.F_Layer); // int 客户信誉等级
  37. $('#customer_bedept').val(cusBase.F_BeDept); // int 客户归属部门
  38. $('#customer_berelatedAcc').val(cusBase.F_BeRelatedAcc); //string 客户归属涉税会计
  39. $('#customer_beauditAcc').val(cusBase.F_BeAuditAcc); //string 客户归属审核会计
  40. $('#customer_bemakeAcc').val(cusBase.F_BeMakeAcc); //string 客户归属做账会计
  41. $('#customer_RegisteredAddress').val(cusBase.F_RegisteredAddress); // string 注册地址
  42. $('#customer_LegalIDCards').val(cusBase.F_LegalIDCards); // string 法人身份证
  43. $('#customer_Qualification').val(cusBase.F_Qualification); // string 企业资质荣誉
  44. $('#customer_FinancialManager').val(cusBase.F_FinancialManager); // string 客户公司财务负责人
  45. $('#customer_BusinessOwner').val(cusBase.F_BusinessOwner); // string 客户归属业务负责人
  46. $('#customer_Remark1').val(cusBase.F_Remark1); // string 备注1(输入框即可)
  47. $('#customer_Remark2').val(cusBase.F_Remark2); // string 备注2(输入框即可)
  48. $('#customer_Remark3').val(cusBase.F_Remark3); // string 备注3(输入框即可)
  49. $('#customer_key').trigger('blur');
  50. }
  51. var cusLists = data.data.ContactList;
  52. if (cusLists && cusLists.length > 0) {
  53. for (var i = 0; i < cusLists.length; i++) {
  54. var tplstr = '';
  55. tplstr = '<div class="contactList_item col-md-offset-2 clearfix">' +
  56. '<div class="form-group col-md-5 col-sm-5">' +
  57. '<div class="input-group">' +
  58. '<span class="input-group-addon">联系人姓名</span>' +
  59. '<input id="F_Name_' + i + '" type="text" class="form-control" value="' + cusLists[i].F_Name +
  60. '" placeholder="请输入联系人姓名" aria-describedby="联系人姓名">' +
  61. '</div>' +
  62. '</div>' +
  63. '<div class="form-group col-md-5 col-sm-5">' +
  64. '<div class="input-group">' +
  65. '<span class="input-group-addon">联系人电话</span>' +
  66. '<input id="F_Telephone_' + i + '" value="' + cusLists[i].F_Telephone +
  67. '" type="text" class="form-control" placeholder="请输入联系人电话" aria-describedby="联系人电话">' +
  68. '</div>' +
  69. '</div>' +
  70. '<div class="form-group col-md-5 col-sm-5">' +
  71. '<div class="input-group">' +
  72. '<span class="input-group-addon">联系人邮箱</span>' +
  73. '<input id="F_Email_' + i + '" value="' + cusLists[i].F_Email +
  74. '" type="text" class="form-control" placeholder="请输入联系人邮箱" aria-describedby="联系人邮箱">' +
  75. '</div>' +
  76. '</div>' +
  77. '<div class="form-group col-md-5 col-sm-5">' +
  78. '<div class="input-group">' +
  79. '<span class="input-group-addon">联系人职务</span>' +
  80. '<input id="F_Duties_' + i + '" value="' + cusLists[i].F_Duties +
  81. '" type="text" class="form-control" placeholder="请输入联系人职务" aria-describedby="联系人职务">' +
  82. '</div>' +
  83. '</div>' +
  84. '<div class="form-group col-md-5 col-sm-5">' +
  85. '<div class="input-group">' +
  86. '<span class="input-group-addon">联系人QQ</span>' +
  87. '<input id="F_QQ_' + i + '" value="' + cusLists[i].F_QQ +
  88. '" type="text" class="form-control" placeholder="请输入联系人QQ" aria-describedby="联系人QQ">' +
  89. '</div>' +
  90. '</div>' +
  91. '<div class="form-group col-md-5 col-sm-5">' +
  92. '<div class="input-group">' +
  93. '<span class="input-group-addon">联系人MSN</span>' +
  94. '<input id="F_MSN_' + i + '" value="' + cusLists[i].F_MSN +
  95. '" type="text" class="form-control" placeholder="请输入联系人MSN" aria-describedby="联系人MSN">' +
  96. '</div>' +
  97. '</div>' +
  98. '<div class="form-group col-md-10 col-sm-10">' +
  99. '<div class="input-group">' +
  100. '<span class="input-group-addon">联系人备注</span>' +
  101. '<input id="F_Remark_' + i + '" value="' + cusLists[i].F_Remark +
  102. '" type="text" class="form-control" placeholder="请输入联系人备注" aria-describedby="联系人备注">' +
  103. '</div>' +
  104. '</div>' +
  105. '<div class="form-group col-md-5 col-sm-5">' +
  106. '<div class="input-group">' +
  107. '<span class="input-group-addon">是否主要联系人</span>' +
  108. '<div class="isMain" id="F_IsMain_' + i + '">' +
  109. '<label class="radio-inline">' +
  110. '<input type="radio" name="inlineOptions_' + i + '" value="true"> 是' +
  111. '</label>' +
  112. '<label class="radio-inline">' +
  113. '<input type="radio" name="inlineOptions_' + i + '" value="false"> 否' +
  114. '</label>' +
  115. '</div>' +
  116. '</div>' +
  117. '</div>' +
  118. '<button class="form-control btn btn-default" style="width:60px;margin-left:15px" onclick="btn_delete($(this))">删除</button>' +
  119. '</div>';
  120. $('#contactList').prepend(tplstr);
  121. $('#F_IsMain_' + i).find('input[type="radio"][value="' + cusLists[i].F_IsMain +'"]').prop('checked', true);
  122. }
  123. indexNum = cusLists.length;
  124. }
  125. }
  126. });
  127. }
  128. //保存
  129. function saveCustomer() {
  130. if (!$.trim($('#customer_code').val()) ||
  131. !$.trim($('#customer_companyname').val())
  132. ) {
  133. layer.msg('带红色星号的是必填项,请填写或选择后再保存!');
  134. return;
  135. }
  136. var contactList = $('#contactList').find('.contactList_item');
  137. for (var i = 0; i < contactList.length; i++) {
  138. var F_Name = $(contactList[i]).find('input[id*="F_Name_"]').val();
  139. var F_Telephone = $(contactList[i]).find('input[id*="F_Telephone_"]').val();
  140. var F_Email = $(contactList[i]).find('input[id*="F_Email_"]').val();
  141. var F_Duties = $(contactList[i]).find('input[id*="F_Duties_"]').val();
  142. var F_QQ = $(contactList[i]).find('input[id*="F_QQ_"]').val();
  143. var F_MSN = $(contactList[i]).find('input[id*="F_MSN_"]').val();
  144. if (!regexs.chOrenOrnum.test($.trim(F_Name))) {
  145. layer.confirm('您添加的联系人姓名格式不正确(只能输入中文、英文、数字)!', {
  146. icon: 2,
  147. btn: ['确定']
  148. });
  149. return;
  150. }
  151. if (!regexs.phone.test($.trim(F_Telephone))) {
  152. layer.confirm('您添加的联系人电话号码格式不正确!', {
  153. icon: 2,
  154. btn: ['确定']
  155. });
  156. return;
  157. }
  158. if (F_Email && !regexs.email.test($.trim(F_Email))) {
  159. layer.confirm('您添加的联系人邮箱格式不正确!', {
  160. icon: 2,
  161. btn: ['确定']
  162. });
  163. return;
  164. }
  165. if (F_Duties && !regexs.chOrenOrnum.test($.trim(F_Duties))) {
  166. layer.confirm('您添加的联系人职务格式不正确!', {
  167. icon: 2,
  168. btn: ['确定']
  169. });
  170. return;
  171. }
  172. if (F_QQ && !regexs.QQreg.test($.trim(F_QQ))) {
  173. layer.confirm('您添加的联系人QQ格式不正确!', {
  174. icon: 2,
  175. btn: ['确定']
  176. });
  177. return;
  178. }
  179. if (F_MSN && !regexs.chOrenOrnum.test($.trim(F_MSN))) {
  180. layer.confirm('您添加的联系人MSN格式不正确!', {
  181. icon: 2,
  182. btn: ['确定']
  183. });
  184. return;
  185. }
  186. }
  187. var wURL, loadIndex;
  188. var edit_id = helper.request.queryString("edit_id");
  189. if (edit_id) {
  190. wURL = "CustomerNew/Update";
  191. } else {
  192. wURL = "CustomerNew/Add";
  193. }
  194. $.ajax({
  195. type: 'post',
  196. url: huayi.config.callcenter_url + wURL,
  197. dataType: 'json',
  198. async: true,
  199. beforeSend: function() { //触发ajax请求开始时执行
  200. $('#save_btns').attr("disabled", true);
  201. $('#save_btns').text('保存中...');
  202. loadIndex = layer.load();
  203. },
  204. data: {
  205. F_CustomerId: edit_id, // 否 string id
  206. // F_KeyWords: $('#customer_key').val(), //string 关键词
  207. F_CustomerCode: $('#customer_code').val(), //string 客户编号
  208. F_CompanyName: $('#customer_companyname').val(), //string 公司名称
  209. F_CompanyAddress: $('#customer_comaddress').val(), //string 公司地址
  210. F_LegalName: $('#customer_legalName').val(), //string 法人姓名
  211. F_LegalTel: $('#customer_lehalTel').val(), //string 法人电话
  212. F_SubTrade: $('#customer_subtrade').val(), // int 所属行业
  213. F_TaxCategory: $('#customer_taxCategory').val(), // int 税务类别
  214. F_TaxPointDes: $('#customer_taxPointDes').val(), //string 税点描述
  215. F_InvoiceRange: $('#customer_invoiceRange').val(), //string 开票范围
  216. F_Layer: $('#customer_layer').val(), // int 客户信誉等级
  217. F_BeDept: $('#customer_bedept').attr('data-id'), // int 客户归属部门
  218. F_BeRelatedAcc: $('#customer_berelatedAcc').val(), //string 客户归属涉税会计
  219. F_BeAuditAcc: $('#customer_beauditAcc').val(), //string 客户归属审核会计
  220. F_BeMakeAcc: $('#customer_bemakeAcc').val(), //string 客户归属做账会计
  221. ContactList: getFields(), //List联系人列表
  222. F_RegisteredAddress: $('#customer_RegisteredAddress').val(), // string 注册地址
  223. F_LegalIDCards: $('#customer_LegalIDCards').val(), // string 法人身份证
  224. F_Qualification: $('#customer_Qualification').val(), // string 企业资质荣誉
  225. F_FinancialManager: $('#customer_FinancialManager').val(), // string 客户公司财务负责人
  226. F_BusinessOwner: $('#customer_BusinessOwner').val(), // string 客户归属业务负责人
  227. F_Remark1: $('#customer_Remark1').val(), // string 备注1(输入框即可)
  228. F_Remark2: $('#customer_Remark2').val(), // string 备注2(输入框即可)
  229. F_Remark3: $('#customer_Remark3').val(), // string 备注3(输入框即可)
  230. token: $.cookie("token")
  231. },
  232. success: function(data) {
  233. layer.close(loadIndex);
  234. if (data.state === "success") {
  235. var index = parent.layer.getFrameIndex(window.name);
  236. parent.layer.close(index);
  237. parent.$('#cusList').bootstrapTable('refresh');
  238. parent.layer.msg("保存成功");
  239. } else {
  240. $('#save_btns').attr("disabled", false);
  241. $('#save_btns').text('保存');
  242. }
  243. },
  244. error: function(textStatus) {
  245. layer.close(loadIndex);
  246. layer.confirm('网络繁忙,请稍后再试...', {
  247. icon: 7,
  248. closeBtn: 0,
  249. btn: ['确定'] //按钮
  250. });
  251. $('#save_btns').attr("disabled", false);
  252. $('#save_btns').text('保存');
  253. },
  254. complete: function(XMLHttpRequest, textStatus) {
  255. layer.close(loadIndex);
  256. if (textStatus == 'timeout') {
  257. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  258. xmlhttp.abort();
  259. layer.confirm('网络超时,请稍后再试...', {
  260. icon: 7,
  261. closeBtn: 0,
  262. btn: ['确定'] //按钮
  263. });
  264. }
  265. $('#save_btns').attr("disabled", false);
  266. $('#save_btns').text('保存');
  267. },
  268. });
  269. }
  270. //添加联系人
  271. function btn_add() {
  272. var tplstr = '';
  273. tplstr = '<div class="contactList_item col-md-offset-2 clearfix">' +
  274. '<div class="form-group col-md-5 col-sm-5">' +
  275. '<div class="input-group">' +
  276. '<span class="input-group-addon">联系人姓名</span>' +
  277. '<input id="F_Name_' + indexNum +
  278. '" type="text" class="form-control" placeholder="请输入联系人姓名" aria-describedby="联系人姓名">' +
  279. '</div>' +
  280. '</div>' +
  281. '<div class="form-group col-md-5 col-sm-5">' +
  282. '<div class="input-group">' +
  283. '<span class="input-group-addon">联系人电话</span>' +
  284. '<input id="F_Telephone_' + indexNum +
  285. '" type="text" class="form-control" placeholder="请输入联系人电话" aria-describedby="联系人电话">' +
  286. '</div>' +
  287. '</div>' +
  288. '<div class="form-group col-md-5 col-sm-5">' +
  289. '<div class="input-group">' +
  290. '<span class="input-group-addon">联系人邮箱</span>' +
  291. '<input id="F_Email_' + indexNum +
  292. '" type="text" class="form-control" placeholder="请输入联系人邮箱" aria-describedby="联系人邮箱">' +
  293. '</div>' +
  294. '</div>' +
  295. '<div class="form-group col-md-5 col-sm-5">' +
  296. '<div class="input-group">' +
  297. '<span class="input-group-addon">联系人职务</span>' +
  298. '<input id="F_Duties_' + indexNum +
  299. '" type="text" class="form-control" placeholder="请输入联系人职务" aria-describedby="联系人职务">' +
  300. '</div>' +
  301. '</div>' +
  302. '<div class="form-group col-md-5 col-sm-5">' +
  303. '<div class="input-group">' +
  304. '<span class="input-group-addon">联系人QQ</span>' +
  305. '<input id="F_QQ_' + indexNum + '" type="text" class="form-control" placeholder="请输入联系人QQ" aria-describedby="联系人QQ">' +
  306. '</div>' +
  307. '</div>' +
  308. '<div class="form-group col-md-5 col-sm-5">' +
  309. '<div class="input-group">' +
  310. '<span class="input-group-addon">联系人MSN</span>' +
  311. '<input id="F_MSN_' + indexNum +
  312. '" type="text" class="form-control" placeholder="请输入联系人MSN" aria-describedby="联系人MSN">' +
  313. '</div>' +
  314. '</div>' +
  315. '<div class="form-group col-md-10 col-sm-10">' +
  316. '<div class="input-group">' +
  317. '<span class="input-group-addon">联系人备注</span>' +
  318. '<input id="F_Remark_' + indexNum +
  319. '" type="text" class="form-control" placeholder="请输入联系人备注" aria-describedby="联系人备注">' +
  320. '</div>' +
  321. '</div>' +
  322. '<div class="form-group col-md-5 col-sm-5">' +
  323. '<div class="input-group">' +
  324. '<span class="input-group-addon">是否主要联系人</span>' +
  325. '<div class="isMain" id="F_IsMain_' + indexNum + '">' +
  326. '<label class="radio-inline">' +
  327. '<input type="radio" name="inlineOptions_' + indexNum + '" value="true"> 是' +
  328. '</label>' +
  329. '<label class="radio-inline">' +
  330. '<input type="radio" name="inlineOptions_' + indexNum + '" value="false" checked="checked"> 否' +
  331. '</label>' +
  332. '</div>' +
  333. '</div>' +
  334. '</div>' +
  335. '<button class="form-control btn btn-default" style="width:60px;margin-left:15px" onclick="btn_delete($(this))">删除</button>' +
  336. '</div>';
  337. $('#contactList').prepend(tplstr);
  338. indexNum++;
  339. }
  340. //删除联系人
  341. function btn_delete(el) {
  342. el.parent().remove();
  343. }
  344. //获取联系人信息
  345. function getFields() {
  346. var goodslists = [];
  347. var goodsLists_items = $('#contactList').find('.contactList_item');
  348. $.each(goodsLists_items, function(i, v) {
  349. goodslists.push({
  350. "F_Name": $(v).find('input[id*="F_Name_"]').val(),
  351. "F_Telephone": $(v).find('input[id*="F_Telephone_"]').val(),
  352. "F_Email": $(v).find('input[id*="F_Email_"]').val(),
  353. "F_Duties": $(v).find('input[id*="F_Duties_"]').val(),
  354. "F_QQ": $(v).find('input[id*="F_QQ_"]').val(),
  355. "F_MSN": $(v).find('input[id*="F_MSN_"]').val(),
  356. "F_Remark": $(v).find('input[id*="F_Remark_"]').val(),
  357. "F_IsMain": $(v).find('div[id*="F_IsMain_"]').find('input[type="radio"]:checked').val(),
  358. });
  359. });
  360. //去重
  361. // helper.methods.uniqueObjArray(goodslists, 'F_Name');
  362. return goodslists;
  363. }
  364. /**
  365. * 获取客户归属部门
  366. * el1, 树形结构元素id名 customerTreeView
  367. * el2, 搜索框元素id名 customer_bedept
  368. * */
  369. function getDepts(el1, el2) {
  370. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  371. //初始化 样式
  372. $('#' + el2).on('focus click', function() {
  373. $('#' + el1).removeClass('hidden').addClass('show');
  374. });
  375. $('#' + el2).on('keyup', function() {
  376. if($(this).val() == '') {
  377. $('#' + el1).treeview('uncheckAll', {
  378. silent: true
  379. });
  380. $(this).attr('data-id', '0');
  381. }
  382. });
  383. $('#' + el2 + ' .caret').on('click', function() {
  384. $('#' + el1).removeClass('hidden').addClass('show');
  385. });
  386. $('#' + el1).mouseleave(function() {
  387. $(this).removeClass('show').addClass('hidden');
  388. });
  389. $.getJSON(huayi.config.callcenter_url + 'Department/GetDeptList', {
  390. token: $.cookie("token")
  391. }, function(result) {
  392. if(result.state.toLowerCase() == "success") {
  393. var defaultDatas = helper.methods.buildTree(result.data);
  394. var sortChildrenArr = helper.methods.objToArray(defaultDatas[0].children);
  395. sortChildrenArr.sort(helper.methods.compare('sort'));
  396. var sortChildrenObj = helper.methods.arrayToObj(sortChildrenArr);
  397. defaultDatas[0].children = sortChildrenObj;
  398. if(defaultDatas) {
  399. var $sTree = $('#' + el1).treeview({
  400. color: "#1ab394",
  401. selectedBackColor: '#1ab394',
  402. expandIcon: 'glyphicon glyphicon-chevron-right',
  403. collapseIcon: 'glyphicon glyphicon-chevron-down',
  404. nodeIcon: 'fa fa-folder-o',
  405. //selectedIcon: "glyphicon glyphicon-stop",
  406. //icon: "glyphicon glyphicon-stop",
  407. //emptyIcon: 'glyphicon',
  408. //showCheckbox: true,
  409. selectable: true,
  410. state: {
  411. selected: true
  412. },
  413. data: defaultDatas,
  414. onNodeSelected: function(event, node) {
  415. $sTree.treeview('clearSearch');
  416. $('#' + el2).val(node.text);
  417. $('#' + el2).attr('data-id', node.id);
  418. $('#' + el1).removeClass('show').addClass('hidden');
  419. },
  420. onNodeUnselected: function(event, node) {
  421. $('#' + el2).attr('data-id', 0);
  422. $('#' + el2).attr('placeholder', '请选择客户归属部门');
  423. }
  424. });
  425. // $('#' + el1).treeview('collapseAll', {
  426. // silent: true
  427. // });
  428. $('#' + el1).treeview('expandAll', { levels: 2, silent: true });
  429. var findSNodes = function() {
  430. return $sTree.treeview('search', [$('#' + el2).val(), {
  431. ignoreCase: false,
  432. exactMatch: false
  433. }]);
  434. };
  435. $('#' + el2).on('keyup focus', function(e) {
  436. var selectableNodes = findSNodes();
  437. //var m = $('#' + el1).treeview('getParent', selectableNodes);
  438. //$('#' + el1).treeview('selectNode', [ m, { silent: true } ]);
  439. });
  440. }
  441. dtd.resolve(); // 改变Deferred对象的执行状态
  442. }
  443. })
  444. return dtd.promise(); // 返回promise对象
  445. }
  446. //验证(所有 input.form-control)的方法
  447. function valideInput() {
  448. var _that = $(this);
  449. //console.log($(this).attr('id'));
  450. switch ($(this).attr('id')) {
  451. case 'customer_code': //验证客户编号
  452. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', false);
  453. break;
  454. case 'customer_companyname': //验证公司名称
  455. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', false);
  456. break;
  457. case 'customer_legalName': //验证法人姓名
  458. valideMethods(_that, regexs.userNameReg, '格式不正确(只能输入2-20位汉字可以包含·•)!', true);
  459. break;
  460. case 'customer_lehalTel': //验证法人电话
  461. valideMethods(_that, regexs.phone, '您输入的电话号码格式不正确!', true);
  462. break;
  463. case 'customer_subtrade': //验证所属行业
  464. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  465. break;
  466. case 'customer_taxCategory': //验证 税务类别
  467. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  468. break;
  469. case 'customer_invoiceRange': //验证 开票范围
  470. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  471. break;
  472. case 'customer_layer': //验证 客户信誉等级
  473. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  474. break;
  475. case 'customer_berelatedAcc': //客户归属涉税会计
  476. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  477. break;
  478. case 'customer_beauditAcc': //客户归属审核会计
  479. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  480. break;
  481. case 'customer_bemakeAcc': //客户归属做账会计
  482. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  483. break;
  484. case 'customer_RegisteredAddress': //注册地址
  485. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  486. break;
  487. case 'customer_LegalIDCards': //法人身份证
  488. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  489. break;
  490. case 'customer_Qualification': //企业资质荣誉
  491. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  492. break;
  493. case 'customer_FinancialManager': //客户公司财务负责人
  494. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  495. break;
  496. case 'customer_BusinessOwner': //客户归属业务负责人
  497. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  498. break;
  499. case 'customer_Remark1': //备注1
  500. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  501. break;
  502. case 'customer_Remark2': //备注2
  503. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  504. break;
  505. case 'customer_Remark3': //备注3
  506. valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
  507. break;
  508. }
  509. if ($('#tab_user_contents').find('.has-error').length > 0) {
  510. $('.project_save').attr('disabled', true);
  511. $('#save_btns').off('click', saveCustomer);
  512. } else {
  513. $('.project_save').attr('disabled', false);
  514. $('#save_btns').off('click', saveCustomer);
  515. $('#save_btns').on('click', saveCustomer);
  516. }
  517. }
  518. /**
  519. * 验证方法
  520. * _this :传递的this
  521. * regRlues: 验证的规则
  522. * msg: 提示信息
  523. * isRes:boolean 是否允许验证的内容为空,true:允许为空,false:不允许为空
  524. * */
  525. function valideMethods(_this, regRlues, msg, isRes) {
  526. var txtTpips = _this.parent().parent().find('.text-tips');
  527. if (txtTpips) {
  528. txtTpips.parent().remove();
  529. }
  530. if (!isRes) {
  531. //不为空
  532. if (!regRlues.test($.trim(_this.val()))) {
  533. _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
  534. _this.parent().find('.glyphicon').remove();
  535. $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  536. $('<div class="col-md-10 col-md-offset-2"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent()
  537. .parent());
  538. $('.project_save').attr('disabled', true);
  539. } else {
  540. _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
  541. _this.parent().find('.glyphicon').remove();
  542. $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  543. }
  544. } else {
  545. //为空不验证;但是有内容就验证;
  546. if ($.trim(_this.val())) {
  547. if (!regRlues.test($.trim(_this.val()))) {
  548. _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
  549. _this.parent().find('.glyphicon').remove();
  550. $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  551. $('<div class="col-md-10 col-md-offset-2"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent()
  552. .parent());
  553. $('.project_save').attr('disabled', true);
  554. } else {
  555. _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
  556. _this.parent().find('.glyphicon').remove();
  557. $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
  558. }
  559. } else {
  560. _this.parent().find('.glyphicon').remove();
  561. _this.parent().parent().removeClass('has-error has-success has-feedback');
  562. }
  563. }
  564. }