| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- /**
- * 修改增加客户信息
- * */
- $(function() {
- var user_Id = helper.request.queryString("eid");
- var pid = helper.request.queryString("pid");
- //判断是否是添加住户
- if(pid){
- $('#purchase_info').hide();//隐藏购房信息
- }else{
- $('#purchase_info').show();//显购房信息
- }
-
- //出生年月
- laydate.render({
- elem: '#customer_birthday',
- theme: '#1ab394',
- //type: 'month',
- calendar: true
- });
- //获取 区域 项目 期号下拉
- helper.getDropList.getProLocations($('#head_form_rengin'), $('#head_form_pro'), $('#head_form_floor'));
- //获取房主关系
- helper.getDropList.getlistDropByDic($('#ower_relationship'), 'FZGX');
- //getProLists(); //项目下拉
- if(user_Id) {
- user_Id = '' + user_Id;
- user_Id = user_Id.indexOf('_') === -1 ? user_Id : user_Id.split('_')[0];
- getCustomer(user_Id);
- }
- //绑定验证(所有 input.form-control)
- $('#tab_user_contents').find("input[class='form-control']").on('blur keyup', valideInput);
- /*
- $('#customer_scaleResume').on('focus click', function() {
- $('#reginsTreeView').removeClass('hidden').addClass('show');
- });
- $('#customer_scaleResume').on('keyup', function() {
- if($(this).val() == '') {
- $('reginsTreeView').treeview('uncheckAll', {
- silent: true
- });
- $(this).attr('data-id', '0');
- }
- });
- $('#customer_scaleResume + .caret').on('click', function() {
- $('#reginsTreeView').removeClass('hidden').addClass('show');
- });
- $('#reginsTreeView').mouseleave(function() {
- $(this).removeClass('show').addClass('hidden');
- });*/
- });
- //获取单个用户
- function getCustomer(ids) {
- $.getJSON(huayi.config.callcenter_url + "Customer/GetCustomer", {
- cid: ids,
- token: $.cookie("token")
- }, function(data) {
- if(data.state.toLowerCase() == "success") {
- data = data.data;
- if(data) {
- //基本信息
- $('#customer_name').val(data.F_CustomerName); //是 string 姓名/联系人
- $('#customer_code').val(data.F_CustomerCode); //是 string 客户工作单位
- if(data.F_CustomerEName) {
- $('#customer_sex').find("input[type='radio'][value= " + data.F_CustomerEName + "]").prop("checked", true); //性别
- }
- $('#customer_birthday').val(data.F_CustomerPym); //否 string 出生年月
- $('#customer_card').val(data.F_LegalRepresentativeCardID); //否 string 身份证号
- $('#customer_education').val(data.F_CustomerLayer); //否 int 学历
- $('#customer_postCode').val(data.F_PostCode); //否 string 收入层次
- $('#customer_business').val(data.F_BusinessProfile); //否 string 客户职业
- $('#customer_openingBank').val(data.F_OpeningBank); //否 string 职务
- $('#customer_website').val(data.F_Website); //否 string 兴趣爱好
- $('#customer_brand').val(data.F_Url); //否 string 车辆品牌
- $('#customer_kind').val(data.F_Kind); //否 string 车牌号码
- //联系信息
- $('#customer_mobile').val(data.F_Mobile); //否 string 手机号码
- // $('#customer_tel').val(data.F_Telephone); //否 string 电话
- // $('#customer_fax').val(data.F_Fax); //否 string 传真
- // $('#customer_email').val(data.F_Email); //否 string 邮箱
- $('#customer_address').val(data.F_Address); //否 string 通讯住址
- $('#customer_nature').val(data.F_Nature); //否 string 籍贯(精准到县)
- //购房信息
- // if(data.F_ScaleResume && data.F_CategoryId) {
- // $('#customer_scaleResume').val(data.F_ScaleResume); //否 string 所购项目
- // $('#customer_scaleResume').attr('data-id', data.F_CategoryId); //否 string 所购项目id
- //// $('#customer_scaleResume').on('focus',function(){
- //// $('#btn-select-node').trigger('click');
- //// });
- // } else {
- // $('#customer_scaleResume').val('请选择所购项目');
- // $('#customer_scaleResume').attr('data-id', 0);
- // }
- $('#head_form_rengin').selectpicker('val', data.F_Layer).trigger('change'); //区域 待修改
- $('#head_form_pro').selectpicker('val', data.F_CategoryId).trigger('change'); //项目
- $('#head_form_floor').selectpicker('val', data.F_CustomerType).trigger('change'); //期号
- $('#customer_natures').val(data.F_CustomerNature);// 否 string 楼号
- $('#customer_class').val(data.F_CustomerClass); // 否 string 单元号
-
- $('#customer_floor').val(data.F_BusinessLicenseID); //否 string 所购楼层信息
- $('#ower_relationship').selectpicker('val', data.F_CustomerNatureID).trigger('change'); //房主关系
- $('#customer_trade').val(data.F_TradeId); //否 int 总房款
- $('#customer_regionId').val(data.F_RegionId); //否 int 老带新套数
- $('#customer_bankAccount').val(data.F_BankAccount); //否 string 老带新项目
- $('#customer_legalRepresentative').val(data.F_LegalRepresentative); //否 string 置业顾问
- //家庭情况
- if(data.F_TaxID) {
- $('#customer_merrige').find("input[type='radio'][value= " + data.F_TaxID + "]").prop("checked", true); //性别
- }
- $('#customer_mainProduct').val(data.F_MainProduct); //否 string 家庭人口
- $('#customer_spouse').val(data.F_CustomerFrom); //否 string 客户配偶情况
- $('#customer_children').val(data.F_TrackInfo); //否 string 客户子女情况
- $('#customer_parent').val(data.F_TrackState); //否 string 客户父母情况
- $('#customer_consumption').val(data.F_ImportDegree); //否 string 客户消费偏好
- $('#customer_notes').val(data.F_Notes); //否 string 其他备注
- //基本信息
- if(data.Sex) {
- $('#accountSex').find("input[type='radio'][value= " + data.Sex + "]").prop("checked", true); //性别
- }
- if(data.Birthday) {
- $('#accountBirthday').val(data.Birthday.split(' ')[0].substring(0, 7)); //出生年月
- }
-
- $('#customer_name').trigger('blur');
- }
- }
- });
- }
- //保存项目
- function saveCustomer() {
- var user_Id = helper.request.queryString("eid");
- var pid = helper.request.queryString("pid");
- var eID;
- var house;
-
- //判断是否是添加住户
- if(pid){
- if(!$.trim($('#customer_name').val()) ||
- !$.trim($('#customer_card').val()) ||
- ($.trim($('#ower_relationship').val()) === "0") ||
- !$.trim($('#customer_mobile').val())
- ) {
- layer.msg('带红色星号的是必填项,请填写或选择后再保存!');
- return;
- }
- }else{
- if(!$.trim($('#customer_name').val()) ||
- !$.trim($('#customer_card').val()) ||
- ($.trim($('#ower_relationship').val()) === "0") ||
- !$.trim($('#customer_mobile').val()) ||
- ($.trim($('#head_form_rengin').val()) === "0") ||
- ($.trim($('#head_form_pro').val()) === "0") ||
- ($.trim($('#head_form_floor').val()) === "0") ||
- !$.trim($('#customer_floor').val())
-
- ) {
- layer.msg('带红色星号的是必填项,请填写或选择后再保存!');
- return;
- }
- }
- if(user_Id) {
- webURL = 'Customer/Update';
- user_Id = '' + user_Id;
- if(user_Id.indexOf('_') > -1) {
- eID = user_Id.split('_')[0];
- house = user_Id.split('_')[1];
- } else {
- eID = user_Id;
- }
- } else {
- webURL = 'Customer/Add';
- pid = pid === "" ? 0 : helper.request.queryString("pid");
- }
- $.post(huayi.config.callcenter_url + webURL, {
- F_CustomerId: eID, //F_UserId为0是添加,>0修改
- //基本信息
- F_CustomerName: $('#customer_name').val(), //是 string 姓名/联系人
- F_CustomerCode: $('#customer_code').val(), //是 string 客户工作单位
- F_CustomerEName: $('#customer_sex').find("input[type='radio']:checked").val(), //否 string 性别(男,女)
- F_CustomerPym: $('#customer_birthday').val(), //否 string 出生年月
- F_LegalRepresentativeCardID: $('#customer_card').val(), //否 string 身份证号
- F_CustomerLayer: $('#customer_education').val(), //否 int 学历
- F_PostCode: $('#customer_postCode').val(), //否 string 收入层次
- F_BusinessProfile: $('#customer_business').val(), //否 string 客户职业
- F_OpeningBank: $('#customer_openingBank').val(), //否 string 职务
- F_Website: $('#customer_website').val(), //否 string 兴趣爱好
- F_Url: $('#customer_brand').val(), //否 string 车辆品牌
- F_Kind: $('#customer_kind').val(), //否 string 车牌号码
- //联系信息
- F_Mobile: $('#customer_mobile').val(), //否 string 手机号码
- // F_Telephone: $('#customer_tel').val(), //否 string 电话
- // F_Fax: $('#customer_fax').val(), //否 string 传真
- // F_Email: $('#customer_email').val(), //否 string 邮箱
- F_Address: $('#customer_address').val(), //否 string 通讯住址
- F_Nature: $('#customer_nature').val(), //否 string 籍贯(精准到县)
- //购房信息
- //F_ScaleResume: $('#customer_scaleResume').val(), //否 string 所购项目
- //F_CategoryId: $('#customer_scaleResume').attr('data-id'), //否 string 所购项目id
- F_Layer: $('#head_form_rengin').val(), // 否 int 区域id
- F_CustomerNatureID: $('#ower_relationship').val(), //否 int 房主关系
- F_ScaleResume: $('#head_form_pro').find('option:selected').text(), // 否 string 所购项目
- F_CategoryId: $('#head_form_pro').val(), // 否 string 所购项目id
- F_CustomerType: $('#head_form_floor').val(), // 否 string 期号id
-
- F_CustomerNature: $('#customer_natures').val(), // 否 string 楼号
- F_CustomerClass: $('#customer_class').val(), // 否 string 单元号
-
- F_BusinessLicenseID: $('#customer_floor').val(), //否 string 所购楼层信息(房间号)
- F_TradeId: $('#customer_trade').val(), //否 int 总房款
- F_RegionId: $('#customer_regionId').val(), //否 int 老带新套数
- F_BankAccount: $('#customer_bankAccount').val(), //否 string 老带新项目
- F_LegalRepresentative: $('#customer_legalRepresentative').val(), //否 string 置业顾问
- //家庭情况
- F_TaxID: $('#customer_merrige').find("input[type='radio']:checked").val(), //否 string 婚姻状况
- F_MainProduct: $('#customer_mainProduct').val(), //否 string 家庭人口
- F_CustomerFrom: $('#customer_spouse').val(), //否 string 客户配偶情况
- F_TrackInfo: $('#customer_children').val(), //否 string 客户子女情况
- F_TrackState: $('#customer_parent').val(), //否 string 客户父母情况
- F_ImportDegree: $('#customer_consumption').val(), //否 string 客户消费偏好
- F_Notes: $('#customer_notes').val(), //否 string 其他备注
- parentid: pid, //否 int 用户级别 父级子级 修改的时候不传
- token: $.cookie("token")
- }, function(data) {
- data = JSON.parse(data);
- if(data.state.toLowerCase() == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- if(pid === 0 || house != "house") {
- parent.table.reload('t_callTotal');
- } else {
- parent.table.reload('t_callTotal1');
- }
- parent.layer.msg("保存成功");
- }
- });
- }
- //验证(所有 input.form-control)的方法
- function valideInput() {
- var _that = $(this);
- //console.log($(this).attr('id'));
- switch($(this).attr('id')) {
- case 'customer_name': //验证姓名
- valideMethods(_that, regexs.userNameReg, '格式不正确(只能输入2-20位汉字可以包含·•)!', false);
- break;
- case 'customer_code': //验证客户单位
- valideMethods(_that, regexs.proTitle, '格式不正确(2-30位,只能输入中英文数字 空格 + - 中文标点)!', true);
- break;
- case 'customer_card': //验证身份证号码
- valideMethods(_that, regexs.identityCard, '身份证号码格式不正确!', false);
- break;
- case 'customer_postCode': //验证收入层次
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_business': //验证客户职业
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_openingBank': //验证职务
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_website': //兴趣爱好
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_brand': //验证车辆品牌
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_kind': //验证车牌号码
- valideMethods(_that, regexs.chOrenOrnum, '格式不正确(只能输入中文、英文、数字)!', true);
- break;
- case 'customer_mobile': //验证手机号码
- valideMethods(_that, regexs.phone, '您输入的手机号码格式不正确!', false);
- break;
- case 'customer_tel': //验证电话
- valideMethods(_that, regexs.fax, '您输入的电话格式不正确!', true);
- break;
- case 'customer_fax': //验证传真
- valideMethods(_that, regexs.fax, '您输入的传真格式不正确!', true);
- break;
- case 'customer_email': //验证email
- valideMethods(_that, regexs.email, '您输入的邮箱格式不正确!', true);
- break;
- case 'customer_address': //验证通讯住址
- valideMethods(_that, regexs.address, '格式不正确(只能包含中文、英文、数字、下划线、中英文逗号、中英文句号)!', true);
- break;
- case 'customer_nature': //验证籍贯(精准到县)
- valideMethods(_that, regexs.address, '格式不正确(只能包含中文、英文、数字、下划线、中英文逗号、中英文句号)!', true);
- break;
- case 'customer_floor': //验证所购楼层信息
- valideMethods(_that, regexs.roomNum, '格式不正确(只能输入匹配中文、英文、数字、下划线 和 \ - —— #)!', false);
- break;
- case 'customer_trade': //总房款
- valideMethods(_that, regexs.nums, '格式不正确(只能包含数字)!', true);
- break;
- case 'customer_regionId': //老带新套数
- valideMethods(_that, regexs.nums, '格式不正确(只能包含数字)!', true);
- break;
- case 'customer_bankAccount': //老带新项目
- valideMethods(_that, regexs.chOrnum, '格式不正确(只能包含数字、文字)!', true);
- break;
- case 'customer_legalRepresentative': //置业顾问
- valideMethods(_that, regexs.chOren, '格式不正确(只能输入汉字或字母)!', true);
- break;
- case 'customer_mainProduct': //验证家庭人口
- valideMethods(_that, regexs.chOrnum, '格式不正确(只能包含数字、文字)!', true);
- break;
- }
- if($('#tab_user_contents').find('.has-error').length > 0) {
- $('.project_save').attr('disabled', true);
- $('#btn_save').off('click', saveCustomer);
- } else {
- $('.project_save').attr('disabled', false);
- $('#btn_save').off('click', saveCustomer);
- $('#btn_save').on('click', saveCustomer);
- }
- }
- /**
- * 验证方法
- * _this :传递的this
- * regRlues: 验证的规则
- * msg: 提示信息
- * isRes:boolean 是否允许验证的内容为空,true:允许为空,false:不允许为空
- * */
- function valideMethods(_this, regRlues, msg, isRes) {
- var txtTpips = _this.parent().parent().find('.text-tips');
- if(txtTpips) {
- txtTpips.parent().remove();
- }
- if(!isRes) {
- //不为空
- if(!regRlues.test($.trim(_this.val()))) {
- _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
- _this.parent().find('.glyphicon').remove();
- $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
- $('<div class="col-md-5"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent().parent());
- $('.project_save').attr('disabled', true);
- } else {
- _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
- _this.parent().find('.glyphicon').remove();
- $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
- }
- } else {
- //为空不验证;但是有内容就验证;
- if($.trim(_this.val())) {
- if(!regRlues.test($.trim(_this.val()))) {
- _this.parent().parent().removeClass('has-success has-feedback').addClass('has-error has-feedback');
- _this.parent().find('.glyphicon').remove();
- $('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
- $('<div class="col-md-5"><span class="text-tips">' + msg + '</span></div>').appendTo(_this.parent().parent());
- $('.project_save').attr('disabled', true);
- } else {
- _this.parent().parent().removeClass('has-error has-feedback').addClass('has-success has-feedback');
- _this.parent().find('.glyphicon').remove();
- $('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>').appendTo(_this.parent());
- }
- } else {
- _this.parent().find('.glyphicon').remove();
- _this.parent().parent().removeClass('has-error has-success has-feedback');
- }
- }
- }
- ////项目下拉(树形下拉)
- //function getProLists() {
- // $.getJSON(huayi.config.callcenter_url + 'CusRegionCategory/GetRegionListTree2', {
- // token: $.cookie("token")
- // }, function(result) {
- // if(result.state.toLowerCase() == "success") {
- // result = result.data;
- // if(result) {
- // var defaultDatas = [];
- // var childrenObj = [];
- // for(var i = 0, resultLength = result.length; i < resultLength; i++) {
- // if(result[i].ParentId === 0) {
- // defaultDatas.push({
- // id: result[i].id,
- // ParentId: result[i].ParentId,
- // text: result[i].text,
- // children: []
- // });
- // } else {
- // childrenObj.push({
- // id: result[i].id,
- // ParentId: result[i].ParentId,
- // text: result[i].text,
- // });
- // }
- // }
- //
- // for(var k = 0, defaultDatasLength = defaultDatas.length; k < defaultDatasLength; k++) {
- // for(var j = 0, childrenLength = childrenObj.length; j < childrenLength; j++) {
- // if(defaultDatas[k].id === childrenObj[j].ParentId) {
- // defaultDatas[k].children.push({
- // id: childrenObj[j].id,
- // ParentId: childrenObj[j].ParentId,
- // text: childrenObj[j].text,
- // children: null
- // });
- // }
- // }
- // }
- // var $sTree = $('#reginsTreeView').treeview({
- // color: "#428bca",
- // expandIcon: 'glyphicon glyphicon-chevron-right',
- // collapseIcon: 'glyphicon glyphicon-chevron-down',
- // nodeIcon: 'fa fa-folder-o',
- // //selectedIcon: "glyphicon glyphicon-stop",
- // //icon: "glyphicon glyphicon-stop",
- // //emptyIcon: 'glyphicon',
- // //showCheckbox: true,
- // selectable: true,
- // state: {
- // selected: true
- // },
- // data: defaultDatas,
- // onNodeSelected: function(event, node) {
- //// $('#customer_scaleResume').off('focus',function(){
- //// $('#btn-select-node').trigger('click');
- //// });
- // $sTree.treeview('clearSearch');
- // $('#customer_scaleResume').val(node.text);
- // $('#customer_scaleResume').attr('data-id', node.id);
- // $('#reginsTreeView').removeClass('show').addClass('hidden');
- // },
- // onNodeUnselected: function(event, node) {
- //// $('#customer_scaleResume').off('focus',function(){
- //// $('#btn-select-node').trigger('click');
- //// });
- // $('#customer_scaleResume').val('请选择所购项目');
- // $('#customer_scaleResume').attr('data-id', 0);
- // }
- // });
- // $('#reginsTreeView').treeview('collapseAll', {
- // silent: true
- // });
- // var findSNodes = function() {
- // return $sTree.treeview('search', [$('#customer_scaleResume').val(), {
- // ignoreCase: false,
- // exactMatch: false
- // }]);
- // };
- //
- // var selectableNodes = findSNodes();
- //
- // $('#customer_scaleResume').on('keyup focus', function(e) {
- // selectableNodes = findSNodes();
- // });
- //// $('#btn-select-node').on('click', function (e) {
- //// $sTree.treeview('selectNode', [ selectableNodes[0], { silent: true}]);
- //// });
- //
- // }
- //
- // }
- // })
- //}
|