説明なし

yongHuManger.js 24KB

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