Commit ce84b176 authored by Administrator's avatar Administrator

工单后台

parent 9d295b8e
...@@ -61,10 +61,18 @@ class AlarmOrderController extends Controller ...@@ -61,10 +61,18 @@ class AlarmOrderController extends Controller
DB::beginTransaction(); DB::beginTransaction();
try { try {
// 获取device_id
$device = DB::table('device')
->select('id')
->where('devicenum', $request->input('device_num'))
->find();
if(!$device) {
return $this->jsonErrorData(500, '设备编号不存在!');
}
$order = new AlarmOrder(); $order = new AlarmOrder();
$insertId = $order->insertGetId([ $insertId = $order->insertGetId([
'order_num' => $orderNum, 'order_num' => $orderNum,
'device_id' => $request->input('device_id'), 'device_id' => $device['id'],
'user_id' => $request->input('user_id'), 'user_id' => $request->input('user_id'),
'reportpolice_id' => $reportpolice_id, 'reportpolice_id' => $reportpolice_id,
'created_at' => Carbon::now(), 'created_at' => Carbon::now(),
...@@ -79,13 +87,13 @@ class AlarmOrderController extends Controller ...@@ -79,13 +87,13 @@ class AlarmOrderController extends Controller
DB::commit(); DB::commit();
} catch (QueryException $exception) { } catch (QueryException $exception) {
DB::rollBack(); DB::rollBack();
return $this->jsonErrorData('工单创建失败'); return $this->jsonErrorData(500,'工单创建失败');
} }
if($insertId) { if($insertId) {
return $this->jsonSuccessData('已生成工单!'); return $this->jsonSuccessData('已生成工单!');
}else{ }else{
return $this->jsonErrorData('工单创建失败'); return $this->jsonErrorData(500, '工单创建失败');
} }
} }
...@@ -156,4 +164,22 @@ class AlarmOrderController extends Controller ...@@ -156,4 +164,22 @@ class AlarmOrderController extends Controller
return $this->jsonErrorData(500, '删除工单失败!'); return $this->jsonErrorData(500, '删除工单失败!');
} }
} }
/**
* 获取派单用户
*/
public function getUserInfo()
{
if($this->isadmin()) {
$users = DB::table('users')
->select('users.name, users.username, users.email, users.phone_number, ur.name AS role_name')
->leftJoin('user_roles AS ur', 'ur.id', '=', 'users.user_role_id')
->where('users.user_role_id', '!=', 0)
->get()->toArray();
return $this->jsonSuccessData($users);
}else{
return $this->jsonErrorData(500, '没有权限, 请联系管理员!');
}
}
} }
import request from '@/utils/request';
// 列表
export function alarmOrderList(data) {
return request({
url: '/alarm_order',
method: 'get',
data: data,
});
}
// 新增
export function alarmOrderStore(data) {
return request({
url: '/alarm_order',
method: 'post',
data: data,
});
}
// 更新
export function alarmOrderUpdate(data, id) {
return request({
url: '/alarm_order/' + id,
method: 'patch',
data,
});
}
// 删除
export function alarmOrderDestroy(id) {
return request({
url: '/alarm_order/' + id,
method: 'delete',
});
}
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</el-table-column> </el-table-column>
<el-table-column label="操作"> <el-table-column label="操作">
<template> <template>
<el-button type="primary" effect="dark">生成工单</el-button> <el-button type="primary" effect="dark" @click="createAlarmOrder(scope.row)">生成工单</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
import { police } from '@/api/device'; import { police } from '@/api/device';
import clip from '@/utils/clipboard'; import clip from '@/utils/clipboard';
import BackToTop from '@/components/BackToTop'; import BackToTop from '@/components/BackToTop';
import { alarmOrderStore } from '@/api/alarmOrder';
export default { export default {
components: { BackToTop }, components: { BackToTop },
data() { data() {
...@@ -77,12 +78,34 @@ export default { ...@@ -77,12 +78,34 @@ export default {
'line-height': '45px', // Please keep consistent with height to center vertically 'line-height': '45px', // Please keep consistent with height to center vertically
background: '#e7eaf1', // The background color of the button background: '#e7eaf1', // The background color of the button
}, },
// 报警工单数据
alarmOrderToUserId: 0,
formDataOrder: {
device_num: '',
reportpolice_id: 0,
policestatus: 0,
shutoff_status: 0,
user_id: 0,
},
}; };
}, },
created() { created() {
this.police(); // 列表 this.police(); // 列表
}, },
methods: { methods: {
// 生成工单
createAlarmOrder(data) {
this.formDataOrder.device_num = data.devicenumber;
this.formDataOrder.reportpolice_id = data.id;
this.formDataOrder.policestatus = data.policestatus;
this.formDataOrder.shutoff_status = data.shutoff_status;
this.formDataOrder.user_id = this.alarmOrderToUserId;
alarmOrderStore(this.formDataOrder).then(response => {
console.log(response);
}).catch(err => {
console.log(err);
});
},
shutoffStatus(id) { shutoffStatus(id) {
const shutoff = []; const shutoff = [];
shutoff[0] = '初始化'; shutoff[0] = '初始化';
......
...@@ -54,6 +54,7 @@ Route::group(['middleware' => 'auth:api'], function () { ...@@ -54,6 +54,7 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::patch('alarm_order/{id}', 'AlarmOrderController@update'); // 修改工单 Route::patch('alarm_order/{id}', 'AlarmOrderController@update'); // 修改工单
Route::delete('alarm_order/{id}', 'AlarmOrderController@destroy'); // 删除工单 Route::delete('alarm_order/{id}', 'AlarmOrderController@destroy'); // 删除工单
Route::get('alarm_order/show/{id}', 'AlarmOrderController@show'); // 工单详情 Route::get('alarm_order/show/{id}', 'AlarmOrderController@show'); // 工单详情
Route::get('alarm_order/user', 'AlarmOrderController@getUserInfo'); // 获取派单人员
}); });
//上传图片路由 //上传图片路由
......
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