| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /**
- * 增加或编辑客户档案
- * */
- $(document).ready(function() {
- var cid = helper.request.queryString("cid");
- //获取乡镇或单位下拉
- helper.getDropList.getlistDropByDic($('#t_county'), 'JBDW').then(function() {
- if(cid) {
- getCustomer(cid); //获取信息
- }
- });
- //保存
- $('#btn_save').on('click', saveCustomer);
- });
- //添加或编辑保存
- function saveCustomer() {
- var telreg = /^\d{0,12}$/;
- var cid = helper.request.queryString("cid");
- if(!$.trim($('#t_name').val())) {
- layer.confirm('请输入客户姓名!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- if($.trim($('#t_mobile').val())){
- if(!telreg.test($.trim($('#t_mobile').val()))) {
- layer.confirm('请输入正确的手机号!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- }
- if($.trim($('#t_tel').val())){
- if(!telreg.test($.trim($('#t_tel').val()))) {
- layer.confirm('请输入正确的号码!', {
- icon: 2,
- btn: ['确定']
- });
- return;
- }
- }
- $.post(huayi.config.callcenter_url + "Customer/AddCustomer", {
- id: cid, //int 否 修改时不需要,默认为0
- cusname: $('#t_name').val(), // string 是 姓名
- mobile: $('#t_mobile').val(),// string 否 手机号
- telphone: $('#t_tel').val(),// string 否 电话
- address: $('#t_address').val(),// string 否 住址
- countryid: $('#t_county').val(),// int 否 乡镇或单位id 默认为0
- token: $.cookie("token")
- }, function(result) {
- result = $.parseJSON(result);
- if(result.state.toLowerCase() == "success") {
- var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
- parent.layer.close(index); //再执行关闭
- parent.initTable();
- parent.layer.msg("保存成功");
- }
- });
- }
- //获取信息
- function getCustomer(cid) {
- $.getJSON(huayi.config.callcenter_url + 'Customer/GetCustomer', {
- cid: cid,
- token: $.cookie("token")
- }, function(result) {
- if(result.state.toLowerCase() == "success") {
- var res = result.data;
- if(res) {
- $('#t_name').val(res.cusname); //姓名
- $("#t_mobile").val(res.mobile); //手机号
- $("#t_tel").val(res.telphone); //电话
- $("#t_address").val(res.address); //地址
- $('#t_county').val(res.countryid);// int 否 乡镇或单位id 默认为0
- }
-
- }
- })
- }
|