暂无描述

proManagement.js 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /**
  2. * 项目管理
  3. * */
  4. var stateVal = ''; //1即将到期
  5. $(function() {
  6. $('.tool_bars').authorizeButton();
  7. laydate.render({
  8. elem: '#sc_times',
  9. range: '~',
  10. theme: '#249fea',
  11. });
  12. initTable();
  13. //搜索
  14. $("#sc_btns").click(function() {
  15. initTable();
  16. });
  17. $('#sc_statebtn').find('input[type="radio"]').on('change', function() {
  18. stateVal = $(this).val();
  19. initTable();
  20. });
  21. });
  22. function initTable() {
  23. //先销毁表格
  24. $('#table_all').bootstrapTable('destroy');
  25. //初始化表格,动态从服务器加载数据
  26. $('#table_all').bootstrapTable({
  27. method: "get", //使用get请求到服务器获取数据
  28. url: huayi.config.callcenter_url + "equipmentapi/api/ProjectInfo/getlistsbypage", //获取数据的Servlet地址
  29. contentType: "application/x-www-form-urlencoded",
  30. striped: true, //表格显示条纹
  31. pagination: true, //启动分页
  32. pageSize: 10, //每页显示的记录数
  33. pageNumber: 1, //当前第几页
  34. pageList: [10, 20, 50, 100], //记录数可选列表
  35. search: false, //是否启用查询
  36. showColumns: false, //显示下拉框勾选要显示的列
  37. showRefresh: false, //显示刷新按钮
  38. sidePagination: "server", //表示服务端请求
  39. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  40. //设置为limit可以获取limit, offset, search, sort, order
  41. queryParamsType: "undefined",
  42. queryParams: function queryParams(params) { //设置查询参数
  43. var param = {
  44. pageindex: params.pageNumber,
  45. pagesize: params.pageSize,
  46. isdq: stateVal, //否 int 1即将到期
  47. keyword: $('#sc_keyWords').val(), // 项目名称,项目类型,项目负责人
  48. stime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0],
  49. etime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1],
  50. };
  51. return param;
  52. },
  53. // onPageChange: function(number, size) {
  54. // curentPage = number;
  55. // },
  56. onLoadSuccess: function(res) { //加载成功时执行
  57. //layer.msg("加载成功");
  58. if(res.state.toLowerCase() == "success") {
  59. var newData = {};
  60. newData.state = res.state;
  61. newData.message = res.message;
  62. newData.rows = res.data.rows;
  63. newData.total = res.data.total;
  64. $('#table_all').bootstrapTable('load', newData);
  65. }
  66. $('.tool_down').authorizeOperateButton();
  67. },
  68. onLoadError: function() { //加载失败时执行
  69. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  70. }
  71. });
  72. }
  73. //添加
  74. function btn_add() {
  75. layer.open({
  76. type: 2,
  77. content: "template/addOrEditPro.html", //iframe的url,no代表不显示滚动条
  78. title: '添加项目',
  79. resize: false,
  80. area: ['80%', '90%'], //宽高
  81. });
  82. }
  83. //批量删除
  84. function btn_deletes() {
  85. var ids = $.map($('#table_all').bootstrapTable('getSelections'),
  86. function(row) {
  87. return row.id;
  88. });
  89. /*判断长度*/
  90. if(ids.length <= 0) {
  91. layer.confirm('请选择要删除的选项', {
  92. icon: 7,
  93. btn: ['确定'] //按钮
  94. });
  95. return;
  96. }
  97. btn_delete(ids);
  98. }
  99. //删除
  100. function btn_delete(del_id) {
  101. /*发送请求*/
  102. layer.confirm('您确定要删除当前项目吗?', {
  103. icon: 7,
  104. btn: ['确定', '取消'],
  105. yes: function(index, layero) {
  106. $.post(huayi.config.callcenter_url + "/equipmentapi/api/ProjectInfo/delete", {
  107. ids: del_id,
  108. }, function(result) {
  109. result = JSON.parse(result);
  110. if(result.state.toLowerCase() == "success") {
  111. layer.msg("删除成功");
  112. $('#table_all').bootstrapTable('refresh');
  113. }
  114. })
  115. },
  116. });
  117. }
  118. //编辑
  119. function btn_edit(edit_id) {
  120. layer.open({
  121. type: 2,
  122. content: "template/addOrEditPro.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
  123. title: '编辑项目',
  124. resize: false,
  125. area: ['80%', '90%'], //宽高
  126. });
  127. }
  128. //查看项目详情
  129. function btn_details(edit_id) {
  130. layer.open({
  131. type: 2,
  132. content: "template/seeProDetails.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
  133. title: '查看项目详情',
  134. resize: false,
  135. area: ['80%', '90%'], //宽高
  136. });
  137. }
  138. //开启项目
  139. function btn_start(pid) {
  140. layer.confirm('您确定开启当前项目吗?', {
  141. icon: 7,
  142. btn: ['是', '否'] //按钮
  143. }, function() {
  144. /*发送请求*/
  145. $.ajax({
  146. type: "post",
  147. url: huayi.config.callcenter_url + "equipmentapi/api/ProjectInfo/start",
  148. async: true,
  149. dataType: 'json',
  150. data: {
  151. ids: pid,// 是 string[] id string[] )
  152. },
  153. success: function(data) {
  154. if(data.state.toLowerCase() == 'success') {
  155. layer.msg("当前项目开启成功!");
  156. $('#table_all').bootstrapTable('refresh');
  157. }
  158. }
  159. });
  160. });
  161. }
  162. //终止项目
  163. function btn_end(pid) {
  164. layer.confirm('您确定终止当前项目吗?', {
  165. icon: 7,
  166. btn: ['是', '否'] //按钮
  167. }, function() {
  168. /*发送请求*/
  169. $.ajax({
  170. type: "post",
  171. url: huayi.config.callcenter_url + "equipmentapi/api/ProjectInfo/end",
  172. async: true,
  173. dataType: 'json',
  174. data: {
  175. ids: pid,// 是 string[] id string[] )
  176. },
  177. success: function(data) {
  178. if(data.state.toLowerCase() == 'success') {
  179. layer.msg("当前项目终止成功!");
  180. $('#table_all').bootstrapTable('refresh');
  181. }
  182. }
  183. });
  184. });
  185. }
  186. //格式化操作
  187. function formatterOperate(val, row) {
  188. var str = '<div class="task_tools" onclick = helper.methods.taskTools(this)>' +
  189. '<a title="操作"><i class="fa fa-cogs" aria-hidden="true"></i></a>' +
  190. '<ul class="tool_down">' +
  191. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id + '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  192. '<li><a class="aBtn" authorize="yes" id="HY_edit_' + row.id + '" onclick="btn_edit(\'' + row.id + '\')"><i class="fa icon-edit tub"></i>编辑</a><li>'
  193. if(row.isend === 0){//续约
  194. str += '<li><a class="aBtn" authorize="yes" id="HY_end_' + row.id + '" onclick="btn_end(\'' + row.id + '\')"><i class="glyphicon glyphicon-pause tub"></i>终止</a><li>'
  195. }else{
  196. str += '<li><a class="aBtn" authorize="yes" id="HY_start_' + row.id + '" onclick="btn_start(\'' + row.id + '\')"><i class="glyphicon glyphicon-play tub"></i>开启</a><li>'
  197. }
  198. str += '<li><a class="aBtn" authorize="yes" id="HY_import_' + row.id + '" onclick="btn_import(\'' + row.id + '\')"><i class="fa icon-import tub"></i>导入通讯录</a><li>' +
  199. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id + '\')"><i class="fa icon-delete tub"></i>删除</a><li>' +
  200. '</ul></div>';
  201. return str;
  202. }
  203. //格式化项目状态
  204. function formatterProSate(val, row){
  205. //终止 ,续约
  206. var stateClass, stateName;
  207. switch(val) {
  208. case 1:
  209. stateClass = 'state_audit_refuse';
  210. stateName = '终止';
  211. break;
  212. case 0:
  213. stateClass = 'state_audit_done';
  214. stateName = '续约';
  215. break;
  216. default:
  217. stateClass = 'text-block';
  218. stateName = '-';
  219. break;
  220. }
  221. return '<a class="state_audit ' + stateClass + '" href="javascript:;">' + stateName + '</a>';
  222. }
  223. //导入通讯录
  224. function btn_import(pro_id) {
  225. layer.open({
  226. maxmin: true, //开启最大化最小化按钮
  227. type: 2,
  228. content: "template/importProMailList.html?pro_id=" + pro_id, //iframe的url,no代表不显示滚动条
  229. title: '导入项目通讯录',
  230. area: ['50%', '55%'], //宽高
  231. });
  232. }
  233. //结束时间 超期变红
  234. function formatterEndTime(val, row) {
  235. if(val) {
  236. var d = val.replace(/-/g, "/");
  237. var curDate = helper.DateFormat.getNowDateTime();
  238. curDate = curDate.replace(/-/g, "/");
  239. var str = '';
  240. if(Date.parse(d) >= Date.parse(curDate)) {
  241. str = '<div>' + val + '</div>';
  242. } else {
  243. str = '<div style="color:red;">' + val + '</div>';
  244. }
  245. return str
  246. }
  247. }