Commit 3633024f by mushishixian

termp

parent 4d3b8901
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierContactService;
use App\Http\Transformers\SupplierContactTransformer;
use App\Http\Validators\SupplierContactValidator;
use App\Model\SupplierContactModel;
use Illuminate\Http\Request;
......@@ -25,6 +26,8 @@ class SupplierContactApiController extends Controller
$model->where('supplier_id',$supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('contact_id', 'desc')
->paginate($limit)->toArray();
$transformer = new SupplierContactTransformer();
$list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'],$list['total']);
}
......
......@@ -9,6 +9,7 @@ use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\ViewCheckService;
use App\Model\IntracodeModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Model\SupplierReceiptModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -60,11 +61,23 @@ class SupplierContactController extends Controller
$this->data['receipt'] = $model->where('contact_id', $contactId)->first()->toArray();
}
$intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getAdminIdEncode();
$userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes;
return $this->view('添加联系方式');
}
//供应商详情
public function UpdateSupplierContact($request)
{
$contactId = $request->get('contact_id');
$model = new SupplierContactModel();
$this->data['contact'] = $model->where('contact_id', $contactId)->first()->toArray();
$intracodeModel = new IntracodeModel();
$userCodes = $intracodeModel->getSampleEncode();
$this->data['userCodes'] = $userCodes;
return $this->view('添加联系方式');
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use App\Model\IntracodeModel;
use App\Model\UserInfoModel;
use Closure;
use Common\Model\RedisModel;
......@@ -54,6 +55,9 @@ class CheckLogin
}
$user = $ret->data;
$user->header = $request->cookie('oa_header');
$intracodeModel = new IntracodeModel();
$codeId = $intracodeModel->where('admin_id', $user->userId)->value('code_id');
$user->codeId = $codeId;
$request->user = $user;
}else{
$rsp = curl($login['dingtalk_check'],['token'=>trim($request->input('token'))]);
......@@ -68,6 +72,9 @@ class CheckLogin
}
$user = $ret->data;
$intracodeModel = new IntracodeModel();
$codeId = $intracodeModel->where('admin_id', $user->userId)->value('code_id');
$user->codeId = $codeId;
$request->user = $user;
}
......
<?php
namespace App\Http\Transformers;
use App\Http\Services\AdminUserService;
class SupplierContactTransformer
{
public function transformList($list)
{
$service = new AdminUserService();
foreach ($list as &$item) {
$user = $service->getAdminUserInfoByCodeId($item['can_check_uids']);
$item['channel_name'] = array_get($user, 'name');
}
unset($item);
return $list;
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ class StatusPresenter
public function render($name, $text, $status = null, $data = [0 => '禁用', 1 => '启用'], $option = [])
{
$isRequired = array_get($option, 'required', false);
$width = array_get($option, 'width','auto');
$width = array_get($option, 'width', 'auto');
$requiredHtml = $isRequired ? '<span class="require">*</span>' : "";
$html = <<<EOF
<label class="layui-form-label">
......@@ -30,8 +30,8 @@ EOF;
$optionsHtml = ' <option value="">请选择</option>';
$checked = '';
foreach ($data as $key => $value) {
if ($status !== null) {
$checked = ($key === $status) ? "selected='selected'" : '';
if ($status !== '' || $status != null) {
$checked = ($key == $status) ? "selected='selected'" : '';
}
$optionsHtml = $optionsHtml . "<option value='$key' $checked>$value</option>";
}
......
......@@ -32,7 +32,7 @@
el: '#' + element,
filterable: true,
paging: true,
height: '300px',
height: '250px',
direction: 'auto',
autoRow: true,
prop: {
......
......@@ -63,13 +63,12 @@
, page: {}
});
// allocate_purchase_user
//新增供应商弹窗
$("#add_supplier").click(function () {
admin.open({
type: 2,
content: '/supplier/AddSupplier?view=iframe',
area: ['1000px', '750px'],
area: ['1000px', '720px'],
title: '新增供应商',
end: function () {
// table.reload('list');
......
<script>
layui.use(['table', 'form', 'element', 'layer','admin'], function () {
let admin = layui.admin;
let form = layui.form;
let element = layui.element;
form.on('submit(load)', function (data) {
let url = '/api/supplier_contact/SaveSupplierContact';
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;
});
});
</script>
\ No newline at end of file
......@@ -16,7 +16,7 @@
first: true,//不显示首页
last: false,//不显示尾页
cols: [[
{type: 'checkbox',},
{type: 'radio',},
{field: 'supplier_consignee', title: '联系人', align: 'center'},
{field: 'supplier_position', title: '职位', align: 'center'},
{field: 'supplier_email', title: '邮箱', align: 'center'},
......@@ -24,7 +24,7 @@
{field: 'supplier_telephone', title: '座机', align: 'center'},
{field: 'supplier_qq', title: 'QQ', align: 'center'},
{field: 'supplier_fax', title: '传真', align: 'center'},
{field: 'can_check_uids', title: '采购员', align: 'center'},
{field: 'channel_name', title: '采购员', align: 'center'},
]],
id: 'contactList',
page: {},
......@@ -44,7 +44,26 @@
});
})
//批量删除
//更新
$(document).on('click', '#update_contact', function () {
let checkStatus = table.checkStatus('contactList');
let data = checkStatus.data;
if (!data.size) {
layer.msg('请先选择要操作的联系人', {icon: 5})
}
let contactId = data[0].contact_id;
admin.open({
type: 2,
content: '/supplier_contact/UpdateSupplierContact?view=iframe&contact_id=' + contactId,
area: ['600px', '525px'],
title: '编辑联系人',
end: function () { // 监听弹窗关闭
table.reload('contactList');
}
});
});
//删除
$(document).on('click', '#batchDelete', function () {
let checkStatus = table.checkStatus('contactList');
let data = checkStatus.data;
......
<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="contact_id" value="{{$contact['contact_id']}}">
<input type="hidden" name="supplier_id" value="{{$contact['supplier_id']}}">
<div class="layui-form-item">
<label class="layui-form-label"><span class="require">*</span>联系人</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_consignee" id="supplier_consignee"
placeholder="请输入联系人" class="layui-input"
value="{{$contact['supplier_consignee']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span class="require">*</span>职位</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_position" id="supplier_position"
placeholder="请输入职位" class="layui-input"
value="{{$contact['supplier_position']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span class="require">*</span>邮箱</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_email" id="supplier_email"
placeholder="请输入邮箱" class="layui-input"
value="{{$contact['supplier_email']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"><span class="require">*</span>手机号</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_mobile" id="supplier_mobile"
placeholder="请输入手机号" class="layui-input"
value="{{$contact['supplier_mobile']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">座机</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_telephone" id="supplier_telephone"
placeholder="请输入座机" class="layui-input"
value="{{$contact['supplier_telephone']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">QQ</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_qq" id="supplier_qq"
placeholder="请输入QQ" class="layui-input"
value="{{$contact['supplier_qq']}}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">传真</label>
<div class="layui-input-block block-42">
<input type="text" name="supplier_fax" id="supplier_fax"
placeholder="请输入传真" class="layui-input"
value="{{$contact['supplier_fax']}}">
</div>
</div>
<div class="layui-form-item">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('can_check_uids','采购员',$contact['can_check_uids'],
$userCodes,['required'=>true]) !!}
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info" lay-submit lay-filter="load">保存</button>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
<div class="layui-row">
<div class="layui-btn-group demoTable" style="margin-bottom: 15px;margin-top: 15px">
<button class="layui-btn layui-btn-sm" id="add_contact">新增</button>
<button class="layui-btn layui-btn-sm" id="update_contact">修改</button>
<button class="layui-btn layui-btn-sm" id="batchDelete">删除</button>
</div>
<table class="layui-table" lay-filter="contactList" id="contactList"></table>
......
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