提交 603a79ec authored 作者: chengye's avatar chengye 提交者: wangkr

抄表单重复问题解决,创建元素过滤检测方法

上级 86b01514
......@@ -47,12 +47,9 @@ class Base extends Controller
private function authCheck($user_id){
//通过uid查询roleid通过roleid查询权限列表
$permissions = StaffRoleModel::getStaffRolesById($user_id);
$permissions = explode(',',$permissions);
//获取当前访问路由
$path = Request::pathinfo() ?: '/';
if($path !== '/'){
//检测是否存在数字,如果存在数字则删除最后一个/之后的所有数据
if(preg_match('/[0-9]+/',$path)){
......
......@@ -4,7 +4,6 @@ namespace app\admin\controller;
use app\admin\model\AdminModel;
use app\admin\model\StaffModel;
use think\Config;
use think\Controller;
use think\facade\Cache;
use think\facade\Session;
......
<?php
use app\admin\model\PermissionModel;
use app\admin\model\StaffRoleModel;
use think\db;
use think\facade\Session;
function check_data(){
$user = session('user');
......@@ -341,3 +345,23 @@ function getInvoicesStatusName($statusCode,$index=0){
}
}
}
//检测元素与按钮权限
function check_ele_permission($path){
$user = Session::get('user');
//获取当前用户的所有权限id
$permissions = StaffRoleModel::getStaffRolesById($user['user_id']);
$permissions = explode(',',$permissions);
//查询$path所对应id
$permission = PermissionModel::field('id,nav_url')->get(['nav_url'=>$path]);
if(isset($permission->id)){
if(!in_array($permission->id,$permissions) || $permission == null){
return false;
}
return true;
}
return false;
}
\ No newline at end of file
......@@ -279,25 +279,12 @@ class Useage extends Base
$useage_id = Request::param('uid');
$res = $this->checkEnd($useage_id);
if($res !== true) return $res;
//删除useage表数据
$useage = (new \app\em\model\Useage())->get(['useage_id'=>$useage_id]);
$useage_details = (new UseageDetail())->select(['useage_id'=>$useage_id]);
Db::startTrans();
try{
$useage->delete();
if(!empty($useage_details)){
foreach ($useage_details as $u){
$u->delete();
}
}
Db::commit();
//删除明细表数据
(new UseageDetail())->where('useage_id','=',$useage_id)->delete();
return json(['status'=>1,'message'=>"删除单据成功"]);
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return json(['status'=>0,'message'=>"删除异常,单据删除失败,请联系管理员"]);
}
}
/**
......
......@@ -45,6 +45,7 @@ class EmInvoice extends Base
->select()
->toarray();
$step = 100000;
foreach ($data as &$item){
if($item['payment_balance'] == 0){
......@@ -58,6 +59,8 @@ class EmInvoice extends Base
} else {
$item['sett_amount'] = round($item['settle_amount'] - $item['settle_balance'],3);
}
$item['repo_numb'] = ($item['current_sum_numb'] * $step - $item['last_sum_numb'] * $step ) * $item['rate'] / $step;
}
return $data;
}
......
......@@ -75,7 +75,7 @@
<th lay-data="{field:'station_name',sort: true}">所属基站名</th>
<th lay-data="{templet:'#em_numb',sort: true} ">所属电表号</th>
<th lay-data="{templet: '#useage'}">抄表度数</th>
<th lay-data="{templet: '#repo_numb'}">用电量</th>
<th lay-data="{field: 'repo_numb'}">用电量</th>
<th lay-data="{templet:'#payment'}">缴费金额</th>
<th lay-data="{templet:'#settle'}">结算金额</th>
<th lay-data="{field: 'status'}">账单状态</th>
......
......@@ -200,6 +200,7 @@
</div>
</div>
{if $useage.status < 2}
{if check_ele_permission('useage/check') }
<div class="layui-form-item layui-col-md-offset4">
<button class="layui-btn" lay-filter="pass" lay-submit="">
通过
......@@ -209,6 +210,7 @@
</button>
</div>
{/if}
{/if}
</form>
</div>
</div>
......
......@@ -105,7 +105,12 @@
{{# } }}
</script>
<script type="text/html" id="barDemo">
{{# if(d.status == 1){ }}
<a title="审核" class="layui-btn layui-btn-sm layui-bg-green" href="/useage/{{d.useage_id}}">审核</a>
{{# } }}
{{# if(d.status == 1 || d.status == 3){ }}
<a title="编辑" class="layui-btn layui-btn-sm layui-bg-green" href="/useage_update/{{d.useage_id}}">编辑</a>
<a title="删除" class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</a>
{{# } }}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论