|
- //修改页面
- //onload方法
- var pro_id = "";
- //修改密码传入id
- var pwdId = "";
- var userId_change = "";
- var company_personal_id = "";
-
- //查询渠道表 所需参数
- var search_id = "";
- var user_id = "";
-
- window.onload = function(){
- pro_id = getPar('org_id');
- var channel_style = getPar('channel_style');
- reloadProvinceInfo();
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_detail",
- id:pro_id
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- reloadData(date1);
- search_id = date1.list.ORG_ID;
- }else{
- alert('添加企业信息失败!');
- }
-
- },
- fail: function (date) {
-
- }
- });
- }
-
- //选中企业
- function selectCompany(){
- $('#company').css('display','');
- $('#personal').css('display','');
- $('#company_check').attr('check',true);
- $('#company_show').css('display','');
- $('#personal_show').css('display','none');
-
- }
-
- //选中个人
- function selectPersonal(){
- $('#company').css('display','');
- $('#personal').css('display','');
- $('#personal_check').attr('check',true);
- $('#personal_show').css('display','');
- $('#company_show').css('display','none');
- }
-
-
- //基本信息
- function basicInfo(){
- $('#user_infos').css('display','none');
- $('#infos').css('display','');
- $('#basic_info_btn').css('background-color','lightgray');
- $('#user_info_btn').css('background-color','white');
- }
-
- //个人信息
- function userInfo(){
- var value = $('#select_company_personal input[name="company_personal"]:checked ').val();
-
- $('#user_infos').css('display','');
- $('#infos').css('display','none');
- $('#basic_info_btn').css('background-color','white');
- $('#user_info_btn').css('background-color','lightgray');
- if(value == 0){
- $('#company_user_info').show();
- $('#personal_user_info').hide();
- }else{
- $('#company_user_info').hide();
- $('#personal_user_info').show();
- }
- }
-
- //得到url上的参数
- function getPar(par){
- var local_url = document.location.href;
- local_url = decodeURI(local_url);
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- var get_par = local_url.slice(par.length + get + 1);
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
-
- //加载数据
- function reloadData(data){
- var listDetail = data.list;
- if(listDetail.USER_TYPE==0){
- console.log(listDetail);
- $('#company_check').attr('checked',true);
- $("#personal_check").attr('disabled',true);
- selectCompany();
- //渠道分类
- var obj1 = document.getElementsByName('saleStyle');
- for(i = 0; i < obj1.length; i++)
- {
- if(obj1[i].value == listDetail.SELA_TYPE)
- {
- obj1[i].checked = true;
- }
- }
- //渠道协议号
- $('#channel_id').val(listDetail.CHAN_AGREEMENT);
- //联系人
- $('#linkman').val(listDetail.LINKMAN);
- //联系方式
- $('#com_tel').val(listDetail.LINK_TEL);
- //渠道管理员
- $('#channel_admin').val(listDetail.RESMAN);
- //渠道名称
- $('#channel_name').val(listDetail.CHAN_NAME);
- //合作公司
- $('#teamwork').val(listDetail.CHAN_SHORT);
- //账号
- $('#company_login_name').val(listDetail.user_name);
- //手机号
- $('#company_bound_tel').val(listDetail.phone_no);
- //销售方式
- var obj = document.getElementsByName('saleStyle_company');
- for(i = 0; i < obj.length; i++)
- {
- if(obj[i].value == listDetail.CHAN_TYPE)
- {
- obj[i].checked = true;
- }
- }
- // //省份
- reloadCityInfo(listDetail.province);
- $("#province").val(listDetail.province);
- $("#cantonal").val(listDetail.city);
- //账号相关信息
- $('#company_login_name').val();
- userId_change = listDetail.USER_ID;
-
- $('#personal_login_name').val(listDetail.user_name);
- $('#personal_bound_tel').val(listDetail.phone_no);
- }else{
- console.log(listDetail);
- selectPersonal();
- //加载的是个人信息
- $('#personal_login_name').val(listDetail.user_name);
- $('#personal_bound_tel').val(listDetail.phone_no);
- //渠道分类
- $('#personal_check').attr('checked',true);
- $("#company_check").attr('disabled',true);
- //渠道分类
- var obj1 = document.getElementsByName('saleStyle_personal');
- for(i = 0; i < obj1.length; i++)
- {
- if(obj1[i].value == listDetail.SELA_TYPE)
- {
- obj1[i].checked = true;
- }
- }
- //代理人姓名
- $('#agency_name').val(listDetail.CHAN_NAME);
- //身份证号
- $('#linkman_id').val(listDetail.ID_CARD);
- //联系电话
- $('#tel_personal').val(listDetail.LINK_TEL);
- //负责业务人员
- $('#principal_personal').val(listDetail.RESMAN);
- //个人所属企业
- $('#com_name').val(listDetail.COM_NAME);
- //销售方式
- var obj = document.getElementsByName('saleStyle_personal_channel');
- for(i = 0; i < obj.length; i++)
- {
- if(obj[i].value == listDetail.CHAN_TYPE)
- {
- obj[i].checked = true;
- }
- }
- //省份
- reloadCityInfo(listDetail.province);
- $("#province_personal").val(listDetail.province);
- $("#cantonal_personal").val(listDetail.city);
- userId_change = listDetail.USER_ID;
- }
- }
- //加载省的信息
- function reloadProvinceInfo(){
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_province",
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- var HTML = "";
- var proList = date1.list;
- for (var i = 0; i<proList.length;i ++) {
- var dict = proList[i];
- var tempHTML = '<option value="0">请选择省</option>';
- tempHTML = tempHTML.replace('请选择省',proList[i]['AREA_NAME']);
- tempHTML = tempHTML.replace('0',proList[i]['ID']);
- HTML += tempHTML;
- }
-
- $('#province').html(HTML);
- $('#province_personal').html(HTML);
- // $('#province').attr('size',1);
-
- }else{
- alert('获取省份列表失败');
- }
- },
- fail: function (date) {
- }
- });
- }
-
-
-
- //加载市的信息
- function reloadCityInfo(proid){
-
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- data:{
- type:"channel_city",
- id:proid
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- var HTML = "";
- var proList = date1.list;
- for (var i = 0; i<proList.length;i ++) {
- var dict = proList[i];
- var tempHTML = '<option value="0">请选择市</option>';
- tempHTML = tempHTML.replace('请选择市',proList[i]['AREA_NAME']);
- tempHTML = tempHTML.replace('0',proList[i]['ID']);
- HTML += tempHTML;
- }
- $('#cantonal').html(HTML);
- $('#cantonal_personal').html(HTML);
- }else{
- alert('获取城市列表失败');
- }
- },
- fail: function (date) {
-
- }
- });
- }
-
- //选择省份
- function selectOneProvince(selected){
- $("#province").find("option:selected").text();
- reloadCityInfo(selected.value);
- }
-
-
- //信息保存按钮
- function basicInfoSave(){
-
- var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
-
-
- if(zzz == 0){
- var saleStyle = $('#company input[name="saleStyle"]:checked').val();
-
- var channel_name = $('#channel_name').val();
-
- var linkman = $('#linkman').val();
-
- var teamwork = $('#teamwork').val();
-
- var com_tel = $('#com_tel').val();
-
- var channel_admin = $('#channel_admin').val();
-
- var saleStyle_company = $('#company input[name="saleStyle_company"]:checked ').val();
-
- var channel_id = $('#channel_id').val();
-
- var province = $("#province").find("option:selected").val();
-
- var cantonal = $("#cantonal").find("option:selected").val();
- if(!saleStyle){
- alert('未选择销售方式!');
- return;
- }else if(channel_name==""){
- alert('未输入渠道名称!');
- return;
- }else if(linkman==""){
- alert('未输入联系人!');
- return;
- }else if(com_tel==""){
- alert('未输入联系方式');
- return;
- }else if(channel_admin==""){
- alert('未输入渠道管理员');
- return;
- }else if(!saleStyle_company){
- alert('未选择渠道分类');
- return;
- }
- if( $("#basic_info_save_btn").text() == "保存成功" ) {
- return;
- }
- // $("#basic_info_save_btn").removeClass("btn-info");
- $("#basic_info_save_btn").text("保存中...");
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_updateinfo",
- user_type:0,
- saleStyle:saleStyle,
- channel_name:channel_name,
- teamwork:teamwork,
- linkman:linkman,
- com_tel:com_tel,
- channel_admin:channel_admin,
- saleStyle_company:saleStyle_company,
- channel_id:channel_id,
- province:province,
- cantonal:cantonal,
- cust_id:pro_id,
- org_id:search_id,
- user_id:userId_change
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- alert('修改企业信息成功!');
- $("#basic_info_save_btn").text("成功保存");
- $("#basic_info_save_btn").addClass("removeClass");
- $("#personal_check").attr('disabled',true);
- $("#basic_info_save_btn").attr("onclick", "null");
- $("#basic_info_save_btn").removeClass("btn-primary");
- $("#basic_info_save_btn").css('color','white');
- company_personal_id = pro_id;
- }else{
- alert('添加企业信息失败!');
- }
-
- },
- fail: function (date) {
- }
- });
-
-
-
- // document.info_form_company.submit();
- }else{
- var saleStyle = $('#personal input[name="saleStyle_personal"]:checked ').val();
- var agency_name = $('#agency_name').val();
- var linkman_id = $('#linkman_id').val();
- var tel_personal = $('#tel_personal').val();
- var principal_personal = $('#principal_personal').val();
- var saleStyle_personal = $('#personal input[name="saleStyle_personal_channel"]:checked ').val();
- var com_name = $('#com_name').val();
- var province = $("#province_personal").find("option:selected").val();
- var cantonal = $("#cantonal_personal").find("option:selected").val();
- if(!saleStyle){
- alert('未选择销售方式!');
- return;
- }else if(agency_name==""){
- alert('未输入代理人姓名!');
- return;
- }else if(linkman_id==""){
- alert('未输入身份证号!');
- return;
- }else if(tel_personal==""){
- alert('未输入联系电话');
- return;
- }else if(principal_personal==""){
- alert('未输入负责业务人员');
- return;
- }else if(saleStyle_personal==""){
- alert('未输入负责业务人员');
- return;
- }
- // document.info_form_personal.submit();
- if( $("#basic_info_save_btn").text() == "保存成功" ) {
- return;
- }
- // $("#basic_info_save_btn").removeClass("btn-info");
- $("#basic_info_save_btn").text("保存中...");
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_updateinfo",
- user_type:1,
- saleStyle_personal:saleStyle,
- agency_name:agency_name,
- linkman_id:linkman_id,
- tel_personal:tel_personal,
- principal_personal:principal_personal,
- com_name:com_name,
- saleStyle_personal_channel:saleStyle_personal,
- province:province,
- cantonal:cantonal,
- cust_id:pro_id
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- //这个地方写按钮失效
- alert('修改个人信息成功!');
- $("#basic_info_save_btn").text("成功保存");
- $("#basic_info_save_btn").addClass("removeClass");
- $("#personal_check").attr('disabled',true);
- $("#basic_info_save_btn").attr("onclick", "null");
- $("#basic_info_save_btn").removeClass("btn-primary");
- $("#basic_info_save_btn").css('color','white');
- company_personal_id = pro_id;
- }else{
- alert('添加个人信息失败!');
- }
- },
- fail: function (date) {
- }
- });
- }
-
- }
-
-
- //账号信息保存按钮
- //账号信息保存
- function userInfoSave(){
- var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
- if(zzz == 0){
- if(company_personal_id==""){
- alert('请先完善基本信息');
- }
- var company_login_name = $('#company_login_name').val();
- var company_bound_tel = $('#company_bound_tel').val();
- if(company_login_name==""){
- alert('未输入渠道登录名!');
- }else{
- if( $("#user_info_save_btn").text() == "保存成功" ) {
- return;
- }
- $("#user_info_save_btn").text("保存中...");
-
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_updateuser",
- user_type:0,
- bound_tel:company_bound_tel,
- login_name:company_login_name,
- id:userId_change,
- org_id:search_id,
- user_id:userId_change
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- //这个地方写按钮失效
- alert('成功修改企业账号!');
- $("#user_info_save_btn").text("成功保存");
- $("#user_info_save_btn").addClass("removeClass");
- // $("#personal_check").attr('disabled',true);
- $("#user_info_save_btn").attr("onclick", "null");
- $("#user_info_save_btn").removeClass("btn-primary");
- $("#user_info_save_btn").css('color','white');
- }else{
- alert('添加企业账号失败!');
- }
- },
- fail: function (date) {
- }
- });
- }
- }else{
- var personal_bound_tel = $('#personal_bound_tel').val();
- var personal_login_name = $('#personal_login_name').val();
- if(company_personal_id==""){
- alert('请先完善基本信息');
- }
- if(personal_bound_tel==""){
- alert('未输入绑定手机号!');
- }else{
- // document.userid_form_personal.submit();
- if( $("#user_info_save_btn").text() == "保存成功" ) {
- return;
- }
- $("#user_info_save_btn").text("保存中...");
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_updateuser",
- user_type:1,
- login_name:personal_login_name,
- bound_tel:personal_bound_tel,
- id:userId_change
- },
- async:false,
- dataType: "json",
- success: function (date1) {
- if(date1.code == 0){
- //这个地方写按钮失效
- alert('成功修改个人账号!');
- $("#user_info_save_btn").text("成功保存");
- $("#user_info_save_btn").addClass("removeClass");
- // $("#personal_check").attr('disabled',true);
- $("#user_info_save_btn").attr("onclick", "null");
- $("#user_info_save_btn").removeClass("btn-primary");
- $("#user_info_save_btn").css('color','white');
- }else{
- alert('添加个人账号失败!');
- }
- },
- fail: function (date) {
- }
- });
- }
- }
- }
-
-
- //修改密码
- function changeStartPassword(data){
- $.ajax({
- url:'./st-xm/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- type:"channel_updatepassword",
- id:userId_change
- },
- async:false,
- dataType: "json",
- success: function (data) {
- alert("重置成功!!");
- },
- fail: function (data) {
- }
- });
- }
|