Нет описания

grantAuthorization.js 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /**
  2. * IVR配置管理
  3. * */
  4. $(function() {
  5. $('.tool_bars').authorizeButton();
  6. //系统名称
  7. //helper.getDropList.getlistDropByDic($('#sc_sysname'), 'XTMC');
  8. //项目下拉
  9. helper.getDropList.getProlistDrop($('#sc_pro'));
  10. laydate.render({
  11. elem: '#sc_times',
  12. range: '~',
  13. theme: '#249fea',
  14. });
  15. initTable();
  16. //搜索
  17. $("#sc_btns").click(function() {
  18. initTable();
  19. })
  20. });
  21. function initTable() {
  22. //先销毁表格
  23. $('#table_all').bootstrapTable('destroy');
  24. //初始化表格,动态从服务器加载数据
  25. $('#table_all').bootstrapTable({
  26. method: "get", //使用get请求到服务器获取数据
  27. url: huayi.config.callcenter_url + "configurationapi/api/AuthorizationU3D/getlistsbypage", //获取数据的Servlet地址
  28. contentType: "application/x-www-form-urlencoded",
  29. striped: true, //表格显示条纹
  30. pagination: true, //启动分页
  31. pageSize: 10, //每页显示的记录数
  32. pageNumber: 1, //当前第几页
  33. pageList: [10, 20, 50, 100], //记录数可选列表
  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. pageindex: params.pageNumber, //否 int 页码
  44. pagesize: params.pageSize, //否 int 条数
  45. projectid: $('#sc_pro').val(), //计划名称
  46. isopen: $('#sc_isopen').val(),//启用状态
  47. keyword: $('#keyword').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. responseHandler: function(res) {
  54. //格式化数据
  55. return {
  56. "total": res.data && res.data.total, //总页数
  57. "rows": res.data && res.data.rows,
  58. }
  59. },
  60. onLoadSuccess: function(res) { //加载成功时执行
  61. //layer.msg("加载成功");
  62. $('.tool_down').authorizeOperateButton();
  63. },
  64. onLoadError: function() { //加载失败时执行
  65. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  66. }
  67. });
  68. }
  69. //查看项目详情
  70. function btn_details(edit_id) {
  71. layer.open({
  72. type: 2,
  73. content: "template/seeIvrDetail.html?ids=" + edit_id, //iframe的url,no代表不显示滚动条
  74. title: '查看IVR详情信息',
  75. resize: false,
  76. area: ['80%', '90%'], //宽高
  77. });
  78. }
  79. //添加
  80. function btn_add() {
  81. layer.open({
  82. type: 2,
  83. content: "template/addgrantAuthorization.html", //iframe的url,no代表不显示滚动条
  84. title: '添加授权验证',
  85. resize: false,
  86. area: ['80%', '90%'], //宽高
  87. });
  88. }
  89. //编辑
  90. function btn_edit(edit_id,proid,dates,remarks) {
  91. layer.open({
  92. type: 2,
  93. content: "template/addgrantAuthorization.html?edit_id=" + edit_id+"&proid="+proid+"&dates="+dates+"&remark="+escape(remarks), //iframe的url,no代表不显示滚动条
  94. title: '编辑授权验证',
  95. resize: false,
  96. area: ['80%', '90%'], //宽高
  97. });
  98. }
  99. //批量删除
  100. function btn_deletes() {
  101. var ids = $.map($('#table_all').bootstrapTable('getSelections'),
  102. function(row) {
  103. return row.authorizationcode;
  104. });
  105. /*判断长度*/
  106. if(ids.length <= 0) {
  107. layer.confirm('请选择要删除的选项', {
  108. icon: 7,
  109. btn: ['确定'] //按钮
  110. });
  111. return;
  112. }
  113. btn_delete(ids);
  114. }
  115. //删除
  116. function btn_delete(del_id) {
  117. layer.confirm('您确定要删除当前选中项吗?', {
  118. icon: 7,
  119. btn: ['确定', '取消'],
  120. yes: function(index, layero) {
  121. $.post(huayi.config.callcenter_url + "configurationapi/api/AuthorizationU3D/delete", {
  122. ids: del_id,
  123. }, function(result) {
  124. result = JSON.parse(result);
  125. if(result.state.toLowerCase() == "success") {
  126. layer.msg("删除成功");
  127. $('#table_all').bootstrapTable('refresh');
  128. }
  129. })
  130. },
  131. });
  132. }
  133. //启用
  134. function btn_on(on_id){
  135. layer.confirm('您确定要启用当前选中项吗?', {
  136. icon: 7,
  137. btn: ['确定', '取消'],
  138. yes: function(index, layero) {
  139. $.post(huayi.config.callcenter_url + "configurationapi/api/AuthorizationU3D/open", {
  140. authorizationcode: on_id,
  141. }, function(result) {
  142. result = JSON.parse(result);
  143. if(result.state.toLowerCase() == "success") {
  144. layer.msg("启用成功!");
  145. $('#table_all').bootstrapTable('refresh');
  146. }
  147. })
  148. },
  149. });
  150. }
  151. //禁用
  152. function btn_off(on_id){
  153. layer.confirm('您确定要禁用当前选中项吗?', {
  154. icon: 7,
  155. btn: ['确定', '取消'],
  156. yes: function(index, layero) {
  157. $.post(huayi.config.callcenter_url + "configurationapi/api/AuthorizationU3D/close", {
  158. authorizationcode: on_id,
  159. isenable:0
  160. }, function(result) {
  161. result = JSON.parse(result);
  162. if(result.state.toLowerCase() == "success") {
  163. layer.msg("禁用成功!");
  164. $('#table_all').bootstrapTable('refresh');
  165. }
  166. })
  167. },
  168. });
  169. }
  170. //格式化操作
  171. function formatterOperate(val, row) {
  172. var str = '<div class="task_tools" onclick = helper.methods.taskTools(this)>' +
  173. '<a title="操作"><i class="fa fa-cogs" aria-hidden="true"></i></a>' +
  174. '<ul class="tool_down">' +
  175. // '<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>' +
  176. '<li><a class="aBtn" authorize="yes" id="HY_edit_' + row.id + '" onclick="btn_edit(\'' + row.authorizationcode + '\',\'' + row.projectid + '\',\'' + formatterSdate(row.duedate)+ '\',\'' + row.remark + '\')"><i class="fa icon-edit tub"></i>编辑</a><li>' +
  177. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.authorizationcode + '\')"><i class="fa icon-delete tub"></i>删除</a><li>'
  178. if(val==0){
  179. str +='<li><a class="aBtn" authorize="yes" id="HY_on_' + row.id + '" onclick="btn_on(\'' + row.authorizationcode + '\')"><i class="glyphicon glyphicon-play tub"></i>启用</a><li>'
  180. }else{
  181. str +='<li><a class="aBtn" authorize="yes" id="HY_off_' + row.id + '" onclick="btn_off(\'' + row.authorizationcode + '\')"><i class="glyphicon glyphicon-pause tub"></i>禁用</a><li>'
  182. }
  183. str += '</ul></div>'
  184. return str;
  185. }
  186. //格式化备注内容
  187. function formatterContent(val, row) {
  188. if(val) {
  189. var codeContent = decodeURIComponent(val);
  190. var str = '<div '
  191. if(codeContent.length > 10) {
  192. codeContent = codeContent.substr(0, 10) + "...";
  193. str = str + ' title="' + codeContent + '" ';
  194. }
  195. return str + '>' + codeContent + '</div>';
  196. } else {
  197. return '-';
  198. }
  199. }
  200. //格式化是否启用
  201. function formatterIsenable(val, row) {
  202. //是否启用(呼入流程默认开启)0不启用,1启用
  203. var str="";
  204. if(val==0){
  205. str="禁用";
  206. }else{
  207. str="启用";
  208. }
  209. return str
  210. }
  211. //格式化开始日期
  212. function formatterSdate(val, row) {
  213. return val && val.split(' ')[0];
  214. }
  215. //结束时间 超期变红
  216. function formatterEndTime(val, row) {
  217. if(val){
  218. val=val && val.split(' ')[0]
  219. var str="";
  220. if(row.duedate_day <0){
  221. str = '<div style="color:red;">' + val + '</div>';
  222. }else{
  223. str = '<div style="color:darkgreen;">' + val + '</div>';
  224. }
  225. return str
  226. } else{
  227. return "-";
  228. }
  229. // if(val) {
  230. // var d = val.replace(/-/g, "/");
  231. // var curDate = helper.DateFormat.getNowDateTime();
  232. // curDate = curDate.replace(/-/g, "/");
  233. // var str = '';
  234. // if(Date.parse(d) >= Date.parse(curDate)) {
  235. // str = '<div>' + val.split(' ')[0] + '</div>';
  236. // } else {
  237. // str = '<div style="color:red;">' + val.split(' ')[0] + '</div>';
  238. // }
  239. // return str
  240. // } else {
  241. // return "-";
  242. // }
  243. }
  244. function formatterDuedate(val, row){
  245. var str="";
  246. if(val <0){
  247. str = '<div style="color:red;">' + val + '</div>';
  248. }else{
  249. str = '<div style="color:darkgreen;">' + val + '</div>';
  250. }
  251. return str
  252. }
  253. //项目信息
  254. function GetEquipName(obj) {
  255. obj.empty();
  256. obj.append('<option selected="selected" value="">请选择项目名称</option>');
  257. $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/ProjectInfo/getlistdrop", function(data) {
  258. if(data.state.toLowerCase() == "success") {
  259. var content = data.data;
  260. $(content).each(function(i, n) {
  261. $("<option value='" + n.id + "'>" + n.text + "</option>").appendTo(obj);
  262. })
  263. obj.selectpicker('refresh');
  264. obj.trigger('change');
  265. }
  266. })
  267. }