Commit f72cb9ce authored by Administrator's avatar Administrator

抢险工单列表

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