Commit 3d597bb2 authored by Administrator's avatar Administrator

生成工单

parent ce84b176
...@@ -65,14 +65,14 @@ class AlarmOrderController extends Controller ...@@ -65,14 +65,14 @@ class AlarmOrderController extends Controller
$device = DB::table('device') $device = DB::table('device')
->select('id') ->select('id')
->where('devicenum', $request->input('device_num')) ->where('devicenum', $request->input('device_num'))
->find(); ->first();
if(!$device) { if(!$device) {
return $this->jsonErrorData(500, '设备编号不存在!'); return $this->jsonErrorData(500, '设备编号不存在!');
} }
$order = new AlarmOrder(); $order = new AlarmOrder();
$insertId = $order->insertGetId([ $insertId = $order->insertGetId([
'order_num' => $orderNum, 'order_num' => $orderNum,
'device_id' => $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(),
...@@ -172,8 +172,11 @@ class AlarmOrderController extends Controller ...@@ -172,8 +172,11 @@ class AlarmOrderController extends Controller
{ {
if($this->isadmin()) { if($this->isadmin()) {
$users = DB::table('users') $users = DB::table('users')
->select('users.name, users.username, users.email, users.phone_number, ur.name AS role_name') ->select('users.id', 'users.name', 'users.username', 'users.phone_number', 'ur.name AS role_name', 'ap.area_name AS province', 'aa.area_name AS area', 'ac.area_name AS city')
->leftJoin('user_roles AS ur', 'ur.id', '=', 'users.user_role_id') ->leftJoin('user_roles AS ur', 'ur.id', '=', 'users.user_role_id')
->leftJoin('areachina AS ap', 'ap.areaid', '=', 'users.provinceid')
->leftJoin('areachina AS aa', 'aa.areaid', '=', 'users.areaid')
->leftJoin('areachina AS ac', 'ac.areaid', '=', 'users.cityid')
->where('users.user_role_id', '!=', 0) ->where('users.user_role_id', '!=', 0)
->get()->toArray(); ->get()->toArray();
return $this->jsonSuccessData($users); return $this->jsonSuccessData($users);
......
...@@ -31,3 +31,10 @@ export function alarmOrderDestroy(id) { ...@@ -31,3 +31,10 @@ export function alarmOrderDestroy(id) {
method: 'delete', method: 'delete',
}); });
} }
// 派单人员列表
export function alarmOrderUsers() {
return request({
url: '/alarm_order/user',
method: 'get',
});
}
...@@ -47,14 +47,44 @@ ...@@ -47,14 +47,44 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作"> <el-table-column label="操作">
<template> <template slot-scope="scope">
<el-button type="primary" effect="dark" @click="createAlarmOrder(scope.row)">生成工单</el-button> <el-button type="primary" effect="dark" @click="orderUsers(scope.row)">生成工单</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-tooltip placement="top" content="tooltip"> <el-tooltip placement="top" content="tooltip">
<back-to-top :custom-style="myBackToTopStyle" :visibility-height="300" :back-position="50" transition-name="fade" /> <back-to-top :custom-style="myBackToTopStyle" :visibility-height="300" :back-position="50" transition-name="fade" />
</el-tooltip> </el-tooltip>
<el-dialog title="向谁派发工单?" :visible.sync="dialogFormVisible">
<el-table
ref="singleTable"
:data="alarmOrderUserData"
:highlight-current-row="true"
row-class-name="order-users-row"
style="width: 100%"
@row-click="handleCurrentChange"
>
<el-table-column
label="ID"
width="150"
>
<template slot-scope="scope">
<el-radio v-model="form.alarmOrderToUserId" :label="scope.row.id">{{ scope.row.id }}</el-radio>
</template>
</el-table-column>
<el-table-column property="name" label="用户名" width="150"></el-table-column>
<el-table-column property="username" label="账号" width="120"></el-table-column>
<el-table-column property="phone_number" label="手机号" width="120"></el-table-column>
<el-table-column property="role_name" label="角色"></el-table-column>
<el-table-column property="province" label="省"></el-table-column>
<el-table-column property="city" label="市"></el-table-column>
<el-table-column property="area" label="区域(县)"></el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="createAlarmOrder()"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
...@@ -62,11 +92,13 @@ ...@@ -62,11 +92,13 @@
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'; import { alarmOrderStore, alarmOrderUsers } from '@/api/alarmOrder';
export default { export default {
components: { BackToTop }, components: { BackToTop },
data() { data() {
return { return {
dialogFormVisible: false,
alarmOrderUserData: [],
tableKey: 0, tableKey: 0,
reportpolice: [], reportpolice: [],
myBackToTopStyle: { myBackToTopStyle: {
...@@ -79,7 +111,9 @@ export default { ...@@ -79,7 +111,9 @@ export default {
background: '#e7eaf1', // The background color of the button background: '#e7eaf1', // The background color of the button
}, },
// 报警工单数据 // 报警工单数据
form: {
alarmOrderToUserId: 0, alarmOrderToUserId: 0,
},
formDataOrder: { formDataOrder: {
device_num: '', device_num: '',
reportpolice_id: 0, reportpolice_id: 0,
...@@ -94,14 +128,36 @@ export default { ...@@ -94,14 +128,36 @@ export default {
}, },
methods: { methods: {
// 生成工单 // 生成工单
createAlarmOrder(data) { handleCurrentChange(val) {
console.log(val);
this.form.alarmOrderToUserId = val.id;
this.formDataOrder.user_id = this.form.alarmOrderToUserId;
},
orderUsers(data) {
alarmOrderUsers().then(response => {
if (response.code === 200) {
this.alarmOrderUserData = response.data;
}
}).catch(err => {
console.log(err);
});
this.formDataOrder.device_num = data.devicenumber; this.formDataOrder.device_num = data.devicenumber;
this.formDataOrder.reportpolice_id = data.id; this.formDataOrder.reportpolice_id = data.id;
this.formDataOrder.policestatus = data.policestatus; this.formDataOrder.policestatus = data.policestatus;
this.formDataOrder.shutoff_status = data.shutoff_status; this.formDataOrder.shutoff_status = data.shutoff_status;
this.formDataOrder.user_id = this.alarmOrderToUserId; this.dialogFormVisible = true;
},
createAlarmOrder() {
if (this.formDataOrder.user_id === 0) {
this.$message.error('你的工单要派发给谁呢?');
return;
}
alarmOrderStore(this.formDataOrder).then(response => { alarmOrderStore(this.formDataOrder).then(response => {
console.log(response); console.log(response);
if (response.code === 200) {
this.$message.success('你的工单派发成功了!');
this.dialogFormVisible = false;
}
}).catch(err => { }).catch(err => {
console.log(err); console.log(err);
}); });
...@@ -137,4 +193,7 @@ export default { ...@@ -137,4 +193,7 @@ export default {
</script> </script>
<style> <style>
.order-users-row {
cursor: pointer;
}
</style> </style>
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