提交 afde7c78 authored 作者: chengye's avatar chengye

调整抄表逻辑与流程,去掉峰谷明细

上级 3d6e7091
......@@ -99,7 +99,6 @@ class Useage extends Base
if(!(new Em())->checkEmComplete($em_id)){
$this->error('电表信息不完整,需要补充基础信息','/em');
}
$em = (new \app\em\model\Em)->getEmUseageInfoById($em_id,$detail);
//基站信息
......@@ -114,14 +113,8 @@ class Useage extends Base
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage'));
$this->assign('em',$em);
if($em->rule->pricing_type == 1){
$template = 'default';
} else {
$template = 'special';
}
$this->assign('detail',$detail);
return $this->fetch($template);
return $this->fetch('default');
}
//保存抄表单
......@@ -131,65 +124,29 @@ class Useage extends Base
//数据验证
$validate = new UseageGeneralInfoValidate();
//根据计量模式 验证去表单数据
if(!$validate->scene('s'.$data['pricing_type'])->check($data)){
if(!$validate->scene('s1')->check($data)){
return json(['status'=>0,'message'=>$validate->getError()]);
}
//获取电表基本信息
$em = (new \app\em\model\Em)->getEmInfoById(['id'=>$data['em_id']],'rule');
//保存抄表单
$uModel = new \app\em\model\Useage();
//如果是普通计量模式
if($data['pricing_type'] != 1){
$data['current_sum_numb'] = $data['current_numb'];
$data['last_sum_numb'] = $data['last_numb'];
}
//生成抄表单ID
$data['useage_id'] = $this->getUId();
$uModel->save($data);
//抄表详情更新
$udModel = new UseageDetail(); //抄表详情模型
//如果是普通计量模式
if($data['pricing_type'] == 1){
//添加抄表详情记录
$data['type'] = 5; //保存详情类型 5->default
$udModel->save($data);
//更新主表
$data['type'] = $data['pricing_type']; //保存峰谷信息
$data['last_sum_numb'] = $data['last_numb'];
$data['current_sum_numb'] = $data['current_numb'];
$uModel->save($data);
} else {
$typeArr = [];
$data['last_sum_numb'] = 0;
$data['current_sum_numb'] = 0;
for ($i=0;$i<4;$i++){
$temp = $data;
$last_key = 'uType'.($i+1).'_last_numb';
$curr_key = 'uType'.($i+1).'_current_numb';
$price_key = 'uType'.($i+1).'_price';
//组装峰谷信息
$temp['type'] = $i+1;
$temp['last_numb'] = $data[$last_key];
$temp['current_numb'] = $data[$curr_key];
$temp['price'] = $data[$price_key];
//抄表汇总记录
$data['last_sum_numb'] += $temp['last_numb'];
$data['current_sum_numb'] += $temp['current_numb'];
$typeArr[] = $temp;
}
$udModel->saveAll($typeArr);
//更新主表
$data['type'] = $data['pricing_type']; //保存峰谷信息
$uModel->save($data);
}
//保存用户ID
$user = Session::get('user');
$data['uid'] = $user['user_id'];
//峰谷类型
$data['type'] = $data['pricing_type'];
//单价
$data['price'] = $data['pricing_type'] == 1 ? $em->rule->pay_price : $data['price'];
$uModel->save($data); //保存抄表记录
$data['type'] = $data['type'] == 1 ? 5 : 6;
$udModel = new UseageDetail(); //抄表详情模型
$udModel->save($data);
return json(['status'=>1,'message'=>'添加抄表记录成功']);
}
......@@ -238,10 +195,8 @@ class Useage extends Base
->where('u.useage_id','=',$uid)
->find();
$em = (new \app\em\model\Em())->getBaseInfo($useage->em_id);
$user = Session::get('user');
if($useage){
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],$useage->staff_id));
......@@ -253,34 +208,8 @@ class Useage extends Base
$this->assign('em',$em);
$this->assign('useage',$useage);
//判断是否是峰谷表
if($useage->pricing_type == 2){
//获取峰谷表详情
$useage_detail = (new UseageDetail())->where('useage_id','=',$uid)->select()->toArray();
foreach ($useage_detail as &$ud){
switch ($ud['type']){
case 1:
$ud['typeName'] = '尖峰段';
break;
case 2:
$ud['typeName'] = '峰段';
break;
case 3:
$ud['typeName'] = '谷段';
break;
case 4:
$ud['typeName'] = '平段';
break;
default:
$ud['typeName'] = '普通';
break;
}
}
$this->assign('useage_detail',$useage_detail);
return $this->fetch('detail_special');
} else {
return $this->fetch('detail');
}
}
......
......@@ -12,11 +12,8 @@ class UseageGeneralInfoValidate extends Validate
'current_date' => 'require|date|checkDate',
'photo_id' => 'require',
'staff_id' => 'require',
'uType1_current_numb' => 'require', //波峰
'uType2_current_numb' => 'require', //峰
'uType3_current_numb' => 'require', //谷
'amount' =>'require' //账单金额
'price' => 'require',
'amount' =>'require'
];
protected $message = [
......@@ -28,15 +25,13 @@ class UseageGeneralInfoValidate extends Validate
'current_date.date' => '本次抄表日期格式不正确',
'photo_id.require' => '请上传电表照片',
'staff_id.require' => '请选择抄表员',
'uType1_current_numb.require' => '请填写波峰数据',
'uType2_current_numb.require' => '请填写峰数据',
'uType3_current_numb.require' => '请填写波谷数据',
'price' => '单价必填且只能是数字或小数',
'amount.require' =>'缴费金额未填写'
];
protected $scene = [
's1' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id',
's2' => 'em_id,photo_id,staff_id,uType1_current_numb,uType2_current_numb,uType3_current_numb',
's2' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price',
];
protected function checkDate($value,$rule,$data=[]){
......
......@@ -90,49 +90,53 @@
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
期表数
次抄表日期
</label>
<div class="layui-input-inline">
<input type="text" id="last_numb" name="last_numb" autocomplete="off" class="layui-input" value="{$em.last_sum_numb}" disabled="disabled">
</div>
<div class="layui-form-mid layui-word-aux">
<input type="text" id="last_date" name="last_date"
autocomplete="off" class="layui-input" value="{$em.useage.last_date}" disabled="disabled">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
次抄表日期
次抄表日期
</label>
<div class="layui-input-inline">
<input type="text" id="last_date" name="last_date"
autocomplete="off" class="layui-input" value="{if isset($em.last_date)}{$em.last_date}{/if}" disabled="disabled">
<input type="text" id="current_date" name="current_date"
autocomplete="off" class="layui-input" value="{$em.useage.current_date|date='Y:m:d'}">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
<span class="x-red">*</span>本期表
<span class="x-red">*</span>上期度
</label>
<div class="layui-input-inline">
<input type="text" id="current_numb" name="current_numb"
lay-verify="required" autocomplete="off" class="layui-input" lay-verType="tips"
value="">
<input type="text" id="last_numb" name="last_numb"
autocomplete="off" class="layui-input" disabled="disabled" value="{$em.useage.last_sum_numb}" >
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
本次查表日期
<span class="x-red">*</span>本期度数
</label>
<div class="layui-input-inline">
<input type="text" id="current_date" name="current_date" autocomplete="off" class="layui-input" lay-verType="tips" value="">
<input type="text" id="current_numb" name="current_numb"
autocomplete="off" class="layui-input" value="{$em.useage.current_numb|default=''}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
......@@ -151,7 +155,19 @@
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" {if $em.useage.price } disabled="disabled" {/if} value="{$em.useage.price|default=''}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
......@@ -159,10 +175,9 @@
<span class="x-red">*</span>抄表员
</label>
<div class="layui-input-inline">
<select name="staff_id">
<select name="staff_id" {if $detail==true} disabled="disabled" {/if}>
{foreach $staffs as $u}
<option value="{$u['id']}" {if $u['id'] == $uid} selected {/if}>{$u['name']}</option>
}
{/foreach}
</select>
</div>
......@@ -231,12 +246,12 @@
});
}
laydate.render({
elem:'#current_date',
trigger:'click',
})
//保存抄表单,并且返回列表
form.on('submit(save)',
function (data) {
......@@ -263,8 +278,9 @@
elem: '#up_photo' ,
url: '/upFile',
field: 'up_file',
size:10240,
accept: 'file',
size:10240,
done: function (res) {
if(res.status == 1){
layMsg(res.message)
......@@ -281,29 +297,19 @@
}
}
});
$('#current_numb').change(function(){
var $level = 100000;
var $rate = $('#rate').val();
var $baseNum = $level*$rate;
var $rNum = $(this).val()*$baseNum - $('#last_numb').val()*$baseNum;
var ln = $('#last_numb');
var cn = $('#current_numb');
ln.change(function(){
calRn()
})
cn.change(function(){
calRn()
})
function calRn(){
var rn = $('#repo_numb');
var lNv = Number($('#last_numb').val());
var cNv = Number($('#current_numb').val());
if(cNv > lNv){
var reN = (cNv - lNv)*Number($('#rate').val());
rn.val(reN)
} else {
rn.val('')
}
if($rNum < 0){
layMsg('本次抄表必须大于上次抄表读数',5);
$('#current_numb').focus();
} else{
$('#repo_numb').val( $rNum/$baseNum )
}
})
});
</script>
{/block}
\ No newline at end of file
......@@ -151,7 +151,19 @@
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" disabled="disabled" value="{$useage.price}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
......@@ -215,8 +227,6 @@
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//消息提示
function layMsg(msg,type=6,time=1000){
layer.msg(msg,{
......@@ -225,6 +235,7 @@
});
}
//保存抄表单,并且返回列表
form.on('submit(check)',
function (data) {
......@@ -241,7 +252,7 @@
window.location.href='/useage';
})
} else {
layer.msg(data.msg,{icon: 5,time: 1000 })
layer.msg(data.message || data.msg,{icon: 5,time: 1000 })
}
}
});
......
......@@ -151,6 +151,20 @@
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" disabled="disabled" value="{$useage.price}">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
......@@ -183,27 +197,6 @@
</div>
</div>
<div class="layui-col-md10" style="padding:0 130px 0 30px;margin-bottom: 20px;">
<table class="layui-table layui-form">
<thead>
<tr>
<th>阶段</th>
<th>上期表数</th>
<th>本期表数</th>
<th>单价</th>
</thead>
<tbody>
{volist name="useage_detail" id="item"}
<tr>
<td>{$item.typeName}</td>
<td><input type="text" class="no-border" name="uType{$i}_last_numb" value="{$item.last_numb}" disabled="disabled"></td>
<td><input type="text" class="no-border current_numb" name="uType{$i}_current_numb" value="{$item.current_numb|default=''}" disabled="disabled"></td>
<td><input type="text" class="no-border" name="uType{$i}_price" value="{$item.price|default=''}" disabled="disabled"></td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
......
......@@ -95,7 +95,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="last_date" name="last_date"
autocomplete="off" class="layui-input" value="{if isset($em.last_date)}{$em.last_date}{/if}" disabled="disabled">
autocomplete="off" class="layui-input" value="{$em.useage.last_date}" disabled="disabled">
</div>
</div>
</div>
......@@ -107,7 +107,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="current_date" name="current_date"
autocomplete="off" class="layui-input" value="{if isset($em.current_date)}{$em.current_date}{/if}">
autocomplete="off" class="layui-input" value="{$em.useage.current_date|date='Y:m:d'}">
</div>
</div>
</div>
......@@ -119,7 +119,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="last_numb" name="last_numb"
autocomplete="off" class="layui-input" disabled="disabled" value="{$em.last_sum_numb}" >
autocomplete="off" class="layui-input" disabled="disabled" value="{$em.useage.last_sum_numb}" >
</div>
<div class="layui-form-mid layui-word-aux">
......@@ -134,7 +134,7 @@
</label>
<div class="layui-input-inline">
<input type="text" id="current_numb" name="current_numb"
autocomplete="off" class="layui-input" disabled="disabled">
autocomplete="off" class="layui-input" value="{$em.useage.current_numb|default=''}">
</div>
<div class="layui-form-mid layui-word-aux">
......@@ -155,6 +155,21 @@
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" value="">
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
</div>
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
......@@ -186,29 +201,6 @@
</div>
</div>
</div>
<div class="layui-col-md10" style="padding:0 130px 0 30px;margin-bottom: 20px;">
<table class="layui-table layui-form">
<thead>
<tr>
<th>阶段</th>
<th>上期表数</th>
<th>本期表数</th>
<th>单价</th>
</thead>
<tbody>
{volist name="em.useage" id="item"}
<tr>
<td>{$item.typeName}</td>
<td><input type="text" class="no-border" name="uType{$i}_last_numb" value="{$item.last_numb}" disabled="disabled"></td>
<td><input type="text" class="no-border current_numb" name="uType{$i}_current_numb" value="{$item.current_numb|default=''}"></td>
<td><input type="text" class="no-border" name="uType{$i}_price" value="{$item.price|default=''}"></td>
</tr>
{/volist}
</tbody>
</table>
</div>
</div>
</div>
</div>
......@@ -261,7 +253,6 @@
trigger:'click',
})
//保存抄表单,并且返回列表
form.on('submit(save)',
function (data) {
......@@ -307,24 +298,18 @@
}
}
});
$('#current_numb').change(function(){
$leve = 100000;
var $rNum = $(this).val()*$leve - $('#last_numb').val()*$leve;
if($rNum < 0){
layMsg('本次抄表必须大于上次抄表读数',5);
$('#current_numb').focus();
} else{
$('#repo_numb').val( $rNum/$leve )
//总度数实时更新
$sum = $('#current_numb');
$('.current_numb').change(function(){
var $sum_numb = 0;
for (var i = 0; i < $('.current_numb').length; i++) {
$temp_numb = $('.current_numb').eq(i).val();
if($temp_numb != 'undefind' && $temp_numb != ''){
$sum_numb += Number($temp_numb)
}
}
$sum.val($sum_numb);
var nm = Number($('#rate').val()) * $sum_numb;
$('#repo_numb').val(nm);
})
});
</script>
{/block}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论