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']);
}
......
<?php
namespace App\Model\Bom;
class BomItemMatchModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item_matching'; //库名
protected $primaryKey = 'matching_id'; //设置id
protected $guarded = ['matching_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
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();
}
<?php
namespace App\Model\Bom;
class BomItemMatchModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item_matching'; //库名
protected $primaryKey = 'matching_id'; //设置id
protected $guarded = ['matching_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
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)->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);
}
}
\ No newline at end of file
<?php
namespace App\Model\Bom;
class BomItemModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item'; //库名
protected $primaryKey = 'bom_item_id'; //设置id
protected $guarded = ['bom_item_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
public function getBomItems($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->get();
}
<?php
namespace App\Model\Bom;
class BomItemModel extends BomItemMatchBaseModel{
protected $connection = 'bom'; //库名
protected $table = 'bom_item'; //库名
protected $primaryKey = 'bom_item_id'; //设置id
protected $guarded = ['bom_item_id']; //设置字段黑名单
public $timestamps = true;
const CREATED_AT = 'add_time';
const UPDATED_AT = 'update_time';
protected $dateFormat = 'Y-m-d H:i:s';
public function fromDateTime($value){
return strtotime(parent::fromDateTime($value));
}
public function getBomAmount($bom_id){
$suffix = substr(strrev($bom_id),0,1);
return self::suffix($suffix)->where('bom_id', $bom_id)->where("status",1)->selectRaw("sum(price*number) as amount")->first();
}
public function getBomItems($request,$bom_id){
$page = $request->input("page",1);
$limit = $request->input("limit",10);
$suffix = substr(strrev($bom_id),0,1);
$query = self::suffix($suffix)->select("*")->where('bom_id', $bom_id);
$query = $query->paginate($limit,[],'page',$page);
return $query;
}
}
\ No newline at end of file
<?php
return [
'admin' => ['admin@ichunt.com'],
'login' => [
'login' => 'http://' . env('LOGIN_DOMAIN', '') . '/login',
'logout'=> 'http://' . env('LOGIN_DOMAIN', '') . '/logout',
'check' => 'http://' . env('LOGIN_DOMAIN', '') . '/api/checklogin',
'search'=> 'http://' . env('LOGIN_DOMAIN', '') . '/api/search',
],
'domain' => 'liexin.net',
// 订单系统
'order_url' => 'http://order.liexin.net',
// API项目
'api_domain' => 'http://api.liexin.com/',
'upload_key' => 'fh6y5t4rr351d2c3bryi', // 上传文件key
// 权限系统
'perm_url' => 'http://perm.liexin.net',
// 获取用户权限接口
'perm_api' => 'http://perm.liexin.net/api/perms/',
// 获取用户许可权限接口
'check_access_api' => 'http://perm.liexin.net/api/perms/access',
// 竞调账户配置显示时间
'vp_time_set' => '2018-05-01',
// 基石服务地址
'SERVICE_DOMAIN' => 'http://192.168.1.100',
//中间服务秘钥
'SERVICE_KEY' => 'j9q##VRhaXBEtznIEeDiR@1Hvy0sW3wp',
// 快递配置
'express_fee_key' => 'express_fee',
'express_fee' => [
'sz_inside' => 10,
'gd_inside' => 10,
'gd_outside' => 15,
],
// www站点
'main_url' => 'https://www.liexin.com/',
// 新增自营线下订单内部账号
'internal-account' => '15011111111',
// 新增用户入口
'add-user-url' => 'http://member.liexin.net/add',
// 编辑用户入口
'check-user-url' => 'http://member.liexin.net/list',
// 查询SKUID接口
// 'search-skuid' => 'http://footstone.liexin.net/webapi/sku_list',
// 'search-skuid' => 'http://www.liexin.com/v3/sku/list',
'search-skuid' => 'http://api.liexin.com/goods/detail',
// 新增SKU入口
'add-sku-url' => 'http://footstone.liexin.net/manage/addsku',
// 查询联营SKU入口
'search-sku-url-1' => 'http://footstone.liexin.net/manage/skulist',
// 查询自营SKU入口
'search-sku-url-2' => 'http://footstone.liexin.net/manage/GoodsList',
// 新增自营线上订单付款地址
'pay_online_url' => 'http://www.liexin.com/v3/pay/online?id=',
// 获取自营商品库存
'self-stock-url' => 'http://footstone.liexin.net/webapi/goods_details?sku_id=',
// 财务系统接口地址 (自营发票)
'finance-self-invoice-url' => 'http://192.168.1.97/webapi/checkOrderBillStatus',
// 支付地址
'pay_url' => 'https://www.liexin.com/v3/pay/online?id=',
// 订单微服务
'order_api_domain' => 'http://orderapi.liexin.com',
// crm
'crm_domain' => 'http://lcrm.liexin.net',
// 导出系统
'export_url' => 'http://export.liexin.com',
'export_joint_source_id' => 16,
'export_self_source_id' => 17,
];
<?php
return [
'admin' => ['admin@ichunt.com'],
'login' => [
'login' => 'http://' . env('LOGIN_DOMAIN', '') . '/login',
'logout'=> 'http://' . env('LOGIN_DOMAIN', '') . '/logout',
'check' => 'http://' . env('LOGIN_DOMAIN', '') . '/api/checklogin',
'search'=> 'http://' . env('LOGIN_DOMAIN', '') . '/api/search',
],
'domain' => 'liexin.net',
// 订单系统
'order_url' => 'http://order.liexin.net',
// API项目
'api_domain' => 'http://api.liexin.com/',
'upload_key' => 'fh6y5t4rr351d2c3bryi', // 上传文件key
// 权限系统
'perm_url' => 'http://perm.liexin.net',
// 获取用户权限接口
'perm_api' => 'http://perm.liexin.net/api/perms/',
// 获取用户许可权限接口
'check_access_api' => 'http://perm.liexin.net/api/perms/access',
// 竞调账户配置显示时间
'vp_time_set' => '2018-05-01',
// 基石服务地址
'SERVICE_DOMAIN' => 'http://192.168.1.100',
//中间服务秘钥
'SERVICE_KEY' => 'j9q##VRhaXBEtznIEeDiR@1Hvy0sW3wp',
// 快递配置
'express_fee_key' => 'express_fee',
'express_fee' => [
'sz_inside' => 10,
'gd_inside' => 10,
'gd_outside' => 15,
],
// www站点
'main_url' => 'https://www.liexin.com/',
// 新增自营线下订单内部账号
'internal-account' => '15011111111',
// 新增用户入口
'add-user-url' => 'http://member.liexin.net/add',
// 编辑用户入口
'check-user-url' => 'http://member.liexin.net/list',
// 查询SKUID接口
// 'search-skuid' => 'http://footstone.liexin.net/webapi/sku_list',
// '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',
// 查询联营SKU入口
'search-sku-url-1' => 'http://footstone.liexin.net/manage/skulist',
// 查询自营SKU入口
'search-sku-url-2' => 'http://footstone.liexin.net/manage/GoodsList',
// 新增自营线上订单付款地址
'pay_online_url' => 'http://www.liexin.com/v3/pay/online?id=',
// 获取自营商品库存
'self-stock-url' => 'http://footstone.liexin.net/webapi/goods_details?sku_id=',
// 财务系统接口地址 (自营发票)
'finance-self-invoice-url' => 'http://192.168.1.97/webapi/checkOrderBillStatus',
// 支付地址
'pay_url' => 'https://www.liexin.com/v3/pay/online?id=',
// 订单微服务
'order_api_domain' => 'http://orderapi.liexin.com',
// crm
'crm_domain' => 'http://lcrm.liexin.net',
// 导出系统
'export_url' => 'http://export.liexin.com',
'export_joint_source_id' => 16,
'export_self_source_id' => 17,
];
......@@ -2,65 +2,138 @@ 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]
layer.open({
title: "保存bom单",
content: "你确定保存吗?",
btn: ['确认?', '取消'],
yes: function(index) {
layer.close(index);
$.ajax({
url : "/ajax/bom/saveBomInfo",
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);
},
error: function(err) {
console.log(err)
}
})
//layer.msg('保存中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
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: "你确定保存吗?",
btn: ['确认?', '取消'],
yes: function(index) {
layer.close(index);
$.ajax({
url : "/ajax/bom/saveBomInfo",
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);
}
})
}
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);
}
},
cancel: function(index) {
layer.close(index);
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