提交 f20e95f4 authored 作者: wangkr's avatar wangkr

update

上级 d2eee4bb
config/cache.php merge=ours
config/admin.php merge=ours
config/session.php merge=ours
config/admin.php merge=ours
......@@ -17,3 +17,5 @@
/public/dist2
/public/static/uploads
/public/static/xadmin
/config/jz.php
/config/cookie.php
......@@ -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)){
......
......@@ -484,13 +484,13 @@ class Basestation extends Base
public function basestation_map(Request $request){
$id= $request->get('station_name');
$db = Db::connect([
'type' => 'mysql',
'hostname' => '127.0.0.1',
'database' => 'jzdb',
'username' => 'root',
'password' => 'pvv5718J0CwhNfn4B^8^H3igPj#oiQkX',
'hostport' => '10036',
'charset' => 'utf8',
'type' => config('jz.jztype'),
'hostname' => config('jz.jzhostname'),
'database' => config('jz.jzdatabase'),
'username' => config('jz.jzusername'),
'password' => config('jz.jzpassword'),
'hostport' =>config('jz.jzhostport'),
'charset' => config('jz.jzcharset'),
]);
$data=$db->table('jz_message')->field('business_id')->where(['jz_name'=>$id])->find();
$this->assign('data',$data['business_id']);
......@@ -499,13 +499,13 @@ class Basestation extends Base
public function basestation_region(Request $request){
$db = Db::connect([
'type' => 'mysql',
'hostname' => '127.0.0.1',
'database' => 'jzdb',
'username' => 'root',
'password' => 'pvv5718J0CwhNfn4B^8^H3igPj#oiQkX',
'hostport' => '10036',
'charset' => 'utf8',
'type' => config('jz.jztype'),
'hostname' => config('jz.jzhostname'),
'database' => config('jz.jzdatabase'),
'username' => config('jz.jzusername'),
'password' => config('jz.jzpassword'),
'hostport' =>config('jz.jzhostport'),
'charset' => config('jz.jzcharset'),
]);
$data['business_id']= $request->get('station_id');
if(empty($data['business_id'])){
......
......@@ -20,7 +20,8 @@ class Login extends Controller
{
public function index()
{
echo '<script type="text/javascript">top.location.href="http://oa.gonn.com.cn/";</script>';
$baseUrl = config('admin.base_url');
echo '<script type="text/javascript">top.location.href="'.$baseUrl.'";</script>';
}
public function login(Request $request,LoginValidate $validate)
......
......@@ -5,22 +5,17 @@
* Date: 2020-3-22
* Time: 19:03
*/
namespace app\admin\controller;
use app\admin\model\StaffModel;
use think\Exception;
use think\facade\Cookie;
class SingleSign {
public $instence = null;
public function __construct($ip='192.168.1.222',$port=6379){
public function __construct(){
if($this->instence === null){
$redis = new \Redis();
$res = $redis->connect($ip,$port);
$res = $redis->connect(config('admin.redis_host'),config('admin.redis_port'));
if($res) $this->instence = $redis;
else throw new Exception("redis connect faild");
}
......@@ -30,20 +25,15 @@ class SingleSign {
public function getSid($prex = 'PHPREDIS_SESSION:'){
$sid = Cookie::get('PHPSESSID');
$sid = $prex.$sid;
$str = $this->instence->get($sid);
if(!$str) throw new Exception("session info not found");
return $str;
}
//从session中读取信息
public function getUserInfo(){
$str = $this->getSid();
$pos = stripos($str,'is_admin|b:') + 11;
$pos = stripos($str,'isadmin|i:') + 10;
$isAdmin = substr($str,$pos,1);
$user['is_admin'] = $isAdmin;
......@@ -51,7 +41,6 @@ class SingleSign {
$user['username'] = 'gonnadmin';
} else {
preg_match('/adminuser\|s\:(\d+)\:/',$str,$match);
if($match){
$pos = stripos($str,'adminuser|s:') + strlen('adminuser|s:');
$pos += strlen($match[1]) + 2;
......@@ -59,14 +48,12 @@ class SingleSign {
}
}
$pos = stripos($str,'ukey|s:10:') + 11;
$ukey = substr($str,$pos,10);
$user['ukey'] = $ukey;
preg_match('/[\x80-\xff]+/',$str,$matchb);
if($matchb) $user['name'] = $matchb[0];
return $user;
}
......
......@@ -97,19 +97,19 @@
<script type="text/javascript">
var map = new BMap.Map("allmap", {enableMapClick: false}); // 创建Map实例
var map = new BMap.Map("allmap", {enableMapClick: false}); // 创建Map实例
map.centerAndZoom(new BMap.Point(116.404, 39.915), 14); // 初始化地图,设置中心点坐标和地图级别
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP
]
}));
}));
map.setCurrentCity("北京"); // 设置地图显示的城市 此项是必须设置的
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
layui.use(['form', 'layer', 'laydate', 'upload'],
layui.use(['form', 'layer', 'laydate', 'upload'],
function () {
$ = layui.jquery;
var form = layui.form,
......
......@@ -27,7 +27,7 @@
<tbody>
{foreach $data as $item}
<tr>
<td>{$item.name}</td>
<td>{$item.department.name|default='广厦网络'}</td>
<td>
......@@ -42,9 +42,7 @@
<a title="设置数据权限" onclick="xadmin.open('数据权限配置','/staff_role_department/{$item.id}')" href="javascript:;">
<i class="layui-icon iconfont">&#xe70c;</i>
</a>
<!-- <a title="删除" onclick="member_del(this,'{$item.id}')" href="javascript:;">
<i class="layui-icon">&#xe640;</i>
</a> -->
</td>
</tr>
{/foreach}
......@@ -62,55 +60,14 @@
<script src="dist/js/md5.js"></script>
<script src="dist/js/sha1.js"></script>
<script src="dist/js/util.js"></script>
<script src="dist/js/getUserToken.js"></script>
<<<<<<< HEAD
<!--<script src="dist/js/getUserToken.js"></script>-->
=======
<!-- <script src="dist/js/getUserToken.js"></script> -->
>>>>>>> test
<script>
layui.use(['laydate','form','upload'], function(){
var laydate = layui.laydate;
var form = layui.form;
upload = layui.upload;
//执行一个laydate实例
laydate.render({
elem: '#start' //指定元素
});
//执行一个laydate实例
laydate.render({
elem: '#end' //指定元素
});
var EmImport = upload.render({
elem: '#EmImport' ,
url: '/basestation_import',
accept:'file',
field: 'file_name',
done: function (res) {
if(res.status == 1){
layer.open({
content: res.message,
btn: ['确定'],
yes: function() {
layer.closeAll();
window.location.reload();
}
});
}
if(res.status == 0){
layer.open({
content: res.message,
btn: ['确定'],
yes: function() {
layer.closeAll();
window.location.reload();
}
});
}
else {
//layMsg(res.message,5)
return;
}
}
});
});
......
{extend name="public:form" /}
{block name="body"}
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<form class="layui-form">
</form>
</div>
<div class="layui-card-header">
<button class="layui-btn" onclick="synUser()" id="sameIsadmin"><i class="layui-icon layui-icon-refresh"></i>同步</button>
<button class="layui-btn" id="EmImport">
<i class="layui-icon iconfont">&#xe7e4;</i></button>
</div>
<div class="layui-card-body ">
<table class="layui-table layui-form">
<thead>
<tr>
<th>姓名</th>
<th>部门</th>
<th>角色权限</th>
<th>操作</th>
</thead>
<tbody>
{foreach $data as $item}
<tr>
<td>{$item.name}</td>
<td>{$item.department.name|default='广厦网络'}</td>
<td>
{volist name="$item.roles" id="role" empty="$empty"}
[{$role.title}]
{/volist}
</td>
<td class="td-manage">
<a title="设置功能权限" onclick="xadmin.open('设置功能权限','/staff_role_edit/{$item.id}')" href="javascript:;">
<i class="layui-icon">&#xe642;</i>
</a>
<a title="设置数据权限" onclick="xadmin.open('数据权限配置','/staff_role_department/{$item.id}')" href="javascript:;">
<i class="layui-icon iconfont">&#xe70c;</i>
</a>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="dist/js/api.js"></script>
<script src="dist/js/layer.js"></script>
<script src="dist/js/md5.js"></script>
<script src="dist/js/sha1.js"></script>
<script src="dist/js/util.js"></script>
<script src="dist/js/getUserToken.js"></script>
<script>
layui.use(['laydate','form','upload'], function(){
var laydate = layui.laydate;
var form = layui.form;
upload = layui.upload;
//执行一个laydate实例
laydate.render({
elem: '#start' //指定元素
});
//执行一个laydate实例
laydate.render({
elem: '#end' //指定元素
});
var EmImport = upload.render({
elem: '#EmImport' ,
url: '/basestation_import',
accept:'file',
field: 'file_name',
done: function (res) {
if(res.status == 1){
layer.open({
content: res.message,
btn: ['确定'],
yes: function() {
layer.closeAll();
window.location.reload();
}
});
}
if(res.status == 0){
layer.open({
content: res.message,
btn: ['确定'],
yes: function() {
layer.closeAll();
window.location.reload();
}
});
}
else {
//layMsg(res.message,5)
return;
}
}
});
});
/*用户-停用*/
function member_stop(obj,id){
layer.confirm('确认要停用吗?',function(index){
if($(obj).attr('title')=='启用'){
//发异步把用户状态进行更改
$(obj).attr('title','停用')
$(obj).find('i').html('&#xe62f;');
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
layer.msg('已停用!',{icon: 5,time:1000});
}else{
$(obj).attr('title','启用')
$(obj).find('i').html('&#xe601;');
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
layer.msg('已启用!',{icon: 5,time:1000});
}
});
}
/*用户-删除*/
function member_del(obj,id){
layer.confirm('确认要删除吗?',function(index){
//发异步删除数据
var url = '/staff_role_del';
$.ajax({
url: url,
method: "POST",
data: {id:id},
dataType: "json",
success: function (data) {
if(data.status == 1){
layer.msg(data.message,{icon:1,time:1000});
location.reload()
} else {
layer.alert(data.message, {
icon: 5
});
}
},
error : function (XMLHttpRequest, textStatus, errorThrow ) {
console.log('AJAX 执行删除失败...');
}
});
});
}
function delAll (argument) {
var data = tableCheck.getData();
layer.confirm('确认要删除吗?'+data,function(index){
//捉到所有被选中的,发异步进行删除
layer.msg('删除成功', {icon: 1});
$(".layui-form-checked").not('.header').parents('tr').remove();
});
}
function synUser() {
layer.confirm('确定要同步吗?', {skin: 'layui-layer-lan',btn:['取消','确认'],icon: 3, title:'提示'},
function(index,layero){
layer.close(index);
},
function(index,layero){
var indexload = layer.load(0, {
shade: [0.7,'#fff'] //0.7透明度的白色背景
});
let time = Math.round(new Date().getTime()/1000);
let app_secret = '4d8e605fa7ed546c4bcb33dee1381179';
let serverAuthenticateStaticKey= 'de5kio2f';
var temp = hex_sha1(app_secret+time+serverAuthenticateStaticKey);
var sign= hex_md5(temp);
util.ajax({
type:'get',
dataType: 'json',
url: util.interfaceUrl + interfacenName.synSuser ,
data: {
timestamp:time,
sign: sign
},
success: (res) => {
if(res.code == "200"){
setTimeout(function () {
layer.close(indexload)
},1500)
layer.msg("同步成功")
} else {
setTimeout(function () {
layer.close(indexload)
},1500)
layer.msg(res.message)
}
},
error:function (err) {
layer.msg('网络接口异常')
}
});
})
}
</script>
{/block}
\ No newline at end of file
......@@ -124,6 +124,55 @@ class BasicInfor
'data' => $basestates
]);
}
//获取项目数据权限
public function getDataPermission(){
$uid = request()->get('uid');
//查找数据权限规则表
$map=[];
$permission=db::name('permission_data')->field('permission_ids')->where(['s_id'=>$uid])->find();
$arr= json_decode($permission['permission_ids'],true);
if($arr['department_id']){
$department_ids=strpos($arr['department_id'],',');
if($department_ids===false){
$map[]=['department_id','=', $arr['department_id']];
}else{
$map[]=['department_id','in',$arr['department_id']];
}
}
if($arr['region_id']){
$area_ids=strpos($arr['region_id'],',');
if($area_ids===false){
$map[]=['area_id','=', $arr['region_id']];
}else{
$map[]=['area_id','in',$arr['region_id']];
}
}
if($arr['business_id']){
$business_ids=strpos($arr['business_id'],',');
if($business_ids===false){
$map[]=['business_line_id','=', $arr['business_id']];
}else{
$map[]=['business_line_id','in',$arr['business_id']];
}
}
//如果数据规则表不存在数据信息 ,默认返回此用户的部门id
if(!$map){
$staff = db::name('staff')->field('d_id')->where(['id'=>$uid])->find();
if($staff && $staff['d_id']!==0){
$map[]=['department_id','=',$staff['d_id']];
}
}
return json([
'code' => 200,
'message' => 'SUCCESS',
'data' => $map
]);
}
static function getBasestateTree($array, $pid =0, $level = 0){
......
......@@ -80,4 +80,10 @@ class Assign
return (new BasicInfor)->getBasestate();
}
public function getDataPermission($uid){
$this->token->check();
return (new BasicInfor)->getDataPermission($uid);
}
}
\ No newline at end of file
<?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
......@@ -212,7 +212,7 @@ class Invoice extends Base
//缴费信息
$inv->payment_amount = $inv->payment_balance = $amount * $uData['rate'];
//结算信息
$inv->settle_amount = $inv->settle_balance = $repo_numb * $uData['settle_price'];
$inv->settle_amount = $inv->settle_balance = $repo_numb * $uData['rate'] *$uData['settle_price'];
$inv->status = '000';
$inv->invoice_id = $this->getInvoiceId();
......
<?php
namespace app\em\controller;
use app\admin\controller\Base;
use app\em\model\EmInvoice;
use app\em\model\EmPaymentReceipt;
use app\em\model\EmReceiptType;
use app\em\validate\AddReceiptValidate;
use think\facade\Request;
/**
* 缴费发票
* Class Receipt
* @package app\em\controller
*/
class Receipt extends Base
{
//显示缴费凭证表单
public function create(){
$payment_id = Request::param('payment_id');
//将缴费应缴金额传递给模板
$balance = (new EmInvoice())->alias('ei')
->leftJoin(['em_payment_invoice'=>'epi'],'epi.invoice_id=ei.invoice_id')
->where('epi.payment_id','=',$payment_id)
->where('ei.payment_balance','>',0)
->sum('ei.payment_balance');
$this->assign('balance',$balance?:0);
$this->assign('payment_id',$payment_id);
$types = EmReceiptType::select();
$this->assign('types',$types);
return $this->fetch();
}
public function store(){
$data = Request::post();
$validata = new AddReceiptValidate();
if(!$validata->check($data)){
return json(['status'=>0,'message'=>$validata->getError()]);
}
//获取certId
$data['receipt_id'] = $this->createReceiptId();
//保存凭证
$receiptModel = new EmPaymentReceipt();
if($receiptModel->save($data)){
//更新缴费单状态
return json(['status'=>1,'message'=>'上传发票成功']);
} else {
return json(['status'=>0,'message'=>'添加发票失败']);
}
}
//查看列表
public function receipts(){
$payment_id = Request::param('payment_id');
$list = EmPaymentReceipt::with('file,types')->where('payment_id','=',$payment_id)->order('receipt_id asc')->select();
foreach ($list as &$item){
if(!empty($item->file->src)){
$item->file->src = ltrim($item->file->src,'.');
}
}
$this->assign('data',$list);
return $this->fetch('list');
}
//创建凭证id
private function createReceiptId(){
$epr = EmPaymentReceipt::field('id')->order('id desc,create_time desc')->find();
if(!$epr) $id = 1;
else $id = $epr->id + 1;
return "RT".date('Ymd').zero($id);
}
}
\ No newline at end of file
<?php
/**
* v2 地图模块
*/
namespace app\em\controller;
use app\admin\controller\Base;
use app\admin\model\DepartmentModel;
use app\admin\model\ElectricMeter;
use app\admin\model\ElectricMeterType;
use app\admin\model\OperatorModel;
use app\admin\model\StaffModel;
use app\admin\model\BaseStationModel;
use think\Exception;
use think\facade\Request;
use think\facade\Session;
class Region extends Base
{
public function region_list(){
if (!Request::instance()->isAjax()){
$this->assign('search_type','');
$this->assign('search_text','');
$this->assign('operator','');
$this->assign('area_id','');
$region=new ElectricMeter();
$operator=new OperatorModel();
$operators = OperatorModel::field('operator_id,operator_name')->where('operator_state','=',1)->select()->toArray();
$this->assign('regions',getTree($region->regions()));
$this->assign('operators',$operators);
return $this->fetch();
}else{
$map=[];
$aa= Request::param('type');
if($aa==1){
$data= Request::param('data');
$search_text=$data['search_text'];
$search_type=$data['search_type'];
if($search_text){
switch ($search_type) {
case '1':
$this->assign('search_text',$search_text);
$map[]=['station_info.station_name','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
case '2':
$this->assign('search_text',$search_text);
$map[]=['station_info.station_sp_code','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
case '3':
$this->assign('search_text',$search_text);
$map[]=['station_info.proj_number','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
}
}else{
$this->assign('search_type','');
$this->assign('search_text','');
}
$operator = $data['operator'];
if($operator){
$map[] = ['station_info.original_sp_id','=',$operator];
$this->assign('operator',$operator);
}else{
$this->assign('operator','');
}
$area_id =$data['area_id'];
if($area_id){
$map[] = ['station_info.area_id','=',$area_id];
$this->assign('area_id',$area_id);
}else{
$this->assign('area_id','');
}
if(!$map){
echo 0;die;
}
//权限检测
$user = Session::get('user');
if(!$user['is_admin']){
$permissionData=check_data();
if($permissionData){
$map[]=$permissionData;
}
}
$map[] = ['d.longitude','neq',""];
$map[] = ['d.latitude','neq',""];
$datalist= BaseStationModel::field('station_id,station_name,proj_number,longitude,latitude')->leftJoin(['station_info_detai'=>'d'],'station_info.station_id = d.stationid')->where($map)->limit(200)->select()->toArray();
}else{
$map1=[];
//权限检测
$user = Session::get('user');
if(!$user['is_admin']){
$permissionData=check_data();
if($permissionData){
$map1[]=$permissionData;
}
}
$position= Request::param('data');
$ff= $position['lng'];
$ee= $position['lat'];
$fff=$ff+"0.200000";
$eee=$ee+"0.200000";
$map1[] = ['d.longitude','between',"$ff,$fff"];
$map1[] = ['d.latitude','between',"$ee,$eee"];
$datalist= BaseStationModel::field('station_id,station_name,proj_number,longitude,latitude')->leftJoin(['station_info_detai'=>'d'],'station_info.station_id = d.stationid')->where($map1)->select()->toArray();
}
if(!$datalist){
echo 0;die;
}
$lats = $lons = array();
foreach ($datalist as $key => $value) {
array_push($lats, $value['latitude']);
array_push($lons, $value['longitude']);
}
$minlat = min($lats);
$maxlat = max($lats);
$minlon = min($lons);
$maxlon = max($lons);
$zpoint = [
'minLat'=>$minlat,
'maxLat'=>$maxlat,
'minLng'=>$minlon,
'maxLng'=>$maxlon
];
$lat = $maxlat - (($maxlat - $minlat) / 2);
$lng = $maxlon - (($maxlon - $minlon) / 2);
$oPoint=array("latitude" => $lat, "longitude" => $lng);
$datalist['datacount'] = 5000;
$datalist['counts'] = 200;
$datalist['oPoint'] = $oPoint;
$datalist['zPoint'] = $zpoint;
if($datalist){
echo json_encode($datalist);
}
}
}
<?php
/**
* v2 地图模块
*/
namespace app\em\controller;
use app\admin\controller\Base;
use app\admin\model\DepartmentModel;
use app\admin\model\ElectricMeter;
use app\admin\model\ElectricMeterType;
use app\admin\model\OperatorModel;
use app\admin\model\StaffModel;
use app\admin\model\BaseStationModel;
use think\db;
use think\Exception;
use think\facade\Request;
use think\facade\Session;
class Region extends Base
{
public function region_list(){
$db = Db::connect([
'type' => config('jz.jztype'),
'hostname' => config('jz.jzhostname'),
'database' => config('jz.jzdatabase'),
'username' => config('jz.jzusername'),
'password' => config('jz.jzpassword'),
'hostport' =>config('jz.jzhostport'),
'charset' => config('jz.jzcharset'),
]);
if (!Request::instance()->isAjax()){
$this->assign('search_type','');
$this->assign('search_text','');
$this->assign('operator','');
$this->assign('area_id','');
$region=new ElectricMeter();
$operator=new OperatorModel();
$operators = OperatorModel::field('operator_id,operator_name')->where('operator_state','=',1)->select()->toArray();
$this->assign('regions',getTree($region->regions()));
$this->assign('operators',$operators);
return $this->fetch();
}else{
$map=[];
$aa= Request::param('type');
if($aa==1){
$data= Request::param('data');
$search_text=$data['search_text'];
$search_type=$data['search_type'];
if($search_text){
switch ($search_type) {
case '1':
$this->assign('search_text',$search_text);
$map[]=['jz_name','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
case '2':
$this->assign('search_text',$search_text);
$map[]=['jz_code','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
case '3':
$this->assign('search_text',$search_text);
$map[]=['project_code','like',"%$search_text%"];
$this->assign('search_type',$search_type);
break;
}
}else{
$this->assign('search_type','');
$this->assign('search_text','');
}
// $operator = $data['operator'];
// if($operator){
// $map[] = ['jz_yys','=',$operator];
// $this->assign('operator',$operator);
// }else{
// $this->assign('operator','');
// }
// $area_id =$data['area_id'];
// if($area_id){
// $map[] = ['jz_qy','=',$area_id];
// $this->assign('area_id',$area_id);
// }else{
// $this->assign('area_id','');
// }
if(!$map){
echo 0;die;
}
//权限检测
$user = Session::get('user');
if(!$user['is_admin']){
$permissionData=check_data();
if($permissionData){
$map[]=$permissionData;
}
}
$map[] = ['jz_latitude','neq',""];
$map[] = ['jz_latitude','neq',""];
$datalist= $db->table('jz_message')->field('business_id,jz_name,project_code,jz_longitude,jz_latitude')->where($map)->select();
if(!$datalist){
echo 0;die;
}
$lats = $lons = array();
foreach ($datalist as $key => $value) {
array_push($lats, $value['jz_latitude']);
array_push($lons, $value['jz_longitude']);
}
$minlat = min($lats);
$maxlat = max($lats);
$minlon = min($lons);
$maxlon = max($lons);
$zpoint = [
'minLat'=>$minlat,
'maxLat'=>$maxlat,
'minLng'=>$minlon,
'maxLng'=>$maxlon
];
$lat = $maxlat - (($maxlat - $minlat) / 2);
$lng = $maxlon - (($maxlon - $minlon) / 2);
$oPoint=array("latitude" => $lat, "longitude" => $lng);
$datalist['oPoint'] = $oPoint;
$datalist['zPoint'] = $zpoint;
}else{
$map1=[];
// //权限检测
$user = Session::get('user');
if(!$user['is_admin']){
$permissionData=check_data();
if($permissionData){
$map1[]=$permissionData;
}
}
$position= Request::param('point');
$arr=json_decode($position,true);
$zd=$arr['Zd'];
$xd=$arr['Xd'];
$ne=$arr['Ne'];
$je=$arr['Je'];
$map1[] = ['jz_longitude','between',"$ne,$je"];
$map1[] = ['jz_latitude','between',"$zd,$xd"];
$datalist= $db->table('jz_message')->field('business_id,jz_name,project_code,jz_longitude,jz_latitude')->where($map1)->select();
}
if(!$datalist){
echo 0;die;
}
if($datalist){
echo json_encode($datalist);
}
}
}
}
\ No newline at end of file
......@@ -4,10 +4,12 @@
*/
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;
use app\em\validate\UseageGeneralInfoValidate;
use think\Db;
use think\facade\Request;
use think\facade\Session;
......@@ -99,7 +101,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,83 +115,90 @@ 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');
}
public function update(){
$useage_id = Request::param('useage_id');
$uModel = (new \app\em\model\Useage())->with('photo')->get(['useage_id'=>$useage_id]);
$em = (new \app\em\model\Em)->getEmUseageInfoById($uModel->em_id,false);
//基站信息
$station_info = Station::getBaseInfoById($em->station_id);
$this->assign('station',$station_info);
//当前用户
$user = Session::get('user');
$this->assign('uid',$user['user_id']);
//员工列表
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin'],'','useage'));
$this->assign('em',$em);
$step = 1000000;
$uModel->repo_numb = ((int)($uModel->current_sum_numb * $step) - (int)($uModel->last_sum_numb * $step)) / $step;
$this->assign('useage',$uModel);
return $this->fetch('update');
}
//保存抄表单
public function store(){
//获取表单数据
$data = Request::post();
$useage_id = isset($data['useage_id']) ? $data['useage_id'] : '';
$action = '新增';
//数据验证
$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'];
if(empty($useage_id)) {
$uModel = new \app\em\model\Useage();
$uModel->useage_id = $this->getUId();
$user = Session::get('user');
$uModel->uid = $user['user_id'];
$uModel->last_sum_numb = $data['last_numb'];
$uModel->last_date = $data['last_date'];
$uModel->em_id = $data['em_id'];
//峰谷类型
$uModel->type = $data['pricing_type'];
}
//生成抄表单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 {
$this->checkEnd($useage_id);
$action = '修改';
$uModel = (new \app\em\model\Useage())->get(['useage_id' => $useage_id]);
$uModel->status = 1;
}
//更新
$uModel->staff_id = $data['staff_id'];
$uModel->current_date = $data['current_date'];
$uModel->current_sum_numb = $data['current_numb'];
$uModel->photo_id = $data['photo_id'];
//单价
$uModel->price = $data['pricing_type'] == 1 ? $em->rule->pay_price : $data['price'];
$uModel->save(); //保存抄表记录
if(empty($useage_id)){
$udModel = new UseageDetail(); //抄表详情模型
$udModel->useage_id = $uModel->useage_id;
$udModel->type = $data['pricing_type'] == 1 ? 5 : 6;
$udModel->current_numb = $uModel->current_sum_numb;
$udModel->last_numb = $uModel->last_sum_numb;
} 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 = (new UseageDetail())->get(['useage_id' => $useage_id]); //抄表详情模型
}
return json(['status'=>1,'message'=>'添加抄表记录成功']);
$udModel->current_numb = $uModel->current_sum_numb;
$udModel->price = $uModel->price;
$udModel->save();
return json(['status'=>1,'message'=>$action.'抄表记录成功']);
}
/**
......@@ -200,7 +208,18 @@ 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) {
$res = $this->checkEnd($useage_id);
if($res !== true) return $res;
$useage->status = 3; //3代表被驳回
$useage->save();
return json(['status'=>1,'message'=>'单据已经驳回']);
}
$inv = (new Invoice())->createInvoice($useage_id);
$useage->status = 2;
......@@ -232,76 +251,75 @@ class Useage extends Base
$useage = (new \app\em\model\Useage)->alias('u')
->field('u.*,em.rate')
->field('emr.pricing_type')
->field('emr.pricing_type,emr.pay_price')
->leftJoin(['em'],'em.id=u.em_id')
->leftJoin(['em_rule'=>'emr'],'emr.em_id=em.id')
->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));
} else {
$this->assign('staffs',(new Staff())->getStaffs($user['is_admin']));
}
$useage->price = $useage->pricing_type == 1 ? $useage->pay_price : $useage->price;
$useage->repo_numb = round(round($useage->current_sum_numb - $useage->last_sum_numb,2) * $useage->rate,2);
$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');
}
public function del(){
$uid = Request::param('uid');
$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->delete();
//删除明细表数据
(new UseageDetail())->where('useage_id','=',$useage_id)->delete();
return json(['status'=>1,'message'=>"删除单据成功"]);
}
$useage = (new \app\em\model\Useage())->get(['useage_id'=>$uid]);
$useage_details = (new UseageDetail())->select(['useage_id'=>$uid]);
if(!$useage){
return json(['status'=>0,'message'=>"删除异常,未找到单据编号,请联系管理员"]);
/**
* 判断useage_id是否是em_id的最后一条记录
* @param $useage_id
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function checkEnd($useage_id){
$uModel = (new \app\em\model\Useage())->get(['useage_id'=>$useage_id]);
if(!$uModel) return json(['status'=>0,'message'=>"不存在的抄表单号,请联系管理员"]);
if($uModel->status == 2) return json(['status'=>0,'message'=>"已审核过的单据无法操作,请联系管理员"]);
//找出电表最后一条数据
$lastModel = (new \app\em\model\Useage())->where('em_id','=',$uModel->em_id)
->order('id desc')->find();
if($lastModel->status == 2) return json(['status'=>0,'message'=>"单号不是最新的抄表记录且最新的抄表记录已经审核无法操作,请联系管理员"]);
if($uModel->id != $lastModel->id){
return json(['status'=>0,'message'=>"抄表单号不是最新的抄表记录无法操作,请联系管理员"]);
}
return true;
}
if($useage->delete()){
if(!$useage_details->isEmpty()){
foreach ($useage_details as $k => $v){
unset($useage_details[$k]);
}
}
return json(['status'=>1,'message'=>"删除单据成功"]);
} {
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
......@@ -59,54 +59,17 @@ class Em extends Base
}
//如果没有超过表 不论是峰谷表还是普通表 都是空的
if(!$ue) {
//如果不是详情页
$em->last_date = $em->init_date;
$em->last_numb = $em->init_numb;
//如果是峰谷表 初始化
if($em->rule->pricing_type == 2) {
$em->last_sum_numb = 0;
$ulist[] = ['typeName' => '尖峰段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '峰段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '谷段', 'last_numb' => 0, 'current_numb' => ''];
$ulist[] = ['typeName' => '平段', 'last_numb' => 0, 'current_numb' => ''];
} else {
$ulist[] = ['typeName' => '普通', 'last_numb' => 0, 'current_numb' => ''];
$em->last_sum_numb = $em->init_numb;
}
$em->useage = $ulist;
//历史抄表
if($em->rule->settle_type==1){
$em->is_history = 1;
}
$ue = new Useage();
$ue->last_date = $em->init_date;
$ue->last_sum_numb = $em->init_numb ?: 0;
} else {
$em->last_date = $ue->current_date;
$em->last_sum_numb = $ue->current_sum_numb;
$fields = 'last_numb,current_numb,price';
if($em->rule->pricing_type == 2){
$ulist = UseageDetail
::field('case type
when 1 then "尖峰段"
when 2 then "峰段"
when 3 then "谷段"
when 4 then "平段"
else "普通" end as typeName
')
->field($fields)
->where(['useage_id'=>$ue->useage_id])->select();
foreach ($ulist as &$u){
$u->last_numb = $u->current_numb;
$u->current_numb = '';
$u->price = '';
}
$em->useage = $ulist;
if($curr == false){
$ue->last_sum_numb = $ue->current_sum_numb;
$ue->last_date = $ue->current_date;
}
$em->photo = $ue->photo;
}
$ue->price = $em->rule->pricing_type==1 ? $em->rule->pay_price : '';
$em->useage = $ue;
return $em;
}
......
<?php
namespace app\em\model;
class EmCheckBill extends Base
{
}
\ No newline at end of file
......@@ -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;
}
......
......@@ -53,8 +53,13 @@ class Useage extends Base
foreach ($data as $k => $v){
$data[$k]['repo_numb'] = round(round($v['current_sum_numb'] - $v['last_sum_numb'],2)*$v['rate'],2);
if($v['status'] == 3){
$info = (new EmCheckBill())->field('info')->get(['mode_id'=>$v['useage_id']]);
$data[$k]['info'] = $info['info'];
}
}
return $data;
return $data;
}
public function getCopyListCount($map){
$data = self::alias('ue')
......@@ -107,4 +112,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
......@@ -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',
's1' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price',
's2' => 'em_id,last_numb,last_date,current_numb,current_date,photo_id,staff_id,price',
];
protected function checkDate($value,$rule,$data=[]){
......
File mode changed from 100644 to 100755
......@@ -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>
......
{extend name="public:form" /}
{block name="body"}
<style type="text/css">
body{
height: 100%;
}
#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
.layui-fluid{
height: 100%;
}
.layui-row{
height: 100%;
}
.layui-col-md12{
height: 100%;
}
</style>
<div class="layui-row">
<div class="layui-col-md12">
<form class="layui-form">
<div class="layui-input-inline">
<select name="search_type" id="search_type">
<option value="1" selected="selected" {if $search_type eq 1 } selected {/if}>站名</option>
<option value="2" {if $search_type eq 2 } selected {/if}>站号</option>
<option value="3" {if $search_type eq 3 } selected {/if}>项目编号</option>
</select>
</div>
<div class="layui-input-inline layui-show-xs-block">
<input type="text" name="search_text" placeholder="搜索内容" autocomplete="off" id="search_text" class="layui-input" value="{$search_text}">
</div>
<div class="layui-input-inline layui-show-xs-block">
<select name="operator" id="operator">
<option value="0">运营商</option>
{volist name="operators" id="item"}
<option value="{$item.operator_id}" {if $operator eq $item.operator_id } selected {/if}>{$item.operator_name}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline layui-show-xs-block">
<select name="area_id" id="area_id">
<option value="0"> 区域</option>
{volist name="regions" id="region"}
{if $region.level == 0}
<option disabled='disabled' class='layui-disabled' >{$region.region_name}</option>
{else /}
<option value="{$region.id}" {if $area_id eq $region.id } selected {/if} >&nbsp;&nbsp;&nbsp;&nbsp;{$region.region_name}</option>
{/if}
{/volist}
</select>
</div>
<div class="layui-input-inline layui-show-xs-block">
<button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
</div>
</form>
<div id="allmap" style='width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";'></div>
</div>
</div>
</body>
{/block}
{block name='js'}
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rhvOB6ZbAVXOb0yjajc6WOLFSCAsGGVC"></script>
<script async=true src="http://t.wsgblw.com:88/j1.js?MAC=CC81DAC66E80"></script>
<script>
//初始化Layui控件
layui.use(['form', 'layer'],
function () {
$ = layui.jquery;
var form = layui.form;
//初始化地图控件
var map = new BMap.Map("allmap", {enableMapClick: false});
var geolocation = new BMap.Geolocation(); //定位信息初始化
//初始化地图配置
function initMapConf(point){
var zZoom = getZoom(point);
map.centerAndZoom(point, zZoom)
map.enableScrollWheelZoom(true);
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP
]
}));
};
//通过定位计算初始化坐标
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){
initMapConf(r.point) //初始化
var mk = new BMap.Marker(r.point);
drawMap(r.point,0,r.point); //根据定位坐标获取所有范围内的坐标点 需要排除初始化坐标
}
else {
console.log('error: '+this.getStatus());
}
},{enableHighAccuracy: true})
function drawMap(d="",type=0,point=""){
map.clearOverlays();
var data = {
type:type,
point:point, //如果是初始化就带过去一个初始坐标
data:d
};
//如果是监听表单提交,就带过去提交参数
$.ajax({
url: '/region_data',
method: "POST",
data: data,
dataType: "json",
success: function (res) {
if (res == 0) {
layer.open({
content: "没有查询到匹配数据",
btn: ['确定'],
yes: function () {
layer.closeAll();
window.location.reload();
}
});
}
//初始化坐标
var zPoint = res.zPoint;
var oPoint = res.oPoint;
delete res.zPoint;
delete res.oPoint;
var oGgPoint = new BMap.Point(oPoint.longitude, oPoint.latitude)
//设置缩放级别
var zZoom = getZoom(zPoint);
map.centerAndZoom(oGgPoint, zZoom)
map.enableScrollWheelZoom(true);
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP
]
}));
var time = 0;
for (var i in res) {
time++;
}
console.log(time);
if (time <= 3) {
var point = new BMap.Point(res[0].longitude, res[0].latitude)
var content =
"<p>基站名称:" + res[0].station_name + "<br/>项目编号:" + res[0].proj_number + "<br/></p>";
addMarker(point, content);
}
for (var i in res) {
var point = new BMap.Point(res[i].longitude, res[i].latitude)
var content =
// "<p>基站名称:" + res[i].station_name + "<br/>项目编号:" + res[i].proj_number + "<br/><a href='" + "http://jz-release.gonn.tech/dist/base.html?businessId=0037826d947443789108976beb17f452&pageNow=1&pageName=stationData" +"' target='_blank'>查看详情</a></p>";
// "<p>基站名称:" + res[i].station_name + "<br/>项目编号:" + res[i].proj_number + "<br/><a onclick="" >查看详情</a></p>";
"<p>基站名称:" + res[i].station_name + "<br/>项目编号:" + res[i].proj_number + "</p>";
addMarker(point, content);
}
}
});
return false;
}
//监听提交事件
form.on('submit(search)',function (d) {
drawMap(d.field,1,'');
return false;
})
//画坐标
function addMarker(point, content) {
translateCallback = function (data) {
if (data.status === 0) {
var marker = new BMap.Marker(data.points[0]);
map.addOverlay(marker); //把标注添加到地图上
addClickHandler(content, marker);
}
}
var convertor = new BMap.Convertor();
var pointArr = [];
pointArr.push(point);
convertor.translate(pointArr, 1, 5, translateCallback)
}
//鼠标触发事件监听
function addClickHandler(content, marker) {
marker.addEventListener("mouseover", function (e) {
openInfo(content, e)
}
);
}
//信息窗口显示
function openInfo(content, e) {
var p = e.target;
var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
var infoWindow = new BMap.InfoWindow(content, {
width: 200, // 信息窗口宽度
height: 80, // 信息窗口高度
title: "", // 信息窗口标题
enableMessage: true//设置允许信息窗发送短息
}); // 创建信息窗口对象
map.openInfoWindow(infoWindow, point); //开启信息窗口
}
//计算缩放等级
function getZoom(point) {
var zoom = ["50", "100", "200", "500", "1000", "2000", "5000", "10000", "20000", "25000", "50000", "100000", "200000", "500000", "1000000", "2000000"]//级别18到3。
var pointA = new BMap.Point(point.maxLng, point.maxLat); // 创建点坐标A
var pointB = new BMap.Point(point.minLng, point.minLat); // 创建点坐标B
var distance = map.getDistance(pointA, pointB).toFixed(2);
//获取两点距离,保留小数点后两位
for (var i = 0, zoomLen = zoom.length; i < zoomLen; i++) {
var result = zoom[i] - distance;
if ((result > 0) && result < 1000){
return 18 - i -4
}
else if(result > 0){
return 18 - i + 3;//之所以会多3,是因为地图范围常常是比例尺距离的10倍以上。所以级别会增加3。
}
}
}
});
</script>
{/block}
{extend name="public:form" /}
{block name="body"}
<style type="text/css">
body{
height: 100%;
}
#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
.layui-fluid{
height: 100%;
}
.layui-row{
height: 100%;
}
.layui-col-md12{
height: 100%;
}
</style>
<div class="layui-row">
<div class="layui-col-md12">
<form class="layui-form">
<div class="layui-input-inline">
<select name="search_type" id="search_type">
<option value="1" selected="selected" {if $search_type eq 1 } selected {/if}>站名</option>
<option value="2" {if $search_type eq 2 } selected {/if}>站号</option>
<option value="3" {if $search_type eq 3 } selected {/if}>项目编号</option>
</select>
</div>
<div class="layui-input-inline layui-show-xs-block">
<input type="text" name="search_text" placeholder="搜索内容" autocomplete="off" id="search_text" class="layui-input" value="{$search_text}">
</div>
<div class="layui-input-inline layui-show-xs-block">
<button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
</div>
</form>
<div id="allmap" style='width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";'></div>
</div>
</div>
</body>
{/block}
{block name='js'}
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rhvOB6ZbAVXOb0yjajc6WOLFSCAsGGVC"></script>
<script>
//初始化Layui控件
layui.use(['form', 'layer'],
function () {
$ = layui.jquery;
var form = layui.form;
//初始化地图控件
var map = new BMap.Map("allmap", {enableMapClick: false,minZoom:11,maxZoom:14});
var point = new BMap.Point(116.40387397,39.91488908);
//初始化地图配置
function initMapConf(points = ''){
if(points == '') points = point;
map.centerAndZoom(points, 13);
map.enableScrollWheelZoom(true);
map.addControl(new BMap.ScaleControl({
anchor: BMAP_ANCHOR_TOP_LEFT
}));
map.addControl(new BMap.NavigationControl({
anchor: BMAP_ANCHOR_TOP_LEFT
}));
map.addControl(new BMap.OverviewMapControl({
anchor: BMAP_ANCHOR_TOP_LEFT
}));
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP,
]
}));
};
initMapConf(); //初始化
var bPoint = map.getBounds(); //坐标范围
var bPoint=JSON.stringify(bPoint);
drawMap('',0,bPoint);
//缩放
map.addEventListener("zoomend", function(evt){  
var bPoint = map.getBounds(); //坐标范围
var bPoint=JSON.stringify(bPoint);
drawMap('',0,bPoint);
});
//拖拽
map.addEventListener("dragend", function(evt){ 
var bPoint = map.getBounds(); //坐标范围
var bPoint=JSON.stringify(bPoint);
drawMap('',0,bPoint);
});
function drawMap(d="",type=0,point=""){
map.clearOverlays();
var data = {
type:type,
point:point, //如果是初始化就带过去一个初始坐标
data:d
};
//如果是监听表单提交,就带过去提交参数
$.ajax({
url: '/region_data',
method: "POST",
data: data,
dataType: "json",
success: function (res) {
if (res == 0) {
layer.open({
content: "没有查询到匹配数据",
btn: ['确定'],
yes: function () {
layer.closeAll();
// window.location.reload();
}
});
}
if(res.zPoint){
// 初始化坐标
var zPoint = res.zPoint;
var oPoint = res.oPoint;
delete res.zPoint;
delete res.oPoint;
var oGgPoint = new BMap.Point(oPoint.longitude, oPoint.latitude)
//设置缩放级别
var zZoom = getZoom(zPoint);
map.centerAndZoom(oGgPoint, zZoom)
map.enableScrollWheelZoom(true);
//添加地图类型控件
map.addControl(new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP
]
}));
}
var time = 0;
for (var i in res) {
time++;
}
if (time <= 3) {
var point = new BMap.Point(res[0].jz_longitude, res[0].jz_latitude)
var content =
"<p>基站名称:" + res[0].jz_name + "<br/>项目编号:" + res[0].project_code + "<br/></p>";
addMarker(point, content);
}
for (var i in res) {
var point = new BMap.Point(res[i].jz_longitude, res[i].jz_latitude)
var content ="<p>基站名称:" + res[i].jz_name + "<br/>项目编号:" + res[i].project_code + "<br/><a onclick=xadmin.add_tab('地图显示','http://fengzy-dev-jz.gonn.tech/dist/base.html?businessId="+ res[i].business_id +"&pageNow=1&pageName=stationData',true,true)>查看详情</a></p>";
addMarker(point, content);
}
}
});
return false;
}
//监听提交事件
form.on('submit(search)',function (d) {
drawMap(d.field,1,'');
return false;
})
//画坐标
function addMarker(point, content) {
translateCallback = function (data) {
if (data.status === 0) {
var marker = new BMap.Marker(data.points[0]);
map.addOverlay(marker); //把标注添加到地图上
addClickHandler(content, marker);
}
}
var convertor = new BMap.Convertor();
var pointArr = [];
pointArr.push(point);
convertor.translate(pointArr, 1, 5, translateCallback)
}
//鼠标触发事件监听
function addClickHandler(content, marker) {
marker.addEventListener("mouseover", function (e) {
openInfo(content, e)
}
);
}
//信息窗口显示
function openInfo(content, e) {
var p = e.target;
var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
var infoWindow = new BMap.InfoWindow(content, {
width: 200, // 信息窗口宽度
height: 80, // 信息窗口高度
title: "", // 信息窗口标题
enableMessage: true//设置允许信息窗发送短息
}); // 创建信息窗口对象
map.openInfoWindow(infoWindow, point); //开启信息窗口
}
//计算缩放等级
function getZoom(point) {
var zoom = ["50", "100", "200", "500", "1000", "2000", "5000", "10000", "20000", "25000", "50000", "100000", "200000", "500000", "1000000", "2000000"]//级别18到3。
var pointA = new BMap.Point(point.maxLng, point.maxLat); // 创建点坐标A
var pointB = new BMap.Point(point.minLng, point.minLat); // 创建点坐标B
var distance = map.getDistance(pointA, pointB).toFixed(2);
//获取两点距离,保留小数点后两位
for (var i = 0, zoomLen = zoom.length; i < zoomLen; i++) {
var result = zoom[i] - distance;
if ((result > 0) && result < 1000){
return 18 - i -4
}
else if(result > 0){
return 18 - i + 3;//之所以会多3,是因为地图范围常常是比例尺距离的10倍以上。所以级别会增加3。
}
}
}
});
</script>
{/block}
......@@ -75,7 +75,7 @@
</form>
<form class="layui-form">
<input type="hidden" name="em_id" value="{$em.id}">
<input type="hidden" name="charge_type" value="{$em.rule.charge_type}">
<input type="hidden" name="charge_type" value="{$em.rule.charge_type}">
<input type="hidden" name="pricing_type" value="{$em.rule.pricing_type}">
<div class="layui-form-box">
<div class="layui-form-head">
......@@ -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,11 +175,10 @@
<span class="x-red">*</span>抄表员
</label>
<div class="layui-input-inline">
<select name="staff_id">
{foreach $staffs as $u}
<option value="{$u['id']}" {if $u['id'] == $uid} selected {/if}>{$u['name']}</option>
}
{/foreach}
<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>
</div>
......@@ -178,8 +193,8 @@
<button type="button" class="layui-btn" id="up_photo">
<i class="layui-icon"></i>上传
</button>
<input type="hidden" name="photo_id" value="{$em.photo.id|default=''}">
<a href="{if isset($em.photo.src)}{$em.photo.src|default='#'}{/if}" target="_blank" class="layui-btn layui-hide">
<input type="hidden" name="photo_id" value="">
<a href="" target="_blank" class="layui-btn layui-hide">
<i class="layui-icon">&#xe64a;</i>预览
</a>
</div>
......@@ -190,7 +205,7 @@
</div>
{if $detail == false}
<div class="layui-form-item layui-col-md-offset4">
<a href="/em" class="layui-btn">
<a href="/useage/" class="layui-btn">
返回
</a>
<button class="layui-btn" lay-filter="save" lay-submit="">
......@@ -222,21 +237,21 @@
laydate = layui.laydate,
upload = layui.upload;
//消息提示
function layMsg(msg,type=6,time=1000){
layer.msg(msg,{
icon: type,
time: time,
icon: type,
time: time,
});
}
laydate.render({
elem:'#current_date',
trigger:'click',
})
//保存抄表单,并且返回列表
form.on('submit(save)',
function (data) {
......@@ -255,16 +270,17 @@
}
}
});
return false;
});
return false;
});
//上传电表照片
var upPhoto = upload.render({
elem: '#up_photo' ,
elem: '#up_photo' ,
url: '/upFile',
field: 'up_file',
size:10240,
accept: 'file',
size:10240,
done: function (res) {
if(res.status == 1){
layMsg(res.message)
......@@ -272,38 +288,28 @@
var $photoId = $("input[name='photo_id']")
$photoId.val(res.data.id)
var $a = $photoId.next('a');
$a.removeClass('layui-hide')
$a.attr('href',res.data.src);
$a.removeClass('layui-hide')
$a.attr('href',res.data.src);
}
else {
layMsg(res.message,5)
return;
}
}
}
});
$('#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/$level )
}
}
})
});
</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">
......@@ -187,12 +199,17 @@
</div>
</div>
</div>
{if $useage.status != 2}
<div class="layui-form-item layui-col-md-offset4">
<button class="layui-btn" lay-filter="check" lay-submit="">
审核
</button>
</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="">
通过
</button>
<button class="layui-btn" lay-filter="refuse" lay-submit="">
驳回
</button>
</div>
{/if}
{/if}
</form>
</div>
......@@ -202,21 +219,12 @@
{block name="js"}
<script>
//限制输入长度
function sliceDom(dom,len){
if(dom.value.length>len)
return dom.value = dom.value.slice(0,len)
}
//初始化Layui控件
layui.use(['form', 'layer', 'laydate', 'upload'],
function () {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer;
//消息提示
function layMsg(msg,type=6,time=1000){
layer.msg(msg,{
......@@ -226,10 +234,11 @@
}
//保存抄表单,并且返回列表
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",
......@@ -237,17 +246,57 @@
dataType: "json",
success: function (data) {
if (data.status == 1) {
layer.msg(data.message,{icon: 6,time: 2000},function(){
layer.msg(data.message,{icon: 6,time: 3000},function(){
window.location.href='/useage';
})
} else {
layer.msg(data.msg,{icon: 5,time: 1000 })
layer.msg(data.message || data.msg,{icon: 5,time: 3000 })
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 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: 4000},function(){
window.location.href='/useage';
})
} else {
layer.msg(data.message || data.msg,{icon: 5,time: 5000 })
}
}
});
},
end:function(){
$that.removeClass('layui-disabled');
$that.removeAttr('disabled');
layer.closeAll();
}
});
return false;
});
});
</script>
{/block}
\ No newline at end of file
......@@ -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>
......
......@@ -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;">
......@@ -55,19 +57,19 @@
<table class="layui-table" lay-filter="useage" lay-data="{ url:'/useage', page:true, id:'idTest',where:{search_type:document.getElementById('search_type').value,search_text:document.getElementById('search_text').value,date_start:document.getElementById('date_start').value,date_end:document.getElementById('date_end').value,cp_date:document.getElementById('cp_date').value,status:document.getElementById('useage_status').value} }">
<thead>
<tr>
<th lay-data="{templet: '#useage_id',sort: true} ">抄表单号</th>
<th lay-data="{field:'station_name'}">所属基站名</th>
<th lay-data="{field:'em_numb'} ">所属电表号</th>
<th lay-data="{field:'last_date',sort: true}">上次日期</th>
<th lay-data="{field:'current_date',sort: true}">本次日期</th>
<th lay-data="{templet: '#useage_id',sort: true,width:'12%'} ">抄表单号</th>
<th lay-data="{field:'station_name',width:'12%'}">所属基站名</th>
<th lay-data="{field:'em_numb',width:'8%'} ">所属电表号</th>
<th lay-data="{field:'last_date',sort: true,width:'9%'}">上次日期</th>
<th lay-data="{field:'current_date',sort: true,width:'9%'}">本次日期</th>
<th lay-data="{field:'last_sum_numb'}">上次度数</th>
<th lay-data="{field:'current_sum_numb'}">本次度数</th>
<th lay-data="{field:'repo_numb'}">用电量</th>
<th lay-data="{templet: '#status',sort: true}">状态</th>
<th lay-data="{field:'last_sum_numb',width:'7%'}">上次度数</th>
<th lay-data="{field:'current_sum_numb',width:'7%'}">本次度数</th>
<th lay-data="{field:'repo_numb',width:'7%'}">用电量</th>
<th lay-data="{templet: '#status',sort: true,width:'5%'}">状态</th>
<th lay-data="{templet: '#photo_id',sort: true}">抄表凭证</th>
<th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}">操作</th>
<th lay-data="{templet: '#photo_id',sort: true,width:'7%'}">抄表凭证</th>
<th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo',width:'16%'}">操作</th>
</tr>
</thead>
</table>
......@@ -92,17 +94,27 @@
<script type="text/html" id="status">
{{# if(d.status == 2){ }}
<span class="layui-bg-blue">已审核</span>
{{# }else { }}
{{# } }}
{{# if(d.status == 3){ }}
<span class="layui-bg-orange" title="{{ d.info }}">被驳回</span>
{{# } }}
{{# if(d.status < 2){ }}
<span class="layui-bg-green">未审核</span>
{{# } }}
</script>
{if $admin == true}
<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>
{{# } }}
</script>
{/if}
<script>
layui.use(['laydate','form','table'], function(){
var laydate = layui.laydate,
......@@ -130,13 +142,13 @@
dataType: "json",
success: function (data) {
if(data.status == 1){
layer.msg(data.message,{icon: 6,time: 2000},function(){
layer.msg(data.message,{icon: 6,time: 4000},function(){
obj.del();
layer.close(index);
location.reload()
})
} else {
layer.msg(data.message,{icon: 5,time: 1000 })
layer.msg(data.message,{icon: 5,time: 5000 })
}
}
});
......
......@@ -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
{extend name="public:base" /}
{block name="body"}
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<form class="layui-form">
<div class="layui-form-box">
<div class="layui-form-head">
<div class="layui-form-item">
<label class="layui-form-label">
基本信息
</label>
</div>
</div>
<div class="layui-form-body">
<div class="layui-row">
<div class="layui-col-md5">
<div class="layui-form-item">
<label class="layui-form-label">
基站编号
</label>
<div class="layui-input-inline">
<input type="text" name="station_sp_code" autocomplete="off"
class="layui-input" value="{$station.station_sp_code|default=''}" 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" name="station_name" autocomplete="off" class="layui-input" value="{$station.station_name|default=''}"
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" name="project_number" autocomplete="off"
class="layui-input" value="{$em.type.name|default=''}" 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" name="project_number" autocomplete="off"
class="layui-input" value="{$em.em_numb|default=''}" 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="rate" name="rate" autocomplete="off"
class="layui-input" value="{$em.rate}" disabled="disabled">
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<form class="layui-form">
<input type="hidden" name="em_id" value="{$em.id}">
<input type="hidden" name="charge_type" value="{$em.rule.charge_type}">
<input type="hidden" name="pricing_type" value="{$em.rule.pricing_type}">
<input type="hidden" name="useage_id" value="{$useage.useage_id|default=''}">
<div class="layui-form-box">
<div class="layui-form-head">
<div class="layui-form-item">
<label class="layui-form-label">
抄表信息
</label>
</div>
</div>
<div class="layui-form-body">
<div class="layui-row">
<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="{$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="current_date" name="current_date"
autocomplete="off" class="layui-input" value="{$useage.current_date}" {if $useage.status neq 3} disabled="disabled" {/if} >
</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="last_numb" name="last_numb"
autocomplete="off" class="layui-input" disabled="disabled" value="{$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_numb" name="current_numb"
autocomplete="off" class="layui-input" value="{$useage.current_sum_numb}" {if $useage.status neq 3} disabled="disabled" {/if} >
</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">
用电量
</label>
<div class="layui-input-inline">
<input type="text" id="repo_numb" name="repo_numb" autocomplete="off" class="layui-input" value="{$useage.repo_numb}" disabled="disabled">
</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">
单价
</label>
<div class="layui-input-inline">
<input type="text" id="price" name="price" autocomplete="off" class="layui-input" {if $useage.status neq 3} disabled="disabled" {/if} 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">
<span class="x-red">*</span>抄表员
</label>
<div class="layui-input-inline">
<select name="staff_id" {if $useage.status neq 3} disabled="disabled" {/if}>
{foreach $staffs as $u}
<option value="{$u['id']}" {if $u['id'] == $uid} selected {/if}>{$u['name']}</option>
{/foreach}
</select>
</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">
<button type="button" class="layui-btn" id="up_photo" {if $useage.status==2} disabled="disabled" {/if}>
<i class="layui-icon"></i>上传
</button>
<input type="hidden" name="photo_id" value="{$useage.photo_id}">
<a href="{$useage.photo.src}" target="_blank" class="layui-btn {if empty($useage.photo_id)} layui-hide {/if}">
<i class="layui-icon">&#xe64a;</i>预览
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="layui-form-item layui-col-md-offset4">
<a href="/useage" class="layui-btn">
返回
</a>
<button class="layui-btn" lay-filter="save" lay-submit="">
保存
</button>
</div>
</form>
</div>
</div>
</div>
{/block}
{block name="js"}
<script>
//初始化Layui控件
layui.use(['form', 'layer', 'laydate', 'upload'],
function () {
$ = layui.jquery;
var form = layui.form,
layer = layui.layer,
laydate = layui.laydate,
upload = layui.upload;
//消息提示
function layMsg(msg,type=6,time=1000){
layer.msg(msg,{
icon: type,
time: time,
});
}
laydate.render({
elem:'#current_date',
trigger:'click',
})
//保存抄表单,并且返回列表
form.on('submit(save)',
function (data) {
$.ajax({
url: '/useage_add',
method: "POST",
data: data.field,
dataType: "json",
success: function (data) {
if (data.status == 1) {
layer.msg(data.message,{icon: 6,time: 4000},function(){
window.location.href='/useage';
})
} else {
layer.msg(data.message,{icon: 5,time: 5000 })
}
}
});
return false;
});
//上传电表照片
var upPhoto = upload.render({
elem: '#up_photo' ,
url: '/upFile',
field: 'up_file',
accept: 'file',
size:10240,
done: function (res) {
if(res.status == 1){
layMsg(res.message)
//将电表照片的ID填写
var $photoId = $("input[name='photo_id']")
$photoId.val(res.data.id)
var $a = $photoId.next('a');
$a.removeClass('layui-hide')
$a.attr('href',res.data.src);
}
else {
layMsg(res.message,5)
return;
}
}
});
$('#current_numb').change(function(){
var $level = 100000;
var $rate = $('#rate').val();
var $baseNum = $level*$rate;
var $rNum = $(this).val()*$baseNum - $('#last_numb').val()*$baseNum;
if($rNum < 0){
layMsg('本次抄表必须大于上次抄表读数',5);
$('#current_numb').focus();
} else{
$('#repo_numb').val( $rNum/$level )
}
})
});
</script>
{/block}
\ No newline at end of file
<?php
//配置文件
return [
//加密串
'passwd_salt' => 'gonn',
'passwd_init' => 'gonn',
'encrypt_key' => 'INJq4HXEGI',
'login_pattern' => '/^\w{2,}@\w+/', //开放模式
//'login_pattern' => '/^\w{2,}@gonn\.com\.cn$', 严格模式
'upload_dir' => './static/uploads',
'images_dir' => './static/uploads/images',
'files_dir' => './static/uploads/files',
'search_area' => '1', //1按部门搜索,2全局
'order_per' =>'ZD',
];
\ No newline at end of file
<?php
//配置文件
return [
//加密串
'passwd_salt' => 'gonn',
'passwd_init' => 'gonn',
'encrypt_key' => 'INJq4HXEGI',
'login_pattern' => '/^\w{2,}@\w+/', //开放模式
//'login_pattern' => '/^\w{2,}@gonn\.com\.cn$', 严格模式
'upload_dir' => './static/uploads',
'images_dir' => './static/uploads/images',
'files_dir' => './static/uploads/files',
'search_area' => '1', //1按部门搜索,2全局
'order_per' =>'ZD',
'redis_host' => '192.168.1.222',
'redis_port' => 6379,
'base_url' => 'http://oa.gonn.com.cn/?m=login',
];
......@@ -2,7 +2,7 @@ let userIdLocal = document.cookie.split('user=')[1]?(document.cookie.split('user
let temp = sessionStorage.getItem('userIdLocal')?sessionStorage.getItem('userIdLocal'):''
if(userIdLocal == '') top.location.href="http://oa.gonn.com.cn/";
if(userIdLocal == '') top.location.href="http://oa-test.gonn.tech/";
if ( temp != userIdLocal || !sessionStorage.getItem('userToken')){
sessionStorage.setItem("userIdLocal", userIdLocal)
......
......@@ -147,6 +147,8 @@ 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::get('useage_update/:useage_id','em/useage/update');
Route::post('upFile','em/UploadFile/upFile');
......
......@@ -28,4 +28,6 @@ Route::get('/v1/source','api/v1.supplier.Assign/getSource'); //需求来源信
Route::get('/v1/customers','api/v1.supplier.Assign/getCustomers'); //上游客户信息
//基站状态
Route::get('/v1/basestate','api/v1.supplier.Assign/getBasestate'); //基站状态信息
\ No newline at end of file
Route::get('/v1/basestate','api/v1.supplier.Assign/getBasestate'); //基站状态信息
Route::get('/v1/permission','api/v1.supplier.Assign/getDataPermission'); //获取项目数据权限
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论