123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- {extend name="base"/}
- {block name="resources"}
- {/block}
- {block name="main"}
- <div class="layui-collapse ns-tips">
- <div class="layui-colla-item">
- <h2 class="layui-colla-title">操作提示</h2>
- <ul class="layui-colla-content layui-show">
- <li>您可以查看和编辑广告栏的图片</li>
- <li>侧广告位上传尺寸: 223*440px</li>
- </ul>
- </div>
- </div>
- <!-- 列表 -->
- <table id="adv_position" lay-filter="adv_position"></table>
- <!-- 广告图片 -->
- <script type="text/html" id="imgae">
- <div class="ns-img-box">
- <img layer-src src="{{ns.img(d.imgae)}}" />
- </div>
- </script>
- <!-- 操作 -->
- <script type="text/html" id="operation">
- <div class="ns-table-btn">
- <a class="layui-btn" lay-event="edit">编辑</a>
- </div>
- </script>
- <!--<!– 批量删除 –>-->
- <!--<script type="text/html" id="batchOperation">-->
- <!-- <button class="layui-btn layui-btn-primary" lay-event="del">批量删除</button>-->
- <!--</script>-->
- {/block}
- {block name="script"}
- <script>
- var table, form,
- repeat_flag = false; //防重复标识
- layui.use('form', function() {
- form = layui.form;
- form.render();
- table = new Table({
- elem: '#adv_position',
- url: ns.url("admin/SideAdv/index"), cols: [
- [{
- width: '3%',
- type: 'checkbox',
- unresize: 'false',
- }, {
- field: 'title',
- title: '标题',
- unresize: 'false',
- templet: '#title',
- width: '20%'
- },{
- title: '图片',
- unresize: 'false',
- templet: '#imgae',
- width: '15%'
- }, {
- title: '操作',
- toolbar: '#operation',
- unresize: 'false',
- templet: '#operation',
- width: '17%'
- }]
- ],
- // bottomToolbar: "#batchOperation"
- });
- /**
- * 监听工具栏操作
- */
- table.tool(function(obj) {
- var data = obj.data;
- switch (obj.event) {
- case 'manager': //管理
- location.href = ns.url("admin/banner/lists?ap_id=" + data.ap_id);
- break;
- case 'edit': //编辑
- location.href = ns.url("admin/SideAdv/editAdv?ap_id=" + data.id);
- break;
- case 'delete': //删除
- deletePosition(data.id);
- break;
- }
- });
- /**
- * 批量操作
- */
- table.bottomToolbar(function(obj) {
- if (obj.data.length < 1) {
- layer.msg('请选择要操作的数据');
- return;
- }
- switch (obj.event) {
- case "del":
- var id_array = new Array();
- for (i in obj.data) id_array.push(obj.data[i].ap_id);
- deletePosition(id_array.toString());
- break;
- }
- });
- /**
- * 删除
- */
- function deletePosition(ap_ids) {
- if (repeat_flag) return false;
- repeat_flag = true;
- layer.confirm('确定要删除该广告位吗?', function() {
- $.ajax({
- url: ns.url("admin/banner/deleteBanner"),
- data: {ap_ids},
- dataType: 'JSON',
- type: 'POST',
- success: function(res) {
- layer.msg(res.message);
- repeat_flag = false;
- if (res.code == 0) {
- table.reload();
- }
- }
- });
- }, function() {
- layer.close();
- repeat_flag = false;
- });
- }
- /**
- * 监听搜索
- */
- form.on('submit(search)', function(data) {
- table.reload({
- page: {
- curr: 1
- },
- where: data.field
- });
- });
- });
- // 监听单元格编辑--编辑宽度
- function editPosition(id, type, event) {
- var value = $(event).val();
- if (!new RegExp("^\\d+$").test(value)) {
- layer.msg("广告位宽高必须为大于等于0的整数");
- return;
- }
- $.ajax({
- type: 'POST',
- url: ns.url("admin/banner/editPositionField"),
- data: {
- 'type': type,
- 'value': value,
- 'ap_id': id
- },
- dataType: 'JSON',
- success: function(res) {
- layer.msg(res.message);
- if (res.code == 0) {
- table.reload();
- }
- }
- });
- }
- function add() {
- location.href = ns.url("admin/SideAdv/addSide");
- }
- </script>
- {/block}
|