You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

572 lines
15 KiB

  1. //修改页面
  2. //onload方法
  3. var pro_id = "";
  4. //修改密码传入id
  5. var pwdId = "";
  6. var userId_change = "";
  7. var company_personal_id = "";
  8. //查询渠道表 所需参数
  9. var search_id = "";
  10. var user_id = "";
  11. window.onload = function(){
  12. pro_id = getPar('org_id');
  13. var channel_style = getPar('channel_style');
  14. reloadProvinceInfo();
  15. $.ajax({
  16. url:'./st-xm/control.php', //请求地址
  17. type: "post", //请求方式
  18. // data: data, //请求参数
  19. data:{
  20. type:"channel_detail",
  21. id:pro_id
  22. },
  23. async:false,
  24. dataType: "json",
  25. success: function (date1) {
  26. if(date1.code == 0){
  27. reloadData(date1);
  28. search_id = date1.list.ORG_ID;
  29. }else{
  30. alert('添加企业信息失败!');
  31. }
  32. },
  33. fail: function (date) {
  34. }
  35. });
  36. }
  37. //选中企业
  38. function selectCompany(){
  39. $('#company').css('display','');
  40. $('#personal').css('display','');
  41. $('#company_check').attr('check',true);
  42. $('#company_show').css('display','');
  43. $('#personal_show').css('display','none');
  44. }
  45. //选中个人
  46. function selectPersonal(){
  47. $('#company').css('display','');
  48. $('#personal').css('display','');
  49. $('#personal_check').attr('check',true);
  50. $('#personal_show').css('display','');
  51. $('#company_show').css('display','none');
  52. }
  53. //基本信息
  54. function basicInfo(){
  55. $('#user_infos').css('display','none');
  56. $('#infos').css('display','');
  57. $('#basic_info_btn').css('background-color','lightgray');
  58. $('#user_info_btn').css('background-color','white');
  59. }
  60. //个人信息
  61. function userInfo(){
  62. var value = $('#select_company_personal input[name="company_personal"]:checked ').val();
  63. $('#user_infos').css('display','');
  64. $('#infos').css('display','none');
  65. $('#basic_info_btn').css('background-color','white');
  66. $('#user_info_btn').css('background-color','lightgray');
  67. if(value == 0){
  68. $('#company_user_info').show();
  69. $('#personal_user_info').hide();
  70. }else{
  71. $('#company_user_info').hide();
  72. $('#personal_user_info').show();
  73. }
  74. }
  75. //得到url上的参数
  76. function getPar(par){
  77. var local_url = document.location.href;
  78. local_url = decodeURI(local_url);
  79. var get = local_url.indexOf(par +"=");
  80. if(get == -1){
  81. return false;
  82. }
  83. var get_par = local_url.slice(par.length + get + 1);
  84. var nextPar = get_par.indexOf("&");
  85. if(nextPar != -1){
  86. get_par = get_par.slice(0, nextPar);
  87. }
  88. return get_par;
  89. }
  90. //加载数据
  91. function reloadData(data){
  92. var listDetail = data.list;
  93. if(listDetail.USER_TYPE==0){
  94. console.log(listDetail);
  95. $('#company_check').attr('checked',true);
  96. $("#personal_check").attr('disabled',true);
  97. selectCompany();
  98. //渠道分类
  99. var obj1 = document.getElementsByName('saleStyle');
  100. for(i = 0; i < obj1.length; i++)
  101. {
  102. if(obj1[i].value == listDetail.SELA_TYPE)
  103. {
  104. obj1[i].checked = true;
  105. }
  106. }
  107. //渠道协议号
  108. $('#channel_id').val(listDetail.CHAN_AGREEMENT);
  109. //联系人
  110. $('#linkman').val(listDetail.LINKMAN);
  111. //联系方式
  112. $('#com_tel').val(listDetail.LINK_TEL);
  113. //渠道管理员
  114. $('#channel_admin').val(listDetail.RESMAN);
  115. //渠道名称
  116. $('#channel_name').val(listDetail.CHAN_NAME);
  117. //合作公司
  118. $('#teamwork').val(listDetail.CHAN_SHORT);
  119. //账号
  120. $('#company_login_name').val(listDetail.user_name);
  121. //手机号
  122. $('#company_bound_tel').val(listDetail.phone_no);
  123. //销售方式
  124. var obj = document.getElementsByName('saleStyle_company');
  125. for(i = 0; i < obj.length; i++)
  126. {
  127. if(obj[i].value == listDetail.CHAN_TYPE)
  128. {
  129. obj[i].checked = true;
  130. }
  131. }
  132. // //省份
  133. reloadCityInfo(listDetail.province);
  134. $("#province").val(listDetail.province);
  135. $("#cantonal").val(listDetail.city);
  136. //账号相关信息
  137. $('#company_login_name').val();
  138. userId_change = listDetail.USER_ID;
  139. $('#personal_login_name').val(listDetail.user_name);
  140. $('#personal_bound_tel').val(listDetail.phone_no);
  141. }else{
  142. console.log(listDetail);
  143. selectPersonal();
  144. //加载的是个人信息
  145. $('#personal_login_name').val(listDetail.user_name);
  146. $('#personal_bound_tel').val(listDetail.phone_no);
  147. //渠道分类
  148. $('#personal_check').attr('checked',true);
  149. $("#company_check").attr('disabled',true);
  150. //渠道分类
  151. var obj1 = document.getElementsByName('saleStyle_personal');
  152. for(i = 0; i < obj1.length; i++)
  153. {
  154. if(obj1[i].value == listDetail.SELA_TYPE)
  155. {
  156. obj1[i].checked = true;
  157. }
  158. }
  159. //代理人姓名
  160. $('#agency_name').val(listDetail.CHAN_NAME);
  161. //身份证号
  162. $('#linkman_id').val(listDetail.ID_CARD);
  163. //联系电话
  164. $('#tel_personal').val(listDetail.LINK_TEL);
  165. //负责业务人员
  166. $('#principal_personal').val(listDetail.RESMAN);
  167. //个人所属企业
  168. $('#com_name').val(listDetail.COM_NAME);
  169. //销售方式
  170. var obj = document.getElementsByName('saleStyle_personal_channel');
  171. for(i = 0; i < obj.length; i++)
  172. {
  173. if(obj[i].value == listDetail.CHAN_TYPE)
  174. {
  175. obj[i].checked = true;
  176. }
  177. }
  178. //省份
  179. reloadCityInfo(listDetail.province);
  180. $("#province_personal").val(listDetail.province);
  181. $("#cantonal_personal").val(listDetail.city);
  182. userId_change = listDetail.USER_ID;
  183. }
  184. }
  185. //加载省的信息
  186. function reloadProvinceInfo(){
  187. $.ajax({
  188. url:'./st-xm/control.php', //请求地址
  189. type: "post", //请求方式
  190. // data: data, //请求参数
  191. data:{
  192. type:"channel_province",
  193. },
  194. async:false,
  195. dataType: "json",
  196. success: function (date1) {
  197. if(date1.code == 0){
  198. var HTML = "";
  199. var proList = date1.list;
  200. for (var i = 0; i<proList.length;i ++) {
  201. var dict = proList[i];
  202. var tempHTML = '<option value="0">请选择省</option>';
  203. tempHTML = tempHTML.replace('请选择省',proList[i]['AREA_NAME']);
  204. tempHTML = tempHTML.replace('0',proList[i]['ID']);
  205. HTML += tempHTML;
  206. }
  207. $('#province').html(HTML);
  208. $('#province_personal').html(HTML);
  209. // $('#province').attr('size',1);
  210. }else{
  211. alert('获取省份列表失败');
  212. }
  213. },
  214. fail: function (date) {
  215. }
  216. });
  217. }
  218. //加载市的信息
  219. function reloadCityInfo(proid){
  220. $.ajax({
  221. url:'./st-xm/control.php', //请求地址
  222. type: "post", //请求方式
  223. data:{
  224. type:"channel_city",
  225. id:proid
  226. },
  227. async:false,
  228. dataType: "json",
  229. success: function (date1) {
  230. if(date1.code == 0){
  231. var HTML = "";
  232. var proList = date1.list;
  233. for (var i = 0; i<proList.length;i ++) {
  234. var dict = proList[i];
  235. var tempHTML = '<option value="0">请选择市</option>';
  236. tempHTML = tempHTML.replace('请选择市',proList[i]['AREA_NAME']);
  237. tempHTML = tempHTML.replace('0',proList[i]['ID']);
  238. HTML += tempHTML;
  239. }
  240. $('#cantonal').html(HTML);
  241. $('#cantonal_personal').html(HTML);
  242. }else{
  243. alert('获取城市列表失败');
  244. }
  245. },
  246. fail: function (date) {
  247. }
  248. });
  249. }
  250. //选择省份
  251. function selectOneProvince(selected){
  252. $("#province").find("option:selected").text();
  253. reloadCityInfo(selected.value);
  254. }
  255. //信息保存按钮
  256. function basicInfoSave(){
  257. var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
  258. if(zzz == 0){
  259. var saleStyle = $('#company input[name="saleStyle"]:checked').val();
  260. var channel_name = $('#channel_name').val();
  261. var linkman = $('#linkman').val();
  262. var teamwork = $('#teamwork').val();
  263. var com_tel = $('#com_tel').val();
  264. var channel_admin = $('#channel_admin').val();
  265. var saleStyle_company = $('#company input[name="saleStyle_company"]:checked ').val();
  266. var channel_id = $('#channel_id').val();
  267. var province = $("#province").find("option:selected").val();
  268. var cantonal = $("#cantonal").find("option:selected").val();
  269. if(!saleStyle){
  270. alert('未选择销售方式!');
  271. return;
  272. }else if(channel_name==""){
  273. alert('未输入渠道名称!');
  274. return;
  275. }else if(linkman==""){
  276. alert('未输入联系人!');
  277. return;
  278. }else if(com_tel==""){
  279. alert('未输入联系方式');
  280. return;
  281. }else if(channel_admin==""){
  282. alert('未输入渠道管理员');
  283. return;
  284. }else if(!saleStyle_company){
  285. alert('未选择渠道分类');
  286. return;
  287. }
  288. if( $("#basic_info_save_btn").text() == "保存成功" ) {
  289. return;
  290. }
  291. // $("#basic_info_save_btn").removeClass("btn-info");
  292. $("#basic_info_save_btn").text("保存中...");
  293. $.ajax({
  294. url:'./st-xm/control.php', //请求地址
  295. type: "post", //请求方式
  296. // data: data, //请求参数
  297. data:{
  298. type:"channel_updateinfo",
  299. user_type:0,
  300. saleStyle:saleStyle,
  301. channel_name:channel_name,
  302. teamwork:teamwork,
  303. linkman:linkman,
  304. com_tel:com_tel,
  305. channel_admin:channel_admin,
  306. saleStyle_company:saleStyle_company,
  307. channel_id:channel_id,
  308. province:province,
  309. cantonal:cantonal,
  310. cust_id:pro_id,
  311. org_id:search_id,
  312. user_id:userId_change
  313. },
  314. async:false,
  315. dataType: "json",
  316. success: function (date1) {
  317. if(date1.code == 0){
  318. alert('修改企业信息成功!');
  319. $("#basic_info_save_btn").text("成功保存");
  320. $("#basic_info_save_btn").addClass("removeClass");
  321. $("#personal_check").attr('disabled',true);
  322. $("#basic_info_save_btn").attr("onclick", "null");
  323. $("#basic_info_save_btn").removeClass("btn-primary");
  324. $("#basic_info_save_btn").css('color','white');
  325. company_personal_id = pro_id;
  326. }else{
  327. alert('添加企业信息失败!');
  328. }
  329. },
  330. fail: function (date) {
  331. }
  332. });
  333. // document.info_form_company.submit();
  334. }else{
  335. var saleStyle = $('#personal input[name="saleStyle_personal"]:checked ').val();
  336. var agency_name = $('#agency_name').val();
  337. var linkman_id = $('#linkman_id').val();
  338. var tel_personal = $('#tel_personal').val();
  339. var principal_personal = $('#principal_personal').val();
  340. var saleStyle_personal = $('#personal input[name="saleStyle_personal_channel"]:checked ').val();
  341. var com_name = $('#com_name').val();
  342. var province = $("#province_personal").find("option:selected").val();
  343. var cantonal = $("#cantonal_personal").find("option:selected").val();
  344. if(!saleStyle){
  345. alert('未选择销售方式!');
  346. return;
  347. }else if(agency_name==""){
  348. alert('未输入代理人姓名!');
  349. return;
  350. }else if(linkman_id==""){
  351. alert('未输入身份证号!');
  352. return;
  353. }else if(tel_personal==""){
  354. alert('未输入联系电话');
  355. return;
  356. }else if(principal_personal==""){
  357. alert('未输入负责业务人员');
  358. return;
  359. }else if(saleStyle_personal==""){
  360. alert('未输入负责业务人员');
  361. return;
  362. }
  363. // document.info_form_personal.submit();
  364. if( $("#basic_info_save_btn").text() == "保存成功" ) {
  365. return;
  366. }
  367. // $("#basic_info_save_btn").removeClass("btn-info");
  368. $("#basic_info_save_btn").text("保存中...");
  369. $.ajax({
  370. url:'./st-xm/control.php', //请求地址
  371. type: "post", //请求方式
  372. // data: data, //请求参数
  373. data:{
  374. type:"channel_updateinfo",
  375. user_type:1,
  376. saleStyle_personal:saleStyle,
  377. agency_name:agency_name,
  378. linkman_id:linkman_id,
  379. tel_personal:tel_personal,
  380. principal_personal:principal_personal,
  381. com_name:com_name,
  382. saleStyle_personal_channel:saleStyle_personal,
  383. province:province,
  384. cantonal:cantonal,
  385. cust_id:pro_id
  386. },
  387. async:false,
  388. dataType: "json",
  389. success: function (date1) {
  390. if(date1.code == 0){
  391. //这个地方写按钮失效
  392. alert('修改个人信息成功!');
  393. $("#basic_info_save_btn").text("成功保存");
  394. $("#basic_info_save_btn").addClass("removeClass");
  395. $("#personal_check").attr('disabled',true);
  396. $("#basic_info_save_btn").attr("onclick", "null");
  397. $("#basic_info_save_btn").removeClass("btn-primary");
  398. $("#basic_info_save_btn").css('color','white');
  399. company_personal_id = pro_id;
  400. }else{
  401. alert('添加个人信息失败!');
  402. }
  403. },
  404. fail: function (date) {
  405. }
  406. });
  407. }
  408. }
  409. //账号信息保存按钮
  410. //账号信息保存
  411. function userInfoSave(){
  412. var zzz = $('#select_company_personal input[name="company_personal"]:checked ').val();
  413. if(zzz == 0){
  414. if(company_personal_id==""){
  415. alert('请先完善基本信息');
  416. }
  417. var company_login_name = $('#company_login_name').val();
  418. var company_bound_tel = $('#company_bound_tel').val();
  419. if(company_login_name==""){
  420. alert('未输入渠道登录名!');
  421. }else{
  422. if( $("#user_info_save_btn").text() == "保存成功" ) {
  423. return;
  424. }
  425. $("#user_info_save_btn").text("保存中...");
  426. $.ajax({
  427. url:'./st-xm/control.php', //请求地址
  428. type: "post", //请求方式
  429. // data: data, //请求参数
  430. data:{
  431. type:"channel_updateuser",
  432. user_type:0,
  433. bound_tel:company_bound_tel,
  434. login_name:company_login_name,
  435. id:userId_change,
  436. org_id:search_id,
  437. user_id:userId_change
  438. },
  439. async:false,
  440. dataType: "json",
  441. success: function (date1) {
  442. if(date1.code == 0){
  443. //这个地方写按钮失效
  444. alert('成功修改企业账号!');
  445. $("#user_info_save_btn").text("成功保存");
  446. $("#user_info_save_btn").addClass("removeClass");
  447. // $("#personal_check").attr('disabled',true);
  448. $("#user_info_save_btn").attr("onclick", "null");
  449. $("#user_info_save_btn").removeClass("btn-primary");
  450. $("#user_info_save_btn").css('color','white');
  451. }else{
  452. alert('添加企业账号失败!');
  453. }
  454. },
  455. fail: function (date) {
  456. }
  457. });
  458. }
  459. }else{
  460. var personal_bound_tel = $('#personal_bound_tel').val();
  461. var personal_login_name = $('#personal_login_name').val();
  462. if(company_personal_id==""){
  463. alert('请先完善基本信息');
  464. }
  465. if(personal_bound_tel==""){
  466. alert('未输入绑定手机号!');
  467. }else{
  468. // document.userid_form_personal.submit();
  469. if( $("#user_info_save_btn").text() == "保存成功" ) {
  470. return;
  471. }
  472. $("#user_info_save_btn").text("保存中...");
  473. $.ajax({
  474. url:'./st-xm/control.php', //请求地址
  475. type: "post", //请求方式
  476. // data: data, //请求参数
  477. data:{
  478. type:"channel_updateuser",
  479. user_type:1,
  480. login_name:personal_login_name,
  481. bound_tel:personal_bound_tel,
  482. id:userId_change
  483. },
  484. async:false,
  485. dataType: "json",
  486. success: function (date1) {
  487. if(date1.code == 0){
  488. //这个地方写按钮失效
  489. alert('成功修改个人账号!');
  490. $("#user_info_save_btn").text("成功保存");
  491. $("#user_info_save_btn").addClass("removeClass");
  492. // $("#personal_check").attr('disabled',true);
  493. $("#user_info_save_btn").attr("onclick", "null");
  494. $("#user_info_save_btn").removeClass("btn-primary");
  495. $("#user_info_save_btn").css('color','white');
  496. }else{
  497. alert('添加个人账号失败!');
  498. }
  499. },
  500. fail: function (date) {
  501. }
  502. });
  503. }
  504. }
  505. }
  506. //修改密码
  507. function changeStartPassword(data){
  508. $.ajax({
  509. url:'./st-xm/control.php', //请求地址
  510. type: "post", //请求方式
  511. // data: data, //请求参数
  512. data:{
  513. type:"channel_updatepassword",
  514. id:userId_change
  515. },
  516. async:false,
  517. dataType: "json",
  518. success: function (data) {
  519. alert("重置成功!!");
  520. },
  521. fail: function (data) {
  522. }
  523. });
  524. }