Commit d7eda654 authored by 冯超鹏's avatar 冯超鹏

提交新功能

parent 1da5945d
Pipeline #30 failed with stages
......@@ -170,15 +170,20 @@ class DevicesController extends Controller
->where('dtype','=',$type)
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->join('device_type as dy',"device.dtype",'=','dy.tid')
->join('gas as g',"device.status",'=','g.id')
->join('status as p',"device.devicepolice",'=','p.status')
->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')
->select('dy.tname','g.gas','device.*','p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
return $devicelist;
$count = $databadevice
->where('dtype','=',$type)
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
}
//返回用户设备列表
......@@ -189,19 +194,68 @@ class DevicesController extends Controller
->where('uid','=',Auth::id())
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->join('device_type as dy',"device.dtype",'=','dy.tid')
->join('gas as g',"device.status",'=','g.id')
->join('status as p',"device.devicepolice",'=','p.status')
->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')
->select('dy.tname','g.gas','device.*','p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
return $devicelist;
$count = $databadevice
->where('dtype','=',$type)
->where('uid','=',Auth::id())
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
}
private function deviceDataSearchData($devicenum,$pagenNum,$limit) : array {
$databadevice = DB::table('device');
$devicelist = $databadevice
->where('devicenum','=',$devicenum)
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->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')
->select('dy.tname','g.gas','device.*','p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->where('dtype','=',$devicenum)
->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
}
//批量上传设备
public function batchdevice(){
}
//获取设备详情信息
public function deviceDataInfo($id){
$devicedata = Device::where('device.id','=',$id)
->leftjoin('contactsuser as c','c.contactsid','=','device.contactsid')
->select('c.*','device.deviceuuid','device.devicelinkman','device.devicephone','device.devicecoord')
->get();
$devicedatainfo = Device::where('id','=',$id)
->select('deviceuuid','devicelinkman','devicephone','devicecoord')
->get();
return $this->jsonSuccessData(['devicedata'=>$devicedata,'devicedatainfo'=>$devicedatainfo]);
}
//搜索设备账号
public function deviceDataSearch(Request $request){
$data = $request->input('deviceName');
$pagenNum=$request->input('page')-1;//页数
$limit = $request->input('limit');
if($pagenNum === '' || $limit == '' || $data == ''){
return $this->jsonErrorData(105,'请求参数不能为空');
}
return $this->jsonSuccessData($this->deviceDataSearchData($data,$pagenNum,$limit));
}
//推送获取数据监测数据
public function equipment(){
......
......@@ -264,24 +264,84 @@ class UserController extends Controller
return $this->jsonErrorData(105, 'page不能为空');
}
if (is_null($limit)) {
return $this->jsonErrorData(105, 'limt不能为空');
return $this->jsonErrorData(105, 'limit不能为空');
}
$users = DB::table('BackgroundUser as b')
->where('b.state', '=', '2')
->join('areachina as p', 'b.provinceid', '=', 'p.areaid')
->join('areachina as c', 'b.cityid', '=', 'c.areaid')
->join('areachina as a', 'b.areaid', '=', 'a.areaid')
->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid')
->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid')
->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid')
->orderBy('b.id', 'desc')
->select('b.username', 'b.nickname', 'b.email', 'b.state', 'a.area_name as area', 'c.area_name as city', 'p.area_name as province')
->select('b.username','b.id', 'b.add_time' , 'b.nickname', 'b.email', 'b.state', 'a.area_name as area', 'c.area_name as city', 'p.area_name as province')
->offset($pagenNum)
->limit($limit)
->get();
$count = DB::table('BackgroundUser')->where('state', '=', '2')->count();
$davicenum = DB::table('BackgroundUser')
->where('state', '=', '2')
->select('id')
->get()->toArray();
$data = [];
foreach (array_column($davicenum, 'id') as $k=>$value){
$countdevice_type = DB::table('device')
->where('uid','=',$value)
->count();
$usernum['count'] =$countdevice_type;
$usernum['id'] = $value;
array_push($data,$usernum);
}
$data = ['users' =>$users,'count'=>$count,'davicenum'=>$data];
if ($users) {
return $this->jsonSuccessData($users);
return $this->jsonSuccessData($data);
} else {
return $this->jsonErrorData(105, '获取失败');
}
}
//用户搜索
public function userSeek(Request $request){
$keys = $request->all();
$handle = DB::table('BackgroundUser as b');
foreach ($keys as $key => $val) {
if ($key == 'page') {
unset($keys[$key]);
} elseif ($key == 'limit'){
unset($keys[$key]);
}
}
foreach ($keys as $k => $v) {
if ($v == '正常'){
$v = 2;
}else if ($v == '禁用'){
$v = 3;
}else if ($v == '已删除'){
$v = 1;
}
$keys[$key] && $handle->where('b.'.$k, 'like', '%' . $v . '%');
}
$datas = $handle
->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid')
->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid')
->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid')
->orderBy('b.id', 'desc')
->select('b.username','b.id', 'b.add_time' , 'b.nickname', 'b.email', 'b.state', 'a.area_name as area', 'c.area_name as city', 'p.area_name as province')
->get();
$davicenum = DB::table('BackgroundUser')
->where('state', '=', '2')
->select('id')
->get()->toArray();
$data = [];
foreach (array_column($davicenum, 'id') as $k=>$value){
$countdevice_type = DB::table('device')
->where('uid','=',$value)
->count();
$usernum['count'] =$countdevice_type;
$usernum['id'] = $value;
array_push($data,$usernum);
}
$cont = $handle->count();
$data = ['users'=>$datas,'count'=>$cont,'davicenum'=>$data];
return $this->jsonSuccessData($data);
}
//新增用户
public function addUser(Request $request)
......
......@@ -64,7 +64,7 @@ class WxuserController extends Controller
}else if ($k == 'state'){
if ($v == '正常'){
$v = 2;
}else if ('禁用'){
}else if ($v == '禁用'){
$v = 1;
}
}
......
import request from '@/utils/request';
export function deviceTypeList() { // 设备类型
return request({
url: 'devices/devicetype',
method: 'get',
});
}
export function deviceList(page, limit, type) {
return request({
url: 'devices/devicelist?page=' + page + '&limit=' + limit + '&type=' + type,
method: 'get',
});
}
export function deviceDataInfo(id) {
return request({
url: '/devices/deviceDataInfo/' + id,
method: 'get',
});
}
export function deviceDataSearch(data) {
return request({
url: '/devices/deviceDataSearch',
method: 'post',
data,
});
}
import request from '@/utils/request';
export function userList(limit, page,) { // 用户列表
return request({
url: 'user/HUserList?page=' + page + '&limit=' + limit,
method: 'get',
});
}
export function userDelete(data) {
return request({
url: 'user/deleteuser',
method: 'post',
data,
});
}
export function deviceDataInfo(id) {
return request({
url: '/devices/deviceDataInfo/' + id,
method: 'get',
});
}
export function userSeek(data) {
return request({
url: '/user/userSeek',
method: 'post',
data,
});
}
......@@ -19,6 +19,7 @@ import chartsRoutes from './modules/charts';
import tableRoutes from './modules/table';
import adminRoutes from './modules/admin';
import deviceRoutes from './modules/device';
import usersRoutes from './modules/users';
import nestedRoutes from './modules/nested';
import errorRoutes from './modules/error';
import excelRoutes from './modules/excel';
......@@ -130,6 +131,7 @@ export const asyncRoutes = [
tableRoutes,
adminRoutes,
deviceRoutes,
usersRoutes,
{
path: '/theme',
component: Layout,
......
......@@ -4,10 +4,10 @@ const deviceRoutes = {
path: '/device',
component: Layout,
redirect: '/device/index',
name: 'Device',
name: 'Devices',
alwaysShow: true,
meta: {
title: 'device',
title: '设备管理',
icon: 'device',
permissions: ['view menu administrator'],
},
......@@ -16,7 +16,7 @@ const deviceRoutes = {
path: 'device',
component: () => import('@/views/device/index'),
name: 'Device',
meta: { title: '设备管理', icon: 'devicelist', permissions: ['manage user'] },
meta: { title: '设备列表', icon: 'devicelist', permissions: ['manage user'] },
},
],
};
......
import Layout from '@/layout';
const usersRoutes = {
path: '/users',
component: Layout,
redirect: '/user/index',
name: 'users',
alwaysShow: true,
meta: {
title: '用户管理',
icon: 'peoples',
permissions: ['view menu administrator'],
},
children: [
{
path: 'userlist',
component: () => import('@/views/user/index'),
name: 'Userlist',
meta: { title: '用户列表', icon: 'user', permissions: ['manage user'] },
},
],
};
export default usersRoutes;
<template>
<div></div>
<div class="app-container">
<div class="filter-container">
<el-form ref="query" :model="deviceSearch" style="display: inline-block;">
<el-input v-model="deviceSearch.deviceName" placeholder="用户名称" style="width: 200px;" class="filter-item" name="userskk" />
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
{{ $t('table.search') }}
</el-button>
</el-form>
<el-button v-if="device != '' " v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
{{ $t('table.export') }}
</el-button>
</div>
<el-tabs v-model="activeName" stretch @tab-click="handleClick">
<el-tab-pane v-for="item in list" :key="item.tid" :label="item.tname" :tid="item.tid" :name="item.tid==1 ? 'second' : list.tid"></el-tab-pane>
</el-tabs>
<el-table :key="tableKey" v-loading="loading" :data="device" border fit highlight-current-rows>
<el-table-column align="center" label="id" width="80">
<template slot-scope="scope">
<span style="color: #409EFF;" @click="deviceinfo(scope.row.id)">{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备编号" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备类型" width="150">
<template slot-scope="scope">
<span>{{ scope.row.tname }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="介质状态" width="170">
<template slot-scope="scope">
<span>{{ scope.row.gas }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备名称" width="170">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="浓度" width="170">
<template slot-scope="scope">
<span>{{ scope.row.nd }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="是否已删除设备" width="170">
<template slot-scope="scope">
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==1 ? '设备已删除' : '设备正常' }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备备注" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceremark }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备详情" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceinfo }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.deviceaddtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="设备实时状态" width="170">
<template slot-scope="scope">
<span>
<el-tag :type=" scope.row.status_name=='正常' ? 'success' : 'warning' " effect="dark">{{ scope.row.status_name }}</el-tag>
</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="170">
<template slot-scope="scope">
<span :style="{color:( scope.row.devicestatus==1 ? '#67C23A' : '#F56C6C' )}">{{ scope.row.devicestatus==1 ? '正常' : '设备错误' }}</span>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="page" :limit.sync="limit" @pagination="getList" />
<el-dialog :visible.sync="dialogPvVisible" title="设备详情信息" width="50%">
<el-table :data="devicefistr">
<el-table-column type="expand">
<template>
<el-form v-for="item in deviceDataInfo" :key="item.id" label-position="left" inline class="demo-table-expand">
<el-form-item label="姓名">
<span>{{ item.contacts_name }}</span>
</el-form-item>
<el-form-item label="手机号">
<span @click="handleCopyphone(item.contacts_phone,$event)">{{ item.contacts_phone }}</span>
</el-form-item>
<el-form-item label="添加用户">
<span>{{ item.isadmin==1 ? '管理员' : '用户' }}</span>
</el-form-item>
<el-form-item label="状态">
<span :style="{color:( item.isstatus==1 ? '#67C23A' : '#F56C6C' )}">{{ item.isstatus==1 ? '开启' : '禁用' }}</span>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column label="设备uuid" prop="deviceuuid"></el-table-column>
<el-table-column label="设备联系人" prop="devicelinkman"></el-table-column>
<el-table-column label="设备手机号" prop="devicephone"></el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
import { deviceTypeList, deviceList, deviceDataInfo, deviceDataSearch } from '@/api/device';
import Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard';
import { parseTime } from '@/utils';
export default {
name: 'Devicetype',
components: { Pagination },
directives: { waves },
data() {
return {
tableKey: 0,
downloadLoading: false,
pvData: [],
dialogPvVisible: false,
activeName: 'second',
list: [],
loading: true,
device: [],
deviceDataInfo: [],
devicefistr: [],
page: 1,
deviceSearch: {
deviceName: '',
limit: 10,
page: 1,
},
limit: 10,
type: '',
total: 0,
};
},
created() {
this.getList(); // 设备状态
this.devicelist();
},
methods: {
getList() {
deviceTypeList()
.then(response => {
var devicetype = response.data;
this.list = devicetype['devicetype'];
})
.catch(err => {
console.log(err);
});
},
devicelist() {
const limit = this.limit;
const page = this.page;
this.loading = true;
deviceList(page, limit, this.type)
.then(response => {
var devicetype = response.data['devicelist'];
this.device = devicetype;
this.device.forEach((element, index) => {
element['index'] = (page - 1) * limit + index + 1;
});
this.total = response.data.count;
this.loading = false;
})
.catch(err => {
console.log(err);
});
},
handleClick(tab) {
this.type = tab.$attrs.tid;
this.devicelist();
},
handleCopy(text, event) {
clip(text, event);
},
deviceinfo(row) {
this.dialogPvVisible = true;
this.deviceData(row);
},
deviceData(id){
deviceDataInfo(id)
.then(response => {
var deviceData = response.data['devicedata'];
this.deviceDataInfo = deviceData;
this.devicefistr = response.data['devicedatainfo'];
})
.catch(err => {
console.log(err);
});
},
handleCopyphone(text, event){
clip(text, event);
},
handleDownload() {
this.downloadLoading = true;
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id', '设备编号', '设备名称', '设备类型', '介质状态', '设备备注', '添加时间', '设备实时状态', '是否已删除设备'];
const filterVal = ['id', 'devicenum', 'username', 'tname', 'gas', 'deviceremark', 'deviceaddtime', 'status_name', 'delete'];
const data = this.formatJson(filterVal, this.device);
excel.export_json_to_excel({
header: tHeader,
data,
filename: '设备列表',
});
this.downloadLoading = false;
});
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'deviceaddtime') {
return parseTime(v[j]);
} else if (j === 'delete') {
return v[j] === 1 ? '已删除' : '正常';
} else {
return v[j];
}
}));
},
handleSubmit() {
deviceDataSearch(this.deviceSearch)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
this.devicelist();
}
var deviceData = response.data['devicelist'];
this.device.forEach((element, index) => {
element['index'] = (this.deviceSearch.page - 1) * this.deviceSearch.limit + index + 1;
});
this.device = deviceData;
this.total = response.data.count;
})
.catch(err => {
console.log(err);
});
},
},
};
</script>
<style>
.demo-table-expand {
font-size: 0;
}
.demo-table-expand label {
width: 90px;
color: #99a9bf;
}
.demo-table-expand .el-form-item {
margin-right: 0;
margin-bottom: 0;
width: 50%;
}
</style>
......@@ -133,7 +133,6 @@
</el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="dialogPvVisible" title="Reading statistics">
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
<el-table-column prop="key" label="Channel" />
......@@ -376,3 +375,4 @@ export default {
},
};
</script>
<template>
<div class="app-container">
<div class="filter-container">
<el-form ref="query" :model="userdata" style="display: inline-block;">
<el-input v-model="userdata.nickname" placeholder="用户名称" style="width: 200px;" class="filter-item" name="userskk" />
<el-select v-model="userdata.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOne">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
{{ $t('table.search') }}
</el-button>
</el-form>
<el-button v-if="userList != '' " v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
{{ $t('table.export') }}
</el-button>
</div>
<el-table :key="tableKey" v-loading="loading" :data="userList" border fit highlight-current-rows>
<el-table-column align="center" label="id" width="80">
<template slot-scope="scope">
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="账号名称" width="150">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户名称" width="150">
<template slot-scope="scope">
<span>{{ scope.row.nickname }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户邮箱" width="170">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.email,$event)">{{ scope.row.email }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户下设备数量" width="170">
<template slot-scope="scope">
<span v-for="item in userDaviceNum" :key="item.index">{{ scope.row.id==item.id ? item.count : '' }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户地址" width="170">
<template slot-scope="scope">
<span>{{ scope.row.province }}-{{ scope.row.area }}-{{ scope.row.city }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<template slot-scope="scope">
<span>{{ scope.row.add_time | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="170">
<template slot-scope="scope">
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : ( scope.row.state==3 ? '#909399' : '#67C23A' ) )}">{{ scope.row.state==1 ? '用户已被删除' : ( scope.row.state==3 ? '禁用' : '正常' ) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="userUpdate(scope.row.id)">编辑</el-button>
<el-popover width="160" trigger="click" placement="top">
<p>此删除,分丢弃废纸篓,和删除</p>
<div style="text-align: right; margin: 0">
<el-button size="mini" type="text" @click="userDelete(scope.row.id, 1)">丢弃废纸篓</el-button>
<el-button type="text" size="mini" @click="userDelete(scope.row.id, 2)">删除</el-button>
</div>
<el-button slot="reference" size="mini" type="danger">删除</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="userdata.page" :limit.sync="userdata.limit" @pagination="getUserList" />
<el-dialog :visible.sync="dialogPvVisible" title="编辑用户" width="100%" style="margin-top: auto;">
<el-form :model="upUserData" class="demo-ruleForm" status-icon>
<el-form-item label="账号名称" prop="username">
<el-input v-model.number="upUserData.username"></el-input>
</el-form-item>
<el-form-item label="用户名称" prop="nickname">
<el-input v-model.number="upUserData.nickname"></el-input>
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model.number="upUserData.email"></el-input>
</el-form-item>
<el-form-item label="自定义标题" prop="title">
<el-input v-model.number="upUserData.title"></el-input>
</el-form-item>
<el-form-item label="自定义公司名称" prop="company">
<el-input v-model.number="upUserData.company"></el-input>
</el-form-item>
<el-form-item label="密码" prop="pass">
<el-input v-model="upUserData.pass" type="password" autocomplete="off" show-password></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="checkPass">
<el-input v-model="upUserData.checkPass" type="password" autocomplete="off" show-password></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="resetForm()">重置</el-button>
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import { userList, userSeek, userDelete } from '@/api/users';
import Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard';
import { parseTime } from '@/utils';
export default {
name: 'UserData',
components: { Pagination },
directives: { waves },
data() {
return {
tableKey: 0,
downloadLoading: false,
dialogPvVisible: false,
userList: [],
userDaviceNum: [],
calendarTypeOptions: ['正常', '禁用', '已删除'],
total: 0,
userdata: {
limit: 10,
page: 1,
nickname: undefined,
state: undefined,
},
upUserData: {
password: undefined,
checkPass: undefined,
username: undefined,
nickname: undefined,
title: undefined,
email: undefined,
company: undefined,
},
};
},
created() {
this.getUserList(); // 用户列表
},
methods: {
getUserList() {
this.loading = true;
userList(this.userdata.limit, this.userdata.page)
.then(response => {
var userlistdata = response.data.users;
this.userList = userlistdata;
this.userList.forEach((element, index) => {
element['index'] = (this.userdata.page - 1) * this.userdata.limit + index + 1;
});
this.total = response.data.count;
this.userDaviceNum = response.data.davicenum;
this.loading = false;
})
.catch(err => {
console.log(err);
});
},
// 搜索
handleSubmit() {
userSeek(this.userdata)
.then(response => {
var userlistdata = response.data.users;
this.userList = userlistdata;
this.userList.forEach((element, index) => {
element['index'] = (this.userdata.page - 1) * this.userdata.limit + index + 1;
});
this.total = response.data.count;
this.userDaviceNum = response.data.davicenum;
})
.catch(err => {
console.log(err);
});
},
handleDownload() {
this.downloadLoading = true;
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id', '账号名称', '用户名称', '用户邮箱', '用户地址(省)', '用户地址(市)', '用户地址(区)', '创建时间', '状态'];
const filterVal = ['id', 'username', 'nickname', 'email', 'province', 'area', 'city', 'add_time', 'state'];
const data = this.formatJson(filterVal, this.userList);
excel.export_json_to_excel({
header: tHeader,
data,
filename: '用户列表',
});
this.downloadLoading = false;
});
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
if (j === 'add_time') {
return parseTime(v[j]);
} else if (j === 'state') {
return v[j] === 1 ? '用户已被删除' : (v[j] === 3 ? '禁用' : '正常');
} else {
return v[j];
}
}));
},
handleCopy(text, event) {
clip(text, event);
},
// 编辑
userUpdate(id) {
this.dialogPvVisible = true;
},
userDelete(id, type) {
var data = {
'duserid': id,
'type': type,
};
userDelete(data)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
this.getUserList();
}
})
.catch(err => {
console.log(err);
});
},
// 删除
selectOne(event, item) {
if (event === '') {
this.userdata.state = undefined;
}
},
// 重置
resetForm() {
for (const key in this.upUserData) {
this.upUserData[key] = undefined;
}
},
submitForm() {
},
},
};
</script>
<style>
</style>
......@@ -3,10 +3,10 @@
<div class="filter-container">
<el-form ref="query" :model="query" style="display: inline-block;">
<el-input v-model="query.nickname" placeholder="用户名称" style="width: 200px;" class="filter-item" name="userskk" />
<el-select v-model="query.sex" placeholder="性别" clearable style="width: 90px" class="filter-item">
<el-select v-model="query.sex" placeholder="性别" clearable style="width: 90px" class="filter-item" @change="selectOneSex">
<el-option v-for="item in importanceOptions" :key="item" :label="item" :value="item" />
</el-select>
<el-select v-model="query.state" placeholder="状态" clearable class="filter-item" style="width: 130px">
<el-select v-model="query.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOneState">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
......@@ -39,7 +39,7 @@
<el-table-column v-if="showReviewer" align="center" label="openid" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.openid,$event)">{{ scope.row.openid }}</span>
<span style="color: #909399;" @click="handleCopy(scope.row.openid,$event)">{{ scope.row.openid }}</span>
</template>
</el-table-column>
......@@ -65,7 +65,7 @@
</el-table-column>
<el-table-column align="center" label="状态" width="170">
<template slot-scope="scope">
<span>{{ scope.row.state==1 ? '禁用' : '正常' }}</span>
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.state==1 ? '禁用' : '正常' }}</span>
</template>
</el-table-column>
</el-table>
......@@ -166,6 +166,16 @@ export default {
this.total = data.cont;
this.loading = false;
},
selectOneSex(event, item) {
if (event === '') {
this.query.sex = undefined;
}
},
selectOneState(event, item) {
if (event === '') {
this.query.state = undefined;
}
},
},
};
</script>
......@@ -30,6 +30,8 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::get('wxuser/wxlist', 'WxuserController@wxlist');//微信用户列表
Route::post('wxuser/seek','WxuserController@seek');//微信搜索
Route::get('user/HUserList', 'UserController@HUserList');//用户列表
Route::post('user/userSeek', 'UserController@userSeek');//用户搜索
Route::post('user/addUser', 'UserController@addUser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//新增用户
Route::post('user/deleteuser','UserController@deleteuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除用户
Route::match(['get','post'],'user/Upuser','UserController@Upuser')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//更新用户
......@@ -52,6 +54,8 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/devicelist', 'DevicesController@devicelist');//设备列表
Route::get('devices/userdevicelist', 'DevicesController@userdevicelist');//用户设备列表
Route::get('devices/deviceDataInfo/{id}', 'DevicesController@deviceDataInfo');//设备详情
Route::post('devices/deviceDataSearch', 'DevicesController@deviceDataSearch');//设备搜索列表
Route::get('devices/devicetype','DevicesController@devicetype');//设备类型
Route::post('devices/deletedecice','DevicesController@deletedecice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除设备
Route::post('devices/adddevice','DevicesController@adddevice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//新增设备
......@@ -60,7 +64,6 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/equipment','DevicesController@equipment');//获取设备监测列表
Route::get('devices/police','DevicesController@police');//获取设备当前报警列表
});
//装维中心
......
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