Commit 1f10e656 authored by Administrator's avatar Administrator

分页bug

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