machineManage.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>网站管理</title>
  6. <script src="../../js/min-loader-next.js"></script>
  7. </head>
  8. <body class="content">
  9. <div class="order-body">
  10. <div class="order-tiaojian back-gray">
  11. <div class="tiaojian-part1" id = "conditions">
  12. <div class="fl f12-gray4-op mt4">所选条件:</div>
  13. </div>
  14. <div class="tiaojian-part2 fr demoTable">
  15. <button class="layui-btn order-bnt1" data-type="reload" >搜索</button>
  16. <button class="layui-btn order-bnt2" data-type="reset">重置</button>
  17. <button class="layui-btn order-bnt2" id = "addMachine">新增机器</button>
  18. <a href="#" id="toggle" class="top">收起</a>
  19. </div>
  20. </div>
  21. <form class="layui-form" action="javascript:void(0)" id = "formName">
  22. <div class="order-select back-border" id="content">
  23. <div class="layui-inline">
  24. <label class="f12-gray4">时间:</label>
  25. <input readonly class="search-select" type="text" name="strDate" id ="strDate" value="" placeholder="请选择时间(区间)" />
  26. </div>
  27. <div class="layui-inline">
  28. <label class="f12-gray4">标题:</label>
  29. <input onchange = "changeSelectCon(1,this,'inp')" class="search-select" type="text" name="titleId" id ="titleId" value="" placeholder="请输入标题" />
  30. </div>
  31. <div class="layui-inline">
  32. <label class="f12-gray4">机台号:</label>
  33. <input onchange = "changeSelectCon(2,this,'qpp')" class="search-select" type="text" name="machineId" id ="machineId" value="" placeholder="请输入机台号" />
  34. </div>
  35. </div>
  36. </form>
  37. </div>
  38. <div class="shadow-content" style="margin:1.5rem;">
  39. <table id="newsManage" lay-filter="tableFilter"></table>
  40. </div>
  41. <!--操作功能-->
  42. <script type="text/html" id="barDemo">
  43. <a class="layui-btn layui-btn-xs" lay-event="equCode">二维码</a>
  44. <a class="layui-btn layui-btn-xs" lay-event="detail">查看货道</a>
  45. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  46. {{# if(d.songStatus == '00'){ }}
  47. <a class="layui-btn layui-btn-xs" lay-event="close">关闭音乐</a>
  48. {{# } }}
  49. {{# if(d.songStatus == '01'){ }}
  50. <a class="layui-btn layui-btn-xs" lay-event="open">开启音乐</a>
  51. {{# } }}
  52. </script>
  53. <script type="text/html" id="switchTwo">
  54. <div style="width:90px;height:70px">
  55. {{#
  56. if(!isEmpty(d.imgUrl)&& d.url != "null"){ }}
  57. <img src="{{ d.imgUrl}}">
  58. {{# } }}
  59. </div>
  60. </script>
  61. <script>
  62. //添加消息
  63. $(document).on('click','#addMachine', function(){
  64. openMainTabPage('201001-01', ' 新增机器', 'machineManage/addmachine.html', '', '201001', reload);
  65. });
  66. $("#toggle").click(function() {
  67. $(this).html($("#content").is(":hidden") ? "收起" + "<i class='iconfont up iconSelect_drop-down'/></i>" : "展开" +
  68. "<i class='iconfont up iconSelect_drop-down'/></i>");
  69. $("#content").slideToggle();
  70. });
  71. layui.use('laydate', function(){
  72. var laydate = layui.laydate;
  73. //日期范围
  74. laydate.render({
  75. elem: '#strDate'
  76. ,range: true
  77. ,format:'yyyyMMdd'
  78. ,done: function(value, date, endDate){
  79. changeSelectCon(0,"strDate",'date',value)
  80. }
  81. });
  82. })
  83. var table;
  84. layui.use('table', function(){
  85. table = layui.table;
  86. table.render({
  87. id : 'newsManage'
  88. ,elem: '#newsManage'
  89. ,limit:10
  90. ,url: '../MachineManageAction/queryEqumentInf' //数据接口
  91. ,method: 'post'
  92. ,where:{MINView:"JSON", token: 'sasasas'}
  93. ,page: true //开启分页
  94. ,cols: [[ //表头
  95. {type:'numbers', title: '序号',width:'5%', fixed: true, align: 'center'}
  96. ,{field: 'machineNo', title: '机台号', width:"15%", sort: true, fixed: 'left'}
  97. ,{field: 'name', title: '机器名称', width:"20%"}
  98. ,{field: 'stateDesc', title: '状态', width:"10%"}
  99. ,{field: 'payeeNo', title: '支付账号', width:"10%"}
  100. ,{field: 'equTypeDesc', title: '机器类型', width:"10%"}
  101. ,{field: 'createTime', title: '创建时间', width:"15%"}
  102. ,{field: 'operate', title: '操作', width: "15%", toolbar: '#barDemo',fixed: 'right'}
  103. ]]
  104. ,done: function(res, curr, count){
  105. //如果是异步请求数据方式,res即为你接口返回的信息。
  106. console.log(res);
  107. //得到当前页码
  108. console.log(curr);
  109. //得到数据总量
  110. console.log(count);
  111. }
  112. ,even: true //开启隔行背景
  113. });
  114. // 监听工具条(操作)
  115. table.on('tool(tableFilter)', function(obj){ //注:tool是工具条事件名,tableFilter是table原始容器的属性 lay-filter="对应的值"
  116. var data = obj.data; //获得当前行数据
  117. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
  118. var tr = obj.tr; //获得当前行 tr 的DOM对象
  119. var id = data.id;
  120. if(layEvent == 'detail'){ //查看
  121. showDetail(data);
  122. } else if(layEvent == 'close'){ //关闭音乐
  123. layer.confirm('真的要关闭音乐吗', function(index){
  124. $.request({
  125. action : '../../MachineManageAction/closeSong',
  126. data : {
  127. id : id ,//机器名
  128. status :"01"
  129. },
  130. success : function(data) {
  131. //成功后刷新
  132. var btn=$(".layui-laypage-btn")[0];
  133. btn.click();
  134. layer.alert('操作成功!', {
  135. icon: 6,
  136. title: "提示"
  137. });
  138. },
  139. error : function(data) {
  140. layer.alert('操作失败!', {
  141. icon: 5,
  142. title: "提示"
  143. });
  144. }
  145. });
  146. });
  147. }else if(layEvent == 'open'){ //开音乐
  148. layer.confirm('真的要开启音乐吗', function(index){
  149. $.request({
  150. action : '../../MachineManageAction/closeSong',
  151. data : {
  152. id : id ,//机器名
  153. status :"00"
  154. },
  155. success : function(data) {
  156. //成功后刷新
  157. var btn=$(".layui-laypage-btn")[0];
  158. btn.click();
  159. layer.alert('操作成功!', {
  160. icon: 6,
  161. title: "提示"
  162. });
  163. },
  164. error : function(data) {
  165. layer.alert('操作失败!', {
  166. icon: 5,
  167. title: "提示"
  168. });
  169. }
  170. });
  171. });
  172. }else if(layEvent == 'edit'){ //编辑
  173. editDetail(data);
  174. }else if(layEvent =='equCode'){//二维码
  175. layui.sessionData("ROW_DATA", {key:"NOW_ROW", value:data});
  176. layer.open({
  177. type: 2,
  178. title: '查看二维码',
  179. shadeClose: true,
  180. shade: 0.6,
  181. area: ['50%', '80%'],
  182. content: 'erWm.html'
  183. });
  184. }
  185. });
  186. var $ = layui.$, active = {
  187. reload: function(){
  188. reload();
  189. }
  190. ,reset: function(){
  191. $('#formName')[0].reset();
  192. $("#conditions").html('<div class="fl f12-gray4-op mt4">所选条件:</div>');
  193. }
  194. };
  195. $('.layui-btn').on('click', function(){
  196. var type = $(this).data('type');
  197. active[type] ? active[type].call(this) : '';
  198. });
  199. });
  200. function reload() {
  201. var strDate = $('#strDate').val();
  202. var titleId = $('#titleId').val();
  203. var machineId = $('#machineId').val();
  204. var paramId = '1';
  205. //执行重载
  206. table.reload('newsManage', {
  207. page: {
  208. curr: 1 //重新从第 1 页开始
  209. }
  210. ,where: {
  211. strDate : strDate,
  212. titleId : titleId,
  213. paramId : paramId,
  214. machineId : machineId
  215. }
  216. });
  217. }
  218. // function showDetail(data) {
  219. // var params = {};
  220. // params.columnNumber = 2; //每行显示两个字段
  221. // // 要显示的数据
  222. // params.fields = [
  223. // {field: 'id', title: 'ID'}
  224. // ,{field: 'title', title: '标题'}
  225. // ,{field: 'moduleDesc', title: '模块'}
  226. // ,{field: 'statusDesc', title: '状态'}
  227. // ,{field: 'createuser', title: '创建人'}
  228. // ,{field: 'createtime', title: '创建日期'}
  229. // ,{field: 'modifyuser', title: '修改人'}
  230. // ,{field: 'modifytime', title: '修改时间'}
  231. // ];
  232. // // 寄存当前数据
  233. // setNowRowData(data, params);
  234. // layer.open({
  235. // type: 2,
  236. // title: '消息详情',
  237. // shadeClose: true,
  238. // shade: 0.8,
  239. // //maxmin: true, //开启最大化最小化按钮
  240. // area: ['800px', '500px'],
  241. // content: '../../web/showDetail.html'
  242. // });
  243. // }
  244. function changeSelectCon(index, t, type, dateValue){
  245. if (type == "date") {
  246. if (isEmpty(dateValue)) {
  247. $("#search" + index).remove();
  248. } else {
  249. $("#search" + index).remove();
  250. if (isEmpty($("#search" + index).attr("name"))) {
  251. $("#conditions").append(getSelectConHtml(index, t, type,dateValue));
  252. }
  253. }
  254. } else if (type == 'inp') {
  255. if (isEmpty($(t).val())) {
  256. $("#search" + index).remove();
  257. } else {
  258. $("#search" + index).remove();
  259. if (isEmpty($("#search" + index).attr("name"))) {
  260. $("#conditions").append(getSelectConHtml(index, t, type));
  261. }
  262. }
  263. } else if (type == 'qpp') {
  264. if (isEmpty($(t).val())) {
  265. $("#search" + index).remove();
  266. } else {
  267. $("#search" + index).remove();
  268. if (isEmpty($("#search" + index).attr("name"))) {
  269. $("#conditions").append(getSelectConHtml(index, t, type));
  270. }
  271. }
  272. }else {
  273. if (isEmpty($(t).val())) {
  274. $("#search" + index).remove();
  275. } else {
  276. $("#search" + index).remove();
  277. if (isEmpty($("#search" + index).attr("name"))) {
  278. $(t).attr("id","subjects");
  279. $("#conditions").append(getSelectConHtml(index, t, type));
  280. }
  281. }
  282. }
  283. }
  284. var array = new Array('时间','标题','机台号');
  285. function getSelectConHtml(index, t, type,dateValue){
  286. var name;
  287. var value;
  288. if(type == "inp"){
  289. value = t.value.substr(0,5)+"..";
  290. }
  291. if (type == "date") {
  292. value = dateValue;
  293. }
  294. if (type == "qpp") {
  295. value = t.value.substr(0,5)+"..";
  296. }
  297. if(type == "sel"){
  298. value = $("#state").find("option:selected").text();
  299. }
  300. if (type == "date") {
  301. name = $("#"+t).attr("id");
  302. } else {
  303. name = $(t).attr("id");
  304. }
  305. var html = '<div class="fl xuanzhong-active" id = "search' + index + '" name = "' + name + '" onclick = "removeSearch(this)">' +
  306. '<div class="fl">' + array[index] + '</div>' +
  307. ':<i>'+value+'</i>' +
  308. '<svg class="icon" aria-hidden="true">' +
  309. '<use xlink:href="#iconicon_close1"></use>' +
  310. '</svg>' +
  311. '</div>';
  312. return html;
  313. }
  314. function removeSearch(t) {
  315. if ($(t).attr("name") == 'subjects') {
  316. initSelect('state', "ORDER_STT", "state", ' ', true);
  317. form.render();
  318. $(t).remove();
  319. } else {
  320. $("#"+$(t).attr("name")).val('');
  321. $(t).remove();
  322. }
  323. }
  324. //编辑
  325. function editDetail(data) {
  326. // 寄存当前数据
  327. layui.sessionData("ROW_DATA", {key:"NOW_ROW", value:data});
  328. openMainTabPage('201001-02', ' 编辑', 'machineManage/editmachine.html', '', '201001', reload);
  329. }
  330. //查看货道
  331. function showDetail(data) {
  332. // 寄存当前数据
  333. layui.sessionData("ROW_DATA", {key:"NOW_ROW", value:data});
  334. openMainTabPage('201001-03', ' 查看货道', 'machineManage/machineDetail.html', '', '201001', reload);
  335. }
  336. </script>
  337. </body>
  338. </html>