Geen omschrijving

yongHuManger.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. var token = $.cookie("token");
  2. var id; //当前节点id
  3. var pid; //当前父节点ID
  4. var name; //选择的name
  5. var pidName; //父节点name
  6. var keyWord = $('.searCon').val(); //关键字
  7. var xlName; //添加下拉框节点name
  8. var table = $('#table1'); //右边表格
  9. var exportParams
  10. //搜索按钮
  11. $('.searchGo').click(function() {
  12. keyWord = $('.searCon').val();
  13. initTable(token, id, keyWord);
  14. //if(keyWord) {
  15. // initTable(token, id, keyWord);
  16. //} else {
  17. // layer.confirm('请输入搜索内容!', {
  18. // btn: ['确定']
  19. // });
  20. // return;
  21. //}
  22. })
  23. //搜索按钮
  24. $('.exportFile').click(function() {
  25. exportParams.isdc = 1
  26. helper.method.exportFileFun("UserAccount/GetList",exportParams)
  27. })
  28. $.get(huayi.config.callcenter_url + "Department/GetDeptList", {
  29. "token": $.cookie("token"),
  30. "pid": pid
  31. }, function(result) {
  32. result = $.parseJSON(result);
  33. $.fn.zTree.init($("#treeDemo"), setting1, result.data); //实例化树形图
  34. });
  35. var setting1 = {
  36. data: {
  37. key: {
  38. name: "text"
  39. },
  40. simpleData: {
  41. enable: true,
  42. idKey: "id",
  43. rootPId: 0
  44. }
  45. },
  46. callback: {
  47. onClick: zTreeOnClick
  48. }
  49. };
  50. function zTreeOnClick(event, treeId, treeNode) {
  51. id = treeNode.id;
  52. name = treeNode.text;
  53. var pidnode = treeNode.getParentNode();
  54. if(pidnode) {
  55. pidName = pidnode.text;
  56. pid = pidnode.id;
  57. console.log(pid);
  58. } else {
  59. pidName = "顶级分类";
  60. pid == 0;
  61. console.log(pid);
  62. }
  63. keyWord = $('.searCon').val();
  64. initTable(token, id, keyWord)
  65. };
  66. //===============添加功能开始=============================
  67. laydate.skin('molv');
  68. //用户生日
  69. laydate({
  70. elem: '#ygbirth',
  71. event: 'focus',
  72. istoday: true,
  73. format: 'YYYY-MM-DD', // 分隔符可以任意定义,该例子表示只显示年月
  74. });
  75. //下拉
  76. $('.inps').focus(function() {
  77. $(this).siblings('.addTree').css('display', 'block');
  78. })
  79. $('.xl').click(function() {
  80. var xl = $(this).siblings('.addTree');
  81. if(xl.css('display') == 'block') {
  82. xl.css('display', 'none')
  83. } else {
  84. xl.css('display', 'block')
  85. }
  86. })
  87. $('.addTree').mouseleave(function() {
  88. $(this).css('display', 'none')
  89. })
  90. //添加按钮
  91. $('.add').click(function() {
  92. $('.addModel').css('display', 'block');
  93. addjs(token); //获取所属角色
  94. adddep(); //获取所属部门
  95. addzxz(); //获取坐席组
  96. addRegion(); //获取大区办事处
  97. })
  98. $('.addBtr').click(function() {
  99. $('.addModel').css('display', 'none');
  100. })
  101. //保存添加按钮
  102. $('.addCun').click(function() {
  103. if($('.add_ygName').val() == '' || $('.add_pwd').val() == '' || $('.inps1').val() == '' || $('.inps2').val() == '') {
  104. layer.confirm('标红内容不允许为空!', {
  105. btn: ['确定']
  106. });
  107. return;
  108. } else if($('.add_pwd').val() !== $('.add_pwd2').val()) {
  109. layer.confirm('密码输入不一致!', {
  110. btn: ['确定']
  111. });
  112. return;
  113. } else {
  114. addCun(did, jsid, zxid)
  115. $('.addModel').css('display', 'none');
  116. }
  117. })
  118. //保存所调方法
  119. function addCun(did, jsid, zxid) {
  120. $.ajax({
  121. type: "post",
  122. url: huayi.config.callcenter_url + "UserAccount/AddUsers",
  123. async: true,
  124. dataType: 'json',
  125. data: {
  126. token: $.cookie("token"),
  127. // usercode: $('.add_ygCode').val(),
  128. username: $('.add_ygName').val(),
  129. password: $('.add_pwd').val(),
  130. extno: $('.add_fenji').val(),
  131. //wxno:$('.add_wxno').val(),
  132. deptid: did,
  133. roleid: jsid,
  134. groupid: zxid, //'组id?'
  135. isseat: $('.addhwb input[name="huwu"]:checked ').val(),
  136. searright: $('.addzxqx input[name="zxqx"]:checked ').val(),
  137. sex: $('.addSex input[name="sex"]:checked ').val(),
  138. mobile: $('.add_mobile').val(),
  139. telphone: $('.add_telphone').val(),
  140. birth: $('.add_birth').val(),
  141. hjtype: $('.add_zxlx input[name="zxqx"]:checked ').val(),
  142. Post:$('.add_post').val(),
  143. remark: $('.add_remark').val(),
  144. level: $('#searchRegionId').val(),
  145. deptcode: $('#searchOfficeId').val(),
  146. },
  147. success: function(data) {
  148. if(data.state.toLowerCase() == "success") {
  149. var res = data.data;
  150. layer.confirm('<div>员工工号:' + res.F_UserCode + '</div><div>密码:' + res.F_Password +'</div>', {
  151. btn: ['确定']
  152. });
  153. table.bootstrapTable('refresh');
  154. Clean();
  155. }
  156. }
  157. });
  158. }
  159. //清除表格
  160. function Clean() {
  161. $('.add_ygName').val('');
  162. $('.add_pwd').val('');
  163. $('.add_pwd2').val('');
  164. $('.add_fenji').val('');
  165. $('.inps1').val('');
  166. $('.inps2').val('');
  167. $('.inps3').val('');
  168. $('.addhwb input[name="huwu"]').removeAttr('checked');
  169. $('.addzxqx input[name="zxqx"]').removeAttr('checked');
  170. $('.addSex input[name="sex"]').removeAttr('checked');
  171. $('.add_mobile').val('');
  172. $('.add_post').val('');
  173. $('.add_telphone').val('');
  174. $('.add_birth').val('');
  175. $('.add_zxlx input[name="zxqx"]').removeAttr('checked');
  176. $('.add_remark').val('');
  177. $('#searchRegionId').val('');
  178. $('#searchOfficeId').val('');
  179. $('#searchRegionName').val('');
  180. $('#searchRegionId1').val('');
  181. $('#searchOfficeId1').val('');
  182. $('#searchRegionName1').val('');
  183. // chan_jsid = 0;
  184. // chanDid = 0;
  185. // chanZxid = 0;
  186. ygbh = 0;
  187. buMenId = 0;
  188. }
  189. //所属角色列表
  190. var jsid; //角色id
  191. $('.xlAdd_one ul').on('click', 'li', function() {
  192. $('.inps1').val($(this).html());
  193. jsid = $(this).attr('data-id');
  194. console.log(jsid);
  195. // $(this).addClass('fouceli').siblings().removeClass('fouceli');
  196. $(this).parent().parent().css('display', 'none');
  197. })
  198. //获取角色列表
  199. function addjs(token) {
  200. $('.xlAdd_one ul').html('');
  201. $.ajax({
  202. type: "get",
  203. url: huayi.config.callcenter_url + "RoleInfo/GetRoleList",
  204. async: true,
  205. dataType: 'json',
  206. data: {
  207. token: token,
  208. code: '',
  209. name: '',
  210. pageindex: 1, //页码
  211. pagesize: 100, //条数
  212. },
  213. success: function(data) {
  214. var con = data.rows;
  215. // console.log(con);
  216. for(var i = 0; i < con.length; i++) {
  217. $('<li data-id=' + con[i].F_RoleId + '>' + con[i].F_RoleName + '</li>').appendTo('.xlAdd_one ul');
  218. }
  219. }
  220. });
  221. }
  222. //获取所属部门
  223. var setting2 = {
  224. data: {
  225. key: {
  226. name: "text"
  227. },
  228. simpleData: {
  229. enable: true,
  230. idKey: "id",
  231. rootPId: 0
  232. }
  233. },
  234. callback: {
  235. onClick: ztreeDep
  236. }
  237. };
  238. var did; //部门id
  239. var dname; //部门name
  240. function ztreeDep(event, treeId, treeNode) {
  241. did = treeNode.id;
  242. dname = treeNode.text;
  243. $('.inps2').val(dname);
  244. };
  245. function adddep() {
  246. $.get(huayi.config.callcenter_url + "Department/GetDeptList", {
  247. "token": $.cookie("token"),
  248. "pid": pid
  249. }, function(result) {
  250. result = $.parseJSON(result);
  251. $.fn.zTree.init($("#xlAdd_depTree"), setting2, result.data); //实例化树形图
  252. });
  253. }
  254. //获取坐席组列表
  255. var setting3 = {
  256. data: {
  257. key: {
  258. name: "F_ZXZName"
  259. },
  260. simpleData: {
  261. enable: true,
  262. idKey: "F_ZXZID",
  263. rootPId: 0
  264. }
  265. },
  266. callback: {
  267. onClick: ztreeZxz
  268. }
  269. };
  270. var zxid; //坐席组id
  271. var zxname; //坐席组name
  272. function ztreeZxz(event, treeId, treeNode) {
  273. zxid = treeNode.F_ZXZID;
  274. zxname = treeNode.F_ZXZName;
  275. $('.inps3').val(zxname);
  276. };
  277. function addzxz() {
  278. $.get(huayi.config.callcenter_url + "SeatGroup/GetSeatList?", {
  279. "token": $.cookie("token")
  280. }, function(result) {
  281. result = $.parseJSON(result);
  282. $.fn.zTree.init($("#xlAdd_zxz"), setting3, result.data); //实例化树形图
  283. });
  284. }
  285. //zTree 大区、办事处
  286. var settingRegionalOffice = {
  287. data: {
  288. key: {
  289. name: "text"
  290. },
  291. simpleData: {
  292. enable: true,
  293. idKey: "id",
  294. rootPId: 0
  295. }
  296. },
  297. check: {
  298. enable: true,
  299. autoCheckTrigger: true,
  300. chkboxType: {
  301. "Y": "s",
  302. "N": "s",
  303. },
  304. chkStyle: "checkbox",
  305. },
  306. view: {
  307. dblClickExpand: true
  308. },
  309. callback: {
  310. beforeClick: beforeClick,
  311. onCheck: onCheck,
  312. },
  313. };
  314. function beforeClick(treeId, treeNode) {
  315. var zTree = $.fn.zTree.getZTreeObj("selectRegionZtree");
  316. nodes = zTree.getCheckedNodes(true);
  317. zTree.checkNode(treeNode, !treeNode.checked, null, true);
  318. return false;
  319. }
  320. function onCheck(e, treeId, treeNode) {
  321. var zTree = $.fn.zTree.getZTreeObj("selectRegionZtree");
  322. nodes = zTree.getCheckedNodes(true);
  323. var regionName = "", regionId = "", officeId = "";
  324. for (var i=0, l=nodes.length; i<l; i++) {
  325. regionName += nodes[i].text + ",";
  326. if(nodes[i].level === 1) {
  327. regionId += nodes[i].id + ","
  328. } else if (nodes[i].level === 2) {
  329. officeId += nodes[i].id + ","
  330. }
  331. }
  332. if (regionName.length > 0 ) {
  333. regionName = regionName.substring(0, regionName.length-1);
  334. $("#searchRegionName").val(regionName);
  335. } else {
  336. $("#searchRegionName").val(regionName);
  337. }
  338. if (officeId.length > 0 ) {
  339. $('#searchRegionId').attr("value", "1");
  340. officeId = officeId.substring(0, officeId.length-1);
  341. $('#searchOfficeId').attr("value",officeId);
  342. } else {
  343. $('#searchRegionId').attr("value", "");
  344. $('#searchOfficeId').attr("value",officeId);
  345. }
  346. }
  347. function addRegion() {
  348. $.get(huayi.config.callcenter_url + "Department/GetDepartmentList", {
  349. "token": $.cookie("token"),
  350. }, function(result) {
  351. result = $.parseJSON(result);
  352. $.fn.zTree.init($("#selectRegionZtree"), settingRegionalOffice, result.data); //实例化树形图
  353. });
  354. }
  355. //***********************添加功能结束=============================
  356. //=======================修改功能开始==============================
  357. laydate.skin('molv');
  358. //用户生日
  359. laydate({
  360. elem: '#chan_ygbirth',
  361. event: 'focus',
  362. istoday: true,
  363. format: 'YYYY-MM-DD', // 分隔符可以任意定义,该例子表示只显示年月
  364. });
  365. // var chan_uc;
  366. $('.change').click(function() {
  367. if(ygbh) {
  368. $('.changeModel').css('display', 'block');
  369. addRegion1(); //大区、办事处
  370. chanjs(token); //角色列表
  371. chanGetDep(); //部门列表
  372. chanGetzx(); //获取坐席
  373. // getYG(chan_uc, ygbh);
  374. } else {
  375. layer.confirm('请选择要修改的行!', {
  376. btn: ['确定']
  377. });
  378. return;
  379. }
  380. })
  381. //删除
  382. $('.move').click(function() {
  383. if(ygbh) {
  384. // move(chan_uc);
  385. $('.delModel').css('display', 'block');
  386. } else {
  387. layer.confirm('请选择要删除的行!', {
  388. btn: ['确定']
  389. });
  390. return;
  391. }
  392. })
  393. //关闭按钮
  394. $('.delBtr').click(function() {
  395. $('.delModel').css('display', 'none');
  396. })
  397. //确定删除按钮
  398. $('.sure').click(function() {
  399. move(chan_uc);
  400. $('.delModel').css('display', 'none');
  401. })
  402. //取消删除按钮
  403. $('.return').click(function() {
  404. $('.delModel').css('display', 'none');
  405. })
  406. function move(chan_uc) {
  407. $.ajax({
  408. type: "post",
  409. url: huayi.config.callcenter_url + "UserAccount/DeleteUsers",
  410. async: true,
  411. dataType: 'json',
  412. data: {
  413. token: token,
  414. ids: chan_uc,
  415. },
  416. success: function(data) {
  417. if(data.state.toLowerCase() == "success") {
  418. layer.msg("删除成功!");
  419. // 清除数据
  420. ygbh = 0;
  421. // 重新加载
  422. initTable(token, id, keyWord);
  423. }
  424. }
  425. });
  426. }
  427. //所属角色列表
  428. var chan_jsid; //角色id
  429. $('.xlChan_four ul').on('click', 'li', function() {
  430. $('.inps4').val($(this).html());
  431. chan_jsid = $(this).attr('data-id');
  432. console.log(chan_jsid);
  433. // $(this).addClass('fouceli').siblings().removeClass('fouceli');
  434. $(this).parent().parent().css('display', 'none');
  435. })
  436. //获取角色列表
  437. function chanjs(token) {
  438. $('.xlChan_four ul').html('');
  439. $.ajax({
  440. type: "get",
  441. url: huayi.config.callcenter_url + "RoleInfo/GetRoleList",
  442. async: true,
  443. dataType: 'json',
  444. data: {
  445. token: token,
  446. code: '',
  447. name: '',
  448. pageindex: 1, //页码
  449. pagesize: 100, //条数
  450. },
  451. success: function(data) {
  452. var con = data.rows;
  453. // console.log(con);
  454. for(var i = 0; i < con.length; i++) {
  455. $('<li data-id=' + con[i].F_RoleId + '>' + con[i].F_RoleName + '</li>').appendTo('.xlChan_four ul');
  456. }
  457. //获取用户信息
  458. getYG(chan_uc, ygbh);
  459. }
  460. });
  461. }
  462. //获取所属部门
  463. var setting4 = {
  464. data: {
  465. key: {
  466. name: "text"
  467. },
  468. simpleData: {
  469. enable: true,
  470. idKey: "id",
  471. rootPId: 0
  472. }
  473. },
  474. callback: {
  475. onClick: chanaDep
  476. }
  477. };
  478. var chanDid; //部门id
  479. var chanDname; //部门name
  480. function chanaDep(event, treeId, treeNode) {
  481. chanDid = treeNode.id;
  482. chanDname = treeNode.text;
  483. $('.inps5').val(chanDname);
  484. };
  485. function chanGetDep() {
  486. $.get(huayi.config.callcenter_url + "Department/GetDeptList", {
  487. "token": $.cookie("token"),
  488. "pid": pid
  489. }, function(result) {
  490. result = $.parseJSON(result);
  491. $.fn.zTree.init($("#xlChan_depTree"), setting4, result.data); //实例化树形图
  492. });
  493. }
  494. //获取坐席组列表
  495. var setting5 = {
  496. data: {
  497. key: {
  498. name: "F_ZXZName"
  499. },
  500. simpleData: {
  501. enable: true,
  502. idKey: "F_ZXZID",
  503. rootPId: 0
  504. }
  505. },
  506. callback: {
  507. onClick: chanZxz
  508. }
  509. };
  510. var chanZxid; //坐席组id
  511. var chanZxname; //坐席组name
  512. function chanZxz(event, treeId, treeNode) {
  513. chanZxid = treeNode.F_ZXZID;
  514. chanZxname = treeNode.F_ZXZName;
  515. $('.inps6').val(chanZxname);
  516. };
  517. function chanGetzx() {
  518. $.get(huayi.config.callcenter_url + "SeatGroup/GetSeatList?flag=ZXZ", {
  519. "token": $.cookie("token")
  520. }, function(result) {
  521. result = $.parseJSON(result);
  522. $.fn.zTree.init($("#xlchan_zxz"), setting5, result.data); //实例化树形图
  523. });
  524. }
  525. //zTree 大区、办事处
  526. var settingRegionalOffice1 = {
  527. data: {
  528. key: {
  529. name: "text"
  530. },
  531. simpleData: {
  532. enable: true,
  533. idKey: "id",
  534. rootPId: 0
  535. }
  536. },
  537. check: {
  538. enable: true,
  539. autoCheckTrigger: true,
  540. chkboxType: {
  541. "Y": "s",
  542. "N": "s",
  543. },
  544. chkStyle: "checkbox",
  545. },
  546. view: {
  547. dblClickExpand: true
  548. },
  549. callback: {
  550. beforeClick: beforeClick1,
  551. onCheck: onCheck1,
  552. },
  553. };
  554. function beforeClick1(treeId, treeNode) {
  555. var zTree = $.fn.zTree.getZTreeObj("selectRegionZtree1");
  556. nodes = zTree.getCheckedNodes(true);
  557. zTree.checkNode(treeNode, !treeNode.checked, null, true);
  558. return false;
  559. }
  560. function onCheck1(e, treeId, treeNode) {
  561. var zTree = $.fn.zTree.getZTreeObj("selectRegionZtree1");
  562. nodes = zTree.getCheckedNodes(true);
  563. var regionName = "", regionId = "", officeId = "";
  564. for (var i=0, l=nodes.length; i<l; i++) {
  565. regionName += nodes[i].text + ",";
  566. if(nodes[i].level === 1) {
  567. regionId += nodes[i].id + ","
  568. } else if (nodes[i].level === 2) {
  569. officeId += nodes[i].id + ","
  570. }
  571. }
  572. if (regionName.length > 0 ) {
  573. regionName = regionName.substring(0, regionName.length-1);
  574. $("#searchRegionName1").val(regionName);
  575. } else {
  576. $("#searchRegionName1").val(regionName);
  577. }
  578. if (officeId.length > 0 ) {
  579. $('#searchRegionId1').attr("value", "1");
  580. officeId = officeId.substring(0, officeId.length-1);
  581. $('#searchOfficeId1').attr("value",officeId);
  582. } else {
  583. $('#searchRegionId1').attr("value", "");
  584. $('#searchOfficeId1').attr("value",officeId);
  585. }
  586. }
  587. function addRegion1() {
  588. $.get(huayi.config.callcenter_url + "Department/GetDepartmentList", {
  589. "token": $.cookie("token"),
  590. }, function(result) {
  591. result = $.parseJSON(result);
  592. $.fn.zTree.init($("#selectRegionZtree1"), settingRegionalOffice1, result.data); //实例化树形图
  593. var zTree = $.fn.zTree.getZTreeObj("selectRegionZtree1");
  594. var treeNode = zTree.getNodes()[0];
  595. var menuIds = $('#searchOfficeId1').val().split(',');
  596. for(var i = 0; i < treeNode.children.length; i++) {
  597. for(var n = 0; n < treeNode.children[i].children.length; n++) {
  598. for(var j = 0; j < menuIds.length; j++) {
  599. if(treeNode.children[i].children[n].id == menuIds[j])
  600. treeNode.children[i].children[n].checked = true
  601. zTree.updateNode(treeNode.children[i].children[n]);
  602. }
  603. }
  604. }
  605. });
  606. }
  607. //获取用户信息
  608. function getYG(chan_uc, ygbh) {
  609. $.ajax({
  610. type: "get",
  611. url: huayi.config.callcenter_url + "UserAccount/GetUser",
  612. async: true,
  613. dataType: 'json',
  614. data: {
  615. token: token,
  616. usercode: ygbh,
  617. userid: chan_uc
  618. },
  619. success: function(data) {
  620. if(data.state.toLowerCase() == "success") {
  621. var ygcon = data.data;
  622. console.log(ygcon.F_ExtensionNumber);
  623. $('.change_ygName').val(ygcon.F_UserName); //员工姓名
  624. $('.change_ygCode').val(ygcon.F_WorkNumber); //员工工号
  625. $('.changeModel .xlChan_four ul li').each(function(i, n) {
  626. if($(n).attr("data-id") == ygcon.F_RoleId) {
  627. $('.inps4').val($(n).text()); //所属角色
  628. var idd = ygcon.F_RoleId;
  629. $('.inps4').attr('data_id', idd);
  630. }
  631. })
  632. $('.inps5').val(ygcon.depname); //所属部门
  633. $('.inps5').attr('data_id', ygcon.F_DeptId);
  634. $('.change_hwb input[name="huwu"][value="' + ygcon.F_SeatFlag + '"]').prop("checked", "checked"); //话务标志
  635. $('.change_zxqx input[name="zxqx"][value="' + ygcon.F_SeatRight + '"]').prop("checked", "checked"); //坐席权限
  636. $('.change_zxlx input[name="call"][value="' + ygcon.F_HJType + '"]').prop("checked", "checked"); //坐席类型
  637. $('.changeSex input[name="sex"][value="' + ygcon.F_SexFlag + '"]').prop("checked", "checked"); //性别
  638. $('.inps6').val(ygcon.F_SeatGroup); //坐席组
  639. $('.inps6').attr('data_id', ygcon.F_GroupId);
  640. $('.change_fenji').val(ygcon.F_ExtensionNumber); //分机号
  641. //$('.change_wxno').val(ygcon.F_WXNo);//外呼显示号码
  642. $('#chan_ygbirth').val(ygcon.F_Birthday); //生日
  643. $('.change_telphone').val(ygcon.F_Telephone); //电话
  644. $('.change_mobile').val(ygcon.F_Mobile); //手机
  645. $('.change_post').val(ygcon.F_Post); //备注
  646. $('.change_remark').val(ygcon.F_Remark); //备注
  647. $('#searchRegionId1').val(ygcon.F_SeatLevel);
  648. $('#searchOfficeId1').val(ygcon.F_DeptCode);
  649. $('#searchRegionName1').val(ygcon.F_DeptName);
  650. }
  651. }
  652. });
  653. }
  654. //关闭按钮
  655. $('.changeBtr').click(function() {
  656. $('.changeModel').css('display', 'none');
  657. })
  658. chan_jsid = $('.inps4').attr('data_id'); //角色ID
  659. chanDid = $('.inps5').attr('data_id'); //部门id
  660. chanZxid = $('.inps6').attr('data_id'); //坐席组id
  661. //保存按钮
  662. $('.changeCun').click(function() {
  663. $('.changeModel').css('display', 'none');
  664. if ($(".inps6").val() === ""){
  665. chanZxid = 0;
  666. }
  667. chan_tj(token, chanDid, chan_jsid, chan_uc, pwd, ygbh, chanZxid);
  668. })
  669. function chan_tj(token, chanDid, chan_jsid, chan_uc, pwd, ygbh, chanZxid) {
  670. $.ajax({
  671. type: "post",
  672. url: huayi.config.callcenter_url + "UserAccount/EditUsers",
  673. async: true,
  674. dataType: 'json',
  675. data: {
  676. token: token,
  677. userid: chan_uc,
  678. usercode: $('.change_ygCode').val(),
  679. username: $('.change_ygName').val(),
  680. password: pwd,
  681. extno: $('.change_fenji').val(),
  682. //wxno:$('.change_wxno').val(),
  683. worknumber: ygbh,
  684. deptid: chanDid,
  685. roleid: chan_jsid,
  686. groupid: chanZxid,
  687. isseat: $('.change_hwb input[name="huwu"]:checked ').val(),
  688. searright: $('.change_zxqx input[name="zxqx"]:checked ').val(),
  689. sex: $('.changeSex input[name="sex"]:checked ').val(),
  690. mobile: $('.change_mobile').val(),
  691. telphone: $('.change_telphone').val(),
  692. birth: $('#chan_ygbirth').val(),
  693. hjtype: $('.change_zxlx input[name="call"]:checked ').val(),
  694. Post: $('.change_post').val(),
  695. remark: $('.change_remark').val(),
  696. level: $('#searchRegionId1').val(),
  697. deptcode: $('#searchOfficeId1').val(),
  698. },
  699. success: function(data) {
  700. if(data.state.toLowerCase() == "success") {
  701. layer.msg("修改成功!");
  702. initTable(token, id, keyWord);
  703. Clean();
  704. }
  705. }
  706. });
  707. }
  708. //***********************修改功能结束==============================
  709. //=======================重设功能开始==============================
  710. $('.again').click(function() {
  711. if(ygbh) {
  712. $('.againModel').css('display', 'block');
  713. $('.again_ygName').val(yhname)
  714. $('.again_ygCode').val(yhgh)
  715. } else {
  716. layer.confirm('请选择要重设密码的用户!', {
  717. btn: ['确定']
  718. });
  719. return;
  720. }
  721. })
  722. //关闭按钮
  723. $('.agBtr').click(function() {
  724. $('.againModel').css('display', 'none');
  725. })
  726. //确定按钮
  727. $('.again_Cun').click(function() {
  728. if($('.again_pwd').val() !== $('.again_pwd2').val()) {
  729. layer.confirm('密码不一致,请重新输入!', {
  730. btn: ['确定']
  731. });
  732. return;
  733. // $('.again_pwd').val('');
  734. $('.again_pwd2').val('');
  735. } else {
  736. $('.againModel').css('display', 'none');
  737. cs(ygbh); //重设密码
  738. }
  739. })
  740. function cs(ygbh) {
  741. $.ajax({
  742. type: "post",
  743. url: huayi.config.callcenter_url + "UserAccount/ResetPwd",
  744. async: true,
  745. dataType: 'json',
  746. data: {
  747. token: token,
  748. usercode: ygbh,
  749. pwd: $('.again_pwd').val()
  750. },
  751. success: function(data) {
  752. if(data.state.toLowerCase() == "success") {
  753. layer.msg("重设密码成功!");
  754. initTable(token, id, keyWord);
  755. Clean();
  756. }
  757. }
  758. });
  759. }
  760. //***********************重设功能结束==============================
  761. var state;
  762. //=======================禁用功能开始==============================
  763. $('.ban').click(function() {
  764. if(buMenId) {
  765. $('.banModel').css('display', 'block');
  766. } else {
  767. layer.confirm('请选择要禁用的用户!', {
  768. btn: ['确定']
  769. });
  770. return;
  771. }
  772. })
  773. //关闭按钮
  774. $('.banBtr').click(function() {
  775. $('.banModel').css('display', 'none');
  776. })
  777. //取消按钮
  778. $('.banReturn').click(function() {
  779. $('.banModel').css('display', 'none');
  780. })
  781. //确定按钮
  782. $('.banSure').click(function() {
  783. $('.banModel').css('display', 'none');
  784. state = 1;
  785. console.log(state);
  786. bu(chan_uc, state);
  787. })
  788. function bu(chan_uc, state) {
  789. $.ajax({
  790. type: "post",
  791. url: huayi.config.callcenter_url + "UserAccount/DelUsers",
  792. async: true,
  793. dataType: 'json',
  794. data: {
  795. token: token,
  796. ids: chan_uc,
  797. state: state
  798. },
  799. success: function(data) {
  800. if(data.state.toLowerCase() == "success") {
  801. initTable(token, id, keyWord);
  802. Clean();
  803. }
  804. }
  805. });
  806. }
  807. //***********************禁用功能结束==============================
  808. //=======================启用功能开始==============================
  809. $('.using').click(function() {
  810. if(buMenId) {
  811. $('.useModel').css('display', 'block');
  812. } else {
  813. layer.confirm('请选择要启用的用户!', {
  814. btn: ['确定']
  815. });
  816. return;
  817. }
  818. })
  819. //关闭按钮
  820. $('.useBtr').click(function() {
  821. $('.useModel').css('display', 'none');
  822. })
  823. //取消按钮
  824. $('.useReturn').click(function() {
  825. $('.useModel').css('display', 'none');
  826. })
  827. //确定按钮
  828. $('.useSure').click(function() {
  829. state = 0;
  830. console.log(state);
  831. $('.useModel').css('display', 'none');
  832. bu(chan_uc, state);
  833. })
  834. //***********************启用功能结束==============================
  835. //右边表格
  836. initTable(token, id, keyWord);
  837. function initTable(token, id, keyWord) {
  838. //先销毁表格
  839. table.bootstrapTable('destroy');
  840. //初始化表格,动态从服务器加载数据
  841. table.bootstrapTable({
  842. method: "get", //使用get请求到服务器获取数据
  843. url: huayi.config.callcenter_url + "UserAccount/GetList", //获取数据的Servlet地址
  844. contentType: 'application/x-www-form-urlencoded',
  845. striped: true, //表格显示条纹
  846. pagination: true, //启动分页
  847. pageSize: 10, //每页显示的记录数
  848. pageNumber: 1, //当前第几页
  849. pageList: [10, 15, 20, 30, 50, 100], //记录数可选列表
  850. search: false, //是否启用查询
  851. showColumns: false, //显示下拉框勾选要显示的列
  852. showRefresh: false, //显示刷新按钮
  853. sidePagination: "server", //表示服务端请求
  854. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  855. //设置为limit可以获取limit, offset, search, sort, order
  856. queryParamsType: "undefined",
  857. queryParams: function queryParams(params) { //设置查询参数
  858. var param = {
  859. pageindex: params.pageNumber,
  860. pagesize: params.pageSize,
  861. token: token,
  862. dptid: id,
  863. key: keyWord.replace(/\ +/g,"")
  864. };
  865. // 导出参数
  866. exportParams = param;
  867. return param;
  868. },
  869. onLoadSuccess: function() { //加载成功时执行
  870. //layer.msg("加载成功");
  871. },
  872. onLoadError: function() { //加载失败时执行
  873. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  874. }
  875. });
  876. }
  877. /*选中行添加背景颜色*/
  878. var ygbh, chan_uc, pwd, buMenId, yhname, yhgh;
  879. table.on("click-row.bs.table", function(e, row, ele) {
  880. $('.success').removeClass('success'); //去除之前选中的行的,选中样式
  881. $(ele).addClass('success'); //添加当前选中的 success样式用于区别
  882. ygbh = row.F_UserCode; //用户编号
  883. chan_uc = row.F_UserId; //用户id
  884. pwd = row.F_Password; //密码
  885. buMenId = row.F_DeptId; //部门id
  886. yhname = row.F_UserName; //用户name
  887. yhgh = row.F_WorkNumber; //用户工号
  888. // alert(chan_uc)
  889. });
  890. function setCode(val, row, index) {
  891. return index + 1;
  892. }
  893. function setZuoType(val) {
  894. var str = '';
  895. switch(val + '') {
  896. case '0':
  897. str = "呼入组";
  898. break;
  899. case '1':
  900. str = "呼出组";
  901. break;
  902. }
  903. return str;
  904. }
  905. function setYongState(val) {
  906. var str = '';
  907. switch(val + '') {
  908. case '0':
  909. str = "正常";
  910. break;
  911. case '1':
  912. str = "禁用";
  913. break;
  914. }
  915. return str;
  916. }
  917. document.onkeydown = function (e) { // 回车提交表单
  918. var theEvent = window.event || e;
  919. var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
  920. if (code == 13) {
  921. keyWord = $('.searCon').val();
  922. initTable(token, id, keyWord);
  923. }
  924. }