Commit da09c8f6 by mushishixian

fix

parents b829da5c 4d3e46ba
......@@ -94,3 +94,4 @@ PERM_GOURL=http://perm.liexin.net
ADMIN_GROUP=10000,20000
MENU_ID=16
MENU_URL=http://data.liexin.net/api/config/
FOOTSTONE_URL=http://footstone.liexin.net
\ No newline at end of file
......@@ -8,6 +8,7 @@ use App\Model\BrandModel;
use App\Model\SelfClassifyModel;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\DB;
//通用API,比如获取品牌列表,分类列表等
class CommonApiController extends Controller
......@@ -61,6 +62,34 @@ class CommonApiController extends Controller
exit();
}
private function SearchBrand($request)
{
$brandName = $request->input('brand_name');
$type = $request->input('type');
if (empty($type)) {
$type = 1;
}
$connection = $type == 1 ? 'spu' : 'self';
$table = $type == 1 ? 'brand' : 'brand';
$db = DB::connection($connection)->table($table)->where('status', '1');
if ($brandName) {
$db = $db->where('brand_name', 'like', '%' . $brandName . '%');
}
$count = $db->count();
$list = $db->select('brand_name', 'brand_id')->paginate(17);
$list = $list ? $list->toArray() : [];
$data = array_get($list, 'data');
$lastPage = array_get($list, 'last_page');
echo json_encode([
'errcode' => 0,
'errmsg' => 'ok',
'total' => $count,
'count' => $count,
'data' => $data,
'last_page' => $lastPage
]);
}
public function test($request)
{
$as = new AdminUserService();
......
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SkuService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Transformers\SupplierContactTransformer;
use App\Http\Validators\SupplierContactValidator;
use App\Model\RedisModel;
use App\Model\SupplierContactModel;
use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SkuApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
public function GetSkuList($request)
{
$skuService = new SkuService();
$data = $skuService->getSkuList();
$this->response(0, 'ok', $data['list'], $data['total']);
}
public function UpdateSkuStatus($request)
{
$map = $request->input('goods_id');
if (empty($map) || !is_array($map)) {
$this->response(-1, '请选择要操作的SKU', '0');
}
$status = $request->input('status');
$userId = $request->cookie('oa_user_id');
$sKey = $request->cookie('oa_skey');
$cookie = 'oa_user_id=' . $userId . '; oa_skey=' . $sKey;
$url = env('FOOTSTONE_URL') . '/fsapi/operation_sku_status';
$params = [
'goods_id' => $map,
'status' => $status
];
$params = http_build_query($params);
$result = curl($url, $params, true, false, $cookie);
$result = json_decode($result, true);
if ($result['errcode'] == 0) {
$this->response(0, '操作成功');
} else {
$this->response(-1, '操作失败,原因是 : ' . $result['errmsg']);
}
}
//批量下架
public function BatchOffShelf($request)
{
$supplierCode = $request->get('supplier_code');
$brandId = $request->get('brand_ids');
$brandId = str_replace(',', '', $brandId);
$updateTime = $request->get('update_time');
if (empty($supplierCode)) {
$this->response(-1, '请选择供应商');
}
$startTime = $endTime = 0;
if ($updateTime) {
$updateTime = explode('~', $updateTime);
$startTime = $updateTime[0];
$endTime = $updateTime[1];
}
$map = [
'supplier_code' => $supplierCode,
'brand_id' => $brandId,
'start_time' => $startTime,
'end_time' => $endTime,
];
$url = env('FOOTSTONE_URL') . '/uploadSkuApi/batchOffShelf';
$userId = $request->cookie('oa_user_id');
$sKey = $request->cookie('oa_skey');
$cookie = 'oa_user_id=' . $userId . '; oa_skey=' . $sKey;
$result = curl($url, $map, true, false, $cookie);
$result = json_decode($result, true);
if (isset($result['errcode']) && $result['errcode'] === 0) {
$this->response(0, '批量下架任务已经发送,请等待任务完成,期间你可以刷新列表查看下架情况');
} else {
$this->response(-1, '批量下架失败');
}
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SkuStatisticsService;
use App\Http\Services\SupplierStatisticsService;
use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SkuStatisticsApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
public function GetSkuStatistics($request)
{
$service = new SkuStatisticsService();
$statistics = $service->getSkuListStatistics();
$data = [];
foreach ($statistics as $name => $count) {
$data[$name] = array_get(config('fixed.SkuListCompassMenuMap'), $name) . "(${count})";
}
$this->response(0, 'ok', $data);
}
}
<?php
namespace App\Http\Controllers\Filter;
use App\Http\Services\DepartmentService;
use App\Model\SupplierSyncModel;
class SkuListFilter
{
//查询条件
public function listFilter()
{
$map = request()->all();
//只获取专卖的数据
$map['supplier_id'] = 17;
if ((!empty($map['create_time']))) {
$times = explode('~', $map['create_time']);
$startTime = strtotime($times[0]) ?: 1420041600;
$endTime = strtotime($times[1]) ?: time();
$map['create_time/range'] = $startTime . ',' . $endTime;
unset($map['create_time']);
}
if ((!empty($map['update_time']))) {
$times = explode('~', $map['update_time']);
$startTime = strtotime($times[0]) ?: 1420041600;
$endTime = strtotime($times[1]) ?: time();
$map['update_time/range'] = $startTime . ',' . $endTime;
unset($map['update_time']);
}
if (!empty($map['source_type'])) {
switch ($map['source_type']) {
case 'all':
break;
case 'expire':
$map['expire_day'] = 7;
break;
case "off_shelf":
$map["goods_status/condition"] = 3;
break;
}
unset($map['source_type']);
}
if (!empty($map['stock_compare_type']) && !empty($map['stock_num'])) {
switch ($map['stock_compare_type']) {
case 'eq':
$map['stock/sr'] = 'eq,' . $map['stock_num'];
break;
case 'gt':
$map['stock/sr'] = 'gt,' . $map['stock_num'];
break;
case 'lt':
$map['stock/sr'] = 'lt,' . $map['stock_num'];
break;
}
unset($map['stock_compare_type'], $map['stock_num']);
}
foreach ($map as $k => $v) {
if (empty($v) and $v != '0') {
unset($map[$k]);
}
}
$map['p'] = $map['page'];
unset($map['page']);
$map['offset'] = $map['limit'];
unset($map['limit']);
if (!empty($map['p']) && $map['p'] > 1000) {
$map['p'] = rand(5, 1000);
}
return $map;
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Http\Services\LogService;
use App\Model\BrandModel;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierLogModel;
use Illuminate\Http\Request;
use DB;
class SkuController extends Controller
{
public function Entrance(Request $request, $id = 'index')
{
if ($request->path() == '/') {
$path = 'web/index';
} else {
$path = $request->path();
}
$this->data = [
'menus' => $request->menus,
'header' => $request->user->header,
'username' => $request->user->email,
'user_email' => $request->user->email,
'uri' => '/' . $path,
'id' => $id
];
return $this->$id($request);
}
public function __call($method, $parameters)
{
return $this->errhtml('Not', '没有这个页面');
}
public function SkuList($request)
{
//获取筛选框的品牌数据
$brandSelectValue = [];
$selectBrandIds = $request->get('brand_id/condition');
if ($selectBrandIds) {
$brandModel = new BrandModel();
$brandSelectValue = $brandModel->whereIn('brand_id', explode(',', $selectBrandIds))->get();
$brandSelectValue = $brandSelectValue ? $brandSelectValue->toArray() : [];
$brandSelectValue = array_map(function ($value) {
return array_only($value, ['brand_name', 'brand_id']);
}, $brandSelectValue);
}
$this->data['brandSelectValue'] = $brandSelectValue;
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode();
return $this->view('供应商日志');
}
//批量下sku
public function BatchOffShelf($request)
{
//获取所有启用的供应商编码
$model = new SupplierChannelModel();
$suppliers = $model->where('is_type', 0)->where('status', 2)->select(['supplier_name', 'supplier_code'])->get();
$supplierCodes = [];
foreach ($suppliers as $supplier) {
$supplier = $supplier->toArray();
$supplierCodes[$supplier['supplier_code']] = $supplier['supplier_name'] . '(' . $supplier['supplier_code'] . ')';
}
$this->data['supplierCodes'] = $supplierCodes;
return $this->view('批量下架');
}
}
<?php
namespace App\Http\Services;
//价格相关服务
use App\Model\RedisModel;
use Illuminate\Support\Facades\DB;
//用于判断是否已经查看的服务
class PriceService
{
//获取最小阶梯的价格
public function getMoqPrice($price)
{
$price = is_array($price) ? $price : json_decode($price, true);
if (count($price) >=1){
return $price[0];
}
return [];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Http\Controllers\Filter\SkuListFilter;
use App\Model\IntracodeModel;
use App\Model\RedisModel;
use Illuminate\Support\Facades\DB;
class SkuService
{
//获取供应商列表需要统计的信息
public function getSkuList()
{
$data['data']['goods_id'] = [];
$filter = new SkuListFilter();
$map = $filter->listFilter();
$url = env('ES_SKU_URL', '');
$map['show_status'] = 1;
$return = curl($url, $map, 1);
$data = json_decode($return, true);
$list = [];
if (isset($data['error_code']) && $data['error_code'] == 0) {
$redis = new RedisModel;
//处理供应商
foreach ($data['data']['goods_id'] as $k => $goodsId) {
$uploadItemService = new SkuUploadItemService();
$auditData = $uploadItemService->getSkuAuditData($data['data']['goods_id']);
if (empty($goodsId) || $goodsId == 0) {
continue;
}
$sku = json_decode($redis->hget('sku', $goodsId), true);
//赋值
$sku['goods_id'] = $goodsId;
$sku['update_time'] = date('Y-m-d H:i:s', $sku['update_time']);
$sku['status_name'] = Config('field.GoodsStatus')[$sku['goods_status']];
if (!empty($auditData[$goodsId])) {
$sku['audit_time'] = date('Y-m-d H:i:s', $auditData[$goodsId]['audit_time']);
$sku['audit_user'] = $auditData[$goodsId]['audit_name'];
}
//添加sku是否过期
$sku['is_expire'] = $data['data']['status'][$goodsId] && $data['data']['status'][$goodsId] > 0 ? 0 : 1;
$spu = json_decode($redis->hget('spu', $sku['spu_id']), true);
//型号处理
if (empty($sku['goods_name'])&&!empty($spu)) {
$sku['goods_name'] = $spu['spu_name'];
}
$sku['encap'] = array_get($spu, 'encap', '');
if (array_get($auditData, $sku['goods_id'])) {
$sku['audit_time'] = $auditData[$sku['goods_id']]["audit_time"];
$sku['audit_user'] = $auditData[$sku['goods_id']]["audit_user"];
}
//制造商处理
if (empty($sku['brand_name'])&&!empty($spu)) {
$brand = $redis->hget('brand_id', $spu['brand_id']);
if ($brand) {
$sku['brand_name'] = $brand;
} else {
$brand = DB::connection('spu')->table('brand')->where('brand_id',
$spu['brand_id'])->lists('brand_name', 'brand_id');
if ($brand) {
$sku['brand_name'] = $brand[$spu['brand_id']];
}
}
}
//获取价格
$moqPrice = [];
if (!empty($sku['ladder_price'])) {
$priceService = new PriceService();
$moqPrice = $priceService->getMoqPrice($sku['ladder_price']);
}
$sku['cn_price'] = array_get($moqPrice, 'price_cn');
$sku['us_price'] = array_get($moqPrice, 'price_us');
$list[] = $sku;
}
$intracodeModel = new IntracodeModel();
$encodedList = array_column($list, 'encoded');
$encodedUsers = $intracodeModel->getEncodedUserByEncoded($encodedList);
$list = array_map(function ($item) use ($encodedUsers) {
$encoded = array_get($item, 'encoded', 0);
$item['encoded_user_name'] = array_get($encodedUsers, $encoded, '');
$item['moq'] = $item['moq'] ?: 0;
$item['stock'] = $item['stock'] ?: 0;
return $item;
}, $list);
}
return [
'list' => $list,
'total' => !empty($data['data']['total']) ? $data['data']['total'] : 0
];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class SkuStatisticsService
{
//获取供应商列表需要统计的信息
public function getSkuListStatistics()
{
$total = $this->getStatisticsCount('all');
//七天内过期的
$expire = $this->getStatisticsCount('expire');
//下架的
$offShelf = $this->getStatisticsCount('off_shelf');
$result = [
'all' => $total,
'expire' => $expire,
'off_shelf' => $offShelf,
];
$result = array_map(function ($value) {
if ($value > 999) {
$value = '999+';
}
return $value;
}, $result);
return $result;
}
private function getStatisticsCount($type)
{
$url = env('ES_SKU_URL', '');
$map['supplier_id'] = 17;
switch ($type) {
case "all":
break;
case "expire":
$map['expire_day'] = 7;
break;
case "off_shelf":
$map["goods_status/condition"] = 3;
break;
}
$result = curl($url, $map);
$result = json_decode($result, true);
$total = 0;
if (isset($result['error_code']) && $result['error_code'] == 0) {
$total = $result['data']['total'];
}
return $total;
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\SkuUploadItem;
use App\Model\SupplierChannelModel;
use App\Model\UserInfoModel;
use Illuminate\Support\Facades\DB;
class SkuUploadItemService
{
//获取sku审核信息
public function getSkuAuditData($goodsIds = [])
{
$uploadItemModel = new SkuUploadItem();
$auditData = $uploadItemModel->whereIn('sku_id', array_values($goodsIds))->select([
'sku_id',
'audit_user',
'audit_time',
])->where('audit_user', '!=', 0)->get();
$auditData = $auditData ? $auditData->toArray() : [];
$data = $userIds = [];
foreach ($auditData as $key => $value) {
$data[$value['sku_id']] = $value;
$userIds[] = $value['audit_user'];
}
$userModel = new UserInfoModel();
$userIds = array_unique($userIds);
$users = $userModel->whereIn('userId', $userIds)->pluck('name', 'userId');
$users = $users ? $users->toArray() : [];
$data = array_map(function ($value)use ($users) {
$value['audit_name'] = array_get($users, $value['audit_user']);
return $value;
}, $data);
return $data;
}
}
\ No newline at end of file
......@@ -20,8 +20,8 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route::match(['get', 'post'], '/supplier/{key}', 'SupplierController@info');
Route::match(['get', 'post'], '/supplier_contact/{key}', 'SupplierContactController@info');
Route::match(['get', 'post'], '/supplier_receipt/{key}', 'SupplierReceiptController@info');
// Route::match(['get', 'post'], '/supplier_sync_log/{key}', 'SupplierSyncLogController@info');
Route::match(['get', 'post'], '/index/{key}', 'IndexController@Entrance');
Route::match(['get', 'post'], '/sku/{key}', 'SkuController@Entrance');
Route::match(['get', 'post'], '/log/{key}', 'LogController@Entrance');
// Route::match(['get', 'post'], '/api/{key}', 'ApiController@Entrance');
// Route::match(['get', 'post'], '/hd/{key}', 'HandleController@Entrance');
......@@ -35,8 +35,10 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_log/{key}', 'SupplierLogApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_contact/{key}', 'SupplierContactApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_statistics/{key}', 'SupplierStatisticsApiController@Entrance');
Route::match(['get', 'post'], '/api/sku_statistics/{key}', 'SkuStatisticsApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier/{key}', 'SupplierApiController@Entrance');
Route::match(['get', 'post'], '/api/log/{key}', 'LogApiController@Entrance');
Route::match(['get', 'post'], '/api/sku/{key}', 'SkuApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_receipt/{key}', 'SupplierReceiptApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_sync_log/{key}', 'SupplierSyncLogApiController@Entrance');
});
......
......@@ -96,4 +96,24 @@ class IntracodeModel extends Model
$userCodes = $temp + $codes;
return $userCodes;
}
//获取内部编码相关信息
public function getEncodedUserByEncoded($encodedList = [])
{
$encodedUsers = [];
$codes = $this->select('code_id', 'admin_id')
->whereIn('code_id',$encodedList)
->get();
if (empty($codes)) {
return [];
}
$codes = $codes->toArray();
$adminIds = array_column($codes, 'admin_id');
$userModel = new UserInfoModel();
$users = $userModel->whereIn('userId',$adminIds)->pluck('name', 'userId');
foreach ($codes as $key=>$code) {
$encodedUsers[$code['code_id']] = array_get($users, $code['admin_id']);
}
return $encodedUsers;
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SkuUploadItem extends Model
{
protected $table='sku_upload_item_0';
protected $primaryKey = 'id';
protected $connection = 'spu';
public $timestamps = false;
}
<?php
return [
//0:自营 1:联营 2:专卖
'GoodsStatusName' => [
0 => '自营',
1 => '联营',
2 => '专卖',
],
'GoodsStatus'=>[
1 => '上架',
3 => '下架',
],
//sku列表用
'SkuStatus' => array(
0 => '待审核',
1 => '上架',
2 => '审核不通过',
3 => '下架',
4 => '删除'
),
'SKU' => array(
'spu_id' => 1,
'encoded' => 1,
'moq' => 1,
'mpq' => 1,
'old_goods_id' => 1,
'goods_type' => 1,
'goods_status' => 1,
'batch_sn' => 1,
'stock' => 1,
'hk_delivery_time' => 1,
'cn_delivery_time' => 1,
'ladder_price' => 1,
'update_time' => 1,
'goods_images' => 1,
'canal' => 1,
'supplier_id' => 1,
'cp_time' => 1,
),
];
\ No newline at end of file
......@@ -216,4 +216,10 @@ return [
'to_follow_up' => '待跟进',
'no_sku' => '无sku',
],
//Sku列表的罗盘对应菜单id
'SkuListCompassMenuMap' => [
'all' => '全部',
'expire' => '七天后过期',
'off_shelf' => '下架',
],
];
......@@ -9,7 +9,9 @@ return [
'menuId' => env('MENU_ID'),
'menuUrl' => env('MENU_URL'),
'notAuth' => [
'SwitchWarehouse'
'SwitchWarehouse',
'SkuList',
'BatchOffShelf'
]//不用验证权限的方法
],
];
......@@ -29,7 +29,6 @@ return [
'uploadskulist' => 'http://footstone.liexin.net/footstone/uploadskulist',
'batch' => 'http://footstone.liexin.net/footstone/Batches?', // 批量下架
'exportMonopoly' => 'http://footstone.liexin.net/footstone/exportMonopoly?', // 专卖商品批量导出
'templet' => 'http://footstone.liexin.com/footstone/templet?', // 专卖商品批量导出
'templet' => 'http://footstone.liexin.net/footstone/templet?', // 专卖商品批量导出
],
];
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin','xmSelect'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
let xmSelect = layui.xmSelect;
//渲染主营品牌的多选
function getBrandOption(element, brandType) {
let brandUrl = '/api/common/getBrandList?type=' + brandType;
let brandRes = ajax(brandUrl);
let brandList = brandRes.data;
return {
el: '#' + element,
filterable: true,
paging: true,
size: 'small',
radio: true,
height: '250px',
direction: 'auto',
autoRow: true,
prop: {
name: 'brand_name',
value: 'brand_id',
},
pageSize: 30,
data: brandList,
on: function (brandList) {
let arr = brandList.arr;
let brandIds = '';
for (let i in arr) {
brandIds += arr[i].brand_id + ',';
}
let idName = 'brand_ids';
$('#' + idName).val(brandIds);
},
};
}
let brandOption = getBrandOption('brand_selector', 2);
xmSelect.render(brandOption);
form.on('submit(batchOffShelf)', function (data) {
let url = '/api/sku/BatchOffShelf';
let res = ajax(url, data.field);
if (!res) {
layer.msg('网络错误,请重试', {icon: 6});
} else {
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
}
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'layer', 'Split', 'admin','xmSelect'], function () {
let $ = layui.jquery;
let Split = layui.Split;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
Split(['#s1', '#s2', '#s3'], {sizes: [7, 12, 8], minSize: 70});
let table = layui.table;
let form = layui.form;
let admin = layui.admin;
let xmSelect = layui.xmSelect;
let initCondition = {source_type: 'all'};
let whereCondition = initCondition;
let type = 'all';
//点击罗盘筛选
$('.main_filter').click(function () {
$('.main_filter').attr('class', 'main_filter');
$(this).attr('class', 'main_filter layui-badge layui-bg-green');
type = $(this).attr('id');
initCondition.source_type = type
table.reload('skuList', {
page: {
curr: 1
}
, where: whereCondition
});
});
let cols = [
{type: 'checkbox'},
{field: 'goods_name', title: '型号', align: 'center', width: 200},
{
field: 'brand_name', title: '品牌', align: 'center', width: 120
},
{field: 'encap', title: '封装', align: 'center', width: 80},
{field: 'canal', title: '供应商编码', align: 'center', width: 120},
{
field: 'moq', title: '起订量', align: 'center', width: 70
},
{field: 'stock', title: '库存数量', align: 'center', width: 80},
{
field: 'cn_price', title: '国内含币价(¥)', align: 'center', width: 120
},
{field: 'us_price', title: '香港交货价($)', align: 'center', width: 120},
{field: 'cn_delivery_time', title: '大陆交期', align: 'center', width: 100},
{field: 'hk_delivery_time', title: '香港交期', align: 'center', width: 100},
{
field: 'status_name', title: '状态', align: 'center', width: 70, templet: function (d) {
return d.goods_status === 1 ? "<a class='layui-btn layui-btn-xs'>上架</a>" :
"<a class='layui-btn layui-btn-xs layui-btn-danger'>下架</a>";
}
},
{
field: 'is_expire', title: '过期', align: 'center', width: 80, templet: function (d) {
return d.is_expire === 1 ? "<a class='layui-btn layui-btn-xs layui-btn-danger'></a>" :
"<a class='layui-btn layui-btn-xs'></a>";
}
},
{field: 'encoded_user_name', title: '上传人', align: 'center', width: 100},
{field: 'update_time', title: '更新时间', align: 'center', width: 150},
{field: 'mpq', title: '标准包装量', align: 'center', width: 120},
{field: 'batch_sn', title: '批次', align: 'center', width: 80},
{field: 'audit_time', title: '审核时间', align: 'center', width: 150},
{field: 'audit_user', title: '审核人', align: 'center', width: 100},
// {field: 'create_time', title: '上传时间', align: 'center', width: 150},
{
field: ' access_way', title: '接入方式', align: 'center', width: 150, templet: function (d) {
return "人工上传";
}
},
{field: 'goods_id', title: 'SKUID', align: 'center', width: 180},
];
let currentPage = 0;
table.render({
elem: '#skuList'
, url: '/api/sku/GetSkuList'
, method: 'post'
, size: 'sm'
, limit: 20
, cellMinWidth: 50 //全局定义常规单元格的最小宽度
, where: whereCondition
, loading: true
, first: true //不显示首页
, last: false //不显示尾页
, cols: [cols]
, id: 'skuList'
, page: {}
, done: function (res, curr, count) {
currentPage = curr;
}
});
//渲染多选
let brandSelect = xmSelect.render({
el: '#brandSelect',
name: 'brand_id',
searchTips: '请输入要查找的制造商',
paging: true,
empty: '没有查找到数据',
prop: {
name: 'brand_name',
value: 'brand_id'
},
height: "1300px",
remoteSearch: true,
autoRow: true,
pageRemote: true,
filterable: true,
remoteMethod: function (val, cb, show, pageIndex) {
//val: 搜索框的内容, 不开启搜索默认为空, cb: 回调函数, show: 当前下拉框是否展开, pageIndex: 当前第几页
$.ajax({
url: '/api/common/SearchBrand',
type: 'post',
data: {
brand_ids: $('#brand_ids').val(),
brand_name: val,
page: pageIndex
},
dataType: 'json',
timeout: 10000,
success: function (res) {
if (!res) return layer.msg('网络错误,请重试', {icon: 5});
if (res.errcode === 0) {
cb(res.data, res.last_page);
} else {
layer.msg(res.errmsg, {icon: 6});
}
},
error: function () {
return layer.msg('网络错误,请重试', {icon: 5});
}
});
},
on: function (data) {
let brandIds = '';
for (let x in data.arr) // x 为属性名
{
brandIds = brandIds + data.arr[x].brand_id + ',';
}
$("#brand_id_condition").val(brandIds);
}
});
brandSelect.setValue(JSON.parse($('#brand_id_condition').attr('select_value')));
//批量上架
$("#batch_putaway").click(function () {
let checkStatus = table.checkStatus('skuList');
let data = checkStatus.data;
let skuIds = [];
$.each(data, function (index, value) {
skuIds.push(value.goods_id);
});
if (skuIds.length === 0) {
layer.msg('请选择要操作的sku', {icon: 5});
return;
}
batchUpdateGoodsStatus(skuIds, 'passed');
})
//批量下架
$("#batch_off_shelf").click(function () {
let checkStatus = table.checkStatus('skuList');
let data = checkStatus.data;
let skuIds = [];
$.each(data, function (index, value) {
skuIds.push(value.goods_id);
});
if (skuIds.length === 0) {
layer.msg('请选择要操作的sku', {icon: 5});
return;
}
batchUpdateGoodsStatus(skuIds, 'offshelf');
})
//根据供应商编码已经品牌等去基石调用接口下架
$("#remote_batch_off_shelf").click(function () {
layer.open({
type: 2,
content: '/sku/BatchOffShelf?view=iframe',
area: ['800px', '600px'],
title: '批量下架SKU',
end: function () {
table.reload('skuList');
// supplierStatistics();
}
});
});
//批量上下架操作
function batchUpdateGoodsStatus(skuId, status) {
let statusName = status === 'offshelf' ? '下架' : '上架';
layer.confirm('确定要' + statusName + "选中的这些商品吗", function (index) {
$.ajax({
type: 'post',
url: '/api/sku/UpdateSkuStatus',
timeout: 30000, //超时时间设置,单位毫秒
data: {
goods_id: skuId,
status: status
},
dataType: 'json',
success: function (resp) {
close();
if (!resp) {
layer.msg('网络连接失败', {icon: 5});
return false;
}
if (resp.err_code === 0) {
layer.msg('操作成功', {icon: 6});
table.reload('skuList', {
page: {
curr: currentPage
},
});
} else {
return false;
}
}
});
layer.closeAll();
});
}
form.on('submit(load)', function (data) {
whereCondition = $.extend(false, initCondition, data.field);
//执行重载
table.reload('skuList', {
page: {
curr: 1
}
, where: whereCondition
});
supplierStatistics();
return false;
});
form.on('submit(reset)', function (data) {
layer.load(1);
location.reload();
});
});
</script>
\ No newline at end of file
......@@ -61,6 +61,7 @@
filterable: true,
paging: true,
height: '250px',
size: 'small',
direction: 'auto',
autoRow: true,
prop: {
......
......@@ -9,6 +9,7 @@
let layer = layui.layer;
let fileName = '';
var loadIndex = 0;
upload.render({
elem: '.uploadButton'
, url: '{{config('website.UploadUrl')}}' //改成您自己的上传接口
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('supplier_code','供应商选择 : ',null,
$supplierCodes,['required'=>true,'width'=>'400px']) !!}
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px;">
<label class="layui-form-label">
品牌 : </label>
<div class="layui-input-block">
<div id="brand_selector" class="layui-input-inline"
style="width: 400px;height: 20px;line-height: 20px">
</div>
<input type="hidden" name="brand_ids"
id="brand_ids">
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('timeIntervalPresenter','App\Presenters\TimeIntervalPresenter')
{!! $timeIntervalPresenter->render('update_time','更新时间 : ') !!}
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="batchOffShelf">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-warm" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
@include('web.sku.SkuListCommon')
<div style="margin-left: 20px;margin-right: 20px">
<div class="layui-btn-group demoTable" style="margin-top: 15px">
@if(checkPerm('TempTemp'))
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier">新增</button>
@endif
<button type="button" class="layui-btn layui-btn-sm" id="batch_putaway">上架</button>
<button type="button" class="layui-btn layui-btn-sm" id="batch_off_shelf">下架</button>
<button type="button" class="layui-btn layui-btn-sm" id="remote_batch_off_shelf">批量下架</button>
</div>
<table class="layui-table" id="skuList" lay-filter="skuList"></table>
</div>
<script>
</script>
<style>
.main_filter {
cursor: pointer;
}
xm-select {
min-height: 27px;
}
</style>
<div class="layui-fluid" id="type_filter">
<div class="layui-card">
<div class="layui-card-body" style="padding: 0;">
<div class="split-group" style="height: 130px;">
<div class="split-item" id="s1">
<div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" id="all">全部()</a>
</div>
</div>
<div class="split-item" id="s2" style="text-align: center">
<div class="layui-row">
<a class="main_filter" id="expire">
</a>
</div>
<div class="layui-row">
<a class="main_filter" id="off_shelf">
</a>
</div>
</div>
<div class="split-item" id="s3" style="text-align: center">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-collapse">
@if(checkPerm('ViewFilter'))
<!--通用的筛选-->
<form class="layui-form" style="margin-top: 15px">
<?php
$routerName = explode('/', request()->path())[1];
?>
<div class="layui-row">
<div class="layui-inline">
<label class="layui-form-label">商品型号</label>
<div class="layui-input-inline">
<input type="text" value="" name="goods_name/condition" placeholder="请输入型号" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">品牌</label>
<div class="layui-input-inline">
<div id="brandSelect" style="width: 155px"></div>
<input type="hidden" id="brand_id_condition"
select_value="{{json_encode($brandSelectValue)}}"
name="brand_id/condition" value="{{request()->get('brand_id/condition') or ''}}"
class="layui-input"/>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">供应商编码</label>
<div class="layui-input-inline">
<input type="text" value="" name="canal/condition" placeholder="请输入供应商编码" autocomplete="off"
class="layui-input">
</div>
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('goods_status/condition','SKU状态',request()->get('goods_status/condition'),config('field.SkuStatus')) !!}
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('status/condition','是否过期',request()->get('status/condition'),[0=>'是',1=>'否']) !!}
</div>
</div>
<div class="layui-row">
<div class="layui-inline">
<label class="layui-form-label">起订量和库存</label>
<div class="layui-input-inline">
<select name="moq_stock_compare">
<option value="">请选择</option>
<option value="lt">起订量 < 库存</option>
<option value="gt">起订量 > 库存</option>
<option value="e">起订量 = 库存</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">库存数量</label>
<div class="layui-input-inline">
<div class="layui-row">
<div class="layui-col-xs6" style="width: 74px">
<select name="stock_compare_type">
<option value="">请选择</option>
<option value="gt"> ></option>
<option value="lt"> <</option>
<option value="eq"> =</option>
</select>
</div>
<div class="layui-col-xs6" style="width: 84px;">
<input type="text" value="" name="stock_num" placeholder="数量" autocomplete="off"
class="layui-input">
</div>
</div>
</div>
</div>
<div class="layui-inline">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('encoded/condition','上传人',request()->get('encoded/condition'),
$userCodes) !!}
</div>
<div class="layui-inline" style="width: 600px">
@inject('transformableTimeIntervalPresenter','App\Presenters\Filter\TransformableTimeIntervalPresenter')
{!! $transformableTimeIntervalPresenter->render(['update_time'=>'更新时间','create_time'=>'上传时间']) !!}
</div>
</div>
<div class="layui-row" style="margin-top:10px;margin-bottom: 10px;margin-left: 20px;">
<button class="layui-btn layui-btn-sm layui-btn load" id="getSupplierListButton" lay-submit=""
lay-filter="load">查询
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn" lay-submit="" lay-filter="reset">重置
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn hide_filter_type">隐藏罗盘</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn show_filter_type"
style="display: none">显示罗盘
</button>
</div>
</form>
@endif
</div>
<script>
//一进来就去获取统计数据
function supplierStatistics() {
let res = ajax('/api/sku_statistics/GetSkuStatistics');
if (res.err_code === 0) {
$.each(res.data, function (index, value) {
let menuObj = $('#' + index);
menuObj.text('');
menuObj.append(value);
});
}
}
supplierStatistics();
//罗盘隐藏
$('.hide_filter_type').click(function () {
$(this).hide();
$('#type_filter').hide();
$('.show_filter_type').show();
});
$('.show_filter_type').click(function () {
$(this).hide();
$('#type_filter').show();
$('.hide_filter_type').show();
});
</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