Commit 0540a7fb by 孙龙

up

parent 5b331f1e
<?php
namespace App\Exceptions;
class BomException extends \Exception{
}
\ No newline at end of file
......@@ -77,7 +77,14 @@ class BomApiController extends Controller{
//bom单详情 保存bom单
public function saveBomInfo($request,$id){
$this->bomService->saveBomInfo($request);
$res = $this->bomService->saveBomInfo($request);
return $this->ajaxReturn($res['errcode'],$res['errmsg']);
}
public function createBomOrder($request,$id){
$res = $this->bomService->createBomOrder($request);
return $this->ajaxReturn($res['errcode'],$res['errmsg']);
}
......
......@@ -27,10 +27,22 @@ class BomItemMatchModel extends BomItemMatchBaseModel{
public function getBomItemsMatching($bom_id,$bom_item_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("bom_item_id",$bom_item_id)->first();
return self::suffix($suffix)->where('bom_id', $bom_id)->where("bom_item_id",$bom_item_id)->where("status",1)->first();
}
public function updateBomMatch($bom_id,$where,$data){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where($where)->update($data);
}
public function addBomMatch($bom_id,$data){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->insert($data);
}
......
......@@ -25,9 +25,13 @@ class BomItemModel extends BomItemMatchBaseModel{
}
public function getBomItems($bom_id){
public function getBomItems($request,$bom_id){
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->get();
$query = self::suffix($suffix)->select("*")->where('bom_id', $bom_id);
$query = $query->paginate($limit,[],'page',$page);
return $query;
}
......
......@@ -58,6 +58,17 @@ return [
// 'search-skuid' => 'http://www.liexin.com/v3/sku/list',
'search-skuid' => 'http://api.liexin.com/goods/detail',
'search-skuid-finalInfo' => 'http://api.liexin.com/cart/bomOrderGetFinalGoods',
//批量下自营订单
'addzyorder_url' => 'http://api.liexin.com/cart/addBatch',
//联营
'addlyorder_url' => 'http://api.liexin.com/cart/addBatchByOrderSystem',
//创建订单
'api_create_order' => 'http://api.liexin.com/order/create',
// 新增SKU入口
'add-sku-url' => 'http://footstone.liexin.net/manage/addsku',
......
......@@ -2,28 +2,56 @@ layui.use(['form', 'table', 'laydate'], function() {
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
var table = layui.table;
//转换静态表格
table.init('bomView', {
url: '/ajax/bom/BomView?bom_id='+bom_id //数据接口
limit:10
,url: '/ajax/bom/BomView?bom_id='+bom_id //数据接口
,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
,defaultToolbar:[]
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: false //开启分页
,page: true //开启分页
});
//头工具栏事件
table.on('toolbar(bomView)', function(obj){
switch(obj.event){
case 'save_form':
var listdata = layui.table.cache;
console.log(listdata[1])
var datax = {}
datax.data = listdata[1]
function renderTable(){
table.init('bomView', {
limit:10
,url: '/ajax/bom/BomView?bom_id='+bom_id //数据接口
,toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
,defaultToolbar:[]
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
});
}
form.on('checkbox(checkall)', function (data) {
var child = $(data.elem).parents('.layui-tab-item').find('input[type="checkbox"]');
child.each(function (index, item) {
item.checked = data.elem.checked;
});
form.render('checkbox');
});
//监听单元格编辑
table.on('edit(bomView)', function(obj){
var value = obj.value //得到修改后的值
,data = obj.data //得到所在行所有键值
,field = obj.field; //得到字段
if(field != "match_goods_id"){
obj.data.match_goods_id = 0;
obj.update(data) //修改当前行数据
}
});
function save_form_ajax(datax){
layer.open({
title: "保存bom单",
content: "你确定保存吗?",
......@@ -35,32 +63,77 @@ layui.use(['form', 'table', 'laydate'], function() {
type: 'post',
data: datax,
success: function(resp) {
//if (resp.err_code == 0) {
// layer.msg(resp.err_msg);
// // renderTable(); // 重新加载table
// $('.search').trigger("click"); // 触发搜索按钮
// if(typeof resp.data.redictUrl != "undefined"){
// window.location.href=resp.data.redictUrl;
// }
// return false;
//}
//
//layer.alert(resp.err_msg);
if (resp.errcode == 0) {
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
}else{
layer.alert(resp.errmsg);
}
},
error: function(err) {
console.log(err)
}
})
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
//layer.msg('保存中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
function create_order_ajax(datax){
layer.open({
title: "创建bom订单",
content: "你确定下单吗?",
btn: ['确认?', '取消'],
yes: function(index) {
layer.close(index);
$.ajax({
url : "/ajax/bom/createBomOrder",
type: 'post',
data: datax,
success: function(resp) {
if (resp.errcode == 0) {
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
}else{
layer.alert(resp.errmsg);
}
},
error: function(err) {
console.log(err)
}
})
return false;
},
cancel: function(index) {
layer.close(index);
}
})
}
//头工具栏事件
table.on('toolbar(bomView)', function(obj){
var checkStatus = table.checkStatus("layui_table_bomView");
var data = checkStatus.data;
if(checkStatus.data.length <= 0){
layer.msg('请先选择需要保存的数据行', {icon: 16, time: 3000, shade: 0.3})
return
}
var datax = {}
datax.data = data
switch(obj.event){
case 'create_order':
create_order_ajax(datax);
break;
case 'save_form':
save_form_ajax(datax)
break;
};
});
......
......@@ -22,19 +22,22 @@
-webkit-border-radius: 6px;
}
</style>
<table class="layui-table" lay-filter="bomView">
<table class="layui-table" lay-filter="bomView" id="layui_table_bomView">
<thead>
<tr>
<th lay-data="{fixed: 'left',templet:'#checkbd'}"><input type="checkbox" >全选</th>
<th lay-data="{type:'numbers', width:80, sort: true,fixed: 'left'}">序号</th>
<th lay-data="{field:'goods_name', width:150,fixed: 'left'}">需求型号</th>
<th lay-data="{field:'brand_name',fixed: 'left',width:140,}">品牌</th>
<th lay-data="{field:'goods_name', width:150}">需求型号</th>
<th lay-data="{field:'brand_name',width:140,}">品牌</th>
<th lay-data="{field:'number',width:120,}">需求数量</th>
<th lay-data="{field:'attrs',width:120,}">参数</th>
<th lay-data="{field: 'match_goods_id',width:150,edit:'text'}">skuID(可修改)</th>
<th lay-data="{field: 'match_goods_name',width:200,edit:'text'}">推荐型号(可修改)</th>
<th lay-data="{field: 'match_brand_name',width:200,edit:'text'}">推荐品牌(可修改)</th>
<th lay-data="{field:'number', width:130,edit: 'text',edit:'text'}">数量(可修改)</th>
<th lay-data="{field:'match_number', width:130,edit:'text'}"><i class="layui-icon-edit"></i>推荐数量(可修改)</th>
<th lay-data="{field:'match_price',width:130,edit:'text'}">单价(可修改)</th>
<th lay-data="{field:'match_delivery',width:160,edit:'text'}">货期/天(可修改)</th>
<th lay-data="{field:'match_supplier_name'}">供应商</th>
<th lay-data="{field:'match_supplier_name',edit:'text',width:160}">供应商(可修改)</th>
<th lay-data="{field:'match_mpq'}">包装</th>
<th lay-data="{field:'match_moq'}">起订量</th>
<th lay-data="{field:'match_amount',width:100}">小计</th>
......@@ -48,6 +51,7 @@
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="save_form">保存</button>
<button class="layui-btn layui-btn-sm" lay-event="create_order">下单</button>
</div>
</script>
......@@ -60,6 +64,11 @@
@{{# } }}
</script>
<script type="text/html" id="checkbd">
@{{# if (d.is_corder != 1) { }}
<input type="checkbox" name="layTableCheckbox" lay-skin="primary">
@{{# } }}
</script>
<script type="text/html" id="match_extend_order_amount">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment