Commit 6a65bded by 杨树贤

批量修改

parent 347264c0
...@@ -122,6 +122,22 @@ class SupplierExaminationApiController extends Controller ...@@ -122,6 +122,22 @@ class SupplierExaminationApiController extends Controller
$this->response(-1, '删除失败', $result); $this->response(-1, '删除失败', $result);
} }
public function BatchUpdateSupplierExamination($request)
{
$params = $request->only([
'ids',
'examine_result'
]);
if (empty($params['ids'])) {
$this->response(-1, '请选择需要批量修改的检测数据');
}
$result = (new SupplierExaminationService())->batchUpdateSupplierExamination($params);
if ($result) {
$this->response(0, '修改成功');
}
$this->response(-1, '修改失败', $result);
}
//上传IQC检测记录 //上传IQC检测记录
private function ImportSupplierExamination($request) private function ImportSupplierExamination($request)
{ {
......
...@@ -93,4 +93,23 @@ class SupplierExaminationController extends Controller ...@@ -93,4 +93,23 @@ class SupplierExaminationController extends Controller
$this->data['title'] = '添加IQC检测记录'; $this->data['title'] = '添加IQC检测记录';
return $this->view('添加IQC检测记录'); return $this->view('添加IQC检测记录');
} }
public function BatchUpdateSupplierExamination($request)
{
$ids = $request->get('ids');
if (empty($ids)) {
return '请选择对应的检测记录';
}
$this->data['ids'] = $ids;
$ids = explode(',',$ids);
$supplierId = $request->get('supplier_id');
if ($supplierId) {
$supplierName = SupplierChannelModel::where('supplier_id', $supplierId)->value('supplier_name');
$this->data['supplierName'] = $supplierName;
}
$examinationList = SupplierExaminationModel::whereIn('id', $ids)->get()->toArray();
$this->data['examinationList'] = $examinationList;
$this->data['title'] = '批量修改IQC检测记录';
return $this->view('批量修改IQC检测记录');
}
} }
\ No newline at end of file
...@@ -54,6 +54,16 @@ class SupplierExaminationService ...@@ -54,6 +54,16 @@ class SupplierExaminationService
} }
} }
//批量修改
public function batchUpdateSupplierExamination($data)
{
$ids = explode(',', $data['ids']);
return SupplierExaminationModel::whereIn('id',$ids)->update([
'update_time' => time(),
'examine_result' => $data['examine_result'],
]);
}
//删除 //删除
public function deleteSupplierExaminations($ids) public function deleteSupplierExaminations($ids)
{ {
......
<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;
form.on('submit(batchUpdateSupplierExamination)', function (data) {
layer.confirm('是否确认修改IQC检测资料?', function (index) {
let url = '/api/supplier_examination/BatchUpdateSupplierExamination';
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 {
let errMsg = res.err_msg;
let msg = '';
$.each(errMsg.split('|'), function (index, value) {
msg += "<span>" + value + "</span><br>"
});
parent.layer.msg(msg, {icon: 5})
}
}
return false;
});
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
...@@ -159,6 +159,30 @@ ...@@ -159,6 +159,30 @@
return false; return false;
}); });
$("#batch_update_supplier_examination").click(function () {
let checkStatus = table.checkStatus('supplierExaminationList');
let data = checkStatus.data;
let ids = [];
$.each(data, function (i, v) {
ids.push(v.id);
});
if (!ids) {
layer.msg('请先选择要操作的记录', {icon: 5});
} else {
ids = ids.join(',')
layer.open({
type: 2,
content: '/supplier_examination/BatchUpdateSupplierExamination?view=iframe&ids=' + ids + '&supplier_id=' + getQueryVariable('supplier_id'),
area: ['80%', '90%'],
title: '批量修改IQC检测记录',
end: function () {
table.reload('supplierExaminationList');
}
});
}
return false;
});
//启用 //启用
$("#delete_supplier_examination").click(function () { $("#delete_supplier_examination").click(function () {
let checkStatus = table.checkStatus('supplierExaminationList'); let checkStatus = table.checkStatus('supplierExaminationList');
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-body">
<blockquote class="layui-elem-quote layui-text">
<b>检验结果设置</b>
</blockquote>
<form class="layui-form" action="" autocomplete="off">
<input type="hidden" name="ids" value="{{$ids}}">
<div class="layui-form-item">
<div class="layui-col-xs12">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('examine_result','检验结果', '',
config('field.SupplierExamineResult'),['required'=>true]) !!}
</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="batchUpdateSupplierExamination">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
</div>
...@@ -44,9 +44,11 @@ ...@@ -44,9 +44,11 @@
@if(checkPerm('AddSupplierExamination')) @if(checkPerm('AddSupplierExamination'))
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier_examination">新增</button> <button type="button" class="layui-btn layui-btn-sm" id="add_supplier_examination">新增</button>
@endif @endif
@if(checkPerm('BatchUpdateSupplierExamination'))
<button type="button" class="layui-btn layui-btn-sm" id="batch_update_supplier_examination">批量修改</button>
@endif
@if(checkPerm('UpdateSupplierExamination')) @if(checkPerm('UpdateSupplierExamination'))
<button type="button" class="layui-btn layui-btn-sm" id="update_supplier_examination">编辑</button> <button type="button" class="layui-btn layui-btn-sm" id="update_supplier_examination">编辑</button>
@endif @endif
@if($routerName=='SupplierExaminationList') @if($routerName=='SupplierExaminationList')
@if(checkPerm('ImportSupplierExamination')) @if(checkPerm('ImportSupplierExamination'))
......
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