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

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

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