作者 v_bairong06

后台添加库存预警商品列表

  1 +<admintpl file="header" />
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="javascript:;">库存预警商品列表</a></li>
  7 + </ul>
  8 + <form class="well form-search" method="post" action="{:U('WarningGoods/index')}">
  9 + 关键字:
  10 + <input type="text" name="keyword" style="width: 200px;" value="{$formget.keyword|default=''}" placeholder="请输入关键字...">
  11 + <input type="submit" class="btn btn-primary" value="搜索" />
  12 + <a class="btn btn-danger" href="{:U('WarningGoods/index')}">清空</a>
  13 + </form>
  14 + <form class="js-ajax-form" action="" method="post">
  15 + <table class="table table-hover table-bordered table-list">
  16 + <thead>
  17 + <tr>
  18 + <th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
  19 + <th width="50">ID</th>
  20 + <th>商品名称</th>
  21 + <th>品牌名称</th>
  22 + <th>分类名称</th>
  23 + <th width="100">简要描述</th>
  24 + <th width="100">商品价格(现)</th>
  25 + <th width="100">商品价格(原)</th>
  26 + <th width="150">发布时间</th>
  27 + <th width="70">操作</th>
  28 + </tr>
  29 + </thead>
  30 + <foreach name="posts" item="vo">
  31 + <tr>
  32 + <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}" title="ID:{$vo.id}"></td>
  33 + <td><b>{$vo.id}</b></td>
  34 + <td>{$vo.goods_name}</td>
  35 + <td>{$vo.brand_name}</td>
  36 + <td>{$vo.name}</td>
  37 + <td>{$vo.short_name}</td>
  38 + <td>¥{$vo.goods_price}</td>
  39 + <td>¥{$vo.price}</td>
  40 + <td>{:date('Y-m-d H:i',$vo['ctime'])}</td>
  41 + <td>
  42 + <a href="{:U('Portal/AdminGoods/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a>
  43 + </td>
  44 + </tr>
  45 + </foreach>
  46 + <tfoot>
  47 + <tr>
  48 + <th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></label></th>
  49 + <th width="50">ID</th>
  50 + <th>商品名称</th>
  51 + <th>品牌名称</th>
  52 + <th>分类名称</th>
  53 + <th width="100">简要描述</th>
  54 + <th width="100">商品价格(现)</th>
  55 + <th width="100">商品价格(原)</th>
  56 + <th width="150">发布时间</th>
  57 + <th width="70">操作</th>
  58 + </tr>
  59 + </tfoot>
  60 + </table>
  61 + <div class="pagination">{$page}</div>
  62 + </form>
  63 +</div>
  64 +<script src="__PUBLIC__/js/common.js"></script>
  65 +<script>
  66 + function refersh_window() {
  67 + var refersh_time = getCookie('refersh_time');
  68 + if (refersh_time == 1) {
  69 + window.location = "{:U('WarningGoods/index',$formget)}";
  70 + }
  71 + }
  72 + setInterval(function() {
  73 + refersh_window();
  74 + }, 2000);
  75 + $(function() {
  76 + setCookie("refersh_time", 0);
  77 + });
  78 +</script>
  79 +</body>
  80 +</html>
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: 29925
  5 + * Date: 2018/6/5
  6 + * Time: 19:50
  7 + */
  8 +
  9 +namespace Admin\Controller;
  10 +
  11 +use Common\Controller\AdminbaseController;
  12 +
  13 +class WarningGoodsController extends AdminbaseController {
  14 +
  15 + protected $goods_model;
  16 + protected $product_model;
  17 + protected $goods_brand_model;
  18 +
  19 + function _initialize() {
  20 + parent::_initialize();
  21 + $this->goods_model = D("Common/Goods");
  22 + $this->product_model = D("Common/Product");
  23 + $this->goods_brand_model = D("Common/GoodsBrand");
  24 + $this->region();
  25 + }
  26 +
  27 + // 后台商品库存预警列表
  28 + public function index(){
  29 + $warning = M('Warning')->where(array('id'=>1))->getField('num');
  30 + $this->_lists(array("g.is_del"=>0,'g.num'=>array('elt',$warning)));
  31 + $this->display();
  32 + }
  33 +
  34 + /**
  35 + * 商品列表处理方法,根据不同条件显示不同的列表
  36 + * @param array $where 查询条件
  37 + */
  38 + private function _lists($where=array()){
  39 + $start_time = I('request.start_time');
  40 + if(!empty($start_time)){
  41 + $where['g.ctime']=array(
  42 + array('EGT',strtotime($start_time))
  43 + );
  44 + }
  45 +
  46 + $end_time = I('request.end_time');
  47 + if(!empty($end_time)){
  48 + if(empty($where['g.ctime'])){
  49 + $where['g.ctime']=array();
  50 + }
  51 + array_push($where['g.ctime'], array('ELT',strtotime($end_time)));
  52 + }
  53 +
  54 + $keyword = I('request.keyword');
  55 + if(!empty($keyword)){
  56 + $where['g.goods_name|g.short_name|g.goods_keywords']=array('like',"%$keyword%");
  57 + }
  58 +
  59 + $this->goods_model
  60 + ->alias("g")
  61 + ->where($where);
  62 +
  63 + if(!empty($term_id)){
  64 + $this->goods_model->join("__GOODS_BRAND__ b ON g.brand_id = b.id");
  65 + }
  66 +
  67 + $count = $this->goods_model->count();
  68 +
  69 + $page = $this->page($count, 20);
  70 +
  71 + $posts = $this->goods_model
  72 + ->field('g.*,b.brand_name,p.name')
  73 + ->alias("g")
  74 + ->join("__GOODS_BRAND__ b ON g.brand_id = b.id")
  75 + ->join("__PRODUCT__ p ON g.sort_id = p.id")
  76 + ->where($where)
  77 + ->limit($page->firstRow , $page->listRows)
  78 + ->order("g.ctime DESC")
  79 + ->select();
  80 +
  81 + $this->assign("page", $page->show('Admin'));
  82 + $this->assign("formget",array_merge($_GET,$_POST));
  83 + $this->assign("posts",$posts);
  84 + }
  85 +}
