Authored by 王涛
@@ -36,22 +36,6 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -36,22 +36,6 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
36 writeTagsInfo(v); 36 writeTagsInfo(v);
37 }) 37 })
38 } 38 }
39 - //渲染状态信息  
40 - // $.each(noticeTimely.noticeStateList,function (i,v) {  
41 - // //页面渲染  
42 - // var html = $("#noticeTimelyParamAddRowHtml").html();  
43 - // $("#editNoticeTimely_add_table").find("tbody").append(html);  
44 - // $("#editNoticeTimely_add_table").find("tbody tr td a.layui-table-link").on("click",function () {  
45 - // $(this).parents("tr").remove();  
46 - // });  
47 - // //数据渲染  
48 - // var len=$('#editNoticeTimely_add_table').find('tbody tr').size()-1;  
49 - // var $tr=$('#editNoticeTimely_add_table').find('tbody tr').eq(len);  
50 - // $tr.find('input[name="noticeName"]').val(v.noticeName);  
51 - // $tr.find('input[name="noticeState"]').val(v.noticeState);  
52 - // $tr.find('input[name="sendTime"]').val(v.sendTime);  
53 - // $tr.find('input[name="sendContent"]').val(v.sendContent);  
54 - // })  
55 } 39 }
56 }); 40 });
57 }else{ 41 }else{
@@ -13,6 +13,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -13,6 +13,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
13 var accessToken = sessions.getToken()['access_token']; 13 var accessToken = sessions.getToken()['access_token'];
14 var domainName = common.domainName; 14 var domainName = common.domainName;
15 var noticeTimelyTable = {}; 15 var noticeTimelyTable = {};
  16 + var noticeTimelyStateTable = {};
16 var checkList = common.checkPermission(accessToken); 17 var checkList = common.checkPermission(accessToken);
17 //开关 18 //开关
18 var switchElement = ['broadcast', 'retry', 'sendState', 'state']; 19 var switchElement = ['broadcast', 'retry', 'sendState', 'state'];
@@ -82,6 +83,78 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -82,6 +83,78 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
82 }); 83 });
83 }); 84 });
84 85
  86 + //加载表格
  87 + function loadStateTable(id) {
  88 + var params = {};
  89 + params.access_token = accessToken;
  90 + params.noticeTimelyId = id;
  91 + noticeTimelyStateTable = table.render({
  92 + elem: '#table-noticeTimely-state-list',
  93 + url: domainName + '/api-web/noticeTimely/statePage',
  94 + where: params,
  95 + height: 'full',
  96 + limit: common.limit,
  97 + limits: common.limits,
  98 + page: {
  99 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
  100 + theme: '#1E9FFF'
  101 + },
  102 + cols: [[{
  103 + type: 'checkbox'
  104 + }, {
  105 + field: 'noticeName', title: '发送用户', align: 'center', minWidth: '200',
  106 + }, {
  107 + field: 'sendContent', title: '发送内容', align: 'left', minWidth: '700',
  108 + templet: function (d) {
  109 + return '<input type="text" class="layui-input" style= "background-color:transparent;border:0;padding-bottom: 10px" readonly="readonly" name="sendContent" value="' + d.sendContent + '">'
  110 + }
  111 +
  112 + }, {
  113 + field: 'noticeState', title: '发送状态', align: 'center', width: '150',
  114 + templet: function (d) {
  115 + if (d.noticeState == 1) {
  116 + return '已发送';
  117 + } else {
  118 + return '未发送';
  119 + }
  120 + }
  121 + }, {
  122 + field: 'sendTime', title: '发送时间', align: 'center', width: '200'
  123 + }, {
  124 + title: '操作', align: 'center', minWidth: '150', fixed: 'right',
  125 + templet:
  126 + '<div>' +
  127 + ' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-state-delete" lay-tips="删除"><i class="layui-icon">&#xe640;</i></button>' +
  128 + '</div>'
  129 + }]],
  130 + done: function (res) {
  131 + // 点击删除事件
  132 + $('.link-noticeTimely-state-delete').unbind('click').on('click', function () {
  133 + var ids = [$(this).data('id')];
  134 + debugger
  135 + layer.confirm('确认要删除吗?', {icon: 3}, function () {
  136 + layer.load(2);
  137 + $.ajax({
  138 + url: domainName + '/api-web/noticeTimely/stateDelete?access_token=' + accessToken,
  139 + type: 'POST',
  140 + data: JSON.stringify(ids),
  141 + contentType: "application/json;charset=UTF-8",
  142 + success: function (response) {
  143 + layer.closeAll('loading');
  144 + if (response.success) {
  145 + layer.msg('删除成功!', {icon: 1, time: 3000});
  146 + loadStateTable(id);
  147 + } else {
  148 + layer.msg('删除失败!', {icon: 2, time: 3000});
  149 + }
  150 + }
  151 + })
  152 + });
  153 + });
  154 + }
  155 + });
  156 + }
  157 +
