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

提交设备编辑

parent a3c5165f
Pipeline #59 canceled with stages
...@@ -152,16 +152,27 @@ class DevicesController extends Controller ...@@ -152,16 +152,27 @@ class DevicesController extends Controller
if (is_null($deid)) { if (is_null($deid)) {
return $this->jsonErrorData(105, '设备ID不能为空'); return $this->jsonErrorData(105, '设备ID不能为空');
} }
if ($_POST) { if ($request->isMethod('post')) {
$validator = Validator::make($request->all(), $this->getValidationRulesupdevice(false)); $validator = Validator::make($request->all(), $this->getValidationRulesupdevice(false));
if ($validator->fails()) { if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403); return response()->json(['errors' => $validator->errors()], 403);
} }
$data['dtype'] = $request->input('tid');
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if ($k == 'deid') { if ($k == 'deid') {
unset($data[$k]); 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 . ']'); $this->timeline('编辑了设备[设备id' . $deid . ']');
return $this->jsonSuccessData(Device::where('id', '=', $deid)->update($data)); return $this->jsonSuccessData(Device::where('id', '=', $deid)->update($data));
} else { } else {
...@@ -170,7 +181,8 @@ class DevicesController extends Controller ...@@ -170,7 +181,8 @@ class DevicesController extends Controller
->leftjoin('device_type as dt', 'de.dtype', '=', 'dt.tid') ->leftjoin('device_type as dt', 'de.dtype', '=', 'dt.tid')
->leftjoin('gas', 'de.status', '=', 'gas.id') ->leftjoin('gas', 'de.status', '=', 'gas.id')
->leftjoin('danwei as da', 'de.devicemonad', '=', 'da.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(); ->first();
return $this->jsonSuccessData($devi); return $this->jsonSuccessData($devi);
} }
......
No preview for this file type
...@@ -136,3 +136,18 @@ export function userdeviceList(data) { ...@@ -136,3 +136,18 @@ export function userdeviceList(data) {
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,
});
}
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span> <span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="260px"> <el-table-column align="center" label="操作" width="300px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-popover width="160" trigger="click" placement="top"> <el-popover width="160" trigger="click" placement="top">
<p>此操作,分丢弃废纸篓,和禁用用户</p> <p>此操作,分丢弃废纸篓,和禁用用户</p>
...@@ -107,6 +107,7 @@ ...@@ -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-button slot="reference" size="mini" type="danger" :disabled="scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false) ">操作</el-button>
</el-popover> </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="contactsuser(scope.row.id)">添加联系人</el-button>
<el-button slot="reference" size="mini" type="primary" @click="updatedevice(scope.row.id)">编辑设备</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -159,15 +160,61 @@ ...@@ -159,15 +160,61 @@
</el-form> </el-form>
</el-card> </el-card>
</el-drawer> </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> </div>
</template> </template>
<script> <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 Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果 import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard'; import clip from '@/utils/clipboard';
import { parseTime } from '@/utils'; import { parseTime } from '@/utils';
import checkPermission from '@/utils/permission';
export default { export default {
name: 'Devicetype', name: 'Devicetype',
components: { Pagination }, components: { Pagination },
...@@ -184,6 +231,7 @@ export default { ...@@ -184,6 +231,7 @@ export default {
device: [], device: [],
deviceDataInfo: [], deviceDataInfo: [],
devicefistr: [], devicefistr: [],
addUserDevice: [],
page: 1, page: 1,
deviceSearch: { deviceSearch: {
deviceName: '', deviceName: '',
...@@ -195,13 +243,18 @@ export default { ...@@ -195,13 +243,18 @@ export default {
total: 0, total: 0,
paper: undefined, paper: undefined,
drawer: false, drawer: false,
disabled: true,
direction: 'rtl', direction: 'rtl',
drawerup: false,
directionup: 'ltr',
contactsdata: { contactsdata: {
contactsid: undefined, contactsid: undefined,
contacts_name: undefined, contacts_name: undefined,
contacts_phone: undefined, contacts_phone: undefined,
isstatus: undefined, isstatus: undefined,
}, },
updevicedata: {},
deid: undefined,
}; };
}, },
created() { created() {
...@@ -211,6 +264,7 @@ export default { ...@@ -211,6 +264,7 @@ export default {
}, },
methods: { methods: {
checkPermission,
getList() { getList() {
deviceTypeList() deviceTypeList()
.then(response => { .then(response => {
...@@ -393,6 +447,52 @@ export default { ...@@ -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> </script>
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
<span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span> <span v-if="scope.row.status_name!='正常' " :style="{color:( scope.row.status_name=='正常' ? '#67C23A' : '#F56C6C' )}">{{ scope.row.status_name=='正常' ? '正常' : '设备异常' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="260px"> <el-table-column align="center" label="操作" width="300px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-popover width="160" trigger="click" placement="top"> <el-popover width="160" trigger="click" placement="top">
<p>此操作,分丢弃废纸篓,和禁用用户</p> <p>此操作,分丢弃废纸篓,和禁用用户</p>
...@@ -109,6 +109,7 @@ ...@@ -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-button slot="reference" size="mini" type="danger" :disabled="scope.row.delete == 1 ? true : (scope.row.devicestatus > 1 ? true : false) ">操作</el-button>
</el-popover> </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="contactsuser(scope.row.id)">添加联系人</el-button>
<el-button slot="reference" size="mini" type="primary" @click="updatedevice(scope.row.id)">编辑设备</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -160,12 +161,52 @@ ...@@ -160,12 +161,52 @@
</el-form> </el-form>
</el-card> </el-card>
</el-drawer> </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>
</div> </div>
</template> </template>
<script> <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 Pagination from '@/components/Pagination'; // 分页
import waves from '@/directive/waves'; // 水波纹效果 import waves from '@/directive/waves'; // 水波纹效果
import clip from '@/utils/clipboard'; import clip from '@/utils/clipboard';
...@@ -184,6 +225,7 @@ export default { ...@@ -184,6 +225,7 @@ export default {
activeName: 'second', activeName: 'second',
list: [], list: [],
loading: true, loading: true,
disabled: true,
device: [], device: [],
deviceDataInfo: [], deviceDataInfo: [],
devicefistr: [], devicefistr: [],
...@@ -206,6 +248,10 @@ export default { ...@@ -206,6 +248,10 @@ export default {
contacts_phone: undefined, contacts_phone: undefined,
isstatus: undefined, isstatus: undefined,
}, },
drawerup: false,
directionup: 'ltr',
updevicedata: {},
deid: undefined,
}; };
}, },
created() { created() {
...@@ -404,6 +450,52 @@ export default { ...@@ -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> </script>
......
...@@ -88,7 +88,7 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -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/deletedecice','DevicesController@deletedecice')->middleware('permission:' . \App\Laravue\Acl::PERMISSION_PERMISSION_MANAGE);//删除设备
Route::post('devices/adddevice','DevicesController@adddevice');//新增设备 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/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/equipment','DevicesController@equipment');//获取设备监测列表
Route::get('devices/police','DevicesController@police');//获取设备当前报警列表 Route::get('devices/police','DevicesController@police');//获取设备当前报警列表
Route::get('devices/deviceBasket','DevicesController@deviceBasket');//获取设备废纸篓数量 Route::get('devices/deviceBasket','DevicesController@deviceBasket');//获取设备废纸篓数量
......
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