提交 4d9ec805 authored 作者: chengye's avatar chengye 提交者: wangkr

测试中

上级 a70cbfe9
......@@ -4,6 +4,7 @@
*/
namespace app\em\controller;
use app\admin\controller\Base;
use app\em\model\EmCheckBill;
use app\em\model\Staff;
use app\em\model\Station;
use app\em\model\UseageDetail;
......@@ -181,7 +182,16 @@ class Useage extends Base
$useage_id = Request::param('useage_id');
$useage = \app\em\model\Useage::get(['useage_id' => $useage_id]);
if($useage->status == 2) return json(['status'=>0,'message'=>'该抄表单已经生成了账单']);
if($useage->status == 2) return json(['status'=>0,'message'=>'单据已经审核过,不能再次审核']);
//如果是驳回则记录驳回状态
$checkType = Request::param('checkType');
$this->verify($useage_id,$checkType); //1是通过 2是驳回
if($checkType == 2) {
$useage->status = 3; //3代表被驳回
$useage->save();
return json(['status'=>1,'message'=>'单据已经驳回']);
}
$inv = (new Invoice())->createInvoice($useage_id);
$useage->status = 2;
......@@ -278,4 +288,17 @@ class Useage extends Base
return json(['status'=>0,'message'=>"抄表单号不是最新的抄表记录,无法修改,请联系管理员"]);
}
}
//审核
public function verify($usage_id,$status=2){
$user = Session::get('user');
$cModel = new EmCheckBill();
$cModel->info = Request::param('refuseInfo');
$cModel->uid = $user['user_id'];
$cModel->mode = 'useage';
$cModel->mode_id = $usage_id;
$cModel->status = $status;
$cModel->save();
}
}
\ No newline at end of file
<?php
namespace app\em\model;
class EmCheckBill extends Base
{
}
\ No newline at end of file
......@@ -107,4 +107,8 @@ class Useage extends Base
public function em(){
return $this->belongsTo('Em','em_id','id');
}
public function info(){
return $this->HasOne('EmCheckBill','useage_id','useage_id');
}
}
\ No newline at end of file
......@@ -199,10 +199,13 @@
</div>
</div>
</div>
{if $useage.status != 2}
{if $useage.status < 2}
<div class="layui-form-item layui-col-md-offset4">
<button class="layui-btn" lay-filter="check" lay-submit="">
审核
<button class="layui-btn" lay-filter="pass" lay-submit="">
通过
</button>
<button class="layui-btn" lay-filter="refuse" lay-submit="">
驳回
</button>
</div>
{/if}
......@@ -235,12 +238,12 @@
});
}
//保存抄表单,并且返回列表
form.on('submit(check)',
form.on('submit(pass)',
function (data) {
$(this).addClass('layui-disabled');
$(this).attr('disabled','disabled');
data.checkType = 1;
$.ajax({
url: '/useage/check',
method: "POST",
......@@ -253,7 +256,48 @@
})
} else {
layer.msg(data.message || data.msg,{icon: 5,time: 1000 })
window.location.href='/useage';
}
}
});
return false;
});
form.on('submit(refuse)',
function (data) {
var $that = $(this)
var $data = data;
$that.addClass('layui-disabled');
$that.attr('disabled','disabled');
layer.open({
type: 1,
title:'填写驳回理由',
content: '<div class="layui-form-item><div class="layui-input-block" style="padding:15px;"><textarea placeholder="驳回理由" class="layui-textarea" id="refuseInfo" name="refuseInfo"></textarea></div>',
btn:"提交",
yes: function(){
$data.field.checkType = 2;
$data.field.refuseInfo = $('#refuseInfo').val();
$.ajax({
url: '/useage/check',
method: "POST",
data: $data.field,
dataType: "json",
success: function (data) {
if (data.status == 1) {
layer.msg(data.message,{icon: 6,time: 2000},function(){
window.location.href='/useage';
})
} else {
layer.msg(data.message || data.msg,{icon: 5,time: 1000 })
window.location.href='/useage';
}
}
});
},
end:function(){
$that.removeClass('layui-disabled');
$that.removeAttr('disabled');
layer.closeAll();
}
});
return false;
......
......@@ -28,6 +28,8 @@
<option value="0" selected="selected" {if $status eq 0 } selected {/if}>全部</option>
<option value="1" {if $status eq 1 } selected {/if}>未审核</option>
<option value="2" {if $status eq 2 } selected {/if}>已审核</option>
<option value="3" {if $status eq 3 } selected {/if}>被驳回</option>
</select>
</div>
<div class="layui-input-inline" style="width:150px;">
......@@ -92,13 +94,19 @@
<script type="text/html" id="status">
{{# if(d.status == 2){ }}
<span class="layui-bg-blue">已审核</span>
{{# }else { }}
<span class="layui-bg-green">未审核</span>
{{# } }}
{{# if(d.status == 3) { }}
<span class="layui-bg-orange" title="{{ d.info.info }}">被驳回</span>
{{# } }}
{{# if(d.status < 2) { }}
<span class="layui-bg-green" title="{{ d.info.info }}">未审核</span>
{{# } }}
</script>
{if $admin == true}
<script type="text/html" id="barDemo">
{{# if(d.status == 1){ }}
{{# if(d.status == 1 || d.status == 3){ }}
<a title="删除" class="layui-btn layui-btn-sm layui-bg-green" lay-event="update">编辑</a>
<a title="删除" class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</a>
{{# } }}
</script>
......
......@@ -147,6 +147,7 @@ Route::get('useage/:useage_id','em/useage/detail');
Route::get('useage_add/:id','em/useage/create');
Route::post('useage_add','em/useage/store');
Route::post('useage_del','em/useage/del');
Route::post('useage_update','em/useage/update');
Route::post('upFile','em/UploadFile/upFile');
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论