Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
Jz-Php
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
PHP
Jz-Php
Commits
afde7c78
提交
afde7c78
authored
4月 22, 2020
作者:
chengye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整抄表逻辑与流程,去掉峰谷明细
上级
3d6e7091
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
78 行增加
和
166 行删除
+78
-166
Useage.php
application/em/controller/Useage.php
+17
-88
UseageGeneralInfoValidate.php
application/em/validate/UseageGeneralInfoValidate.php
+4
-9
default.html
application/em/view/useage/default.html
+0
-0
detail.html
application/em/view/useage/detail.html
+15
-4
detail_special.html
application/em/view/useage/detail_special.html
+15
-22
special.html
application/em/view/useage/special.html
+27
-43
没有找到文件。
application/em/controller/Useage.php
浏览文件 @
afde7c78
...
...
@@ -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
(
's
1'
)
->
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
);
//抄表详情更新
$data
[
'last_sum_numb'
]
=
$data
[
'last_numb'
];
$data
[
'current_sum_numb'
]
=
$data
[
'current_numb'
];
//保存用户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
();
//抄表详情模型
//如果是普通计量模式
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
);
}
$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'
);
}
return
$this
->
fetch
(
'detail'
);
}
...
...
application/em/validate/UseageGeneralInfoValidate.php
浏览文件 @
afde7c78
...
...
@@ -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
=
[]){
...
...
application/em/view/useage/default.html
浏览文件 @
afde7c78
差异被折叠。
点击展开。
application/em/view/useage/detail.html
浏览文件 @
afde7c78
...
...
@@ -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
.
m
essage
||
data
.
m
sg
,{
icon
:
5
,
time
:
1000
})
}
}
});
...
...
application/em/view/useage/detail_special.html
浏览文件 @
afde7c78
...
...
@@ -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"
>
...
...
@@ -182,28 +196,7 @@
</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="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>
...
...
application/em/view/useage/special.html
浏览文件 @
afde7c78
...
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论