Commit 1f10e656 authored by Administrator's avatar Administrator

分页bug

parent 36278252
Pipeline #107 failed with stages
...@@ -33,65 +33,7 @@ class SwooleCommandController extends Controller ...@@ -33,65 +33,7 @@ class SwooleCommandController extends Controller
*/ */
public function chemicals($data) public function chemicals($data)
{ {
$searchData = json_decode($data, true); return $this->getDevices($data, [1, 5, 10]);
$id = $searchData['userId'];
$uid = $this->parseAbilityAndArgumentsadmin($id);
$where = [];
$whereIn = [1, 5, 10];
if(!empty($searchData['deviceNum'])) {
$where[] = ['devicenum', 'like', "%{$searchData['deviceNum']}%"];
}
if(!empty($searchData['deviceName'])) {
$where[] = ['username', 'like', "%{$searchData['deviceName']}%"];
}
if($searchData['deviceType'] != 0) {
$whereIn = [$searchData['deviceType']];
}
if($searchData['deviceStatus'] != 0) {
$where[] = ['device.devicepolice', '=', $searchData['deviceStatus']];
}
$limit = $searchData['limit'];
$pagenNum = $limit * ($searchData['page'] - 1);//页数
if($uid == 1){
$devicelist = DB::table('device')
->whereIn('dtype', $whereIn)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->where($where)
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc')
->get()->toArray();
$count = DB::table('device')
->whereIn('dtype', $whereIn)
->where($where)
->count();
}else{
$devicelist = DB::table('device')
->whereIn('dtype', $whereIn)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->leftjoin('danwei as dw', 'device.devicemonad', '=', 'dw.id')
->where('device.uid','=',$id)
->where($where)
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'dw.danwei')
->offset($pagenNum)
->limit($limit)
->orderBy('device.id', 'desc')
->get()->toArray();
$count = DB::table('device')
->where('device.uid','=',$id)
->whereIn('dtype', $whereIn)
->where($where)
->count();
}
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
/** /**
...@@ -100,13 +42,18 @@ class SwooleCommandController extends Controller ...@@ -100,13 +42,18 @@ class SwooleCommandController extends Controller
* @return false|string * @return false|string
*/ */
public function fire($data) public function fire($data)
{
return $this->getDevices($data, [2, 4, 6, 7, 8, 9, 11]);
}
public function getDevices($data, $type_ids)
{ {
$searchData = json_decode($data, true); $searchData = json_decode($data, true);
$id = $searchData['userId']; $id = $searchData['userId'];
$uid = $this->parseAbilityAndArgumentsadmin($id); $uid = $this->parseAbilityAndArgumentsadmin($id);
$where = []; $where = [];
$whereIn = [2, 4, 6, 7, 8, 9, 11]; $whereIn = $type_ids;
if(!empty($searchData['deviceNum'])) { if(!empty($searchData['deviceNum'])) {
$where[] = ['devicenum', 'like', "%{$searchData['deviceNum']}%"]; $where[] = ['devicenum', 'like', "%{$searchData['deviceNum']}%"];
} }
......
...@@ -28,8 +28,8 @@ class DevicesController extends Controller ...@@ -28,8 +28,8 @@ class DevicesController extends Controller
public function devicelist(Request $request) public function devicelist(Request $request)
{ {
$type = $request->input('type');//设备类型id $type = $request->input('type');//设备类型id
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit'); $limit = $request->input('limit');
$pagenNum = $limit * ($request->input('page') - 1);//页数
if ($pagenNum === '' || $limit == '') { if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
} }
...@@ -45,8 +45,8 @@ class DevicesController extends Controller ...@@ -45,8 +45,8 @@ class DevicesController extends Controller
public function userdevicelist(Request $request) public function userdevicelist(Request $request)
{ {
$type = $request->input('type');//设备类型id $type = $request->input('type');//设备类型id
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit'); $limit = $request->input('limit');
$pagenNum = $limit * ($request->input('page') - 1);//页数
if ($pagenNum === '' || $limit == '') { if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
} }
...@@ -95,21 +95,20 @@ class DevicesController extends Controller ...@@ -95,21 +95,20 @@ class DevicesController extends Controller
public function physicsdelete(Request $request) public function physicsdelete(Request $request)
{ {
$deviceid = $request->input('deviceid'); $deviceid = $request->input('deviceid');
$databadevice = DB::table('device');
if ($_POST) { if ($_POST) {
$up = $databadevice $up = DB::table('device')
->where('id', '=', $deviceid) ->where('id', '=', $deviceid)
->update(['delete' => 2]); ->update(['delete' => 2]);
return $this->jsonSuccessData($up); return $this->jsonSuccessData($up);
} else { } else {
//返回物理删除设备列表 //返回物理删除设备列表
$type = (int)$request->input('type');//设备类型 $type = (int)$request->input('type');//设备类型
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');//条数 $limit = $request->input('limit');//条数
$pagenNum = $limit * ($request->input('page') - 1);//页数
if ($pagenNum === '' || $limit == '') { if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
} }
$devicelist = $databadevice $devicelist = DB::table('device')
->where('dtype', '=', $type == '' ? '1' : $type) ->where('dtype', '=', $type == '' ? '1' : $type)
->where('delete', '=', '1')//设备逻辑删除状态 ->where('delete', '=', '1')//设备逻辑删除状态
->join('device_type as dy', "device.dtype", '=', 'dy.tid') ->join('device_type as dy', "device.dtype", '=', 'dy.tid')
...@@ -201,8 +200,7 @@ class DevicesController extends Controller ...@@ -201,8 +200,7 @@ class DevicesController extends Controller
//返回设备列表 //返回设备列表
private function whertype($type, $pagenNum, $limit): array private function whertype($type, $pagenNum, $limit): array
{ {
$databadevice = DB::table('device'); $devicelist = DB::table('device')
$devicelist = $databadevice
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
...@@ -213,7 +211,7 @@ class DevicesController extends Controller ...@@ -213,7 +211,7 @@ class DevicesController extends Controller
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
...@@ -222,8 +220,7 @@ class DevicesController extends Controller ...@@ -222,8 +220,7 @@ class DevicesController extends Controller
//返回用户设备列表 //返回用户设备列表
private function userdevice($type, $pagenNum, $limit): array private function userdevice($type, $pagenNum, $limit): array
{ {
$databadevice = DB::table('device'); $devicelist = DB::table('device')
$devicelist = $databadevice
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
...@@ -235,7 +232,7 @@ class DevicesController extends Controller ...@@ -235,7 +232,7 @@ class DevicesController extends Controller
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('dtype', '=', $type) ->where('dtype', '=', $type)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
->count(); ->count();
...@@ -244,9 +241,8 @@ class DevicesController extends Controller ...@@ -244,9 +241,8 @@ class DevicesController extends Controller
private function deviceDataSearchData($devicenum, $pagenNum, $limit, $isuser): array private function deviceDataSearchData($devicenum, $pagenNum, $limit, $isuser): array
{ {
$databadevice = DB::table('device');
if ($isuser != '') { if ($isuser != '') {
$devicelist = $databadevice $devicelist = DB::table('device')
->where('devicenum', '=', $devicenum) ->where('devicenum', '=', $devicenum)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
...@@ -258,13 +254,13 @@ class DevicesController extends Controller ...@@ -258,13 +254,13 @@ class DevicesController extends Controller
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('dtype', '=', $devicenum) ->where('dtype', '=', $devicenum)
->where('uid', '=', Auth::id()) ->where('uid', '=', Auth::id())
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
} else { } else {
$devicelist = $databadevice $devicelist = DB::table('device')
->where('devicenum', '=', $devicenum) ->where('devicenum', '=', $devicenum)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
...@@ -275,7 +271,7 @@ class DevicesController extends Controller ...@@ -275,7 +271,7 @@ class DevicesController extends Controller
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = DB::table('device')
->where('dtype', '=', $devicenum) ->where('dtype', '=', $devicenum)
->count(); ->count();
return ['devicelist' => $devicelist, 'count' => $count]; return ['devicelist' => $devicelist, 'count' => $count];
...@@ -317,8 +313,8 @@ class DevicesController extends Controller ...@@ -317,8 +313,8 @@ class DevicesController extends Controller
public function deviceDataSearch(Request $request) public function deviceDataSearch(Request $request)
{ {
$data = $request->input('deviceName'); $data = $request->input('deviceName');
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit'); $limit = $request->input('limit');
$pagenNum = $limit * ($request->input('page') - 1);
$isuser = $request->input('isuser'); $isuser = $request->input('isuser');
if ($pagenNum === '' || $limit == '' || $data == '') { if ($pagenNum === '' || $limit == '' || $data == '') {
return $this->jsonErrorData(105, '请求参数不能为空'); return $this->jsonErrorData(105, '请求参数不能为空');
......
...@@ -18,8 +18,8 @@ class InstallerController extends Controller ...@@ -18,8 +18,8 @@ class InstallerController extends Controller
{ {
//装维人员列表 //装维人员列表
public function installerlist (Request $request){ public function installerlist (Request $request){
$pagenNum= (int)$request->input('page')-1;//页数
$limit = (int)$request->input('limit'); $limit = (int)$request->input('limit');
$pagenNum= $limit * ((int)$request->input('page')-1);//页数
$instllerdata = Installer::offset($pagenNum)->limit($limit)->get(); $instllerdata = Installer::offset($pagenNum)->limit($limit)->get();
$count = Installer::count(); $count = Installer::count();
return $this->jsonSuccessData(['instllerdata'=>$instllerdata,'count'=>$count]); return $this->jsonSuccessData(['instllerdata'=>$instllerdata,'count'=>$count]);
......
...@@ -447,18 +447,17 @@ class UserController extends Controller ...@@ -447,18 +447,17 @@ class UserController extends Controller
//返回地址列表 //返回地址列表
public function areachina(Request $request) public function areachina(Request $request)
{ {
$region = Db::table('areachina');
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
$areaid = $request->input('areaid'); $areaid = $request->input('areaid');
if ($areaid == '') { if ($areaid == '') {
return $this->jsonErrorData('105', '地区id不能为空'); return $this->jsonErrorData('105', '地区id不能为空');
} }
$area = $region->where('pid', '=', $areaid) $area = Db::table('areachina')->where('pid', '=', $areaid)
->where('status', '=', '1') ->where('status', '=', '1')
->select('area_name', 'areaid') ->select('area_name', 'areaid')
->get(); ->get();
} else { } else {
$area = $region->where('pid', '=', '0') $area = Db::table('areachina')->where('pid', '=', '0')
->where('status', '=', '1') ->where('status', '=', '1')
->select('area_name', 'areaid') ->select('area_name', 'areaid')
->get(); ->get();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Laravue\Models\wxUser; use App\Laravue\Models\WxUser;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
...@@ -24,14 +24,14 @@ class WxuserController extends Controller ...@@ -24,14 +24,14 @@ class WxuserController extends Controller
/* /*
* get请求返回wx用户列表 * get请求返回wx用户列表
* */ * */
$pagenNum=$request->input('page')-1;//页数
$limit = $request->input('limit');
$limit = $request->input('limit');
$pagenNum = $limit * ($request->input('page')-1);//页数
if($pagenNum === '' || $limit == ''){ if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空'); return $this->jsonErrorData(105,'页数或limit不能为空');
} }
$cont = Wxuser::count(); $cont = WxUser::count();
$Wxuser = Wxuser::select('nickname','id','openid','sex','province','city','mobile','country','headimgurl','created_at','state') $Wxuser = WxUser::select('nickname','id','openid','sex','province','city','mobile','country','headimgurl','created_at','state')
->offset($pagenNum) ->offset($pagenNum)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->limit($limit) ->limit($limit)
...@@ -46,7 +46,6 @@ class WxuserController extends Controller ...@@ -46,7 +46,6 @@ class WxuserController extends Controller
//用户搜索 //用户搜索
public function seek (Request $request){ public function seek (Request $request){
$keys = $request->all(); $keys = $request->all();
$handle = DB::table('wx_User');
foreach ($keys as $key => $val) { foreach ($keys as $key => $val) {
if ($key == 'page') { if ($key == 'page') {
unset($keys[$key]); unset($keys[$key]);
...@@ -68,11 +67,11 @@ class WxuserController extends Controller ...@@ -68,11 +67,11 @@ class WxuserController extends Controller
$v = 1; $v = 1;
} }
} }
$keys[$key] && $handle->where($k, 'like', '%' . $v . '%'); $keys[$key] && DB::table('wx_user')->where($k, 'like', '%' . $v . '%');
} }
$datas = $handle->get(); $datas = DB::table('wx_user')->get();
$cont = $handle->count(); $cont = DB::table('wx_user')->count();
$data = ['Wxuser'=>$datas,'cont'=>$cont]; $data = ['Wxuser'=>$datas,'cont'=>$cont];
return $this->jsonSuccessData($data); return $this->jsonSuccessData($data);
} }
......
...@@ -18,10 +18,10 @@ use Spatie\Permission\Traits\HasRoles; ...@@ -18,10 +18,10 @@ use Spatie\Permission\Traits\HasRoles;
* @method static User create(array $user) * @method static User create(array $user)
* @package App * @package App
*/ */
class wxUser extends Authenticatable class WxUser extends Authenticatable
{ {
use Notifiable, HasRoles, HasApiTokens; use Notifiable, HasRoles, HasApiTokens;
protected $table = "wx_User"; protected $table = 'wx_user';
public $timestamps = true; public $timestamps = true;
protected $dateFormat = 'Y-m-d H:i:s'; protected $dateFormat = 'Y-m-d H:i:s';
......
...@@ -8471,9 +8471,9 @@ ...@@ -8471,9 +8471,9 @@
"integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==" "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw=="
}, },
"js-base64": { "js-base64": {
"version": "2.5.2", "version": "3.4.1",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.2.tgz", "resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-3.4.1.tgz?cache=0&sync_timestamp=1596129779367&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-3.4.1.tgz",
"integrity": "sha512-Vg8czh0Q7sFBSUMWWArX/miJeBWYBPpdU/3M/DKSaekLMqrqVPaedp+5mZhie/r0lgrcaYBfwXatEew6gwgiQQ==" "integrity": "sha1-hFWYwq1+sx0zY8Jy1wcsWUYFK0E="
}, },
"js-cookie": { "js-cookie": {
"version": "2.2.1", "version": "2.2.1",
...@@ -12652,6 +12652,11 @@ ...@@ -12652,6 +12652,11 @@
"source-map": "^0.4.2" "source-map": "^0.4.2"
}, },
"dependencies": { "dependencies": {
"js-base64": {
"version": "2.6.3",
"resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.3.tgz?cache=0&sync_timestamp=1596129779367&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.3.tgz",
"integrity": "sha1-ev25tXqncX4V03C2bo82qcuDXcM="
},
"source-map": { "source-map": {
"version": "0.4.4", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
...@@ -13675,6 +13680,14 @@ ...@@ -13675,6 +13680,14 @@
"js-base64": "^2.1.9", "js-base64": "^2.1.9",
"source-map": "^0.5.6", "source-map": "^0.5.6",
"supports-color": "^3.2.3" "supports-color": "^3.2.3"
},
"dependencies": {
"js-base64": {
"version": "2.6.3",
"resolved": "https://registry.npm.taobao.org/js-base64/download/js-base64-2.6.3.tgz?cache=0&sync_timestamp=1596129779367&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-base64%2Fdownload%2Fjs-base64-2.6.3.tgz",
"integrity": "sha1-ev25tXqncX4V03C2bo82qcuDXcM=",
"dev": true
}
} }
}, },
"source-map": { "source-map": {
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
"file-loader": "^6.0.0", "file-loader": "^6.0.0",
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"fuse.js": "^3.6.1", "fuse.js": "^3.6.1",
"js-base64": "^3.4.1",
"js-cookie": "^2.2.1", "js-cookie": "^2.2.1",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"jszip": "^3.2.2", "jszip": "^3.2.2",
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="用户名称" width="150"> <el-table-column align="center" label="用户名称">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.nickname }}</span> <span>{{ scope.row.nickname | handeNickname }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<span>{{ scope.row.sex==1 ? '男' : '女' }}</span> <span>{{ scope.row.sex==1 ? '男' : '女' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="手机号" width="170"> <el-table-column align="center" label="手机号" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.mobile }}</span> <span>{{ scope.row.mobile }}</span>
</template> </template>
...@@ -79,11 +79,17 @@ import clip from '@/utils/clipboard'; ...@@ -79,11 +79,17 @@ import clip from '@/utils/clipboard';
import Pagination from '@/components/Pagination'; // 分页 import Pagination from '@/components/Pagination'; // 分页
import { parseTime } from '@/utils'; import { parseTime } from '@/utils';
import waves from '@/directive/waves'; // 水波纹效果 import waves from '@/directive/waves'; // 水波纹效果
const Base64 = require('js-base64').Base64;
const userResource = new UserResource(); const userResource = new UserResource();
export default { export default {
name: 'Wxuser', name: 'Wxuser',
components: { Pagination }, components: { Pagination },
directives: { waves }, directives: { waves },
filters: {
handeNickname: function(value) {
return Base64.decode(value);
},
},
data() { data() {
return { return {
total: 0, total: 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment