Commit f72cb9ce authored by Administrator's avatar Administrator

抢险工单列表

parent 70d247e1
...@@ -20,12 +20,32 @@ class AlarmOrderController extends Controller ...@@ -20,12 +20,32 @@ class AlarmOrderController extends Controller
public function index(Request $request) public function index(Request $request)
{ {
$where = []; $where = [];
$whereBetween = [0, date('Y-m-d H:i:s')];
$limit = 20; $limit = 20;
if($request->input('limit') > 0) {
$limit = $request->input('limit');
}
$offset = $limit * ($request->input('page') - 1); $offset = $limit * ($request->input('page') - 1);
if($request->input('isuser') == 'user'){ if($request->input('isuser') == 'user'){
$where[] = ['u.id','=',Auth::id()]; $where[] = ['u.id','=',Auth::id()];
} }
if($request->input('order_num')) {
$where[] = ['alarm_order.order_num' , '=', $request->input('order_num')];
}
if($request->input('deviceNum')) {
$where[] = ['r.devicenumber' , '=', $request->input('deviceNum')];
}
if($request->input('state') != 99) {
$where[] = ['alarm_order.state' , '=', $request->input('state')];
}
if($request->input('user_id')) {
$where[] = ['alarm_order.user_id' , '=', $request->input('user_id')];
}
if($request->input('timeRange') != "null") {
$times = explode(',', $request->input('timeRange'));
$whereBetween = [$times[0], $times[1]];
}
$orders = AlarmOrder::selectRaw(' $orders = AlarmOrder::selectRaw('
FROM_UNIXTIME(r.starttime) AS start_time, FROM_UNIXTIME(r.starttime) AS start_time,
FROM_UNIXTIME(r.endtime) AS end_time, FROM_UNIXTIME(r.endtime) AS end_time,
...@@ -42,9 +62,18 @@ class AlarmOrderController extends Controller ...@@ -42,9 +62,18 @@ class AlarmOrderController extends Controller
->leftjoin('device_type AS t', 'r.policestatus', '=', 't.tid') ->leftjoin('device_type AS t', 'r.policestatus', '=', 't.tid')
->offset($offset) ->offset($offset)
->where($where) ->where($where)
->whereBetween('alarm_order.created_at',$whereBetween)
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
return $this->jsonSuccessData($orders); $count = AlarmOrder::leftjoin('reportpolice AS r', 'r.id', '=', 'alarm_order.reportpolice_id')
->whereBetween('alarm_order.created_at',$whereBetween)
->where($where)->count();
$meta = [
'count' => $count,
'current_page' => $request->input('page'),
'limit' => $limit
];
return $this->jsonSuccessData(compact('orders', 'meta'));
} }
......
...@@ -2,10 +2,12 @@ import request from '@/utils/request'; ...@@ -2,10 +2,12 @@ import request from '@/utils/request';
// 列表 // 列表
export function alarmOrderList(data) { export function alarmOrderList(data) {
var params = Object.keys(data).map(function(key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(data[key]);
}).join('&');
return request({ return request({
url: '/alarm_order', url: '/alarm_order?' + params,
method: 'get', method: 'get',
data: data,
}); });
} }
// 新增 // 新增
......
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="工单号">
<el-input v-model="formSearch.order_num" placeholder="输入工单号"></el-input>
</el-form-item>
<el-form-item label="设备编号"> <el-form-item label="设备编号">
<el-input v-model="formSearch.deviceNum" placeholder="输入完整设备编号"></el-input> <el-input v-model="formSearch.deviceNum" placeholder="输入完整设备编号"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="工单状态"> <el-form-item label="工单状态">
<el-select <el-select
v-model="formSearch.deviceStatus" v-model="formSearch.state"
style="margin-left: 20px;" style="margin-left: 20px;"
placeholder="请选择" placeholder="请选择"
> >
...@@ -42,7 +45,7 @@ ...@@ -42,7 +45,7 @@
type="datetimerange" type="datetimerange"
:picker-options="pickerOptions" :picker-options="pickerOptions"
range-separator="至" range-separator="至"
value-format="yyyy/MM/dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
...@@ -54,7 +57,7 @@ ...@@ -54,7 +57,7 @@
</div> </div>
<el-pagination <el-pagination
:current-page="formSearch.page" :current-page="formSearch.page"
:page-sizes="[20, 80, 150, 300]" :page-sizes="[20, 80, 150, 300, 5]"
:page-size="formSearch.limit" :page-size="formSearch.limit"
layout="total, sizes, prev, pager, next, jumper" layout="total, sizes, prev, pager, next, jumper"
:total="formSearch.total" :total="formSearch.total"
...@@ -126,8 +129,12 @@ export default { ...@@ -126,8 +129,12 @@ export default {
data() { data() {
return { return {
alarmOrders: [], alarmOrders: [],
alarmOrderUsersData: [], alarmOrderUsersData: [{
id: 0,
name: '全部',
}],
formSearch: { formSearch: {
order_num: '',
deviceNum: '', deviceNum: '',
state: 0, state: 0,
timeRange: null, timeRange: null,
...@@ -199,7 +206,7 @@ export default { ...@@ -199,7 +206,7 @@ export default {
orderUsers(data) { orderUsers(data) {
alarmOrderUsers().then(response => { alarmOrderUsers().then(response => {
if (response.code === 200) { if (response.code === 200) {
this.alarmOrderUsersData = response.data; this.alarmOrderUsersData = this.alarmOrderUsersData.concat(response.data);
} }
}).catch(err => { }).catch(err => {
console.log(err); console.log(err);
...@@ -207,10 +214,12 @@ export default { ...@@ -207,10 +214,12 @@ export default {
}, },
// 工单列表 // 工单列表
alarmOrdersData() { alarmOrdersData() {
console.log(this.formSearch);
alarmOrderList(this.formSearch).then(response => { alarmOrderList(this.formSearch).then(response => {
if (response.code === 200) { if (response.code === 200) {
console.log(response.data); console.log(response.data);
this.alarmOrders = response.data; this.alarmOrders = response.data.orders;
this.formSearch.total = response.data.meta.count;
} }
}).catch(err => { }).catch(err => {
console.log(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