Commit 0060e6f7 by 杨树贤

Merge branch 'ysx-供应商需求-20230619'

parents a76f972d 17da1d8e
......@@ -92,7 +92,7 @@ class CommonApiController extends Controller
if (!$company) {
$this->response(-1, '获取不到公司');
}
}else{
} else {
$this->response(-2, '供应商跳过天眼查校验');
}
......@@ -100,4 +100,21 @@ class CommonApiController extends Controller
}
//批量校验标准品牌,并且返回具体的id和错误信息
public function checkStandardBrandNameList(Request $request)
{
//接收的是标准品牌名称
$standardBrandNameList = $request->input('standard_brand_name_list');
if (empty($standardBrandNameList)) {
$this->response(0, 'ok', [
'invalid_brand_name_list' => [],
'valid_brand_name_list' => [],
'valid_brand_ids' => [],
]);
}
$standardBrandNameList = explode(',', trim($standardBrandNameList, ','));
$result = (new StandardBrandService())->checkStandardBrandNameList($standardBrandNameList);
$this->response(0, 'ok', $result);
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Services\PurchaseRemarkService;
use App\Http\Transformers\PurchaseRemarkTransformer;
use App\Model\LogModel;
use App\Model\PurchaseRemarkModel;
use Carbon\Carbon;
use Illuminate\Http\Request;
class PurchaseRemarkApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
//获取供应商收款信息
public function GetPurchaseRemarkList($request)
{
$supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10);
$model = new PurchaseRemarkModel();
$model->where('supplier_id', $supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('id', 'desc')
->paginate($limit)->toArray();
$transformer = new PurchaseRemarkTransformer();
$list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'], $list['total']);
}
//保存附件信息
public function SavePurchaseRemark($request)
{
$id = $request->input('id');
$participateContent = $request->input('participate_content');
$startTime = $request->input('start_time');
$endTime = $request->input('end_time');
$supplierId = $request->input('supplier_id');
$remark = $request->input('remark');
if (!$supplierId) {
$this->response(-1, '供应商id不能为空');
}
if ($request->input('participate_type') != 1) {
if (!$participateContent) {
$this->response(-1, '参与内容不能为空');
}
}
if (!$startTime || !$endTime) {
$this->response(-1, '开始和结束时间都不能为空');
}
if (!$remark) {
$this->response(-1, '备注内容不能为空');
}
$remark = $request->only([
'id',
'supplier_id',
'participate_type',
'participate_content',
'start_time',
'end_time',
'remark',
]);
$remark['start_time'] = strtotime($remark['start_time']);
if ($remark['start_time'] < Carbon::now()->startOfDay()->timestamp) {
$this->response(-1, '开始时间不能低于当前日期');
}
$remark['end_time'] = strtotime($remark['end_time']);
if ($remark['start_time'] > $remark['end_time'] || ($remark['start_time'] == $remark['end_time'])) {
$this->response(-1, '结束时间要大于开始时间,并且间隔要大于1天');
}
$remarkService = new PurchaseRemarkService();
$result = $remarkService->savePurchaseRemark($id, $remark);
if (!$result) {
$this->response(-1, '操作失败');
} else {
$logService = new LogService();
$content = !empty($remark['id']) ? '修改采购备注' : '添加采购备注';
$supplierId = $remark['supplier_id'];
$remark = json_encode($remark);
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $content, $content, $remark);
$this->response(0, '保存成功');
}
}
//删除
public function DeletePurchaseRemark($request)
{
$id = $request->get('id');
$model = new PurchaseRemarkModel();
$remark = $model->where('id', $id)->first()->toArray();
$result = $model->where('id', $id)->delete();
if ($result) {
$logService = new LogService();
$content = "删除采购备注";
$logService->AddLog($remark['supplier_id'], LogModel::UPDATE_OPERATE, '删除采购备注', $content);
$this->response(0, '操作成功');
}
$this->response(-1, '操作失败');
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Services\ShippingCostRulerService;
use App\Http\Transformers\ShippingCostRulerTransformer;
use App\Model\LogModel;
use App\Model\ShippingCostRulerModel;
use Illuminate\Http\Request;
class ShippingCostRulerApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
public function GetShippingCostRulerList($request)
{
$supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10);
$model = new ShippingCostRulerModel();
$model->where('supplier_id', $supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('id', 'desc')
->paginate($limit)->toArray();
$transformer = new ShippingCostRulerTransformer();
$list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'], $list['total']);
}
public function SaveShippingCostRuler($request)
{
$id = $request->input('id');
$currency = $request->input('currency');
$orderAmount = $request->input('order_amount');
$shippingCost = $request->input('shipping_cost');
$supplierId = $request->input('supplier_id');
$rulerText = $request->input('ruler_text');
if (!$supplierId) {
$this->response(-1,'供应商id不能为空');
}
if (!$currency) {
$this->response(-1,'订单币种不能为空');
}
if (!$orderAmount) {
$this->response(-1,'单笔订单金额不能为空');
}
$ruler = $request->only([
'id',
'supplier_id',
'order_amount',
'shipping_cost',
'currency',
'condition',
'ruler_text',
]);
$rulerService = new ShippingCostRulerService();
$result = $rulerService->saveShippingCostRuler($id,$ruler);
if (!$result) {
$this->response(-1, '操作失败');
} else {
$logService = new LogService();
$content = !empty($ruler['id']) ? '修改运费规则' : '添加运费规则';
$supplierId = $ruler['supplier_id'];
$ruler = json_encode($ruler);
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $content, $content, $ruler);
$this->response(0, '保存成功');
}
}
public function DeleteShippingCostRuler($request)
{
$id = $request->get('id');
$model = new ShippingCostRulerModel();
$ruler = $model->where('id', $id)->first()->toArray();
$result = $model->where('id', $id)->delete();
if ($result) {
$logService = new LogService();
$content = "删除运费规则";
$logService->AddLog($ruler['supplier_id'], LogModel::UPDATE_OPERATE, '删除运费规则', $content);
$this->response(0, '操作成功');
}
$this->response(-1, '操作失败');
}
}
<?php
namespace App\Http\Controllers;
use App\Model\PurchaseRemarkModel;
use Illuminate\Http\Request;
class PurchaseRemarkController extends Controller
{
public function info(Request $request, $id = '')
{
{
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($name, $arr)
{
$data['errinfo'] = '访问路径错误';
return view('errors.error', $data);
}
//保存采购备注
public function SavePurchaseRemark($request)
{
$id = $request->get('id');
if (!empty($id)) {
$model = new PurchaseRemarkModel();
$remark = $model->where('id', $id)->first()->toArray();
$remark['start_time'] = date('Y-m-d', $remark['start_time']);
$remark['end_time'] = date('Y-m-d', $remark['end_time']);
$this->data['remark'] = $remark;
}
$this->data['title'] = '保存采购备注';
$this->data['view'] = 'SavePurchaseRemark';
return $this->view('保存采购备注');
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers;
use App\Model\ShippingCostRulerModel;
use Illuminate\Http\Request;
class ShippingCostRulerController extends Controller
{
public function info(Request $request, $id = '')
{
{
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($name, $arr)
{
$data['errinfo'] = '访问路径错误';
return view('errors.error', $data);
}
//保存采购备注
public function SaveShippingCostRuler($request)
{
$id = $request->get('id');
if (!empty($id)) {
$model = new ShippingCostRulerModel();
$ruler = $model->where('id', $id)->first()->toArray();
$this->data['ruler'] = $ruler;
}
$this->data['title'] = '保存采购备注';
$this->data['view'] = 'SaveShippingCostRuler';
return $this->view('保存采购备注');
}
}
\ No newline at end of file
......@@ -228,6 +228,7 @@ class SupplierController extends Controller
config('field.SkipChangeSupplierTypeNames'));
$this->data['sku_upload_log_count'] = (new SkuUploadLogService())->getSkuUploadLogCount($supplierId);
$this->data['brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']);
$this->data['exclude_brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']);
$this->data['agency_brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['agency_brands']);
return $this->view('编辑供应商');
}
......
<?php
namespace App\Http\Services;
use App\Model\PurchaseRemarkModel;
//采购备注服务
class PurchaseRemarkService
{
public function savePurchaseRemark($remarkId,$remark)
{
$remarkModel = new PurchaseRemarkModel();
if (empty($remarkId)) {
$remark['create_uid'] = request()->user->userId;
$remark['create_name'] = request()->user->name;
$remark['create_time'] = time();
return $remarkModel->insertGetId($remark);
} else {
$remark['update_time'] = time();
return $remarkModel->where('id', $remarkId)->update($remark)?$remarkId:0;
}
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Model\ShippingCostRulerModel;
//采购备注服务
class ShippingCostRulerService
{
public function saveShippingCostRuler($rulerId,$ruler)
{
$rulerModel = new ShippingCostRulerModel();
if (empty($rulerId)) {
$ruler['create_uid'] = request()->user->userId;
$ruler['create_name'] = request()->user->name;
$ruler['create_time'] = time();
return $rulerModel->insertGetId($ruler);
} else {
$ruler['update_time'] = time();
return $rulerModel->where('id', $rulerId)->update($ruler)?$rulerId:0;
}
}
}
\ No newline at end of file
......@@ -4,11 +4,13 @@
namespace App\Http\Services;
use App\Model\BrandModel;
use App\Model\SpuBrandModel;
use App\Model\RedisModel;
use App\Model\StandardBrandMappingModel;
use App\Model\StandardBrandModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
class StandardBrandService
{
......@@ -95,4 +97,68 @@ class StandardBrandService
$standardBrandIds = StandardBrandModel::whereIn('brand_name', $standardBrandNames)->pluck('standard_brand_id')->toArray();
return $this->getBrandInitValue(implode(',',$standardBrandIds));
}
//根据品牌id获取标准品牌名字列表
public function getStandardBrandNameListByBrandIds($brandIds)
{
$brandIds = explode(',', trim($brandIds, ','));
if (empty($brandIds)) {
return '';
}
$redis = Redis::connection();
$brands = $redis->hmget('standard_brand', $brandIds);
$standardBrandNameList = [];
foreach ($brands as $brand) {
$brand = json_decode($brand, true);
$standardBrandNameList[] = $brand['brand_name'];
}
return $standardBrandNameList ? implode(',', $standardBrandNameList) : '';
}
public function checkStandardBrandNameList($standardBrandNameList = [])
{
//去数据库查询
$validStandardBrandList =StandardBrandModel::whereIn('brand_name',
$standardBrandNameList)
->pluck('brand_name', 'standard_brand_id')->toArray();
$validStandardBrandMap = array_flip($validStandardBrandList);
$invalidBrandNameList = [];
$validStandardBrandNameList = [];
$validStandardBrandIds = [];
//判断哪些是错误的,哪些是正确的
$redis = Redis::connection();
foreach ($standardBrandNameList as $key => $standardBrandName) {
if (in_array($standardBrandName, array_values($validStandardBrandList))) {
$validStandardBrandIds[] = $validStandardBrandMap[$standardBrandName];
$validStandardBrandNameList[] = $standardBrandName;
unset($standardBrandNameList[$key]);
}
}
//剩下没有能直接找到标准品牌的,先当作普通品牌处理,然后去找出标准品牌,如果还是找不到,那就是无效品牌了
foreach ($standardBrandNameList as $key => $checkStandardBrandName) {
//先去找对应的标准品牌
$brandId = BrandModel::where('brand_name', $checkStandardBrandName)->value('brand_id');
$standardBrandId = $redis->hget('standard_brand_mapping', $brandId);
if (empty($standardBrandId)) {
$invalidBrandNameList[] = $checkStandardBrandName;
continue;
}
$standardBrand = $redis->hget('standard_brand', $standardBrandId);
$standardBrand = json_decode($standardBrand, true);
$standardBrandName = array_get($standardBrand, 'brand_name', '');
$standardBrandId = array_get($standardBrand, 'standard_brand_id', '');
if (empty($standardBrandName)) {
$invalidBrandNameList[] = $checkStandardBrandName;
continue;
}
$validStandardBrandIds[] = $standardBrandId;
$validStandardBrandNameList[] = $standardBrandName;
}
//整合数据,返回标准的数据和无效的数据
return [
'invalid_brand_name_list' => $invalidBrandNameList,
'valid_brand_name_list' => $validStandardBrandNameList,
'valid_brand_ids' => $validStandardBrandIds,
];
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class PurchaseRemarkTransformer
{
public function transformList($list)
{
if (empty($list)) {
return [];
}
foreach ($list as &$remark) {
if (!$remark) {
continue;
}
$remark['participate_type_name'] = array_get(config('field.PurchaseRemarkParticipateType'), $remark['participate_type'], '无');
$remark['create_time'] = $remark['create_time'] ? date('Y-m-d H:i:s',
$remark['create_time']) : '';
$remark['update_time'] = $remark['update_time'] ? date('Y-m-d H:i:s',
$remark['update_time']) : '';
$remark['status'] = $remark['end_time'] < time() ? 1 : -1;
$remark['start_time'] = $remark['start_time'] ? date('Y-m-d',
$remark['start_time']) : '';
$remark['end_time'] = $remark['start_time'] ? date('Y-m-d',
$remark['end_time']) : '';
$remark['duration'] = $remark['start_time'] . ' ~ ' . $remark['end_time'];
}
unset($remark);
return $list;
}
}
\ No newline at end of file
<?php
namespace App\Http\Transformers;
class ShippingCostRulerTransformer
{
public function transformList($list)
{
if (empty($list)) {
return [];
}
foreach ($list as &$remark) {
if (!$remark) {
continue;
}
$remark['create_time'] = $remark['create_time'] ? date('Y-m-d H:i:s',
$remark['create_time']) : '';
$remark['update_time'] = $remark['update_time'] ? date('Y-m-d H:i:s',
$remark['update_time']) : '';
}
unset($remark);
return $list;
}
}
\ No newline at end of file
......@@ -30,6 +30,8 @@ Route::group(['middleware' => ['web', 'menu']], function () {
Route::match(['get', 'post'], '/sku/{key}', 'SkuController@Entrance');
Route::match(['get', 'post'], '/log/{key}', 'LogController@Entrance');
Route::match(['get', 'post'], '/supplier_apply/{key}', 'SupplierApplyController@info');
Route::match(['get', 'post'], '/purchase_remark/{key}', 'PurchaseRemarkController@info');
Route::match(['get', 'post'], '/shipping_cost_ruler/{key}', 'ShippingCostRulerController@info');
});
Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
......@@ -50,6 +52,8 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_examination/{key}', 'SupplierExaminationApiController@Entrance');
Route::match(['get', 'post'], '/api/sku_upload_log/{key}', 'SkuUploadLogApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_apply/{key}', 'SupplierApplyApiController@Entrance');
Route::match(['get', 'post'], '/api/purchase_remark/{key}', 'PurchaseRemarkApiController@Entrance');
Route::match(['get', 'post'], '/api/shipping_cost_ruler/{key}', 'ShippingCostRulerApiController@Entrance');
//单独的统计接口
Route::match(['get', 'post'], '/statisticsSkuNumber', function () {
(new \App\Http\Services\DataService())->statisticsSkuNumber();
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class PurchaseRemarkModel extends Model
{
protected $connection='web';
protected $table='purchase_remark';
protected $primaryKey = 'id';
public $timestamps = false;
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class ShippingCostRulerModel extends Model
{
protected $connection='web';
protected $table='shipping_cost_ruler';
protected $primaryKey = 'id';
public $timestamps = false;
}
<?php
namespace App\Presenters;
use App\Http\Services\StandardBrandService;
class StandardBrandNameListPresenter
{
public function render($name, $fieldText, $value = null, $option = [])
{
//因为这个组件是专门给标准品牌用的,所以可以直接去获取标准列表展示出来
$standardBrandNameList = '';
if ($value) {
$standardBrandNameList = (new StandardBrandService())->getStandardBrandNameListByBrandIds($value);
}
$isRequired = \Arr::get($option, 'required', false);
$requiredHtml = $isRequired ? '<span style="color: red;margin-right: 3px">*</span>' : '';
$html = <<<EOF
<label class="layui-form-label">
$requiredHtml $fieldText</label>
<div class="layui-input-block" style="width: 80%">
<input type="hidden" name="$name" value="$value" id="$name">
<div class="layui-col-md7">
<textarea rows="7" placeholder="标准品牌名称,多个用英文逗号隔开" class="layui-textarea" id="${name}_name_list">$standardBrandNameList</textarea>
<blockquote class="layui-elem-quote" id="valid_${name}_name_list">$standardBrandNameList</blockquote>
<span style="color: red" id="invalid_${name}_name_list"></span>
</div>
<div class="layui-col-md5">
<button type="button" class="layui-btn-sm layui-btn" id="check_and_add_${name}_name_list" style="margin-left: 10px;">验证并加入</button>
<p style="margin-top: 130px;margin-left: 10px"></p>
</div>
</div>
<script>
$(document).on('click','#check_and_add_${name}_name_list',function () {
let standardBrandNameList = $('#${name}_name_list').val();
let url = '/api/commonData/checkStandardBrandNameList';
layer.load();
var self = $(this);
$.ajax({
url: url,
type: 'POST',
async: true,
data: {
standard_brand_name_list: standardBrandNameList
},
dataType: 'json',
timeout: 20000,
success: function (res) {
let brandCount = 0;
layer.closeAll();
if (res.code === 0) {
//得到结果后还要操作div
let data = res.data;
let invalidBrandNameList = data.invalid_brand_name_list;
let validBrandIds = data.valid_brand_ids;
let validBrandNameList = data.valid_brand_name_list;
let standardBrandIds = $('#${name}').val();
standardBrandIds = standardBrandIds.split(',');
standardBrandIds = validBrandIds;
standardBrandIds = array_unique(array_remove_empty(standardBrandIds));
$('#${name}').val(standardBrandIds.join(','));
// let validStandardBrandNameList = $('#valid_${name}_name_list').text();
// validStandardBrandNameList = validStandardBrandNameList.split(',');
let validStandardBrandNameList = validBrandNameList;
validStandardBrandNameList = array_unique(array_remove_empty(validStandardBrandNameList));
brandCount = validStandardBrandNameList.length;
$('#valid_${name}_name_list').text(validStandardBrandNameList.join(','));
// $('#${name}_name_list').val(validStandardBrandNameList.join(','));
// let invalidStandardBrandNameList = $('#invalid_${name}_name_list').val();
// let invalidStandardBrandNameList = '';
// invalidStandardBrandNameList = invalidStandardBrandNameList.split(',');
// invalidStandardBrandNameList = $.merge(invalidStandardBrandNameList, invalidBrandNameList);
$('#invalid_${name}_name_list').text('');
let invalidStandardBrandNameList = invalidBrandNameList;
invalidStandardBrandNameList = array_unique(array_remove_empty(invalidStandardBrandNameList));
if (invalidStandardBrandNameList.length > 0){
let text = '品牌名称 : ' + invalidStandardBrandNameList.join('、') + ' 未匹配到标准品牌';
$('#invalid_${name}_name_list').text(text);
$('#invalid_${name}_name_list').val(invalidStandardBrandNameList.join('、'));
}
self.next().text(brandCount+'个');
} else {
layer.msg(res.msg, {icon: 5});
}
},
error: function () {
layer.closeAll();
layer.msg('网络错误', {icon: 5});
}
});
});
</script>
EOF;
return $html;
}
}
\ No newline at end of file
......@@ -249,4 +249,22 @@ return [
3 => 5,
0 => 5,
],
//采购备注参与类型
'PurchaseRemarkParticipateType' => [
1 => '全渠道参与',
2 => '型号',
3 => '品牌',
],
//运费规则币种
'ShippingCostRulerCurrency' => [
1 => '人民币(RMB)',
2 => '美金(USD)'
],
//运费规则条件
'ShippingCostRulerCondition' => [
1 => '小于',
2 => '大于等于'
],
];
\ No newline at end of file
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin', 'xmSelect', 'laydate'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
let laydate = layui.laydate;
let xmSelect = layui.xmSelect;
laydate.render({
elem: '#start_time'
, format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#end_time'
, format: 'yyyy-MM-dd'
});
form.on('radio(participate_type)', function (data) {
let type = data.value;
if (type === '1') {
$('#participate_content').attr('disabled', true);
$('#participate_content').addClass('layui-disabled');
} else {
$('#participate_content').attr('disabled', false);
$('#participate_content').removeClass('layui-disabled');
}
});
form.on('submit(savePurchaseRemark)', function (data) {
let url = '/api/purchase_remark/SavePurchaseRemark';
data.field.supplier_id = getQueryVariable('supplier_id');
let participateType = data.field.participate_type;
//如果是品牌类型,那么就要去校验品牌是否都是对的
if (participateType == 3) {
let checkBrandRes = ajax('/api/common/checkStandardBrandNameList', {standard_brand_name_list: data.field.participate_content});
if (checkBrandRes.code == 0) {
if (checkBrandRes.data.invalid_brand_name_list.length > 0) {
let list = checkBrandRes.data.invalid_brand_name_list.join(',');
list += ' 不是标准品牌名称';
$('#checkStandardBrandNameResult').text(list);
layer.msg("标准品牌校验未通过,请修正品牌后再重新提交")
return false;
}
}
}
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', 'table', 'layer', 'admin', 'xmSelect', 'laydate'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
let laydate = layui.laydate;
let xmSelect = layui.xmSelect;
laydate.render({
elem: '#start_time'
, format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#end_time'
, format: 'yyyy-MM-dd'
});
function setConditionCurrencyName(currency) {
if (currency == 1) {
$('#ruler_condition_center_text').text('元(RMB),收取运费');
$('#ruler_condition_end_text').text('元(RMB)');
} else {
$('#ruler_condition_center_text').text('美元(USD),收取运费');
$('#ruler_condition_end_text').text('美元(USD)');
}
}
let currency = $('#currency').val();
setConditionCurrencyName(currency);
form.on('radio(currency)', function (data) {
currency = data.value;
setConditionCurrencyName(data.value);
setRulerText();
});
let condition = $('#condition').val();
form.on('select(condition)', function (data) {
condition = data.value;
setConditionCurrencyName(currency);
setRulerText();
});
function setRulerText(){
let conditionName = condition == 1 ? '小于' : '大于等于';
//订单金额小于¥100.00,收取运费¥5.00;
let rulerText = '';
let orderAmountFormat;
let shippingCostFormat;
let orderAmount = $('#order_amount').val();
if (orderAmount) {
orderAmount = parseFloat(orderAmount);
$('order_amount').val(orderAmount.toFixed(2));
orderAmountFormat = currency == 1 ? '¥' + orderAmount.toFixed(2) : '$' + orderAmount.toFixed(2);
}
let shippingCost = $('#shipping_cost').val();
if (shippingCost) {
shippingCost = parseFloat(shippingCost);
$('shipping_cost').val(shippingCost.toFixed(2));
shippingCostFormat = currency == 1 ? '¥' + shippingCost.toFixed(2) : '$' + shippingCost.toFixed(2);
console.log(shippingCostFormat);
}
if (orderAmount) {
if (shippingCost == 0) {
rulerText = "订单金额" + conditionName + orderAmountFormat + ",包邮;";
} else {
rulerText = "订单金额" + conditionName + orderAmountFormat + ",收取运费" + shippingCostFormat + ";";
}
}
console.log(rulerText);
$('#ruler_text').val(rulerText);
}
$('#order_amount,#shipping_cost').on('input', function () {
setRulerText();
});
form.on('submit(saveShippingCostRuler)', function (data) {
let url = '/api/shipping_cost_ruler/SaveShippingCostRuler';
data.field.supplier_id = getQueryVariable('supplier_id');
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
......@@ -38,7 +38,7 @@
},
{field: 'description', title: '附件说明', align: 'center', width: 250},
{field: 'validity_period', title: '<span class="require">* </span>有效期', align: 'center', width: 220},
{field: 'create_name', title: '上传人', align: 'center', width: 100},
{field: 'create_name', title: '内部采购', align: 'center', width: 100},
{field: 'create_time', title: '上传时间', align: 'center', width: 150},
]],
id: 'attachmentList',
......
......@@ -2,6 +2,7 @@
layui.use(['table', 'form', 'element', 'layer', 'admin', 'laydate', 'xmSelect'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table;
let layDate = layui.laydate;
let element = layui.element;
let xmSelect = layui.xmSelect;
......@@ -16,5 +17,150 @@
$('#hk_max').val(9999999);
}
});
let isDetail = {{$operate==="update"?0:1}};
let cols = [
{
field: 'status', title: '状态', width: 80, templet: function (data) {
return data.status == 1 ? "<span style='color: red'>停用</span>" : '启用';
}
},
{field: 'participate_type_name', title: '参与类型', width: 140},
{field: 'duration', title: '开始时间 - 截至时间', width: 250},
{field: 'remark', title: '备注内容',},
];
if (!isDetail) {
cols.unshift({field: 'operate', title: '操作', width: 130, templet: '#operate'});
}
table.render({
elem: '#purchaseRemarkList',
url: '/api/purchase_remark/GetPurchaseRemarkList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: {
supplier_id: getQueryVariable("supplier_id")
},
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [cols],
id: 'purchaseRemarkList',
page: {},
});
//新增
$("#savePurchaserRemark").click(function () {
let supplierId = getQueryVariable('supplier_id');
layer.open({
type: 2,
content: '/purchase_remark/SavePurchaseRemark?view=iframe&supplier_id=' + supplierId,
area: ['800px', '725px'],
title: '新增采购备注',
end: function () { // 监听弹窗关闭
table.reload('purchaseRemarkList');
}
});
})
table.on('tool(purchaseRemarkList)', function (obj) {
let data = obj.data;
let layEvent = obj.event;
if (layEvent === 'edit') {
layer.open({
type: 2,
area: ['800px', '725px'],
fixed: false,
offset: '50px',
//不固定
// maxmin: true,
title: '查看采购备注 ',
content: '/purchase_remark/SavePurchaseRemark?view=iframe&supplier_id=' + getQueryVariable('supplier_id') + '&id=' + data.id,
end: function () { // 监听弹窗关闭
table.reload('purchaseRemarkList');
}
});
}
if (layEvent === 'delete') {
layer.confirm('确定要删除该条采购备注吗?', function (index) {
let res = ajax('/api/purchase_remark/DeletePurchaseRemark', {id: data.id});
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6})
table.reload('purchaseRemarkList');
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
cols = [
{field: 'id', title: '规则', width: 80},
{field: 'ruler_text', title: '内容',},
];
if (!isDetail) {
cols.unshift({field: 'operate', title: '操作', width: 130, templet: '#operate'});
}
table.render({
elem: '#shippingCostRulerList',
url: '/api/shipping_cost_ruler/GetShippingCostRulerList',
method: 'get',
cellMinWidth: 80,//全局定义常规单元格的最小宽度
where: {
supplier_id: getQueryVariable("supplier_id")
},
loading: true,
first: true,//不显示首页
last: false,//不显示尾页
cols: [cols],
id: 'shippingCostRulerList',
page: {},
});
//新增
$("#saveShippingCostRuler").click(function () {
let supplierId = getQueryVariable('supplier_id');
layer.open({
type: 2,
content: '/shipping_cost_ruler/SaveShippingCostRuler?view=iframe&supplier_id=' + supplierId,
area: ['800px', '425px'],
title: '添加运费规则',
end: function () { // 监听弹窗关闭
table.reload('shippingCostRulerList');
}
});
})
table.on('tool(shippingCostRulerList)', function (obj) {
let data = obj.data;
console.log(data);
let layEvent = obj.event;
if (layEvent === 'edit') {
layer.open({
type: 2,
area: ['800px', '425px'],
fixed: false,
offset: '50px',
//不固定
// maxmin: true,
title: '查看运费规则 ',
content: '/shipping_cost_ruler/SaveShippingCostRuler?view=iframe&supplier_id=' + getQueryVariable('supplier_id') + '&id=' + data.id,
end: function () { // 监听弹窗关闭
table.reload('shippingCostRulerList');
}
});
}
if (layEvent === 'delete') {
layer.confirm('确定要删除该条运费规则吗?', function (index) {
let res = ajax('/api/shipping_cost_ruler/DeleteShippingCostRuler', {id: data.id});
if (res.err_code === 0) {
layer.msg(res.err_msg, {icon: 6})
table.reload('shippingCostRulerList');
} else {
layer.msg(res.err_msg, {icon: 5})
}
});
}
});
});
</script>
\ No newline at end of file
<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">
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('participate_type','参与类型 :',!empty($remark)?$remark['participate_type']:1,config('field.PurchaseRemarkParticipateType'),['required'=>true,'disable' => !empty($remark)?true:false]) !!}
</div>
<input type="hidden" name="id" value="{{$remark['id'] or ''}}">
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>参与内容 : </label>
<div class="layui-input-block">
<div id="participate_content_div">
<textarea rows="7" name="participate_content"
placeholder="请输入 型号/标准品牌 全称,多个以英文逗号隔开,如果选择品牌类型,会去校验标准品牌是否正确"
class="layui-textarea @if(empty($remark) || (!empty($remark) && $remark['participate_type']==1)) layui-disabled @endif"
@if(empty($remark)|| (!empty($remark) && $remark['participate_type']==1)) disabled @endif
id="participate_content">{{$remark['participate_content'] or ''}}</textarea>
</div>
<blockquote class="layui-elem-quote layui-text">
<b style="color: red" id="checkStandardBrandNameResult"></b>
</blockquote>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>参与时间 : </label>
<div class="layui-input-block">
<div class="layui-col-xs4">
<div class="layui-input-inline">
<input type="text" id="start_time" name="start_time"
placeholder="请输入开始时间"
class="layui-input"
autocomplete="off"
value="{{$remark['start_time'] or ''}}">
</div>
</div>
<div class="layui-col-xs1">
<span style="width: 10px"> --</span>
</div>
<div class="layui-col-xs7" style="margin-left: -25px">
<div class="layui-input-inline">
<input type="text" id="end_time" name="end_time"
placeholder="请输入截止时间"
class="layui-input"
autocomplete="off"
value="{{$remark['end_time'] or ''}}">
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">*</span>备注内容 : </label>
<div class="layui-input-block">
<textarea rows="7" name="remark" placeholder="活动内容(展示在【询报价系统】供销售查看的内容通知)"
class="layui-textarea"
id="remark">{{$remark['remark'] or ''}}</textarea>
</div>
</div>
<div class="layui-form-item">
<div align="right" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="savePurchaseRemark">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">关闭
</button>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form" action="">
<input type="hidden" name="id" value="{{$ruler['id'] or ''}}">
<div class="layui-form-item">
@inject('singleSelectPresenter','App\Presenters\SingleSelectPresenter')
{!! $singleSelectPresenter->render('currency','订单币种 :',!empty($ruler)?$ruler['currency']:1,config('field.ShippingCostRulerCurrency'),['required'=>true]) !!}
</div>
<div class="layui-form-item" >
<label class="layui-form-label"><span style="color: red">*</span>单笔订单金额</label>
<div class="layui-input-block" style="max-height: 30px">
<div class="layui-col-xs2">
<select name="condition" value="{{$ruler['condition'] or 1}}" lay-filter="condition">
@foreach(config('field.ShippingCostRulerCondition') as $key => $name)
<option value="{{$key}}"
@if(!empty($ruler)&&$ruler['condition']==$key) checked selected='selected' @endif
>{{$name}}</option>
@endforeach
</select>
</div>
<div class="layui-col-xs2">
<input class="layui-input" name="order_amount" id="order_amount" value="{{$ruler['order_amount'] or 0}}">
</div>
<div class="layui-col-xs3" style="padding-left: 10px">
<span id="ruler_condition_center_text">
元(RMB),收取运费
</span>
</div>
<div class="layui-col-xs2">
<input class="layui-input" name="shipping_cost" id="shipping_cost" value="{{$ruler['shipping_cost'] or 0}}">
</div>
<div class="layui-col-xs3" style="padding-left: 10px">
<span id="ruler_condition_end_text">
元(RMB)
</span>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">规则预览 : </label>
<div class="layui-input-block">
<textarea rows="1" name="ruler_text" placeholder=""
class="layui-textarea layui-disabled" disabled
id="ruler_text">{{$ruler['ruler_text'] or ''}}</textarea>
</div>
</div>
<div class="layui-form-item">
<div align="right" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="saveShippingCostRuler">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">关闭
</button>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
......@@ -344,6 +344,9 @@
@endif
>
<div class="layui-row" style="padding-bottom: 10px">
@include('web.supplier.SupplierRuler')
<blockquote class="layui-elem-quote layui-text">
<b>采购附加费设置</b>
</blockquote>
......
......@@ -78,9 +78,9 @@
lay-filter="applyAuditSupplier">审核未通过,确认重新提交审核
</button>
@else
{{-- <button type="button" class="layui-btn layui-btn submit-loading" lay-submit--}}
{{-- lay-filter="updateSupplier">确认修改供应商--}}
{{-- </button>--}}
{{-- <button type="button" class="layui-btn layui-btn submit-loading" lay-submit--}}
{{-- lay-filter="updateSupplier">确认修改供应商--}}
{{-- </button>--}}
@if ($supplier['status'] == \App\Model\SupplierChannelModel::STATUS_PASSED && checkPerm('IgnoreUpdateAudit'))
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="updateSupplier">确认修改供应商
......@@ -104,39 +104,40 @@
<ul class="layui-tab-title">
<li
@if(request()->get('tab')=='base_info'||empty(request()->get('tab')))
class="layui-this"
class="layui-this"
@endif
id="base_info">基本信息
</li>
<li
@if(request()->get('tab')=='contact')
class="layui-this"
class="layui-this"
@endif
id="contact">联系人
</li>
<li
@if(request()->get('tab')=='ruler')
class="layui-this"
class="layui-this"
@endif
id="ruler">特殊规则
</li>
<li @if (!checkPerm('UpdateSkuRuler')) style="display: none" @endif
@if(request()->get('tab')=='sku_ruler')
class="layui-this"
class="layui-this"
@endif
id="sku_ruler">SKU概况
</li>
<li @if (!checkPerm('ViewSupplierExamination')) style="display: none" @endif
@if(request()->get('tab')=='examination')
class="layui-this"
class="layui-this"
@endif
id="examination">检测记录
</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item @if(request()->get('tab')=='base_info'||empty(request()->get('tab'))) layui-show @endif">
<div class="layui-tab-item
@if(request()->get('tab')=='base_info'||empty(request()->get('tab'))) layui-show @endif"
>
<div class="layui-row">
<input type="hidden" name="apply_audit_reason" id="apply_audit_reason">
<input type="hidden" name="status" value="{{$supplier['status'] or 0}}">
......@@ -228,22 +229,26 @@
<hr/>
</div>
</div>
{{--联系人--}}
<div class="layui-tab-item @if(request()->get('tab')=='contact') layui-show @endif">
<div @if(!checkPerm('ViewSupplierContact'))style="display: none"@endif>
@include('web.supplier.SupplierContact')
</div>
</div>
{{--特殊规则--}}
<div class="layui-tab-item @if(request()->get('tab')=='ruler') layui-show @endif">
<div
@if(!checkPerm('ViewRuler') || !checkPerm('UpdateRuler'))
style="display: none"
style="display: none"
@endif>
@include('web.supplier.SupplierRuler')
</div>
</div>
{{--sku规则--}}
<div class="layui-tab-item @if(request()->get('tab')=='sku_ruler') layui-show @endif">
@include('web.supplier.SkuRuler')
</div>
{{--iqc记录--}}
<div class="layui-tab-item @if(request()->get('tab')=='examination') layui-show @endif">
@include('web.SupplierExaminationList')
</div>
......
......@@ -237,7 +237,6 @@
</div>
</div>
</div>
</div>
{{--选择“混合分销商”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div class="layui-form-item" id="agency_brands_div"
......
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