355 lines
14 KiB
HTML
355 lines
14 KiB
HTML
{extend name="app/shop/view/base.html"/}
|
|
{block name="resources"}
|
|
<style>
|
|
.goods-table-content{
|
|
width: calc(100% - 40px) !important;
|
|
padding: 0 20px 30px 20px;
|
|
}
|
|
|
|
.goods-info{
|
|
display: inline-flex;
|
|
flex-direction: row;
|
|
flex-wrap: nowrap;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
height: 60px;
|
|
width: 100% !important;
|
|
}
|
|
.goods-info .goods-info-image{
|
|
width: 50px;
|
|
height: 50px;
|
|
margin-right: 10px;
|
|
}
|
|
.goods-info .goods-info-image .goods-logo{
|
|
width: 100% !important;
|
|
height: 100% !important;
|
|
}
|
|
.goods-info .goods-info-desc{
|
|
height: 50px;
|
|
display: inline-flex;
|
|
flex-direction: column;
|
|
flex-wrap: nowrap;
|
|
justify-content: center;
|
|
align-items: flex-start;
|
|
width: calc(100% - 65px);
|
|
}
|
|
.goods-info .goods-info-desc .name{
|
|
height: 25px;
|
|
width: 100%;
|
|
line-height: 25px;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.goods-info .goods-info-desc .brand{
|
|
height: 25px;
|
|
line-height: 25px;
|
|
}
|
|
|
|
.button-group{
|
|
display: inline-flex;
|
|
}
|
|
</style>
|
|
{/block}
|
|
|
|
{block name="body"}
|
|
<!-- 顶部搜索 -->
|
|
<div class="screen layui-collapse">
|
|
<div class="layui-colla-item">
|
|
<div class="layui-colla-content layui-form layui-show member-form" lay-filter="search_form">
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">商品名称</label>
|
|
<div class="layui-input-inline input-append">
|
|
<input type="text" class="layui-input" name="goods_name" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">商品分类</label>
|
|
<div class="layui-input-inline">
|
|
<select name="cate_id" lay-search="">
|
|
<option value="">全部分类</option>
|
|
{foreach $cate_list as $cateKey => $cateVal}
|
|
<optgroup label="{$cateVal['name']}">
|
|
{foreach $cateVal['children'] as $cateChildrenKey => $cateChildrenVal}
|
|
<option value="{$cateChildrenVal['id']}">{$cateChildrenVal['name']}</option>
|
|
{/foreach}
|
|
</optgroup>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">品牌</label>
|
|
<div class="layui-input-inline">
|
|
<select name="brand_name" lay-search="">
|
|
<option value="">全部品牌</option>
|
|
{foreach $brand_list as $brandKey => $brandVal}
|
|
<option value="{$brandVal['name']}">{$brandVal['name']}</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">折扣起</label>
|
|
<div class="layui-input-inline input-append">
|
|
<input type="number" step="0.01" class="layui-input" name="discount_rate_begin" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">折扣止</label>
|
|
<div class="layui-input-inline input-append">
|
|
<input type="number" step="0.01" class="layui-input" name="discount_rate_end" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">结算价起</label>
|
|
<div class="layui-input-inline input-append">
|
|
<input type="number" step="0.01" class="layui-input" name="price_from" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label class="layui-form-label">结算价止</label>
|
|
<div class="layui-input-inline input-append">
|
|
<input type="number" step="0.01" class="layui-input" name="price_to" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
|
<button type="reset" lay-submit lay-filter="reset" class="layui-btn layui-btn-primary">重置</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 列表 -->
|
|
<div class="goods-table-content">
|
|
<table id="listContent" lay-filter="listContent"></table>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 商品信息 -->
|
|
<script type="text/html" id="goodsInfo">
|
|
<div class="goods-info" title="{{ d.name }}">
|
|
<div class="goods-info-image">
|
|
<img class="goods-logo" layer-src src="{{d.logo}}" onerror="this.src = '{:img(\'public/static/img/default_img/head.png\')}' ">
|
|
</div>
|
|
<div class="goods-info-desc">
|
|
<div class="name">{{ d.name }}</div>
|
|
<div class="brand">
|
|
<span class="layui-badge layui-bg-orange">{{ d.brand }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
<!-- 批量操作 -->
|
|
<script type="text/html" id="toolbarOperation">
|
|
<button class="layui-btn layui-btn-primary" lay-event="batch_add">批量入库</button>
|
|
</script>
|
|
|
|
<!-- 批量操作 -->
|
|
<script type="text/html" id="batchOperation">
|
|
<button class="layui-btn layui-btn-primary" lay-event="batch_add">批量入库</button>
|
|
</script>
|
|
<!-- 操作 -->
|
|
<script type="text/html" id="operation">
|
|
<div class="button-group">
|
|
{{# if(d.is_warehousing == 1){ }}
|
|
<button class="layui-btn" lay-event="refresh">刷新</button>
|
|
{{# }else{ }}
|
|
<button class="layui-btn" lay-event="add">入库</button>
|
|
{{# } }}
|
|
</div>
|
|
</script>
|
|
{/block}
|
|
{block name="script"}
|
|
<script>
|
|
var _thisIndex,table,form,editIframe,repeat_flag = false;//防重复标识;
|
|
layui.use(['form'], function() {
|
|
form = layui.form;
|
|
form.render();
|
|
// 基本参数
|
|
_thisIndex = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
|
// 内容获取
|
|
table = new Table({
|
|
elem: '#listContent',
|
|
url: ns.url("funengscm://shop/goods/tableGetList"),
|
|
cols: [
|
|
[
|
|
{
|
|
type: 'checkbox',
|
|
unresize: 'false',
|
|
width: '3%'
|
|
},
|
|
{align: 'left', title: '商品信息', unresize: 'false', templet: '#goodsInfo', width: 300},
|
|
{align: 'center', title: '起售价', field: 'price', unresize: 'false'},
|
|
{align: 'center', title: '起售结算价', field: 'settlementPrice', unresize: 'false'},
|
|
{
|
|
align: 'center', title: '商品利润率', field: 'profitMargin', unresize: 'false', templet: function (data) {
|
|
return `<span class="layui-badge layui-bg-blue">${data.profitMargin}</span>`;
|
|
}
|
|
},
|
|
{
|
|
align: 'center', title: '商品折扣率', field: 'discountRate', unresize: 'false', templet: function (data) {
|
|
return `<span class="layui-badge layui-bg-blue">${data.discountRate}</span>`;
|
|
}
|
|
},
|
|
{align: 'center', title: '商品分类', field: 'productCategoryList', unresize: 'false'},
|
|
{
|
|
align: 'center', title: '是否入库', field: 'is_warehousing', unresize: 'false', templet: function (data) {
|
|
if (data.is_warehousing == 1) return `<span class="layui-badge layui-bg-green">已入库</span>`;
|
|
else return `<span class="layui-badge">未入库</span>`;
|
|
}
|
|
},
|
|
{title: '操作', toolbar: '#operation', unresize: 'false', align: 'center', width: 80}
|
|
]],
|
|
toolbar: '#toolbarOperation',
|
|
bottomToolbar: "#batchOperation"
|
|
});
|
|
// 点击搜索
|
|
form.on('submit(search)', function(data) {
|
|
table.reload({
|
|
page: {
|
|
curr: 1
|
|
},
|
|
where: data.field
|
|
});
|
|
});
|
|
// 重置表单
|
|
form.on('submit(reset)', function(data) {
|
|
let field = {
|
|
page: 1,
|
|
goods_name: '',
|
|
cate_id: '',
|
|
brand_name: '',
|
|
discount_rate_begin: '',
|
|
discount_rate_end: '',
|
|
price_from: '',
|
|
price_to: '',
|
|
};
|
|
form.val("search_form", field);
|
|
layui.form.render();
|
|
// 刷新表格
|
|
table.reload({
|
|
page: {
|
|
curr: 1
|
|
},
|
|
where: field
|
|
});
|
|
});
|
|
// 监听工具栏操作
|
|
table.tool(function(obj) {
|
|
console.log(55555)
|
|
let data = obj.data;
|
|
let type = obj.event;
|
|
if(type === 'add' || type === 'refresh' ){
|
|
let tips = type === 'add' ? '确认将当前商品入库吗?' : '确认刷新当前商品吗,商品刷新后所有信息都将和供应链商品信息同步,包括已修改信息?';
|
|
layer.confirm(tips, function() {
|
|
layer.close();
|
|
// let loadingIndex = ns.loading('open', '正在进行处理,请耐心等待......');
|
|
$.ajax({
|
|
url: ns.url("funengscm://shop/goods/selectGoods"),
|
|
data: {
|
|
'info[id]': data.id,
|
|
is_refresh: type === 'refresh' ? 1 : 0
|
|
},
|
|
dataType: 'JSON',
|
|
type: 'POST',
|
|
success: function(res) {
|
|
// layer.close(loadingIndex);
|
|
if (parseInt(res.code) === 0) {
|
|
layer.confirm('入库成功', {
|
|
title: '操作提示',
|
|
btn: ['返回列表', '继续操作'],
|
|
yes: function () {
|
|
layer.alert(res.message, function(index){
|
|
parent.layer.close(_thisIndex);
|
|
});
|
|
},
|
|
btn2: function () {
|
|
table.reload();
|
|
}
|
|
});
|
|
} else {
|
|
layer.msg(res.message);
|
|
}
|
|
}
|
|
});
|
|
}, function() {
|
|
layer.close();
|
|
});
|
|
}
|
|
});
|
|
/**
|
|
* 批量操作
|
|
*/
|
|
table.bottomToolbar(function (obj) {
|
|
if (obj.data.length < 1) {
|
|
layer.msg('请选择要操作的数据');
|
|
return;
|
|
}
|
|
var id_array = new Array();
|
|
for (i in obj.data){
|
|
if(obj.data[i].is_warehousing!=1){
|
|
id_array.push(obj.data[i].id);
|
|
}
|
|
}
|
|
switch (obj.event) {
|
|
case "batch_add":
|
|
batchAdd(id_array.toString());
|
|
break;
|
|
}
|
|
});
|
|
/**
|
|
* 批量操作
|
|
*/
|
|
table.toolbar(function (obj) {
|
|
if (obj.data.length < 1) {
|
|
layer.msg('请选择要操作的数据');
|
|
return;
|
|
}
|
|
var id_array = new Array();
|
|
for (i in obj.data){
|
|
if(obj.data[i].is_warehousing!=1){
|
|
id_array.push(obj.data[i].id);
|
|
}
|
|
}
|
|
switch (obj.event) {
|
|
case "batch_add":
|
|
batchAdd(id_array.toString());
|
|
break;
|
|
}
|
|
});
|
|
|
|
//商品
|
|
function batchAdd(goods_ids) {
|
|
let loadingIndex = ns.loading('open', '正在进行处理,请耐心等待......');
|
|
$.ajax({
|
|
url: ns.url("funengscm://shop/goods/selectGoods"),
|
|
data: {
|
|
'info[id]': goods_ids,
|
|
is_refresh: 0,
|
|
is_batch: 1
|
|
},
|
|
dataType: 'JSON',
|
|
type: 'POST',
|
|
success: function(res) {
|
|
layer.close(loadingIndex);
|
|
layer.msg(res.message);
|
|
repeat_flag = false;
|
|
layer.close(loadingIndex);
|
|
if (res.code == 0) {
|
|
table.reload();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
{/block} |