2022-08-11 14:43:14 +08:00

126 lines
6.0 KiB
PHP

{extend name="../../admin/view/table"}
{block name="button"}
<!--{if auth("defaults") and $type eq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="950px" data-modal='{:url("defaults")}'>默认回复</button>
<!--{/if}-->
<!--{if auth("subscribe") and $type eq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="950px" data-modal='{:url("subscribe")}'>订阅回复</button>
<!--{/if}-->
<!--{if auth("add") and $type eq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="950px" data-modal='{:url("add")}'>添加规则</button>
<!--{/if}-->
<!--{if auth("state") and $type eq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="RuleTable" data-action='{:url("state")}' data-rule="id#{id};status#0">批量禁用</button>
<!--{/if}-->
<!--{if auth("state") and $type neq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="RuleTable" data-action='{:url("state")}' data-rule="id#{id};status#1">批量启用</button>
<!--{/if}-->
<!--{if auth("remove") and $type neq 'index'}-->
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="RuleTable" data-action='{:url("remove")}' data-rule="id#{id}">批量删除</button>
<!--{/if}-->
{/block}
{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
<ul class="layui-tab-title">
{foreach ['index'=>'回复规则','recycle'=>'回 收 站'] as $k=>$v}
{if isset($type) and $type eq $k}
<li class="layui-this" data-open="{:url('index')}?type={$k}">{$v}</li>
{else}
<li data-open="{:url('index')}?type={$k}">{$v}</li>
{/if}{/foreach}
</ul>
<div class="layui-tab-content">
{include file='keys/index_search'}
<table id="RuleTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
</div>
</div>
{/block}
{block name='script'}
<script>
$(function () {
$('#RuleTable').layTable({
even: true, height: 'full',
sort: {field: 'sort desc,id', type: 'desc'},
where: {type: '{$type|default="index"}'},
cols: [[
{checkbox: true},
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
{
field: 'keys', title: '关键字', minWidth: 100, templet: function (d) {
d.className = 'layui-icon layui-icon-cols font-s12 pointer margin-right-5 pull-left';
return laytpl('<i class="{{d.className}}" data-load="{{d.qrc}}" data-time="false" data-tips-text="生成关键字二维码"></i> {{d.keys}}').render(d);
}
},
{field: 'type', title: '消息类型', align: "center", minWidth: 100},
{field: 'code', title: '在线预览', align: "center", minWidth: 100, templet: '#PreViewTpl'},
{field: 'status', title: '使用状态', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
{field: 'create_at', title: '添加时间', align: 'center', minWidth: 170},
{toolbar: '#toolbar', title: '操作面板', align: 'center', fixed: 'right'}
]]
});
// 数据状态切换操作
layui.form.on('switch(StatusSwitch)', function (obj, data) {
data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
$.form.load("{:url('state')}", data, 'post', function (ret) {
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
$('#RuleTable').trigger('reload');
}); else {
$('#RuleTable').trigger('reload');
}
return false;
}, false);
});
});
</script>
<script type="text/html" id="PreViewTpl">
{{# if(d.type==='音乐'){ }}
<a data-phone-view='{:url("@wechat/api.view/music")}?title={{d.music_title}}&desc={{d.music_desc}}'>预览</a>
{{# }else if(d.type==='图片'){ }}
<a data-phone-view='{:url("@wechat/api.view/image")}?content={{d.image_url}}'>预览</a>
{{# }else if(d.type==='图文'){ }}
<a data-phone-view='{:url("@wechat/api.view/news")}?id={{d.news_id}}'>预览</a>
{{# }else if(d.type==='视频'){ }}
<a data-phone-view='{:url("@wechat/api.view/video")}?title={{d.video_title}}&desc={{d.video_desc}}&url={{d.video_url}}'>预览</a>
{{# }else if(d.type==='语音'){ }}
<a data-phone-view='{:url("@wechat/api.view/voice")}?content={{d.voice_url}}'>预览</a>
{{# }else if(d.type==='文字'||d.type==='转客服'){ }}
<a data-phone-view='{:url("@wechat/api.view/text")}?content={{d.content}}'>预览</a>
{{# }else{ }}
{{d.content}}
{{# } }}
</script>
<!-- 列表排序权重模板 -->
<script type="text/html" id="SortInputTpl">
<input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
</script>
<!-- 状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
<!--{if auth("state")}-->
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{-d.status>0?'checked':''}}>
<!--{else}-->
{{-d.status ? '<b class="color-red">已激活</b>' : '<b class="color-green">已禁用</b>'}}
<!--{/if}-->
</script>
<!-- 操作面板模板 -->
<script type="text/html" id="toolbar">
<!--{if auth("edit") and isset($type) and $type eq 'index'}-->
<a class="layui-btn layui-btn-sm" data-width="950px" data-modal="{:url('edit')}?id={{d.id}}" data-title="编辑回复规则"> </a>
<!--{/if}-->
<!--{if auth("remove") and isset($type) and $type neq 'index'}-->
<a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('remove')}" data-value="id#{{d.id}}" data-confirm="确定要删除该用户吗?"> </a>
<!--{/if}-->
</script>
{/block}