85 // 加载表格 158 // 加载表格
86 function loadTable() { 159 function loadTable() {
87 var params = form.val('form-noticeTimely-condition'); 160 var params = form.val('form-noticeTimely-condition');
@@ -108,38 +181,25 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -108,38 +181,25 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
108 }, { 181 }, {
109 field: 'type', title: '类型', align: 'center', width: '100' 182 field: 'type', title: '类型', align: 'center', width: '100'
110 }, { 183 }, {
111 - field: 'details', title: '内容', align: 'left', width: '400' 184 + field: 'details', title: '内容', align: 'left', minWidth: '400'
112 }, { 185 }, {
113 field: 'frequency', title: '频率', align: 'center', width: '200' 186 field: 'frequency', title: '频率', align: 'center', width: '200'
114 }, { 187 }, {
115 - field: 'noticeNicknames', title: '用户', align: 'center', width: '400'  
116 - }, {  
117 - field: 'voice', title: '响应声音', align: 'right', width: '140',  
118 - templet:  
119 - '<div>' +  
120 - '<span>{{d.voice}}</span>' +  
121 - ' <span data-id="{{d.id}}" data-voice="{{d.voice}}" class="link-noticeTimely-MP3" lay-tips="播放"><i class="layui-icon" style="font-size: 20px">&#xe645;</i></span>' +  
122 - '</div>' 188 + field: 'noticeNicknames', title: '用户', align: 'center', minWidth: '130'
123 }, { 189 }, {
124 - field: 'state', title: '状态', align: 'center', width: '100', 190 + field: 'state', title: '是否启用', align: 'center', width: '100',
125 templet: function (d) { 191 templet: function (d) {
126 var checked = d.state == 2 ? 'checked' : ''; 192 var checked = d.state == 2 ? 'checked' : '';
127 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_state" name="state" lay-skin="switch" lay-text="启用|禁用" ' + checked + ' ></div>' 193 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_state" name="state" lay-skin="switch" lay-text="启用|禁用" ' + checked + ' ></div>'
128 } 194 }
129 }, { 195 }, {
130 - field: 'sendState', title: '发送状态', align: 'center', width: '100',  
131 - templet: function (d) {  
132 - var checked = d.sendState == 1 ? 'checked' : '';  
133 - return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_sendState" name="sendState" lay-skin="switch" lay-text="已发送|未发送" ' + checked + ' ></div>'  
134 - }  
135 - }, {  
136 field: 'broadcast', title: '是否广播', align: 'center', width: '100', 196 field: 'broadcast', title: '是否广播', align: 'center', width: '100',
137 templet: function (d) { 197 templet: function (d) {
138 var checked = d.broadcast == 1 ? 'checked' : ''; 198 var checked = d.broadcast == 1 ? 'checked' : '';
139 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_broadcast" name="broadcast" lay-skin="switch" lay-text="是|否" ' + checked + ' ></div>' 199 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_broadcast" name="broadcast" lay-skin="switch" lay-text="是|否" ' + checked + ' ></div>'
140 } 200 }
141 }, { 201 }, {
142 - field: 'retry', title: '是否重发', align: 'center', width: '100', 202 + field: 'retry', title: '是否轮循', align: 'center', width: '100',
143 templet: function (d) { 203 templet: function (d) {
144 var checked = d.retry == 1 ? 'checked' : ''; 204 var checked = d.retry == 1 ? 'checked' : '';
145 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_retry" name="retry" lay-skin="switch" lay-text="重发|不重发" ' + checked + ' ></div>' 205 return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_retry" name="retry" lay-skin="switch" lay-text="重发|不重发" ' + checked + ' ></div>'
@@ -154,6 +214,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -154,6 +214,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
154 templet: 214 templet:
155 '<div>' + 215 '<div>' +
156 ' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-delete" lay-tips="删除"><i class="layui-icon">&#xe640;</i></button>' + 216 ' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-delete" lay-tips="删除"><i class="layui-icon">&#xe640;</i></button>' +
  217 + ' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-history" lay-tips="历史记录"><i class="layui-icon">&#xe705;</i></button>' +
157 '</div>' 218 '</div>'
158 }]], 219 }]],
159 done: function (res) { 220 done: function (res) {
@@ -169,6 +230,22 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl @@ -169,6 +230,22 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
169 $('.link-noticeTimely-delete').on('click', function () { 230 $('.link-noticeTimely-delete').on('click', function () {
170 deleteById([$(this).data('id')]); 231 deleteById([$(this).data('id')]);
171 }); 232 });
  233 + //点击查看该消息发送的历史记录
  234 + $('.link-noticeTimely-history').unbind('click').on('click', function () {
  235 + var id = $(this).data('id');
  236 + layer.open({
  237 + title: "已发送消息",
  238 + content: $("#noticeTimely-state-html").html(),
  239 + area: ['80%', '70%'],
  240 + btns: ['确认', '取消'],
  241 + success: function (index) {
  242 + loadStateTable(id);
  243 + },
  244 + yes: function (index, layero) {
  245 +
  246 + }
  247 + });
  248 + });
172 //播放声音 249 //播放声音
173 $('.link-noticeTimely-MP3').on('click', function () { 250 $('.link-noticeTimely-MP3').on('click', function () {
174 var voice = $(this).data('voice'); 251 var voice = $(this).data('voice');
@@ -11,32 +11,32 @@ @@ -11,32 +11,32 @@
11 </div> 11 </div>
12 </div> 12 </div>
13 <div class="inline-half layui-inline"> 13 <div class="inline-half layui-inline">
14 - <label class="layui-form-label">类型</label> 14 + <label class="layui-form-label">跳转地址</label>
15 <div class="layui-input-inline"> 15 <div class="layui-input-inline">
16 - <input type="text" name="type" placeholder="请输入类型" value="sql" readonly="readonly" class="layui-input"> 16 + <input type="text" name="site" placeholder="请输入详情页地址" class="layui-input">
17 </div> 17 </div>
18 </div> 18 </div>
19 </div> 19 </div>
20 <div class="layui-form-item"> 20 <div class="layui-form-item">
21 <div class="layui-inline"> 21 <div class="layui-inline">
22 <label class="layui-form-label">状态</label> 22 <label class="layui-form-label">状态</label>
23 - <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:0px"> 23 + <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:105px">
24 <input type="checkbox" id="switch_noticeTimely_state" name="state" lay-skin="switch" lay-text="启用|禁用" value="0" > 24 <input type="checkbox" id="switch_noticeTimely_state" name="state" lay-skin="switch" lay-text="启用|禁用" value="0" >
25 </div> 25 </div>
26 </div> 26 </div>
27 <div class="layui-inline"> 27 <div class="layui-inline">
28 <label class="layui-form-label">是否广播</label> 28 <label class="layui-form-label">是否广播</label>
29 - <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:0px"> 29 + <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:105px">
30 <input type="checkbox" id="switch_noticeTimely_broadcast" name="broadcast" lay-skin="switch" lay-text="是|否" value="0" > 30 <input type="checkbox" id="switch_noticeTimely_broadcast" name="broadcast" lay-skin="switch" lay-text="是|否" value="0" >
31 </div> 31 </div>
32 </div> 32 </div>
33 <div class="layui-inline"> 33 <div class="layui-inline">
34 - <label class="layui-form-label">是否重发</label>  
35 - <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:0px">  
36 - <input type="checkbox" id="switch_noticeTimely_retry" name="retry" lay-skin="switch" lay-text="重发|不重发" value="0" > 34 + <label class="layui-form-label">是否轮循</label>
  35 + <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:105px">
  36 + <input type="checkbox" id="switch_noticeTimely_retry" name="retry" lay-skin="switch" lay-text="轮循|不轮循" value="0" >
37 </div> 37 </div>
38 </div> 38 </div>
39 - <div class="layui-inline"> 39 + <div class="layui-inline" style="display: none !important;">
40 <label class="layui-form-label">发送状态</label> 40 <label class="layui-form-label">发送状态</label>
41 <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:0px"> 41 <div class="layui-input-inline" style="width: calc(20vw - 142px);margin-right:0px">
42 <input type="checkbox" id="switch_noticeTimely_sendState" name="sendState" lay-skin="switch" lay-text="已发送|未发送" value="0" > 42 <input type="checkbox" id="switch_noticeTimely_sendState" name="sendState" lay-skin="switch" lay-text="已发送|未发送" value="0" >
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 </div> 61 </div>
62 </div> 62 </div>
63 <div class="layui-form-item"> 63 <div class="layui-form-item">
64 - <div class="inline-half layui-inline"> 64 + <div class="inline-half layui-inline" style="display: none!important;">
65 <label class="layui-form-label">响应声音</label> 65 <label class="layui-form-label">响应声音</label>
66 <div class="layui-input-inline"> 66 <div class="layui-input-inline">
67 <select name="voice" id="noticeTimely_voice" lay-filter="noticeTimely_voice"> 67 <select name="voice" id="noticeTimely_voice" lay-filter="noticeTimely_voice">
@@ -71,10 +71,10 @@ @@ -71,10 +71,10 @@
71 </select> 71 </select>
72 </div> 72 </div>
73 </div> 73 </div>
74 - <div class="inline-half layui-inline">  
75 - <label class="layui-form-label">详情页地址</label> 74 + <div class="inline-half layui-inline" style="display: none!important;">
  75 + <label class="layui-form-label">类型</label>
76 <div class="layui-input-inline"> 76 <div class="layui-input-inline">
77 - <input type="text" name="site" placeholder="请输入详情页地址" class="layui-input"> 77 + <input type="text" name="type" placeholder="请输入类型" value="sql" readonly="readonly" class="layui-input">
78 </div> 78 </div>
79 </div> 79 </div>
80 </div> 80 </div>
@@ -93,49 +93,49 @@ @@ -93,49 +93,49 @@
93 </div> 93 </div>
94 <button id="btn-noticeTimely-submit" class="hide" lay-submit lay-filter="btn-noticeTimely-submit">提交</button> 94 <button id="btn-noticeTimely-submit" class="hide" lay-submit lay-filter="btn-noticeTimely-submit">提交</button>
95 </form> 95 </form>
96 - <div class="layui-card-body layui-form-pane editNoticeTimelyParam-list" style="padding-top: 0px;">  
97 - <fieldset class="layui-elem-field layui-field-title">  
98 - <legend>消息状态 &nbsp; &nbsp;  
99 - <a class="layui-btn layui-btn-xs layui-btn-normal" id="editNoticeTimelyParamBtn"><i class="layui-icon">&#xe654;</i></a>  
100 - </legend>  
101 - </fieldset>  
102 - <div class="layui-form-item">  
103 - <table id="editNoticeTimely_add_table" class="layui-table">  
104 - <thead>  
105 - <tr>  
106 - <th style="text-align: center;width: 150px">发送用户</th>  
107 - <th style="text-align: center;width: 60px">发送状态</th>  
108 - <th style="text-align: center;width: 150px">发送时间</th>  
109 - <th style="text-align: center;">发送内容</th>  
110 - <th style="text-align: center;width: 60px">操作</th>  
111 - </tr>  
112 - </thead>  
113 - <tbody> 96 +<!-- <div class="layui-card-body layui-form-pane editNoticeTimelyParam-list" style="padding-top: 0px;">-->
  97 +<!-- <fieldset class="layui-elem-field layui-field-title">-->
  98 +<!-- <legend>消息状态 &nbsp; &nbsp;-->
  99 +<!-- <a class="layui-btn layui-btn-xs layui-btn-normal" id="editNoticeTimelyParamBtn"><i class="layui-icon">&#xe654;</i></a>-->
  100 +<!-- </legend>-->
  101 +<!-- </fieldset>-->
  102 +<!-- <div class="layui-form-item">-->
  103 +<!-- <table id="editNoticeTimely_add_table" class="layui-table">-->
  104 +<!-- <thead>-->
  105 +<!-- <tr>-->
  106 +<!-- <th style="text-align: center;width: 150px">发送用户</th>-->
  107 +<!-- <th style="text-align: center;width: 60px">发送状态</th>-->
  108 +<!-- <th style="text-align: center;width: 150px">发送时间</th>-->
  109 +<!-- <th style="text-align: center;">发送内容</th>-->
  110 +<!-- <th style="text-align: center;width: 60px">操作</th>-->
  111 +<!-- </tr>-->
  112 +<!-- </thead>-->
  113 +<!-- <tbody>-->
114 114
115 - </tbody>  
116 - </table>  
117 - </div>  
118 - </div> 115 +<!-- </tbody>-->
  116 +<!-- </table>-->
  117 +<!-- </div>-->
  118 +<!-- </div>-->
119 </article> 119 </article>
120 -<script type="text/html" id="noticeTimelyParamAddRowHtml">  
121 - <tr>  
122 - <td>  
123 - <input type="text" class="layui-input" name="noticeName">  
124 - </td>  
125 - <td>  
126 - <select name="noticeState" class="layui-select" style="min-width: 100px">  
127 - <option value="1">已发送</option>  
128 - <option value="2">未发送</option>  
129 - </select>  
130 - </td>  
131 - <td><input type="text" class="layui-input" readonly="readonly" name="sendTime"></td>  
132 - <td>  
133 - <input type="text" class="layui-input" name="sendContent">  
134 -<!-- <textarea name="details" class="layui-textarea"></textarea>-->  
135 - </td>  
136 - <td align="center" style="min-width: 80px"><a class="layui-table-link layui-btn layui-btn-xs layui-btn-normal" title="删除" ><i style="font-size: 18px" class="layui-icon">&#xe640;</i></a></td>  
137 - </tr>  
138 -</script> 120 +<!--<script type="text/html" id="noticeTimelyParamAddRowHtml">-->
  121 +<!-- <tr>-->
  122 +<!-- <td>-->
  123 +<!-- <input type="text" class="layui-input" name="noticeName">-->
  124 +<!-- </td>-->
  125 +<!-- <td>-->
  126 +<!-- <select name="noticeState" class="layui-select" style="min-width: 100px">-->
  127 +<!-- <option value="1">已发送</option>-->
  128 +<!-- <option value="2">未发送</option>-->
  129 +<!-- </select>-->
  130 +<!-- </td>-->
  131 +<!-- <td><input type="text" class="layui-input" readonly="readonly" name="sendTime"></td>-->
  132 +<!-- <td>-->
  133 +<!-- <input type="text" class="layui-input" name="sendContent">-->
  134 +<!--&lt;!&ndash; <textarea name="details" class="layui-textarea"></textarea>&ndash;&gt;-->
  135 +<!-- </td>-->
  136 +<!-- <td align="center" style="min-width: 80px"><a class="layui-table-link layui-btn layui-btn-xs layui-btn-normal" title="删除" ><i style="font-size: 18px" class="layui-icon">&#xe640;</i></a></td>-->
  137 +<!-- </tr>-->
  138 +<!--</script>-->
139 <script> 139 <script>
140 layui.use('noticeTimelyAdd', function (fn) { 140 layui.use('noticeTimelyAdd', function (fn) {
141 fn({{d}}); 141 fn({{d}});
@@ -36,6 +36,11 @@ @@ -36,6 +36,11 @@
36 </div> 36 </div>
37 </div> 37 </div>
38 </article> 38 </article>
  39 +<script type="text/html" id="noticeTimely-state-html" >
  40 + <div>
  41 + <table id="table-noticeTimely-state-list" lay-filter="table-noticeTimely-state-list"></table>
  42 + </div>
  43 +</script>
39 <script> 44 <script>
40 layui.use('noticeTimelyIndex', function (fn) { 45 layui.use('noticeTimelyIndex', function (fn) {
41 fn(); 46 fn();