Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯超鹏
laravelzh
Commits
f4436f9c
Commit
f4436f9c
authored
Jun 30, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交设备编辑
parent
a3c5165f
Pipeline
#59
canceled with stages
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
226 additions
and
7 deletions
+226
-7
DevicesController.php
app/Http/Controllers/DevicesController.php
+14
-2
dump.rdb
dump.rdb
+0
-0
device.js
resources/js/api/device.js
+15
-0
index.vue
resources/js/views/device/index.vue
+102
-2
index.vue
resources/js/views/userdevice/index.vue
+94
-2
api.php
routes/api.php
+1
-1
No files found.
app/Http/Controllers/DevicesController.php
View file @
f4436f9c
...
...
@@ -152,16 +152,27 @@ class DevicesController extends Controller
if
(
is_null
(
$deid
))
{
return
$this
->
jsonErrorData
(
105
,
'设备ID不能为空'
);
}
if
(
$
_POST
)
{
if
(
$
request
->
isMethod
(
'post'
)
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
$this
->
getValidationRulesupdevice
(
false
));
if
(
$validator
->
fails
())
{
return
response
()
->
json
([
'errors'
=>
$validator
->
errors
()],
403
);
}
$data
[
'dtype'
]
=
$request
->
input
(
'tid'
);
foreach
(
$data
as
$k
=>
$v
)
{
if
(
$k
==
'deid'
)
{
unset
(
$data
[
$k
]);
}
if
(
$k
==
'tid'
)
{
unset
(
$data
[
$k
]);
}
if
(
$k
==
'name'
)
{
unset
(
$data
[
$k
]);
}
if
(
$k
==
'devicenum'
)
{
unset
(
$data
[
$k
]);
}
}
$this
->
timeline
(
'编辑了设备[设备id'
.
$deid
.
']'
);
return
$this
->
jsonSuccessData
(
Device
::
where
(
'id'
,
'='
,
$deid
)
->
update
(
$data
));
}
else
{
...
...
@@ -170,7 +181,8 @@ class DevicesController extends Controller
->
leftjoin
(
'device_type as dt'
,
'de.dtype'
,
'='
,
'dt.tid'
)
->
leftjoin
(
'gas'
,
'de.status'
,
'='
,
'gas.id'
)
->
leftjoin
(
'danwei as da'
,
'de.devicemonad'
,
'='
,
'da.id'
)
->
select
(
'dt.*'
,
'gas.*'
,
'da.*'
,
'de.*'
)
->
leftjoin
(
'users as ud'
,
'de.uid'
,
'='
,
'ud.id'
)
->
select
(
'dt.tid'
,
'ud.name'
,
'de.username'
,
'de.deviceremark'
,
'de.devicelinkman'
,
'de.devicephone'
,
'de.deviceinfo'
,
'de.devicecoord'
,
'de.uid'
,
'de.devicenum'
)
->
first
();
return
$this
->
jsonSuccessData
(
$devi
);
}
...
...
dump.rdb
View file @
f4436f9c
No preview for this file type
resources/js/api/device.js
View file @
f4436f9c
...
...
@@ -136,3 +136,18 @@ export function userdeviceList(data) {
data
,
});
}
export
function
postupdatedevice
(
id
)
{
return
request
({
url
:
'/devices/updatedevice?deid='
+
id
,
method
:
'get'
,
});
}
export
function
updedata
(
data
)
{
return
request
({
url
:
'/devices/updatedevice'
,
method
:
'post'
,
data
,
});
}
resources/js/views/device/index.vue
View file @
f4436f9c
...
...
@@ -96,7 +96,7 @@
<
span
v
-
if
=
"scope.row.status_name!='正常' "
:
style
=
"{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )
}
"
>
{{
scope
.
row
.
status_name
==
'正常'
?
'正常'
:
'设备异常'
}}
<
/span
>
<
/template
>
<
/el-table-column
>
<
el
-
table
-
column
align
=
"center"
label
=
"操作"
width
=
"
26
0px"
>
<
el
-
table
-
column
align
=
"center"
label
=
"操作"
width
=
"
30
0px"
>
<
template
slot
-
scope
=
"scope"
>
<
el
-
popover
width
=
"160"
trigger
=
"click"
placement
=
"top"
>
<
p
>
此操作
,
分丢弃废纸篓
,
和禁用用户
<
/p
>
...
...
@@ -107,6 +107,7 @@
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"danger"
:
disabled
=
"scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false) "
>
操作
<
/el-button
>
<
/el-popover
>
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"primary"
@
click
=
"contactsuser(scope.row.id)"
>
添加联系人
<
/el-button
>
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"primary"
@
click
=
"updatedevice(scope.row.id)"
>
编辑设备
<
/el-button
>
<
/template
>
<
/el-table-column
>
<
/el-table
>
...
...
@@ -159,15 +160,61 @@
<
/el-form
>
<
/el-card
>
<
/el-drawer
>
<
el
-
drawer
title
=
"编辑设备"
:
visible
.
sync
=
"drawerup"
:
direction
=
"directionup"
:
before
-
close
=
"handleCloseup"
>
<
el
-
card
class
=
"box-card"
>
<
el
-
form
ref
=
"updevicedata"
:
model
=
"updevicedata"
label
-
width
=
"80px"
>
<
el
-
form
-
item
label
=
"设备编号"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicenum"
:
disabled
=
"disabled"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"用户名称"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.name"
:
disabled
=
"disabled"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备名称"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.username"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备坐标"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicecoord"
style
=
"width: 80%;"
><
/el-input
>
<
el
-
button
type
=
"primary"
style
=
"left: 18px;z-index: 999;width: 54px;"
@
click
=
"accuracy"
><
span
style
=
"left: -22px;position: relative;"
>
拾取坐标
<
/span></
el
-
button
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备联系人"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicelinkman"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备手机号"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicephone"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备备注"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.deviceremark"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备安装位置"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.deviceinfo"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
v
-
if
=
"checkPermission(['manage isadmin'])"
label
=
"选择用户"
>
<
el
-
select
v
-
model
=
"updevicedata.uid"
placeholder
=
"请选择用户"
>
<
el
-
option
v
-
for
=
"item in addUserDevice"
:
key
=
"item.id"
:
label
=
"item.name"
:
value
=
"item.id"
><
/el-option
>
<
/el-select
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"选择分类"
>
<
el
-
select
v
-
model
=
"updevicedata.tid"
placeholder
=
"请选择分类"
>
<
el
-
option
v
-
for
=
"item in list"
:
key
=
"item.id"
:
label
=
"item.tname"
:
value
=
"item.tid"
><
/el-option
>
<
/el-select
>
<
/el-form-item
>
<
el
-
form
-
item
>
<
el
-
button
type
=
"primary"
@
click
=
"updedata"
>
立即更新
<
/el-button
>
<
el
-
button
@
click
=
"handleCloseup"
>
取消
<
/el-button
>
<
/el-form-item
>
<
/el-form
>
<
/el-card
>
<
/el-drawer
>
<
/div
>
<
/template
>
<
script
>
import
{
deviceTypeList
,
deviceList
,
deviceDataInfo
,
deviceDataSearch
,
deviceBasket
,
deviceDelete
,
addcontactsuser
}
from
'@/api/device'
;
import
{
deviceTypeList
,
deviceList
,
deviceDataInfo
,
deviceDataSearch
,
addUserDevice
,
deviceBasket
,
deviceDelete
,
addcontactsuser
,
postupdatedevice
,
updedata
}
from
'@/api/device'
;
import
Pagination
from
'@/components/Pagination'
;
// 分页
import
waves
from
'@/directive/waves'
;
// 水波纹效果
import
clip
from
'@/utils/clipboard'
;
import
{
parseTime
}
from
'@/utils'
;
import
checkPermission
from
'@/utils/permission'
;
export
default
{
name
:
'Devicetype'
,
components
:
{
Pagination
}
,
...
...
@@ -184,6 +231,7 @@ export default {
device
:
[],
deviceDataInfo
:
[],
devicefistr
:
[],
addUserDevice
:
[],
page
:
1
,
deviceSearch
:
{
deviceName
:
''
,
...
...
@@ -195,13 +243,18 @@ export default {
total
:
0
,
paper
:
undefined
,
drawer
:
false
,
disabled
:
true
,
direction
:
'rtl'
,
drawerup
:
false
,
directionup
:
'ltr'
,
contactsdata
:
{
contactsid
:
undefined
,
contacts_name
:
undefined
,
contacts_phone
:
undefined
,
isstatus
:
undefined
,
}
,
updevicedata
:
{
}
,
deid
:
undefined
,
}
;
}
,
created
()
{
...
...
@@ -211,6 +264,7 @@ export default {
}
,
methods
:
{
checkPermission
,
getList
()
{
deviceTypeList
()
.
then
(
response
=>
{
...
...
@@ -393,6 +447,52 @@ export default {
}
);
}
);
}
,
// 编辑设备
updatedevice
(
id
)
{
const
deviceid
=
id
;
this
.
drawerup
=
true
;
// 打开抽屉
this
.
postupdatedevice
(
deviceid
);
this
.
addUserDevices
();
this
.
deid
=
deviceid
;
}
,
// 关闭
handleCloseup
(
done
)
{
this
.
drawerup
=
false
;
// 关闭抽屉
this
.
deid
=
undefined
;
}
,
// 请求数据
postupdatedevice
(
id
)
{
postupdatedevice
(
id
)
.
then
(
response
=>
{
this
.
updevicedata
=
response
.
data
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
updedata
()
{
this
.
updevicedata
.
deid
=
this
.
deid
;
updedata
(
this
.
updevicedata
)
.
then
(
response
=>
{
this
.
handleCloseup
();
this
.
devicelist
();
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
addUserDevices
()
{
addUserDevice
()
.
then
(
response
=>
{
this
.
addUserDevice
=
response
.
data
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
accuracy
()
{
window
.
open
(
'latlge.html'
);
}
,
}
,
}
;
<
/script
>
...
...
resources/js/views/userdevice/index.vue
View file @
f4436f9c
...
...
@@ -98,7 +98,7 @@
<
span
v
-
if
=
"scope.row.status_name!='正常' "
:
style
=
"{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )
}
"
>
{{
scope
.
row
.
status_name
==
'正常'
?
'正常'
:
'设备异常'
}}
<
/span
>
<
/template
>
<
/el-table-column
>
<
el
-
table
-
column
align
=
"center"
label
=
"操作"
width
=
"
26
0px"
>
<
el
-
table
-
column
align
=
"center"
label
=
"操作"
width
=
"
30
0px"
>
<
template
slot
-
scope
=
"scope"
>
<
el
-
popover
width
=
"160"
trigger
=
"click"
placement
=
"top"
>
<
p
>
此操作
,
分丢弃废纸篓
,
和禁用用户
<
/p
>
...
...
@@ -109,6 +109,7 @@
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"danger"
:
disabled
=
"scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false) "
>
操作
<
/el-button
>
<
/el-popover
>
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"primary"
@
click
=
"contactsuser(scope.row.id)"
>
添加联系人
<
/el-button
>
<
el
-
button
slot
=
"reference"
size
=
"mini"
type
=
"primary"
@
click
=
"updatedevice(scope.row.id)"
>
编辑设备
<
/el-button
>
<
/template
>
<
/el-table-column
>
<
/el-table
>
...
...
@@ -160,12 +161,52 @@
<
/el-form
>
<
/el-card
>
<
/el-drawer
>
<
el
-
drawer
title
=
"编辑设备"
:
visible
.
sync
=
"drawerup"
:
direction
=
"directionup"
:
before
-
close
=
"handleCloseup"
>
<
el
-
card
class
=
"box-card"
>
<
el
-
form
ref
=
"updevicedata"
:
model
=
"updevicedata"
label
-
width
=
"80px"
>
<
el
-
form
-
item
label
=
"设备编号"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicenum"
:
disabled
=
"disabled"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"用户名称"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.name"
:
disabled
=
"disabled"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备名称"
label
-
width
=
"92px"
>
<
el
-
input
v
-
model
=
"updevicedata.username"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备坐标"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicecoord"
style
=
"width: 80%;"
><
/el-input
>
<
el
-
button
type
=
"primary"
style
=
"left: 18px;z-index: 999;width: 54px;"
@
click
=
"accuracy"
><
span
style
=
"left: -22px;position: relative;"
>
拾取坐标
<
/span></
el
-
button
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备联系人"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicelinkman"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备手机号"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.devicephone"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备备注"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.deviceremark"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"设备安装位置"
label
-
width
=
"100px"
>
<
el
-
input
v
-
model
=
"updevicedata.deviceinfo"
style
=
"width: 80%;"
><
/el-input
>
<
/el-form-item
>
<
el
-
form
-
item
label
=
"选择分类"
>
<
el
-
select
v
-
model
=
"updevicedata.tid"
placeholder
=
"请选择分类"
>
<
el
-
option
v
-
for
=
"item in list"
:
key
=
"item.id"
:
label
=
"item.tname"
:
value
=
"item.tid"
><
/el-option
>
<
/el-select
>
<
/el-form-item
>
<
el
-
form
-
item
>
<
el
-
button
type
=
"primary"
@
click
=
"updedata"
>
立即更新
<
/el-button
>
<
el
-
button
@
click
=
"handleCloseup"
>
取消
<
/el-button
>
<
/el-form-item
>
<
/el-form
>
<
/el-card
>
<
/el-drawer
>
<
/div
>
<
/div
>
<
/template
>
<
script
>
import
{
deviceTypeList
,
userdeviceList
,
deviceDataInfo
,
deviceDataSearch
,
deviceBasket
,
deviceDelete
,
addcontactsuser
}
from
'@/api/device'
;
import
{
deviceTypeList
,
userdeviceList
,
postupdatedevice
,
updedata
,
addUserDevice
,
deviceDataInfo
,
deviceDataSearch
,
deviceBasket
,
deviceDelete
,
addcontactsuser
}
from
'@/api/device'
;
import
Pagination
from
'@/components/Pagination'
;
// 分页
import
waves
from
'@/directive/waves'
;
// 水波纹效果
import
clip
from
'@/utils/clipboard'
;
...
...
@@ -184,6 +225,7 @@ export default {
activeName
:
'second'
,
list
:
[],
loading
:
true
,
disabled
:
true
,
device
:
[],
deviceDataInfo
:
[],
devicefistr
:
[],
...
...
@@ -206,6 +248,10 @@ export default {
contacts_phone
:
undefined
,
isstatus
:
undefined
,
}
,
drawerup
:
false
,
directionup
:
'ltr'
,
updevicedata
:
{
}
,
deid
:
undefined
,
}
;
}
,
created
()
{
...
...
@@ -404,6 +450,52 @@ export default {
}
);
}
);
}
,
// 编辑设备
updatedevice
(
id
)
{
const
deviceid
=
id
;
this
.
drawerup
=
true
;
// 打开抽屉
this
.
postupdatedevice
(
deviceid
);
this
.
addUserDevices
();
this
.
deid
=
deviceid
;
}
,
// 关闭
handleCloseup
(
done
)
{
this
.
drawerup
=
false
;
// 关闭抽屉
this
.
deid
=
undefined
;
}
,
// 请求数据
postupdatedevice
(
id
)
{
postupdatedevice
(
id
)
.
then
(
response
=>
{
this
.
updevicedata
=
response
.
data
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
updedata
()
{
this
.
updevicedata
.
deid
=
this
.
deid
;
updedata
(
this
.
updevicedata
)
.
then
(
response
=>
{
this
.
handleCloseup
();
this
.
devicelist
();
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
addUserDevices
()
{
addUserDevice
()
.
then
(
response
=>
{
this
.
addUserDevice
=
response
.
data
;
}
)
.
catch
(
err
=>
{
console
.
log
(
err
);
}
);
}
,
accuracy
()
{
window
.
open
(
'latlge.html'
);
}
,
}
,
}
;
<
/script
>
...
...
routes/api.php
View file @
f4436f9c
...
...
@@ -88,7 +88,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route
::
post
(
'devices/deletedecice'
,
'DevicesController@deletedecice'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//删除设备
Route
::
post
(
'devices/adddevice'
,
'DevicesController@adddevice'
);
//新增设备
Route
::
match
([
'get'
,
'post'
],
'devices/physicsdelete'
,
'DevicesController@physicsdelete'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
);
//返回设备列表和更改设备
Route
::
match
([
'get'
,
'post'
],
'devices/updatedevice'
,
'DevicesController@updatedevice'
)
->
middleware
(
'permission:'
.
\App\Laravue\Acl
::
PERMISSION_PERMISSION_MANAGE
)
;
//更新设备
Route
::
match
([
'get'
,
'post'
],
'devices/updatedevice'
,
'DevicesController@updatedevice'
);
//更新设备
Route
::
get
(
'devices/equipment'
,
'DevicesController@equipment'
);
//获取设备监测列表
Route
::
get
(
'devices/police'
,
'DevicesController@police'
);
//获取设备当前报警列表
Route
::
get
(
'devices/deviceBasket'
,
'DevicesController@deviceBasket'
);
//获取设备废纸篓数量
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment