123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- {extend name="common/base"/}
- <!-- 主体 -->
- {block name="body"}
- <div class="p-3">
- <form class="layui-form gg-form-bar border-t border-x">
- <div class="layui-input-inline">
- <select name="cate_id">
- <option value="">请选择商品分类</option>
- {volist name=":set_recursion(get_goods_cate())" id="v"}
- <option value="{$v.id}">{$v.title}</option>
- {/volist}
- </select>
- </div>
- <div class="layui-input-inline" style="width:300px;">
- <input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
- </div>
- <div class="layui-input-inline">
- <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
- </div>
- </form>
- <table class="layui-hide" id="goods" lay-filter="goods"></table>
- </div>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加商品">+ 添加商品</span>
- </div>
- </script>
- <script type="text/html" id="status">
- <i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok green{{# } else { }}layui-icon-close red{{# } }}"></i>
- </script>
- <script type="text/html" id="is_home">
- <i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok green{{# } else { }}layui-icon-close red{{# } }}"></i>
- </script>
- <script type="text/html" id="barDemo">
- <div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
- </script>
- {/block}
- <!-- /主体 -->
- <!-- 脚本 -->
- {block name="script"}
- <script>
- const moduleInit = ['tool'];
- function gouguInit() {
- var table = layui.table,tool = layui.tool, form = layui.form;
- layui.pageTable = table.render({
- elem: '#goods',
- title: '商品列表',
- toolbar: '#toolbarDemo',
- url: '/admin/goods/datalist',
- page: true,
- limit: 20,
- cellMinWidth: 80,
- cols: [
- [
- {
- fixed: 'left',
- field: 'id',
- title: '编号',
- align: 'center',
- width: 80
- },{
- field: 'cate_title',
- title: '所属分类',
- align: 'center',
- width: 100
- },{
- field: 'type_str',
- title: '属性',
- align: 'center',
- width: 80
- },{
- field: 'title',
- title: '商品名称',
- },{
- field: 'base_price',
- title: '市场价格',
- align: 'center',
- width: 90
- },{
- field: 'price',
- title: '实际价格',
- align: 'center',
- width: 90
- },{
- field: 'stocks',
- title: '商品库存',
- align: 'center',
- width: 80
- },{
- field: 'sales',
- title: '商品销量',
- align: 'center',
- width: 80
- },{
- field: 'read',
- title: '阅读量',
- align: 'center',
- width: 80
- },{
- field: 'is_home',
- title: '首页显示',
- toolbar: '#is_home',
- align: 'center',
- width: 90
- },{
- field: 'sort',
- title: '排序',
- align: 'center',
- width: 80
- },{
- field: 'status',
- title: '上下架',
- toolbar: '#status',
- align: 'center',
- width: 80
- },{
- field: 'admin_name',
- title: '创建人',
- align: 'center',
- width: 100
- },{
- field: 'create_time',
- title: '创建时间',
- align: 'center',
- width: 160
- },{
- fixed: 'right',
- field: 'right',
- title: '操作',
- toolbar: '#barDemo',
- width: 136,
- align: 'center'
- }
- ]
- ]
- });
-
- //监听表头工具栏事件
- table.on('toolbar(goods)', function(obj){
- if (obj.event === 'add') {
- tool.side("/admin/goods/add");
- return false;
- }
- });
- //监听表格行工具事件
- table.on('tool(goods)', function(obj) {
- var data = obj.data;
- if (obj.event === 'read') {
- tool.side('/admin/goods/read?id='+obj.data.id);
- }
- else if (obj.event === 'edit') {
- tool.side('/admin/goods/edit?id='+obj.data.id);
- }
- else if (obj.event === 'del') {
- layer.confirm('确定要删除该记录吗?', {
- icon: 3,
- title: '提示'
- }, function(index) {
- let callback = function (e) {
- layer.msg(e.msg);
- if (e.code == 0) {
- obj.del();
- }
- }
- tool.delete("/admin/goods/del", { id: data.id }, callback);
- layer.close(index);
- });
- }
- return false;
- });
- //监听搜索提交
- form.on('submit(searchform)', function(data) {
- layui.pageTable.reload({
- where: {
- keywords: data.field.keywords
- },
- page: {
- curr: 1
- }
- });
- return false;
- });
- }
- </script>
- {/block}
- <!-- /脚本 -->
|