Commit 64875d7c by 朱继来

Merge branch 'zjl_inquiry_order_20210311' into development

parents 6a5e9848 7711c919
...@@ -105,7 +105,10 @@ Class AddOrderController extends Controller ...@@ -105,7 +105,10 @@ Class AddOrderController extends Controller
// $info['company'] = (new CmsModel())->getCompany(); // 获取公司组织 // $info['company'] = (new CmsModel())->getCompany(); // 获取公司组织
$info['report_ids'] = $request->input('report_ids', ''); // 询价系统销售报价ID $info['report_ids'] = $request->input('report_ids', ''); // 询价系统销售报价ID
$perm = new PermController;
$info['buyers'] = $perm->getUserByDepartmentId(8, 0); // 获取采购部人员
return view('addInquiryOrder', $info); return view('addInquiryOrder', $info);
} }
...@@ -428,6 +431,16 @@ Class AddOrderController extends Controller ...@@ -428,6 +431,16 @@ Class AddOrderController extends Controller
if ($data['is_new']) { // 新版下单页面,layui格式返回 if ($data['is_new']) { // 新版下单页面,layui格式返回
$data = isset($response['data']['list']) ? $response['data']['list'] : []; $data = isset($response['data']['list']) ? $response['data']['list'] : [];
$perm = new PermController;
$buyers = $perm->getUserByDepartmentId(8, 0); // 获取采购部人员
if (!empty($data)) {
foreach ($data as &$v) {
$v['buyerSelect'] = $this->getPurchaseSelect($buyers, $v['buyer_id']);
}
}
return ['code'=>$response['err_code'], 'msg'=>$response['err_msg'], 'data'=>$data, 'count'=>count($data)]; return ['code'=>$response['err_code'], 'msg'=>$response['err_msg'], 'data'=>$data, 'count'=>count($data)];
} }
...@@ -439,6 +452,21 @@ Class AddOrderController extends Controller ...@@ -439,6 +452,21 @@ Class AddOrderController extends Controller
} }
} }
// 生成采购下拉列表
public function getPurchaseSelect($buyers, $buyer_id)
{
$option = '<option vlaue=""></option>';
foreach ($buyers as $k=>$v) {
if ($v->userId == $buyer_id) {
$option .= '<option vlaue="'.$v->userId.'" selected>'.$v->name.'</option>';
} else {
$option .= '<option vlaue="'.$v->userId.'">'.$v->name.'</option>';
}
}
return $option;
}
// 获取订单赠品信息 // 获取订单赠品信息
public function getOrderGift(Request $request) public function getOrderGift(Request $request)
{ {
...@@ -469,7 +497,7 @@ Class AddOrderController extends Controller ...@@ -469,7 +497,7 @@ Class AddOrderController extends Controller
$data['k1'] = time(); $data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi'); $data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
if ($type == 3) { // 联营批量添加 if ($type == 3 || $type == 4) { // 3-联营批量添加、4-询价单
$url = Config('website.api_domain').'cart/changeNumForJoint'; $url = Config('website.api_domain').'cart/changeNumForJoint';
} else { } else {
$url = Config('website.api_domain').'cart/changeNumByOrderSystem'; $url = Config('website.api_domain').'cart/changeNumByOrderSystem';
...@@ -485,6 +513,47 @@ Class AddOrderController extends Controller ...@@ -485,6 +513,47 @@ Class AddOrderController extends Controller
} }
} }
// 修改购物车字段
public function changeField(Request $request)
{
if ($request->isMethod('post')) {
$uid = $request->input('uid');
$cart_id = $request->input('cart_id');
$goods_price = $request->input('goods_price', 0);
$delivery_time = $request->input('delivery_time', '');
$batch = $request->input('batch', '');
$buyer = $request->input('buyer', 0);
$data = [];
if (!$delivery_time) { // 交期不存在
$goods_price && $data['goods_price'] = $goods_price;
$batch && $data['batch'] = $batch;
if ($buyer) {
$CmsModel = new CmsModel;
$data['buyer_id'] = $CmsModel->getSaleId($buyer);
}
} else { // 修改交期
$goods_data = DB::connection('order')->table('lie_shopping_cart')->where('cart_id', $cart_id)->value('goods_data');
if (!$goods_data) {
$goods_data['delivery_time'] = $delivery_time;
} else {
$goods_data = json_decode($goods_data, true);
$goods_data['delivery_time'] = $delivery_time;
}
$data['goods_data'] = json_encode($goods_data);
}
$res = DB::connection('order')->table('lie_shopping_cart')->where('cart_id', $cart_id)->update($data);
if ($res === false) return ['errcode' => -1, 'errmsg' => '修改失败'];
return ['errcode' => 0, 'errmsg' => '修改成功'];
}
}
// 删除购物车商品 // 删除购物车商品
public function deleteGoods(Request $request) public function deleteGoods(Request $request)
{ {
......
...@@ -106,6 +106,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -106,6 +106,7 @@ Route::group(['middleware' => 'web'], function () {
Route::post('/ajax/cartList', 'AddOrderController@cartList'); Route::post('/ajax/cartList', 'AddOrderController@cartList');
Route::post('/ajax/getOrderGift', 'AddOrderController@getOrderGift'); Route::post('/ajax/getOrderGift', 'AddOrderController@getOrderGift');
Route::post('/ajax/changeNum', 'AddOrderController@changeNum'); Route::post('/ajax/changeNum', 'AddOrderController@changeNum');
Route::post('/ajax/changeField', 'AddOrderController@changeField');
Route::post('/ajax/deleteGoods', 'AddOrderController@deleteGoods'); Route::post('/ajax/deleteGoods', 'AddOrderController@deleteGoods');
Route::post('/ajax/create', 'AddOrderController@create'); Route::post('/ajax/create', 'AddOrderController@create');
Route::get('/addorder/success', 'AddOrderController@success'); Route::get('/addorder/success', 'AddOrderController@success');
......
...@@ -731,10 +731,10 @@ layui.config({ ...@@ -731,10 +731,10 @@ layui.config({
return false; return false;
} }
var is_dgk = false; // var is_dgk = false;
if ($('.client-info').css('display') == 'block') { // if ($('.client-info').css('display') == 'block') {
is_dgk = true; // is_dgk = true;
} // }
if (cart_ids.length == 0) { if (cart_ids.length == 0) {
layer.msg('请先添加商品'); layer.msg('请先添加商品');
...@@ -756,54 +756,54 @@ layui.config({ ...@@ -756,54 +756,54 @@ layui.config({
cart_ids: cart_ids, cart_ids: cart_ids,
} }
if (is_dgk) { // 联营包含digikey商品,则填写终端资料 // if (is_dgk) { // 联营包含digikey商品,则填写终端资料
var customer_cn = $('.customer_cn').val(); // var customer_cn = $('.customer_cn').val();
var customer_en = $('.customer_en').val(); // var customer_en = $('.customer_en').val();
var customer_type = $('.customer_type').val(); // var customer_type = $('.customer_type').val();
var product_use_classone_sn = $('.product_use_classone_sn').val(); // var product_use_classone_sn = $('.product_use_classone_sn').val();
var product_use_classtwo_sn = $('.product_use_classtwo_sn').val(); // var product_use_classtwo_sn = $('.product_use_classtwo_sn').val();
var customer_website = $('.customer_website').val(); // var customer_website = $('.customer_website').val();
if (!customer_cn) { // if (!customer_cn) {
layer.msg('请填写终端中文名称'); // layer.msg('请填写终端中文名称');
return false; // return false;
} // }
if (customer_type == '') { // if (customer_type == '') {
layer.msg('请选择客户类型'); // layer.msg('请选择客户类型');
return false; // return false;
} // }
if (customer_type == 1) { // 若客户类型为终端,则外文名称,产品用途和网址为必填 // if (customer_type == 1) { // 若客户类型为终端,则外文名称,产品用途和网址为必填
if (!customer_en) { // if (!customer_en) {
layer.msg('请填写终端英文名称'); // layer.msg('请填写终端英文名称');
return false; // return false;
} // }
var en_reg = /^[a-zA-Z0-9\.\-\s\,\(\)]+$/; // var en_reg = /^[a-zA-Z0-9\.\-\s\,\(\)]+$/;
if(!en_reg.test(customer_en)){ // if(!en_reg.test(customer_en)){
layer.msg('请填写全英文名称'); // layer.msg('请填写全英文名称');
return false; // return false;
} // }
if (product_use_classone_sn == '') { // if (product_use_classone_sn == '') {
layer.msg('请选择产品用途一级分类'); // layer.msg('请选择产品用途一级分类');
return false; // return false;
} // }
if (!customer_website) { // if (!customer_website) {
layer.msg('请填写客户网址'); // layer.msg('请填写客户网址');
return false; // return false;
} // }
} // }
datax.customer_cn = customer_cn; // datax.customer_cn = customer_cn;
datax.customer_en = customer_en; // datax.customer_en = customer_en;
datax.customer_type = customer_type; // datax.customer_type = customer_type;
datax.product_use_classone_sn = product_use_classone_sn; // datax.product_use_classone_sn = product_use_classone_sn;
datax.product_use_classtwo_sn = product_use_classtwo_sn; // datax.product_use_classtwo_sn = product_use_classtwo_sn;
datax.customer_website = customer_website; // datax.customer_website = customer_website;
} // }
$.ajax({ $.ajax({
type: "POST", type: "POST",
...@@ -864,14 +864,13 @@ layui.config({ ...@@ -864,14 +864,13 @@ layui.config({
,{field: 'goods_id', title: 'SKUID', width: 180} ,{field: 'goods_id', title: 'SKUID', width: 180}
,{field: 'goods_name', title: '商品名称', width: 200} ,{field: 'goods_name', title: '商品名称', width: 200}
,{field: 'brand_name', title: '制造商', width: 200} ,{field: 'brand_name', title: '制造商', width: 200}
,{field: 'mpl', title: '倍数'}
,{field: 'goods_number', title: '采购数量', edit: 'text', style: 'backgroud: #ccc', width: 100}
,{field: 'goods_price', title: '采购单价', width: 120}
,{field: 'goods_amount_format', title: '小计'}
,{field: 'delivery_time', title: '货期'}
,{field: 'supplier_name', title: '供应商'} ,{field: 'supplier_name', title: '供应商'}
,{field: 'buyer_id', title: '采购员', templet: '#buyer_id'} ,{field: 'goods_number', title: '采购数量', edit: 'text', style: 'cursor: pointer;', width: 120}
,{field: 'batch', title: '批次'} ,{field: 'goods_price', title: '采购单价', edit: 'text', style: 'cursor: pointer;', width: 120}
,{field: 'goods_amount_format', title: '小计'}
,{field: 'delivery_time', title: '货期', edit: 'text', style: 'cursor: pointer;'}
,{field: 'buyer_id', title: '采购员', templet: '#t_buyer_id'}
,{field: 'batch', title: '批次', edit: 'text', style: 'cursor: pointer;'}
,{title: '操作', align:'center', fixed: 'right', toolbar: '#list_action', width: 80} ,{title: '操作', align:'center', fixed: 'right', toolbar: '#list_action', width: 80}
]] ]]
// ,limit: 10 // ,limit: 10
...@@ -884,10 +883,11 @@ layui.config({ ...@@ -884,10 +883,11 @@ layui.config({
} }
$('.carts-info').show(); // 显示商品table $('.carts-info').show(); // 显示商品table
$(".layui-table-body, .layui-table-box, .layui-table-cell").css('overflow', 'visible'); // 下拉显示
cart_ids = []; cart_ids = [];
for( i=0; i < count; i++){ for(var i = 0; i < count; i++){
cart_ids.push(res.data[i].cart_id); cart_ids.push(res.data[i].cart_id);
} }
...@@ -900,8 +900,36 @@ layui.config({ ...@@ -900,8 +900,36 @@ layui.config({
orderConfirm(user_id, address_id, cart_ids, user_coupon_id); // 确认订单信息 orderConfirm(user_id, address_id, cart_ids, user_coupon_id); // 确认订单信息
} }
}); });
form.render('select');
}; };
//下拉框监听事件
form.on('select(buyer_id)', function(data) {
var cart_id = $('#buyer_id').data('cid');
var value = data.value;
var datax = {
cart_id: cart_id,
buyer: value,
};
$.ajax({
type: "POST",
url: '/ajax/changeField',
data: datax,
dataType: "json",
success: function(resp){
if (resp.errcode == 0) {
layer.msg(resp.errmsg)
return false;
}
layer.msg(resp.errmsg);
},
})
});
// 检查自营商品倍数 // 检查自营商品倍数
function checkSelfMpl(user_id, data, count) function checkSelfMpl(user_id, data, count)
{ {
...@@ -980,47 +1008,83 @@ layui.config({ ...@@ -980,47 +1008,83 @@ layui.config({
}) })
} }
// 修改数量 // 编辑
table.on('edit(list)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值" table.on('edit(list)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
var old = $(this).prev().text(); // 原数量 var old = $(this).prev().text(); // 原数量
var num = obj.value; // 修改后数量 var value = obj.value; // 编辑后值
var cart_id = obj.data.cart_id;
var user_id = $('.user_id').val() ? $('.user_id').val() : 0;
var url = '';
if (!num) { var datax = {
layer.msg('数量不能为0或空'); uid: user_id,
return false; cart_id: cart_id,
} };
console.log(old)
switch (obj.field) {
case 'goods_number':
var min_buy = obj.data.min_buy;
var type = obj.data.type; // 商品添加类型
if (!value) {
layer.msg('数量不能为0或空');
return false;
}
var min_buy = obj.data.min_buy; if (value < min_buy) {
var cart_id = obj.data.cart_id; layer.msg('购买数量低于最小起订量,默认调整为最小起订量');
var type = obj.data.type; // 商品添加类型 value = min_buy;
var user_id = $('.user_id').val() ? $('.user_id').val() : 0; }
var delivery_place = 1; // 1.大陆,2.香港 自营默认是大陆
if (num < min_buy) { var curr_goods_type = obj.data.goods_type;
self.val(min_buy); var joint_goods_type = [1, 2]; // 商品联营类型
layer.msg('购买数量低于最小起订量,默认调整为最小起订量');
num = min_buy; if (joint_goods_type.indexOf(curr_goods_type) == -1) { // 自营数量需要结合倍数
} var mpl = Number(obj.data.mpl); // 倍数
value = Math.ceil(value / mpl) * mpl;
}
datax.type = type;
datax.num = value;
url = '/ajax/changeNum';
break;
case 'goods_price':
if (!value) {
layer.msg('单价不能为0或空');
return false;
}
datax.goods_price = value;
url = '/ajax/changeField';
break;
var curr_goods_type = obj.data.goods_type; case 'delivery_time': // 货期
var joint_goods_type = [1, 2]; // 商品联营类型 datax.delivery_time = value;
if (joint_goods_type.indexOf(curr_goods_type) != -1) { url = '/ajax/changeField';
delivery_place = $('.delivery_place').val(); break;
} else { // 自营数量需要结合倍数
var mpl = Number(obj.data.mpl); // 倍数 case 'batch': // 批次
num = Math.ceil(num / mpl) * mpl; datax.batch = value;
url = '/ajax/changeField';
break;
} }
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: '/ajax/changeNum', url: url,
data: {uid: user_id, num: num, cart_id: cart_id, type: type}, data: datax,
dataType: "json", dataType: "json",
success: function(resp){ success: function(resp){
if (resp.errcode == 0) { if (resp.errcode == 0) {
layer.msg(resp.errmsg) layer.msg(resp.errmsg)
renderTable();
if (obj.field == 'goods_number' || obj.field == 'goods_price') {
renderTable();
}
return false; return false;
} }
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
</div> </div>
</div> </div>
<div class="layui-colla-item client-info"> <!-- <div class="layui-colla-item client-info">
<h2 class="layui-colla-title">终端客户信息</h2> <h2 class="layui-colla-title">终端客户信息</h2>
<div class="layui-colla-content layui-show"> <div class="layui-colla-content layui-show">
@include('addInquiryOrder.dgkInfo') @include('addInquiryOrder.dgkInfo')
</div> </div>
</div> </div> -->
<div class="layui-colla-item order-info"> <div class="layui-colla-item order-info">
<h2 class="layui-colla-title">订单信息</h2> <h2 class="layui-colla-title">订单信息</h2>
......
...@@ -102,14 +102,25 @@ ...@@ -102,14 +102,25 @@
<table id="list" lay-filter="list"></table> <table id="list" lay-filter="list"></table>
<textarea name="remark" id="remark" class="layui-textarea" placeholder="填写订单备注信息"></textarea> <textarea name="remark" id="remark" class="layui-textarea" placeholder="填写订单备注信息"></textarea>
</div>
<script type="text/html" id="buyer_id"> <script>
@{{# if (d.buyer_id != 0) { }} var buyers = eval('{!! json_encode($buyers) !!}');
@{{ d.buyer_id }} </script>
@{{# } }}
</script>
<script type="text/html" id="list_action"> <style>
<a class="btn btn-xs btn-danger" lay-event="del">删除</a> td .layui-form-select{
</script> margin-top: -10px;
</div> margin-left: -15px;
margin-right: -15px;
}
</style>
<script type="text/html" id="t_buyer_id">
<select name="buyer_id" id="buyer_id" lay-filter="buyer_id" data-cid="@{{ d.cart_id }}">
@{{ d.buyerSelect }}
</select>
</script>
<script type="text/html" id="list_action">
<a class="btn btn-xs btn-danger" lay-event="del">删除</a>
</script>
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