@@ -153,7 +153,7 @@ class AdminGoodsController extends AdminbaseController { @@ -153,7 +153,7 @@ class AdminGoodsController extends AdminbaseController {
153 $start_time = I('request.start_time'); 153 $start_time = I('request.start_time');
154 if(!empty($start_time)){ 154 if(!empty($start_time)){
155 $where['g.ctime']=array( 155 $where['g.ctime']=array(
156 - array('EGT',$start_time) 156 + array('EGT',strtotime($start_time))
157 ); 157 );
158 } 158 }
159 159
@@ -162,7 +162,7 @@ class AdminGoodsController extends AdminbaseController { @@ -162,7 +162,7 @@ class AdminGoodsController extends AdminbaseController {
162 if(empty($where['g.ctime'])){ 162 if(empty($where['g.ctime'])){
163 $where['g.ctime']=array(); 163 $where['g.ctime']=array();
164 } 164 }
165 - array_push($where['g.ctime'], array('ELT',$end_time)); 165 + array_push($where['g.ctime'], array('ELT',strtotime($end_time)));
166 } 166 }
167 167
168 $keyword = I('request.keyword'); 168 $keyword = I('request.keyword');
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 <div class="fy-g-item">性别 <eq name="sex" value="1"></eq><eq name="sex" value="2"></eq></div> 39 <div class="fy-g-item">性别 <eq name="sex" value="1"></eq><eq name="sex" value="2"></eq></div>
40 <div class="fy-g-item">民族 {$nation}</div> 40 <div class="fy-g-item">民族 {$nation}</div>
41 <div class="fy-g-item">出生日期 {$birth}</div> 41 <div class="fy-g-item">出生日期 {$birth}</div>
42 - <div class="fy-g-item">所属非遗项目 汉绣</div> 42 + <div class="fy-g-item">所属非遗项目 {$name}</div>
43 </div> 43 </div>
44 </div> 44 </div>
45 <!--杨柳青年画·介绍--> 45 <!--杨柳青年画·介绍-->
@@ -31,21 +31,21 @@ @@ -31,21 +31,21 @@
31 <p class="seach_title">搜索</p> 31 <p class="seach_title">搜索</p>
32 </div> 32 </div>
33 <div class="shoplist_select"> 33 <div class="shoplist_select">
34 - <div class="select_quyu" onclick="qy($(this),region,redata)"> 34 + <div class="select_quyu" onclick="qy($(this),region,'区域')">
35 <p class="shoplist_select_title">区域</p> 35 <p class="shoplist_select_title">区域</p>
36 <i class="iconfont icon-fylb_icon_arrow_norm"></i> 36 <i class="iconfont icon-fylb_icon_arrow_norm"></i>
37 </div> 37 </div>
38 <div class="select_line"> 38 <div class="select_line">
39 39
40 </div> 40 </div>
41 - <div class="select_price" onclick="qy($(this),price,prdata)"> 41 + <div class="select_price" onclick="qy($(this),price,'价格')">
42 <p class="shoplist_select_title">价格</p> 42 <p class="shoplist_select_title">价格</p>
43 <i class="iconfont icon-fylb_icon_arrow_norm"></i> 43 <i class="iconfont icon-fylb_icon_arrow_norm"></i>
44 </div> 44 </div>
45 <div class="select_line"> 45 <div class="select_line">
46 46
47 </div> 47 </div>
48 - <div class="select_pai" onclick="qy($(this),brand,brdata)"> 48 + <div class="select_pai" onclick="qy($(this),brand,'品牌')">
49 <p class="shoplist_select_title">品牌</p> 49 <p class="shoplist_select_title">品牌</p>
50 <i class="iconfont icon-fylb_icon_arrow_norm"></i> 50 <i class="iconfont icon-fylb_icon_arrow_norm"></i>
51 </div> 51 </div>
@@ -89,13 +89,13 @@ @@ -89,13 +89,13 @@
89 // // scrollbar: '.swiper-scrollbar', 89 // // scrollbar: '.swiper-scrollbar',
90 // }) 90 // })
91 // } 91 // }
92 -var page=0; 92 +//var page=0;
93 var region = change(`"{$region_mobile}"`); 93 var region = change(`"{$region_mobile}"`);
94 - console.log(region) 94 +
95 var price = change(`"{$price_search}"`); 95 var price = change(`"{$price_search}"`);
96 -console.log(price) 96 +
97 var brand = change(`"{$brandList}"`); 97 var brand = change(`"{$brandList}"`);
98 -console.log(brand) 98 +
99 var redata="",prdata="",brdata='' 99 var redata="",prdata="",brdata=''
100 function change(arr) { 100 function change(arr) {
101 qyarr = arr.substring(1, arr.length - 1); 101 qyarr = arr.substring(1, arr.length - 1);
@@ -113,8 +113,14 @@ console.log(brand) @@ -113,8 +113,14 @@ console.log(brand)
113 container: 'body', 113 container: 'body',
114 defaultValue: [0], 114 defaultValue: [0],
115 onConfirm: function (result) { 115 onConfirm: function (result) {
116 - that.find(".shoplist_select_title").html(result[0].label)  
117 - datatype=result[0].value 116 + that.find(".shoplist_select_title").html(result[0].label);
  117 + if(datatype=='区域'){
  118 + redata=result[0].value
  119 + }else if(datatype=='价格'){
  120 + prdata=result[0].value
  121 + }else{
  122 + brdata=result[0].value
  123 + }
118 ajax() 124 ajax()
119 }, 125 },
120 id: 'singleLinePicker' 126 id: 'singleLinePicker'
@@ -141,16 +147,19 @@ console.log(brand) @@ -141,16 +147,19 @@ console.log(brand)
141 }, 147 },
142 dataType: 'json', 148 dataType: 'json',
143 success: function(data) { 149 success: function(data) {
  150 + console.log(data)
144 var arrLen = data.data; 151 var arrLen = data.data;
  152 +
145 if(arrLen.length > 0) { 153 if(arrLen.length > 0) {
  154 +
146 for(var i = 0; i < arrLen.length; i++) { 155 for(var i = 0; i < arrLen.length; i++) {
147 - result += "<div class='list_view'><a href='1111'><img src="+arrLen[i].thumb+" class='list_logo'/></a><div class='list_res'><p class='res_title'>"+arrLen[i].name+"</p><p class='res_mintitle'>"+arrLen[i].goods_name+"</p><p class='res_price'>¥"+arrLen[i].goods_price+"<s>¥"+arrLen[i].price+"</s></p></div></div>" 156 + result += "<div class='list_view'><a href='"+arrLen[i].url+"'><img src="+arrLen[i].thumb+" class='list_logo'/></a><div class='list_res'><p class='res_title'>"+arrLen[i].name+"</p><p class='res_mintitle'>"+arrLen[i].goods_name+"</p><p class='res_price'>¥"+arrLen[i].goods_price+"<s>¥"+arrLen[i].price+"</s></p></div></div>"
148 } 157 }
149 $('.list_content').html(result); 158 $('.list_content').html(result);
150 // 如果没有数据 159 // 如果没有数据
151 } else { 160 } else {
152 // 无数据 161 // 无数据
153 - 162 + $('.list_content').html(result);
154 } 163 }
155 }, 164 },
156 error: function(xhr, type) { 165 error: function(xhr, type) {
@@ -112,6 +112,10 @@ @@ -112,6 +112,10 @@
112 box-sizing: border-box; 112 box-sizing: border-box;
113 padding: 0.32rem; 113 padding: 0.32rem;
114 } 114 }
  115 +.main img {
  116 + width: 100% !important;
  117 + height: auto !important;
  118 +}
115 119
116 .main p { 120 .main p {
117 font-size: 0.28rem; 121 font-size: 0.28rem;