Commit 6eac583f by mushishixian

temp

parent cd06e008
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use Illuminate\Http\Request;
......@@ -53,6 +54,9 @@ class SupplierController extends Controller
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode();
$this->data['users'] = $intracodeModel->getAdminUserAndCode();
$supplierStatisticsService = new SupplierStatisticsService();
$statistics = $supplierStatisticsService->getSupplierListStatistics();
$this->data['statistics'] = $statistics;
$this->data['validPerms'] = [];
return $this->view('供应商列表');
}
......
......@@ -23,6 +23,14 @@ class AdminUserService
public function getAdminUserInfo($userId)
{
$user = DB::connection()->table('user_info')->where('userId', $userId)->first();
return $user ? : [];
return $user ?: [];
}
//获取离职人员列表
public function getResignedUsers()
{
$user = DB::connection()->table('user_info')->leftJoin('lie_intracode','user_info.userId','=','lie_intracode.admin_id')
->where('user_info.status', 4)->where('lie_intracode.code_id','!=','')->get();
return $user ?: [];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class SupplierStatisticsService
{
//获取供应商列表需要统计的信息
public function getSupplierListStatistics()
{
$model = new SupplierChannelModel();
$total = $model->count();
//待审核,就是以前的草稿
$pending = $model->where('status', $model::STATUS_PENDING)->count();
//审核中
$inReview = $model->where('status', $model::STATUS_IN_REVIEW)->count();
//通过
$passed = $model->where('status', $model::STATUS_PASSED)->count();
//未通过
$rejected = $model->where('status', $model::STATUS_REJECT)->count();
//禁用
$disable = $model->where('status', $model::STATUS_DISABLE)->count();
//没有渠道开发员
$noPurchaseUid = $model->where('status', '!=', $model::STATUS_DISABLE)->where('purchase_uid', '=', '')->count();
//没有sku的
$noSku = $model->where('sku_num', '==', 0)->count();
$adminUserService = new AdminUserService();
$resignedUsers = $adminUserService->getResignedUsers();
$resignedUserCodes = array_column($resignedUsers, 'code_id');
//存在无效(离职)开发员
$invalidPurchaseUid = $model->where('status', '!=', $model::STATUS_DISABLE)
->whereIn('purchase_uid', $resignedUserCodes)->count();
//构建likeIn语句需要的数据
$likeSqlRaw = implode('|', $resignedUserCodes);
//存在无效(离职)采购员
$invalidChannelUid = $model->where('status', '!=', $model::STATUS_DISABLE)
->whereRaw(DB::raw("channel_uid REGEXP '$likeSqlRaw'"))->count();
//待跟进
$toFollowUp = $model->where('status', '!=', $model::STATUS_DISABLE)->where('to_follow_up', 1)->count();
$result = [
'total' => $total,
'pending' => $pending,
'in_review' => $inReview,
'passed' => $passed,
'rejected' => $rejected,
'disable' => $disable,
'no_purchase_uid' => $noPurchaseUid,
'invalid_channel_uid' => $invalidChannelUid,
'invalid_purchase_uid' => $invalidPurchaseUid,
'to_follow_up' => $toFollowUp,
'no_sku' => $noSku,
];
$result = array_map(function ($value) {
if ($value > 999) {
$value = '999+';
}
return $value;
},$result);
return $result;
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ namespace App\Http\Transformers;
use App\Http\Services\AdminUserService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\SupplierContactModel;
class SupplierTransformer
{
......@@ -32,7 +33,8 @@ class SupplierTransformer
$item['channel_username'] = $this->getChannelNames($item['channel_uid']);
$item['purchase_username'] = array_get($users, $item['purchase_uid']);
$item['status_name'] = array_get(config('fixed.SupplierStatus'), $item['status']);
$item['contact_num'] = 1;
$item['contact_num'] = $this->getContactNum($item['supplier_id']);
$item['has_sku'] = $item['sku_num'] ? '是' : '否';
$item['is_own'] = $item['create_uid'] == request()->user->userId ? "创建" : "指派";
if (empty($item['create_name'])) {
$userInfo = $adminUserService->getAdminUserInfo($item['create_uid']);
......@@ -52,6 +54,12 @@ class SupplierTransformer
return $list;
}
public function getContactNum($supplierId)
{
$model = new SupplierContactModel();
return $model->where('supplier_id', $supplierId)->count();
}
public function getChannelNames($channelUid)
{
$intracodeModel = new IntracodeModel();
......
......@@ -9,6 +9,11 @@ use RedisDB;
class SupplierChannelModel extends Model
{
const STATUS_PENDING = -1;
const STATUS_IN_REVIEW = 1;
const STATUS_PASSED = 2;
const STATUS_REJECT = 3;
const STATUS_DISABLE = -2;
protected $connection = 'web';
protected $table = 'supplier_channel';
public $timestamps = false;
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class SupplierContactModel extends Model
{
protected $connection='web';
protected $table='supplier_contact';
public $timestamps = false;
public function AddInfo($SupplierID='',$data=''){
if(empty($SupplierID) || empty($data) || !is_array($data)) return false;
$Add = array();
foreach ($data as $k=>$v){
foreach($v as $kk=>$vv){
$Add[$kk][$k] = $vv;
$Add[$kk]['supplier_id'] = $SupplierID;
}
}
foreach($Add as $v){
$this->insert($v);
}
return true;
}
public function AddContactInfo($data='', $is_update = false){
if(empty($data) || !is_array($data)) return false;
if ($is_update) { // 更新
$supplier_id = $data['supplier_id'];
unset($data['supplier_id']);
$this->where('supplier_id', '=', $supplier_id)->update($data);
} else {
$this->insert($data);
}
}
public function SaveInfo($SupplierID='',$data=''){
if($SupplierID<=0) return false;
$this->where('supplier_id', '=', $SupplierID)->delete();
return $this->AddInfo($SupplierID,$data);
}
public function ContactInfo($SupplierID=''){
$collert=Request::only('supplier_id');
$collert=TrimX($collert,true,['supplier_id']);
empty($collert) && $collert['supplier_id']=$SupplierID;
if(empty($collert['supplier_id'])) return false;
$info=$this->where('supplier_id','=',$collert['supplier_id'])->get();
if(!$info) return false;
$info=$info->toArray();
// $Arr=[];
// foreach ($info as $k=>$v){
// $Arr[$v['address_type']]=$v;
// }
return $info;
}
}
<?php
namespace App\Presenters\Filter;
class DayTypePresenter
{
public function render($map = [], $linkageName = '')
{
$unique = "unique_" . mt_rand(1, 100000);
$html = <<<EOF
<div class="layui-row" style="width:268px;margin-bottom: 3px;margin-top: 5px">
<div class="layui-col-md2" style="margin-left: 34px">
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm day_type_button" id="${unique}_today">今日</button>
</div>
<div class="layui-col-md2">
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm day_type_button" id="${unique}_today">近三天</button>
</div>
<div class="layui-col-md2">
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm day_type_button" style="margin-left: 11px" id="${unique}_today">本周</button>
</div>
<div class="layui-col-md2">
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm day_type_button" style="margin-left: 10px" id="${unique}_today">本月</button>
</div>
<div class="layui-col-md3">
</div>
</div>
<script>
layui.use(['form', 'element'], function () {
$('.day_type_button').click(function() {
$('.day_type_button').attr('class','layui-btn layui-btn-primary layui-btn-sm day_type_button');
$(this).attr('class','layui-btn layui-btn-sm layui-btn-normal day_type_button');
});
});
</script>
EOF;
return $html;
}
public function optionsRender($data)
{
$optionsHtml = '';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
}
\ No newline at end of file
<?php
namespace App\Presenters\Filter;
class TransformableInputPresenter
{
public function render($map = [])
{
$unique = "unique_" . mt_rand(1, 100000);
$defaultKey = array_keys($map)[0];
$html = <<<EOF
<div class="layui-row" style="width:268px;margin-bottom: 3px;">
<div class="layui-col-md5">
<div class="layui-input-inline" style="width: 100px;margin-left: 10px">
<select lay-filter="$unique">
{$this->optionsRender($map)}
</select>
</div>
</div>
<div class="layui-col-md7" style="margin-left: -3px">
<div class="layui-input-inline">
<input type="text" name="$defaultKey" placeholder="请输入" class="layui-input"
style="width: 158px">
</div>
</div>
</div>
<script>
layui.use(['form', 'element'], function () {
let form = layui.form;
form.on('select($unique)', function(data){
data.othis.parent().parent().parent().find('input').attr('name',data.value);
});
});
</script>
EOF;
return $html;
}
public function optionsRender($data)
{
$optionsHtml = '';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
}
\ No newline at end of file
<?php
namespace App\Presenters\Filter;
class TransformableSelectPresenter
{
public function render($map = [], $data = [])
{
$defaultKey = array_keys($map)[0];
$unique = "unique_" . mt_rand(1, 100000);
$selectUnique = "unique_" . mt_rand(1, 100000);
$html = <<<EOF
<div class="layui-row" style="width:268px;margin-bottom: 3px;">
<div class="layui-col-md5">
<div class="layui-input-inline" style="width: 100px;margin-left: 10px">
<select lay-filter="$unique">
{$this->optionsRender($map)}
</select>
</div>
</div>
<div class="layui-col-md7" style="margin-left: -3px">
<div class="layui-input-inline">
<select class="value_select" name="$defaultKey" lay-filter="$selectUnique">
{$this->selectOptionsRender($data)}
</select>
</div>
</div>
</div>
<script>
layui.use(['form', 'element'], function () {
let form = layui.form;
form.on('select($unique)', function(data){
data.othis.parent().parent().parent().find('.value_select').attr('name',data.value);
});
});
</script>
EOF;
return $html;
}
public function optionsRender($data)
{
$optionsHtml = '';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
public function selectOptionsRender($data)
{
$optionsHtml = ' <option value="">请选择</option>';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
}
\ No newline at end of file
<?php
namespace App\Presenters\Filter;
class TransformableTimeIntervalPresenter
{
public function render($map = [])
{
$unique = "unique_" . mt_rand(1, 100000);
$defaultKey = array_keys($map)[0];
$html = <<<EOF
<div class="layui-row" style="width:268px;margin-bottom: 3px;">
<div class="layui-col-md5">
<div class="layui-input-inline" style="width: 100px;margin-left: 10px">
<select lay-filter="$unique">
{$this->optionsRender($map)}
</select>
</div>
</div>
<div class="layui-col-md7" style="margin-left: -3px">
<div class="layui-input-inline" style="min-width: 150px;width: 158px">
<input type="text" name="$defaultKey" id="$unique" placeholder="请选择时间区间" autocomplete="off" class="layui-input">
</div>
</div>
</div>
<script>
layui.use(['form', 'element','laydate'], function(){
let laydate = layui.laydate;
let form = layui.form;
form.on('select($unique)', function(data){
data.othis.parent().parent().parent().find('input').attr('name',data.value);
});
laydate.render({
elem: '#$unique'
,type: 'date'
,trigger:'click'
,range: '~' //或 range: '~' 来自定义分割字符
});
});
</script>
EOF;
return $html;
}
public function optionsRender($data)
{
$optionsHtml = '';
foreach ($data as $key => $value) {
$optionsHtml = $optionsHtml . "<option value='$key'>$value</option>";
}
return $optionsHtml;
}
}
\ No newline at end of file
......@@ -30,7 +30,7 @@ EOF;
$checked = '';
foreach ($data as $key => $value) {
if ($status !== null) {
$checked = ($key == $status) ? "selected='selected'" : '';
$checked = ($key === $status) ? "selected='selected'" : '';
}
$optionsHtml = $optionsHtml . "<option value='$key' $checked>$value</option>";
}
......
......@@ -110,11 +110,11 @@ return [
'SupplierStatus' => [
-3 => '已拉黑',
-2 => '禁',
-1 => '草稿',
1 => '待审核',
2 => '启用',
3 => '驳回'
-2 => '禁止交易',
-1 => '待审核',
1 => '审核中',
2 => '已通过',
3 => '未通过'
],
'Currency' => [
......
......@@ -3,7 +3,7 @@
let $ = layui.jquery;
let Split = layui.Split;
// 水平分割,需要分割的元素(id)、默认大小(百分比)、最小值(单位px)
Split(['#s1', '#s2', '#s3', '#s4', '#s5'], {sizes: [7, 10, 10, 10, 63], minSize: 100});
Split(['#s1', '#s2', '#s3', '#s4', '#s5'], {sizes: [7, 9, 9, 9, 63], minSize: 70});
let table = layui.table;
let form = layui.form;
......@@ -22,7 +22,13 @@
, cols: [[
{type: 'radio'},
{field: 'supplier_id', title: '供应商ID', align: 'center', width: 80},
{field: 'supplier_code', title: '供应商编码', align: 'center', width: 90},
{
field: 'supplier_code', title: '供应商编码', align: 'center', width: 90, templet: function (data) {
console.log(data)
return "<a href='/supplier/EditSupplier?view=iframe&supplier_id=" + data.supplier_id +
"' target='_blank' style='color: dodgerblue'>" + data.supplier_code + "</a>"
}
},
{field: 'supplier_name', title: '供应商名称', align: 'center'},
{field: 'supplier_group', title: '供应商性质', align: 'center', width: 120},
{
......@@ -37,7 +43,16 @@
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{field: 'status_name', title: '状态', align: 'center',width: 80},
{
field: 'status_name', title: '状态', align: 'center', width: 80, templet: function (data) {
console.log(data.status)
if (data.status === 3) {
return "<span style='color: red' title='" + data.reject_reason + "'>" + data.status_name + "</span>"
} else {
return data.status_name;
}
}
},
{field: 'channel_username', title: '采购员', align: 'center', width: 150},
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110},
{field: 'create_name', title: '创建人', align: 'center', width: 80},
......@@ -48,6 +63,22 @@
, page: {}
});
// layer.confirm('确定禁用该供应商吗', {
// title: info + '供应商'
// , btn: ['确定', '取消']
// }, function () {
// layer.closeAll('dialog'); // 确定时关闭弹框
// let res = ajax('/api/supplier/ChangeSupplierStatus', data);
// if (!res) {
// layer.msg(res.err_msg, {icon: 6});
// } else {
// layer.msg(res.err_msg, {icon: 6});
// location.reload();
// }
// }, function () {
// layer.close();
// });
form.on('submit(load)', function (data) {
form.render();
//执行重载
......
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