Commit 913e35a9 authored by 冯超鹏's avatar 冯超鹏

改东西

parent ce7ff4fe
Pipeline #32 failed with stages
...@@ -168,8 +168,8 @@ class DevicesController extends Controller ...@@ -168,8 +168,8 @@ class DevicesController extends Controller
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
->where('dtype','=',$type) ->where('dtype','=',$type)
->where('delete','=','2')//设备不是删除状态 //->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->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')
->leftjoin('status as p',"device.devicepolice",'=','p.id') ->leftjoin('status as p',"device.devicepolice",'=','p.id')
...@@ -180,8 +180,8 @@ class DevicesController extends Controller ...@@ -180,8 +180,8 @@ class DevicesController extends Controller
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = $databadevice
->where('dtype','=',$type) ->where('dtype','=',$type)
->where('delete','=','2')//设备不是删除状态 //->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist'=>$devicelist,'count'=>$count]; return ['devicelist'=>$devicelist,'count'=>$count];
} }
...@@ -192,8 +192,8 @@ class DevicesController extends Controller ...@@ -192,8 +192,8 @@ class DevicesController extends Controller
$devicelist = $databadevice $devicelist = $databadevice
->where('dtype','=',$type) ->where('dtype','=',$type)
->where('uid','=',Auth::id()) ->where('uid','=',Auth::id())
->where('delete','=','2')//设备不是删除状态 //->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->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')
->leftjoin('status as p',"device.devicepolice",'=','p.id') ->leftjoin('status as p',"device.devicepolice",'=','p.id')
...@@ -205,8 +205,8 @@ class DevicesController extends Controller ...@@ -205,8 +205,8 @@ class DevicesController extends Controller
$count = $databadevice $count = $databadevice
->where('dtype','=',$type) ->where('dtype','=',$type)
->where('uid','=',Auth::id()) ->where('uid','=',Auth::id())
->where('delete','=','2')//设备不是删除状态 // ->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist'=>$devicelist,'count'=>$count]; return ['devicelist'=>$devicelist,'count'=>$count];
} }
...@@ -214,8 +214,8 @@ class DevicesController extends Controller ...@@ -214,8 +214,8 @@ class DevicesController extends Controller
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
->where('devicenum','=',$devicenum) ->where('devicenum','=',$devicenum)
->where('delete','=','2')//设备不是删除状态 //->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->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')
->leftjoin('status as p',"device.devicepolice",'=','p.id') ->leftjoin('status as p',"device.devicepolice",'=','p.id')
...@@ -226,8 +226,8 @@ class DevicesController extends Controller ...@@ -226,8 +226,8 @@ class DevicesController extends Controller
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = $databadevice
->where('dtype','=',$devicenum) ->where('dtype','=',$devicenum)
->where('delete','=','2')//设备不是删除状态 //->where('delete','=','2')//设备不是删除状态
->where('devicestatus','=','1')// //->where('devicestatus','=','1')//
->count(); ->count();
return ['devicelist'=>$devicelist,'count'=>$count]; return ['devicelist'=>$devicelist,'count'=>$count];
} }
......
...@@ -267,7 +267,7 @@ class UserController extends Controller ...@@ -267,7 +267,7 @@ class UserController extends Controller
return $this->jsonErrorData(105, 'limit不能为空'); return $this->jsonErrorData(105, 'limit不能为空');
} }
$users = DB::table('BackgroundUser as b') $users = DB::table('BackgroundUser as b')
->where('b.state', '=', '2') //->where('b.state', '>', '1')
->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid') ->leftjoin('areachina as p', 'b.provinceid', '=', 'p.areaid')
->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid') ->leftjoin('areachina as c', 'b.cityid', '=', 'c.areaid')
->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid') ->leftjoin('areachina as a', 'b.areaid', '=', 'a.areaid')
...@@ -276,9 +276,11 @@ class UserController extends Controller ...@@ -276,9 +276,11 @@ class UserController extends Controller
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
->get(); ->get();
$count = DB::table('BackgroundUser')->where('state', '=', '2')->count(); $count = DB::table('BackgroundUser')
//->where('state', '>', '1')
->count();
$davicenum = DB::table('BackgroundUser') $davicenum = DB::table('BackgroundUser')
->where('state', '=', '2') //->where('state', '>', '1')
->select('id') ->select('id')
->get()->toArray(); ->get()->toArray();
$data = []; $data = [];
...@@ -326,7 +328,7 @@ class UserController extends Controller ...@@ -326,7 +328,7 @@ class UserController extends Controller
->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') ->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(); ->get();
$davicenum = DB::table('BackgroundUser') $davicenum = DB::table('BackgroundUser')
->where('state', '=', '2') //->where('state', '>', '1')
->select('id') ->select('id')
->get()->toArray(); ->get()->toArray();
$data = []; $data = [];
...@@ -397,28 +399,23 @@ class UserController extends Controller ...@@ -397,28 +399,23 @@ class UserController extends Controller
//更新用户 //更新用户
public function Upuser(Request $request) public function Upuser(Request $request)
{ {
if ($_POST) { if ($request->isMethod('post')) {
$userdata = $request->all(); $userdata = $request->all();
$uid = $userdata['userid']; $uid = $userdata['userid'];
if (!isset($userdata['userid']) || $userdata['userid'] == '') { if (!isset($userdata['userid']) || $userdata['userid'] == '') {
return $this->jsonErrorData(105, '用户id不能为空'); return $this->jsonErrorData(105, '用户id不能为空');
} }
$validator = Validator::make($request->all(), $this->getValidationRulesuser(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
} else {
foreach ($userdata as $k => $v) { foreach ($userdata as $k => $v) {
if ($k == 'userid') { if ($k == 'userid') {
unset($userdata[$k]); unset($userdata[$k]);
} }
} }
$re = Users::where('id', '=', (int)$uid)->update($userdata); $re = Users::where('id', '=', (int)$uid)->update($userdata);
if ($re) { if ($re !== false) {
return $this->jsonSuccessData($re); return $this->jsonSuccessData($re);
} else { } else {
return $this->jsonErrorData(105, '更新失败'); return $this->jsonErrorData(105, '更新失败');
} }
}
} else { } else {
// 获取用户数据 // 获取用户数据
$userid = (int)$request->input('userid'); $userid = (int)$request->input('userid');
...@@ -427,7 +424,7 @@ class UserController extends Controller ...@@ -427,7 +424,7 @@ class UserController extends Controller
} }
$userdata = Users::where('id', '=', $userid) $userdata = Users::where('id', '=', $userid)
->select('username', 'nickname', 'email', 'title', 'company', 'mapcenter') ->select('username', 'nickname', 'email', 'title', 'company', 'mapcenter')
->where('state', '=', 2) // ->where('state', '>', '1')
->first(); ->first();
if ($userdata) { if ($userdata) {
return $this->jsonSuccessData($userdata); return $this->jsonSuccessData($userdata);
......
...@@ -15,9 +15,9 @@ export function userDelete(data) { ...@@ -15,9 +15,9 @@ export function userDelete(data) {
}); });
} }
export function deviceDataInfo(id) { export function userDataInfo(id) {
return request({ return request({
url: '/devices/deviceDataInfo/' + id, url: '/user/Upuser?userid=' + id,
method: 'get', method: 'get',
}); });
} }
...@@ -29,3 +29,11 @@ export function userSeek(data) { ...@@ -29,3 +29,11 @@ export function userSeek(data) {
data, data,
}); });
} }
export function postUpUser(data) {
return request({
url: '/user/Upuser',
method: 'post',
data,
});
}
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="是否已删除设备" width="170"> <el-table-column align="center" label="是否已删除设备" width="170">
<template slot-scope="scope"> <template slot-scope="scope">
<span :style="{color:( scope.row.state==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==1 ? '设备已删除' : '设备正常' }}</span> <span :style="{color:( scope.row.delete==1 ? '#F56C6C' : '#67C23A' )}">{{ scope.row.delete ==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="170">
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="170"> <el-table-column align="center" label="状态" width="170">
<template slot-scope="scope"> <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> <span :style="{color:( scope.row.state==1 ? '#F56C6C' : ( scope.row.state==3 ? '#909399' : '#67C23A' ) )}">{{ scope.row.state==1 ? '用户已被丢弃废纸篓' : ( scope.row.state==3 ? '禁用' : '正常' ) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="userdata.page" :limit.sync="userdata.limit" @pagination="getUserList" /> <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-dialog :visible.sync="dialogPvVisible" title="编辑用户" width="85%" style="margin-top: auto;">
<el-form :model="upUserData" class="demo-ruleForm" status-icon> <el-form :model="upUserData" class="demo-ruleForm" status-icon>
<el-form-item label="账号名称" prop="username"> <el-form-item label="账号名称" prop="username">
<el-input v-model.number="upUserData.username"></el-input> <el-input v-model.number="upUserData.username"></el-input>
...@@ -87,12 +87,6 @@ ...@@ -87,12 +87,6 @@
<el-form-item label="自定义公司名称" prop="company"> <el-form-item label="自定义公司名称" prop="company">
<el-input v-model.number="upUserData.company"></el-input> <el-input v-model.number="upUserData.company"></el-input>
</el-form-item> </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-form-item>
<el-button type="primary" @click="submitForm()">提交</el-button> <el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="resetForm()">重置</el-button> <el-button @click="resetForm()">重置</el-button>
...@@ -102,7 +96,7 @@ ...@@ -102,7 +96,7 @@
</div> </div>
</template> </template>
<script> <script>
import { userList, userSeek, userDelete } from '@/api/users'; import { userList, userSeek, userDelete, userDataInfo, postUpUser } from '@/api/users';
import Pagination from '@/components/Pagination'; // 分页 import Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果 import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard'; import clip from '@/utils/clipboard';
...@@ -127,13 +121,12 @@ export default { ...@@ -127,13 +121,12 @@ export default {
state: undefined, state: undefined,
}, },
upUserData: { upUserData: {
password: undefined,
checkPass: undefined,
username: undefined, username: undefined,
nickname: undefined, nickname: undefined,
title: undefined, title: undefined,
email: undefined, email: undefined,
company: undefined, company: undefined,
userid: undefined,
}, },
}; };
}, },
...@@ -205,6 +198,8 @@ export default { ...@@ -205,6 +198,8 @@ export default {
// 编辑 // 编辑
userUpdate(id) { userUpdate(id) {
this.dialogPvVisible = true; this.dialogPvVisible = true;
this.getuserDataInfo(id);
this.upUserData.userid = id;
}, },
userDelete(id, type) { userDelete(id, type) {
var data = { var data = {
...@@ -239,6 +234,47 @@ export default { ...@@ -239,6 +234,47 @@ export default {
} }
}, },
submitForm() { submitForm() {
postUpUser(this.upUserData)
.then(response => {
if (response.code === 105) {
this.$notify.error({
message: response.msg,
type: 'warning',
});
} else {
if (response.code === 200) {
this.dialogPvVisible = false;
this.getUserList();
}
}
})
.catch(err => {
console.log(err);
});
},
getuserDataInfo(id) {
userDataInfo(id)
.then(response => {
if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
} else {
for (const key in this.upUserData) {
for (const k in response.data) {
if (key === k) {
if (response.data[k] !== null) {
this.upUserData[key] = response.data[k];
}
}
}
}
}
})
.catch(err => {
console.log(err);
});
}, },
}, },
}; };
......
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