暂无描述

newRepository.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. var mySwiper = new Swiper ('.swiper-container', {
  2. // direction: 'vertical',
  3. // loop: true,
  4. // 如果需要分页器
  5. pagination: {
  6. el: '.swiper-pagination',
  7. clickable: true,
  8. },
  9. })
  10. var token = $.cookie("token");
  11. var table = $('#table1');
  12. $('#depID').val(0);
  13. $(document).ready(function(){
  14. // $('#firstOne').trigger("click");
  15. //右侧搜索事件
  16. bindtree();
  17. initTable($('#depID').val());
  18. $('#rightSearch').click(function(){
  19. initTable($('#depID').val());
  20. })
  21. function initTable(ids) {
  22. //先销毁表格
  23. table.bootstrapTable('destroy');
  24. //初始化表格,动态从服务器加载数据
  25. table.bootstrapTable({
  26. method: "get", //使用get请求到服务器获取数据
  27. url: huayi.config.callcenter_url + "Repository/GetList", //获取数据的Servlet地址
  28. contentType: "application/x-www-form-urlencoded", striped: true,
  29. striped: true, //表格显示条纹
  30. pagination: true, //启动分页
  31. pageSize: 10, //每页显示的记录数
  32. pageNumber: 1, //当前第几页
  33. pageList: [10, 15, 25], //记录数可选列表
  34. search: false, //是否启用查询
  35. showColumns: false, //显示下拉框勾选要显示的列
  36. showRefresh: false, //显示刷新按钮
  37. sidePagination: "server", //表示服务端请求
  38. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  39. //设置为limit可以获取limit, offset, search, sort, order
  40. queryParamsType: "undefined",
  41. queryParams: function queryParams(params) { //设置查询参数
  42. var param = {
  43. page: params.pageNumber,
  44. pagesize: params.pageSize,
  45. token: token,
  46. deptid:ids,
  47. type:1,
  48. key:$('.rightSearchKey').val(),
  49. // starttime: 否 string 开始时间 (2017-01-09)
  50. // endtime:
  51. };
  52. return param;
  53. },
  54. onLoadSuccess: function () { //加载成功时执行
  55. //layer.msg("加载成功");
  56. },
  57. onLoadError: function () { //加载失败时执行
  58. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  59. }
  60. });
  61. }
  62. function bindtree() {
  63. $.getJSON(huayi.config.callcenter_url + "Department/GetDeptList", { "token": $.cookie("token") }, function (result) {
  64. if (result.state.toLowerCase() == "success") {
  65. tree = $.fn.zTree.init($("#treeDemo"), setting1, result.data);
  66. }
  67. })
  68. }
  69. //获取所属部门
  70. var setting1 = {
  71. data: {
  72. key: {
  73. name: "F_DeptName"
  74. },
  75. simpleData: {
  76. enable: true,
  77. idKey: "F_DeptId",
  78. pIdKey: "F_PartentId",
  79. rootPId: 0
  80. }
  81. },
  82. callback: {
  83. onClick: zTreeOnClick
  84. }
  85. };
  86. function zTreeOnClick(event, treeId, treeNode) {
  87. $('#urgent').css('color','red');
  88. $('#policies').css('color','red');
  89. $('.polices').css('display','none');
  90. $('.addTo').css('display','block');
  91. $('.mechanism').css('visibility','visible');
  92. var depId=treeNode.F_DeptId;
  93. $('#depID').val(depId);
  94. $.getJSON(huayi.config.callcenter_url + "Department/GetDept", { id:depId,"token": $.cookie("token") }, function (result) {
  95. if (result.state.toLowerCase() == "success") {
  96. $('#mechanism').val(result.data.F_Remark);
  97. }
  98. })
  99. initTable(depId);
  100. };
  101. // if($('.allAdd').hasClass('active')){
  102. // $('.addTo').hide();
  103. // }else{
  104. // $('.addTo').show();
  105. // }
  106. $('.unitList li').click(function(){
  107. $('.unitList li').removeClass('active')
  108. $(this).addClass('active');
  109. if($('.allAdd').hasClass('active')){
  110. $('.addTo').hide();
  111. }else{
  112. $('.addTo').show();
  113. }
  114. var depId=$(this).attr('data-id');
  115. var keyWord=$(this).find('div').html();
  116. $('.rightTabKey').html(keyWord);
  117. $('#depID').val(depId);
  118. initTable(depId);
  119. })
  120. //左侧单位鼠标移入效果
  121. $('.unitList li').hover(function(){
  122. $(this).addClass('acs');
  123. },function(){
  124. $(this).removeClass('acs');
  125. })
  126. //右侧关键字鼠标移入效果
  127. $('.keyList li').hover(function(){
  128. $('.keyList li').removeClass('active')
  129. $(this).addClass('active');
  130. },function(){
  131. $(this).removeClass('active');
  132. })
  133. $('.addTo').click(function(){
  134. var depid = $('#depID').val();
  135. if(!depid||depid==0){
  136. layer.msg('请选择一个承办单位');
  137. return;
  138. }
  139. goAdd(depid)
  140. })
  141. //紧急事件添加
  142. $('#urgent').click(function(){
  143. $('#depID').val('99999');
  144. $('.mechanism').css('visibility','hidden');
  145. $('.polices').css('display','none');
  146. $('.addTo').css('display','block');
  147. $('#policies').css('color','red');
  148. $('#urgent').css('color','#048aad');
  149. $('#mechanism').val('');
  150. initTable($('#depID').val());
  151. })
  152. //政策法规添加
  153. $('#policies').click(function(){
  154. $('#depID').val('100000');
  155. $('.mechanism').css('visibility','hidden');
  156. $('.polices').css('display','block');
  157. $('.addTo').css('display','none');
  158. $('#urgent').css('color','red');
  159. $('#policies').css('color','#048aad');
  160. $('#mechanism').val('');
  161. initTable($('#depID').val());
  162. })
  163. $('.polices').click(function(){
  164. var depid=$('#depID').val();
  165. policesAdd(depid)
  166. })
  167. //机构职能保存
  168. $('.btn_save').click(function(){
  169. if($('#depID').val()==0||$('#depID').val()==99999||$('#depID').val()==100000){
  170. layer.msg('请选择一个承办单位');
  171. return;
  172. }
  173. $.ajax({
  174. type: "post",
  175. url: huayi.config.callcenter_url + "Department/UpdateDeptRemark",
  176. async: true,
  177. dataType: 'json',
  178. data: {
  179. token: $.cookie("token"),
  180. id: $('#depID').val(),
  181. remark:$('#mechanism').val(),
  182. },
  183. success: function(data) {
  184. if(data.state.toLowerCase() == 'success') {
  185. layer.msg("保存成功!");
  186. // location=location
  187. }
  188. }
  189. });
  190. })
  191. function policesAdd(ids){
  192. //iframe窗
  193. layer.open({
  194. type: 2,
  195. title: '新增知识库',
  196. area: ['70%', '60%'],
  197. content: 'policesAdd.html?depId='+ ids +''
  198. });
  199. }
  200. function goAdd(ids){
  201. //iframe窗
  202. layer.open({
  203. type: 2,
  204. title: '新增知识库',
  205. area: ['70%', '60%'],
  206. content: 'newRepositoryAdd.html?depId='+ ids +''
  207. });
  208. }
  209. })
  210. //操作
  211. function CZ(val,row){
  212. var Rows = row.Buttons;
  213. var html = '';
  214. for (var i = 0; i < Rows.length; i++) {
  215. var html1 = huayi.config.kapArr[Rows[i].key * 1 - 1];
  216. if (html1) {
  217. html1 = html1.replace("data", row.F_Id);
  218. html1 = html1.replace("data_id", row.F_DeptId);
  219. }
  220. html += html1;
  221. }
  222. return html;
  223. }
  224. //详情
  225. function goDetail(ids,DeptId){
  226. if(DeptId==100000){
  227. layer.open({
  228. type: 2,
  229. title: '查看知识库详情',
  230. area: ['70%', '60%'],
  231. maxmin:true,
  232. content: 'policiesDetails.html?ids='+ ids
  233. });
  234. }else{
  235. //iframe窗
  236. layer.open({
  237. type: 2,
  238. title: '查看知识库详情',
  239. area: ['70%', '60%'],
  240. maxmin:true,
  241. content: 'newRepositoryDetail.html?ids='+ ids+'&&DeptId='+DeptId
  242. });
  243. }
  244. }
  245. //解决
  246. function solve(id) {
  247. var laye = layer.confirm('确定解决?', {
  248. btn: ['确定', '取消'] //可以无限个按钮
  249. }, function() {
  250. //按钮【按钮一】的回调
  251. $.ajax({
  252. type: "post",
  253. url: huayi.config.callcenter_url + "Repository/DelRepository",
  254. async: true,
  255. dataType: 'json',
  256. data: {
  257. token: $.cookie("token"),
  258. type: id
  259. },
  260. success: function(data) {
  261. if(data.state.toLowerCase() == 'success') {
  262. layer.msg("提交成功!");
  263. layer.close(laye);
  264. table.bootstrapTable('refresh');
  265. }
  266. }
  267. });
  268. }, function(index) {
  269. //按钮【按钮二】的回调
  270. layer.close(laye)
  271. });
  272. }
  273. //解决
  274. function solve(id) {
  275. var laye = layer.confirm('确定解决?', {
  276. btn: ['确定', '取消'] //可以无限个按钮
  277. }, function() {
  278. //按钮【按钮一】的回调
  279. $.ajax({
  280. type: "post",
  281. url: huayi.config.callcenter_url + "Repository/OptRep",
  282. async: true,
  283. dataType: 'json',
  284. data: {
  285. token: $.cookie("token"),
  286. repid: id,
  287. type:1
  288. },
  289. success: function(data) {
  290. if(data.state.toLowerCase() == 'success') {
  291. layer.msg("提交成功!");
  292. layer.close(laye);
  293. table.bootstrapTable('refresh');
  294. }
  295. }
  296. });
  297. }, function(index) {
  298. //按钮【按钮二】的回调
  299. layer.close(laye)
  300. });
  301. }
  302. function noSolve(id){
  303. var laye=layer.open({
  304. type: 1,
  305. shade: false,
  306. area: ['430px', '260px'],
  307. title: '请输入未解决原因', //不显示标题
  308. content:
  309. '<div style="padding-top:10px;padding-left:20px;">\n' +
  310. '</span><textarea id="result" type="text" placeholder="请输入未解决原因"></textarea>' +
  311. '</div>',
  312. cancel: function(){
  313. layer.close();
  314. },
  315. btn: ['确定','取消'],//按钮
  316. yes: function(){
  317. if(!$('#result').val()){
  318. layer.msg('请填写未解决原因!');
  319. return false;
  320. }else{
  321. $.ajax({
  322. type: "post",
  323. url: huayi.config.callcenter_url + "Repository/OptRep",
  324. async: true,
  325. dataType: 'json',
  326. data: {
  327. token: $.cookie("token"),
  328. repid: id,
  329. reason:$('#result').val(),
  330. type:2
  331. },
  332. success: function(data) {
  333. if(data.state.toLowerCase() == 'success') {
  334. layer.msg("提交成功!");
  335. layer.close(laye);
  336. table.bootstrapTable('refresh');
  337. }
  338. }
  339. });
  340. }
  341. }
  342. });
  343. }
  344. // //未解决
  345. // function noSolve(id) {
  346. // var laye = layer.confirm('确定未解决?', {
  347. // area: ['500px', '300px'],
  348. // content:
  349. // '<div>\n' +
  350. // '<span class="result_str">未解决原因:</span><textarea id="result" type="text"></textarea>' +
  351. // '</div>',
  352. // btn: ['确定', '取消'] //可以无限个按钮
  353. // }, function() {
  354. // //按钮【按钮一】的回调
  355. // if(!$('#result').val()){
  356. // layer.msg('请填写未解决原因!');
  357. // return false;
  358. // }else{
  359. // $.ajax({
  360. // type: "post",
  361. // url: huayi.config.callcenter_url + "Repository/OptRep",
  362. // async: true,
  363. // dataType: 'json',
  364. // data: {
  365. // token: $.cookie("token"),
  366. // repid: id,
  367. // reason:$('#result').val(),
  368. // type:2
  369. // },
  370. // success: function(data) {
  371. // if(data.state.toLowerCase() == 'success') {
  372. // layer.msg("提交成功!");
  373. // layer.close(laye);
  374. // table.bootstrapTable('refresh');
  375. // }
  376. // }
  377. // });
  378. // }
  379. // }, function(index) {
  380. // //按钮【按钮二】的回调
  381. // layer.close(laye)
  382. // });
  383. // }
  384. //编辑
  385. function goEdit(ids,DeptId){
  386. if(DeptId==100000){
  387. //iframe窗
  388. layer.open({
  389. type: 2,
  390. title: '编辑知识库',
  391. area: ['70%', '60%'],
  392. maxmin:true,
  393. content: 'policesAdd.html?ids='+ ids +'&depId='+$('#depID').val()
  394. });
  395. }else{
  396. //iframe窗
  397. layer.open({
  398. type: 2,
  399. title: '编辑知识库',
  400. area: ['70%', '60%'],
  401. maxmin:true,
  402. // content: 'newRepositoryAdd.html?ids='+ ids +'&depId='+$('#depID').val()
  403. content: 'newRepositoryAdd.html?ids='+ ids +'&depId='+DeptId
  404. });
  405. }
  406. }
  407. //删除
  408. function goDel(id) {
  409. var arr=[];
  410. arr.push(id);
  411. var laye = layer.confirm('您确定要删除吗?', {
  412. btn: ['确定', '取消'] //可以无限个按钮
  413. }, function() {
  414. //按钮【按钮一】的回调
  415. $.ajax({
  416. type: "post",
  417. url: huayi.config.callcenter_url + "Repository/DelRepository",
  418. async: true,
  419. dataType: 'json',
  420. data: {
  421. token: $.cookie("token"),
  422. ids: arr
  423. },
  424. success: function(data) {
  425. if(data.state.toLowerCase() == 'success') {
  426. layer.msg("删除成功!");
  427. layer.close(laye);
  428. table.bootstrapTable('refresh');
  429. }
  430. }
  431. });
  432. }, function(index) {
  433. //按钮【按钮二】的回调
  434. layer.close(laye)
  435. });
  436. }