后台
This commit is contained in:
parent
9565792609
commit
524e2dbfe0
@ -1282,6 +1282,16 @@ class Api extends BaseController
|
||||
return to_assign(0, '操作失败');
|
||||
}
|
||||
|
||||
|
||||
public function category_arr($id=0){
|
||||
$where[]=['is_show','=',1];
|
||||
$where[]=['mer_id','=',0];
|
||||
if($id!=0){
|
||||
$where[1]=['mer_id','=',$id];
|
||||
}
|
||||
$list=Db::connect('shop')->table('eb_store_category')->where($where)
|
||||
->field('store_category_id id,pid,cate_name name')->select();
|
||||
$category_arr=create_tree_list(0,$list,0);
|
||||
return to_assign(0,'操作成功', $category_arr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ class StoreProduct extends BaseController
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
$where[] = ['admin_id','=',$this->uid];
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['is_del','=',0];
|
||||
if (isset($param['keywords']) && !empty($param['keywords'])){
|
||||
$where[]=['store_name','like','%'.$param['keywords'].'%'];
|
||||
}
|
||||
@ -1286,8 +1288,49 @@ class StoreProduct extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 商品库存列表
|
||||
public function stock(){
|
||||
if (request()->isAjax()) {
|
||||
$param = get_params();
|
||||
// $where[] = ['admin_id','=',$this->uid];
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['is_del','=',0];
|
||||
if (isset($param['keywords']) && !empty($param['keywords'])){
|
||||
$where[]=['store_name|bar_code','like','%'.$param['keywords'].'%'];
|
||||
}
|
||||
|
||||
if (isset($param['store_cate']) && !empty($param['store_cate'])){
|
||||
$www[]=['b.cate_id','=',$param['store_cate']];
|
||||
}
|
||||
|
||||
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
|
||||
$order = empty($param['order']) ? 'product_id desc' : $param['order'];
|
||||
|
||||
$bar_code_arr = Db::table('cms_store_product')->where($where)->order($order)->column('bar_code');
|
||||
$www[]=['a.bar_code','in',$bar_code_arr];
|
||||
|
||||
$list = Db::connect('shop')->table('eb_store_product_attr_value')
|
||||
->alias('a')
|
||||
->join('eb_store_product b','a.product_id =b.product_id')
|
||||
->field('a.*,b.cate_id,b.store_name')
|
||||
->withAttr('shangjia',function ($value,$data){
|
||||
return Db::table('cms_admin')->where('id',$this->uid)->value('nickname');
|
||||
})
|
||||
->withAttr('cate_id',function ($value,$data){
|
||||
$www2['store_category_id'] = $data['cate_id'];
|
||||
return Db::connect('shop')->table('eb_store_category')->where($www2)->value('cate_name');
|
||||
})
|
||||
->where($www)
|
||||
->order($order)
|
||||
->paginate($rows, false, ['query' => $param]);
|
||||
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
else{
|
||||
return view();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
@ -119,7 +119,11 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">商品编码<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="bar_code" lay-verify="required" lay-reqText="请输入商品编码"
|
||||
autocomplete="off" placeholder="请输入商品编码" class="layui-input"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">单位<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
|
||||
@ -259,7 +263,7 @@
|
||||
},
|
||||
data: [],
|
||||
})
|
||||
$.get('/admin/product.product/category_arr', function (result) {
|
||||
$.get('/admin/api/category_arr', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
@ -282,7 +286,7 @@
|
||||
data: [],
|
||||
radio: true,
|
||||
})
|
||||
$.get('/admin/product.product/category_arr?id=4', function (result) {
|
||||
$.get('/admin/api/category_arr?id=4', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
|
@ -295,7 +295,7 @@
|
||||
data: [],
|
||||
radio: true,
|
||||
})
|
||||
$.get('/admin/store_product/category_arr', function (result) {
|
||||
$.get('/admin/api/category_arr', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
@ -318,7 +318,7 @@
|
||||
data: [],
|
||||
radio: true,
|
||||
})
|
||||
$.get('/admin/store_product/category_arr?id=4', function (result) {
|
||||
$.get('/admin/api/category_arr?id=4', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
|
@ -109,6 +109,11 @@
|
||||
title: '总库存',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'bar_code',
|
||||
title: '产品条码',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'keyword',
|
||||
title: '关键字',
|
||||
|
@ -67,24 +67,24 @@
|
||||
<td>
|
||||
<div id="cate_id"></div>
|
||||
</td>
|
||||
<td class="layui-td-gray">品牌选择<font>*</font>
|
||||
</td>
|
||||
<td colspan="6">
|
||||
<select name="brand_id" lay-verify="required" lay-search="">
|
||||
<option value="">请选择</option>
|
||||
{volist name='store_brand' id='vo'}
|
||||
<option value="{$vo.brand_id}" {if $detail.brand_id==$vo.brand_id} selected {/if}>{$vo.brand_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">商户分类<font>*</font>
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<div id="mer_cate_id"></div>
|
||||
</td>
|
||||
<!-- <td class="layui-td-gray">品牌选择<font>*</font>-->
|
||||
<!-- </td>-->
|
||||
<!-- <td colspan="6">-->
|
||||
<!-- <select name="brand_id" lay-verify="required" lay-search="">-->
|
||||
<!-- <option value="">请选择</option>-->
|
||||
<!-- {volist name='store_brand' id='vo'}-->
|
||||
<!-- <option value="{$vo.brand_id}" {if $detail.brand_id==$vo.brand_id} selected {/if}>{$vo.brand_name}</option>-->
|
||||
<!-- {/volist}-->
|
||||
<!-- </select>-->
|
||||
<!-- </td>-->
|
||||
</tr>
|
||||
<!-- <tr>-->
|
||||
<!-- <td class="layui-td-gray">商户分类<font>*</font>-->
|
||||
<!-- </td>-->
|
||||
<!-- <td colspan="3">-->
|
||||
<!-- <div id="mer_cate_id"></div>-->
|
||||
<!-- </td>-->
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
|
||||
@ -126,6 +126,12 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">商品编码<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="bar_code" lay-verify="required" lay-reqText="请输入商品编码"
|
||||
autocomplete="off" placeholder="请输入商品编码" class="layui-input" value="{$detail.bar_code}"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">单位<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
|
||||
@ -267,7 +273,7 @@
|
||||
data: [],
|
||||
radio: true,
|
||||
})
|
||||
$.get('/admin/product.product/category_arr', function (result) {
|
||||
$.get('/admin/api/category_arr', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
@ -291,7 +297,7 @@
|
||||
data: [],
|
||||
radio: true,
|
||||
})
|
||||
$.get('/admin/product.product/category_arr?id=4', function (result) {
|
||||
$.get('/admin/api/category_arr?id=4', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
|
@ -61,24 +61,24 @@
|
||||
<td>
|
||||
<div id="cate_id"></div>
|
||||
</td>
|
||||
<td class="layui-td-gray">品牌选择<font>*</font>
|
||||
</td>
|
||||
<td colspan="6">
|
||||
<select name="brand_id" lay-verify="required" lay-search="" disabled>
|
||||
<option value="">请选择</option>
|
||||
{volist name='store_brand' id='vo'}
|
||||
<option value="{$vo.brand_id}" {if $detail.brand_id==$vo.brand_id} selected {/if}>{$vo.brand_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">商户分类<font>*</font>
|
||||
</td>
|
||||
<td colspan="3">
|
||||
<div id="mer_cate_id"></div>
|
||||
</td>
|
||||
<!-- <td class="layui-td-gray">品牌选择<font>*</font>-->
|
||||
<!-- </td>-->
|
||||
<!-- <td colspan="6">-->
|
||||
<!-- <select name="brand_id" lay-verify="required" lay-search="" disabled>-->
|
||||
<!-- <option value="">请选择</option>-->
|
||||
<!-- {volist name='store_brand' id='vo'}-->
|
||||
<!-- <option value="{$vo.brand_id}" {if $detail.brand_id==$vo.brand_id} selected {/if}>{$vo.brand_name}</option>-->
|
||||
<!-- {/volist}-->
|
||||
<!-- </select>-->
|
||||
<!-- </td>-->
|
||||
</tr>
|
||||
<!-- <tr>-->
|
||||
<!-- <td class="layui-td-gray">商户分类<font>*</font>-->
|
||||
<!-- </td>-->
|
||||
<!-- <td colspan="3">-->
|
||||
<!-- <div id="mer_cate_id"></div>-->
|
||||
<!-- </td>-->
|
||||
<!-- </tr>-->
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
|
||||
@ -120,6 +120,12 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">商品编码<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="bar_code" lay-verify="required" lay-reqText="请输入商品编码"
|
||||
autocomplete="off" placeholder="请输入商品编码" class="layui-input" value="{$detail.bar_code}"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="layui-td-gray">单位<font>*</font></td>
|
||||
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
|
||||
@ -256,7 +262,7 @@
|
||||
radio: true,
|
||||
disabled:true,
|
||||
})
|
||||
$.get('/admin/product.product/category_arr', function (result) {
|
||||
$.get('/admin/api/category_arr', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
@ -281,7 +287,7 @@
|
||||
radio: true,
|
||||
disabled:true,
|
||||
})
|
||||
$.get('/admin/product.product/category_arr?id=4', function (result) {
|
||||
$.get('/admin/api/category_arr?id=4', function (result) {
|
||||
demo_cate.update({
|
||||
data: result.data
|
||||
})
|
||||
|
297
app/admin/view/store_product/stock.html
Normal file
297
app/admin/view/store_product/stock.html
Normal file
@ -0,0 +1,297 @@
|
||||
{extend name="common/base"/}
|
||||
<!-- 主体 -->
|
||||
{block name="body"}
|
||||
<style>
|
||||
.layui-input-inline{
|
||||
width:35% !important;
|
||||
}
|
||||
.layui-input-inline .layui-form-item{
|
||||
display:flex;
|
||||
}
|
||||
.layui-input-inline .layui-form-item .layui-form-label{
|
||||
width:30%;
|
||||
}
|
||||
.layui-input-block{
|
||||
margin-left:unset !important;
|
||||
width:75%;
|
||||
}
|
||||
#seleform{
|
||||
border-color: #eee;
|
||||
background-color: #fff;
|
||||
color:#a39f9f;
|
||||
width:100%;
|
||||
}
|
||||
</style>
|
||||
<div class="p-3">
|
||||
<form id="filterform" class="layui-form gg-form-bar border-t border-x">
|
||||
<div class="layui-form-item">
|
||||
|
||||
|
||||
<div class="layui-input-inline">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品分类</label>
|
||||
<div class="layui-input-block">
|
||||
<input id="store_cate" type="hidden" readonly="readonly" name="store_cate">
|
||||
<button id="seleform" lay-filter="seleform" class="layui-btn">请选择</button>
|
||||
<div id="removeselect"><i class="bi-x-lg" style="position: absolute;right:2px;top:10px;z-index: 9;cursor:pointer;"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
|
||||
</form>
|
||||
<table class="layui-hide" id="store_product" lay-filter="store_product"></table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/html" id="barDemo">
|
||||
<div class="layui-btn-group"></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: '#store_product',
|
||||
title: '商品表列表',
|
||||
toolbar: '#toolbarDemo',
|
||||
url: '/admin/store_product/stock',
|
||||
page: true,
|
||||
limit: 20,
|
||||
cellMinWidth: 300,
|
||||
cols: [
|
||||
[
|
||||
{
|
||||
fixed: 'left',
|
||||
field: 'product_id',
|
||||
title: '编号',
|
||||
align: 'center',
|
||||
width: 80
|
||||
},{
|
||||
field: 'shangjia',
|
||||
title: '商家',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'image',
|
||||
title: '商品图片',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
templet: '<div><img src="{{ d.image }}" style="width:30px; height:30px;"></div>',
|
||||
},{
|
||||
field: 'store_name',
|
||||
title: '商品名称',
|
||||
align: 'center',
|
||||
width: 200
|
||||
},{
|
||||
field: 'stock',
|
||||
title: '总库存',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'bar_code',
|
||||
title: '产品条码',
|
||||
align: 'center',
|
||||
width: 150
|
||||
},{
|
||||
field: 'cate_id',
|
||||
title: '分类',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'price',
|
||||
title: '最低价格',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'cost',
|
||||
title: '成本价',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},{
|
||||
field: 'ot_price',
|
||||
title: '原价',
|
||||
align: 'center',
|
||||
width: 100
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
//监听表头工具栏事件
|
||||
table.on('toolbar(store_product)', function(obj){
|
||||
if (obj.event === 'add') {
|
||||
tool.side("/admin/store_product/add");
|
||||
return false;
|
||||
}
|
||||
if (obj.event === 'adds') {
|
||||
tool.side("/admin/store_product/adds");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// 商户商品分类搜索
|
||||
layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){
|
||||
var dropdown = layui.dropdown
|
||||
,util = layui.util
|
||||
,layer = layui.layer
|
||||
,rate = layui.rate
|
||||
// ,table = layui.table
|
||||
,$ = layui.jquery;
|
||||
|
||||
var $ = layui.$, active = {
|
||||
reload: function(){
|
||||
let dataRload = getformdata();
|
||||
//执行重载
|
||||
table.reload('store_product', {
|
||||
page: {
|
||||
curr: 1 //重新从第 1 页开始
|
||||
}
|
||||
,where: {
|
||||
...dataRload
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
//商户商品分类菜单
|
||||
$.ajax({
|
||||
url: '/admin/api/getAllList',
|
||||
method: "get",
|
||||
data: {},
|
||||
success: function(res) {
|
||||
if (res.code!==0)return ;
|
||||
|
||||
//高级演示 - 各种组合
|
||||
dropdown.render({
|
||||
elem: '#seleform'
|
||||
,isAllowSpread: false //禁止菜单组展开收缩
|
||||
,style: 'width: 200px' //定义宽度,默认自适应
|
||||
,id: 'test777' //定义唯一索引
|
||||
,title: 'title1'
|
||||
,data: res.data
|
||||
,click: function(item){
|
||||
$('#seleform').text(item.title);
|
||||
$('#seleform').css({color:'rgba(0,0,0,.85)'});
|
||||
$('#store_cate').val(item.id);
|
||||
|
||||
active['reload'] ? active['reload'].call(this) : '';
|
||||
}
|
||||
});
|
||||
},
|
||||
fail:function(){}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//基础效果
|
||||
rate.render({
|
||||
elem: '#is_good'
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
//监听搜索提交
|
||||
form.on('submit(searchform)', function(data) {
|
||||
layui.pageTable.reload({
|
||||
where: {
|
||||
...data.field
|
||||
},
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
//监听select提交
|
||||
form.on('select(seleform)', function(data) {
|
||||
active['reload'] ? active['reload'].call(this) : '';
|
||||
return false;
|
||||
});
|
||||
|
||||
//监听removeselect点击
|
||||
$('#removeselect').on('click', function(){
|
||||
$('#seleform').text('请选择');
|
||||
$('#seleform').css({color:'#a39f9f'});
|
||||
$('#store_cate').val('');
|
||||
active['reload'] ? active['reload'].call(this) : '';
|
||||
return false;
|
||||
});
|
||||
|
||||
// tab 状态列表切换
|
||||
$('.site-demo-active').on('click', function(){
|
||||
var othis = $(this), type = othis.data('type');
|
||||
$('#protype').val(this.getAttribute('type'));
|
||||
active[type] ? active[type].call(this, othis) : '';
|
||||
});
|
||||
|
||||
});
|
||||
//监听表格行工具事件
|
||||
table.on('tool(store_product)', function(obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'read') {
|
||||
tool.side('/admin/store_product/read?product_id='+obj.data.product_id);
|
||||
}
|
||||
else if (obj.event === 'edit') {
|
||||
tool.side('/admin/store_product/edit?product_id='+obj.data.product_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/store_product/del", { product_id: data.product_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;
|
||||
});
|
||||
|
||||
// 获取表单所有参数
|
||||
function getformdata() {
|
||||
var form = $('#filterform').serializeArray();
|
||||
|
||||
var data = new Array();
|
||||
for(let i=0;i<form.length; i++){
|
||||
data[form[i].name] = form[i].value;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
{/block}
|
||||
<!-- /脚本 -->
|
Loading…
x
Reference in New Issue
Block a user