Browse Source

工人工单列表查询

xyg 2 years ago
parent
commit
60bcd5f490

+ 1 - 1
nngkxxdp/src/main/java/com/example/nngkxxdp/program/controller/WorkerMiniController.java

@@ -69,7 +69,7 @@ public class WorkerMiniController {
             return SendUtil.send(false, ConstStr.REQUEST_WRONGPARAMS);
 
         }
-        return SendUtil.send(true, ConstStr.RESULT_SUCCESS, service.myOrder(page,limit,userId,isUser,todo,close));
+        return service.myOrder(page,limit,userId,isUser,todo,close);
     }
 
     @GetMapping("/orderInfo")

+ 164 - 42
nnzwminiapp/pagesPublic/pages/work-order/work-order.js

@@ -2,6 +2,9 @@
 var dateTimePicker = require('../../../utils/dateTimePicker');
 const FormData = require('../../pages/menu/formData.js');
 const twoHours = 7200000;
+let page = 1;
+let page2 = 1;
+const limit = 10;
 
 import {
     baseUrl,
@@ -14,7 +17,7 @@ Page({
      * 页面的初始数据
      */
     data: {
-        isUser: true,
+        isUser: false,
         currentIndex: 0,
         date: '2023-10-01',
         time: '12:00',
@@ -24,7 +27,11 @@ Page({
         endYear: 2250,
         typeList: ['报修类型一', '报修类型二', '报修类型三'],
         list: [],
-        tempFileList: []
+        repairList: [],
+        completeList: [],
+        tempFileList: [],
+        nodata: false,
+        nodata2: false
     },
 
     /**
@@ -42,6 +49,14 @@ Page({
         });
 
         // 查询所有报修类型
+
+        let isUser = this.data.isUser;
+        if (!isUser) {
+            // 初始化待维修工单
+            this.loadTobeRepair();
+            // 初始化已完成工单
+            // this.loadComplete();
+        }
     },
 
     /**
@@ -76,14 +91,40 @@ Page({
      * 页面相关事件处理函数--监听用户下拉动作
      */
     onPullDownRefresh() {
-
+        console.log("下拉刷新...");
+        if (this.data.currentIndex == 1) {
+            page2 = 1;
+            if (this.data.isUser) {
+                this.loadMyApplication();
+            } else {
+                this.loadComplete();
+            }
+        } else {
+            if (!this.data.isUser) {
+                page = 1;
+                this.loadTobeRepair();
+            }
+        }
     },
 
     /**
      * 页面上拉触底事件的处理函数
      */
     onReachBottom() {
-
+        console.log("上拉加载....");
+        if (this.data.currentIndex == 1) {
+            page2++;
+            if (this.data.isUser) {
+                this.loadMyApplication(true);
+            } else {
+                this.loadComplete(true);
+            }
+        } else {
+            if (!this.data.isUser) {
+                page++;
+                this.loadTobeRepair(true);
+            }
+        }
     },
 
     /**
@@ -94,8 +135,16 @@ Page({
         this.setData({
             currentIndex: e.currentTarget.dataset.idx
         });
-        if (e.currentTarget.dataset.idx == 1) {
-            this.loadMyApplication();
+        if (this.data.isUser) {
+            if (e.currentTarget.dataset.idx == 1) {
+                this.loadMyApplication();
+            }
+        } else {
+            if (e.currentTarget.dataset.idx == 1) {
+                this.loadComplete();
+            } else {
+                this.loadTobeRepair();
+            }
         }
     },
 
@@ -104,7 +153,7 @@ Page({
      * @param {*} e 
      */
     pagechange: function (e) {
-        console.info(e)
+        // console.info(e)
         // 通过touch判断,改变tab的下标值
         if ("touch" === e.detail.source) {
             // let currentPageIndex = this.data.currentIndex;
@@ -113,8 +162,16 @@ Page({
             this.setData({
                 currentIndex: e.detail.current
             });
-            if (e.detail.current == 1) {
-                this.loadMyApplication();
+            if (this.data.isUser) {
+                if (e.detail.current == 1) {
+                    this.loadMyApplication();
+                }
+            } else {
+                if (e.detail.current == 1) {
+                    this.loadComplete();
+                } else {
+                    this.loadTobeRepair();
+                }
             }
         }
     },
@@ -326,40 +383,23 @@ Page({
     /**
      * 加载我的申请
      */
-    loadMyApplication() {
-        let that = this;
-        // let formData = new FormData();
-        // formData.append('id', wx.getStorageSync('userid'));
-        // let data = formData.getData();
-        // request({
-        //     url: '/mini/worker/myOrder',
-        //     method: 'GET',
-        //     data: data.buffer,
-        //     contentType: data.contentType
-        // }).then(res => {
-        //     console.info(res)
-        //     if (res.result) {
-        //     } else {
-        //         wx.showToast({
-        //             title: '加载失败',
-        //             icon: 'error',
-        //             mask: true
-        //         });
-        //     }
-        // });
-        wx.request({
-            url: baseUrl + '/mini/worker/myOrder',
+    loadMyApplication(ispullup) {
+        wx.showLoading({
+            title: '加载中...'
+        });
+        request({
+            url: '/mini/worker/myOrder',
             method: 'GET',
-            header: {
-                'mini-token': wx.getStorageSync('token')
-            },
             data: {
-                'id': wx.getStorageSync('userid')
-            },
-            dataType: 'json',
-            success: function (res) {
-                console.info(res)
-                let data = res.data.data;
+                page: page2,
+                limit: limit,
+                userId: wx.getStorageSync('userid'),
+                isUser: true
+            }
+        }).then(res => {
+            console.info(res)
+            let data = res.data;
+            if (data && data.length > 0) {
                 for (let i in data) {
                     if (data[i].status == 2) {
                         data[i].image = 'status-complete.png';
@@ -369,10 +409,92 @@ Page({
                         data[i].image = 'status-repair.png';
                     }
                 }
-                that.setData({
+                if (ispullup) {
+                    data = data.concat(this.data.list);
+                }
+                this.setData({
                     list: data
                 });
+            } else {
+                if (!ispullup) {
+                    this.setData({
+                        nodata: true
+                    });
+                }
+            }
+            wx.hideLoading();
+        });
+    },
+    /**
+     * 加载待维修工单
+     */
+    loadTobeRepair(ispullup) {
+        wx.showLoading({
+            title: '加载中...'
+        });
+        request({
+            url: '/mini/worker/myOrder',
+            method: 'GET',
+            data: {
+                page: page,
+                limit: limit,
+                userId: wx.getStorageSync('userid'),
+                todo: true
+            }
+        }).then(res => {
+            console.info(res)
+            let data = res.data;
+            if (data && data.length > 0) {
+                if (ispullup) {
+                    data = data.concat(this.data.repairList);
+                }
+                this.setData({
+                    repairList: data
+                });
+            } else {
+                if (!ispullup) {
+                    this.setData({
+                        nodata: true
+                    });
+                }
+            }
+            wx.hideLoading();
+        });
+    },
+    /**
+     * 加载已完成工单
+     */
+    loadComplete(ispullup) {
+        wx.showLoading({
+            title: '加载中...'
+        });
+        request({
+            url: '/mini/worker/myOrder',
+            method: 'GET',
+            data: {
+                page: page2,
+                limit: limit,
+                userId: wx.getStorageSync('userid'),
+                close: true
+            }
+        }).then(res => {
+            console.info(res)
+            let data = res.data;
+            if (data && data.length > 0) {
+                if (ispullup) {
+                    data = data.concat(this.data.completeList);
+                }
+                this.setData({
+                    completeList: data
+                });
+            } else {
+                if (!ispullup) {
+                    this.setData({
+                        nodata2: true
+                    });
+                }
             }
+            wx.hideLoading();
         });
     }
 

+ 2 - 1
nnzwminiapp/pagesPublic/pages/work-order/work-order.json

@@ -2,5 +2,6 @@
     "usingComponents": {},
     "navigationBarTitleText": "工单维修",
     "navigationBarBackgroundColor": "#508FF4",
-    "navigationBarTextStyle": "white"
+    "navigationBarTextStyle": "white",
+    "enablePullDownRefresh": true
 }

+ 20 - 16
nnzwminiapp/pagesPublic/pages/work-order/work-order.wxml

@@ -54,8 +54,8 @@
             </form>
         </swiper-item>
         <swiper-item class="swiperTtemBox">
-            <scroll-view class="viewBox" wx:for="{{list}}" wx:for-item="item" wx:key="index">
-                <view class="item" data-id="{{item.id}}" data-isuser="true" bindtap="toDetail">
+            <scroll-view class="viewBox">
+                <view class="item" wx:for="{{list}}" wx:for-item="item" wx:key="index" data-id="{{item.id}}" data-isuser="true" bindtap="toDetail">
                     <image class="item-status" src="/pages/images/{{item.image}}" mode="" />
                     <view class="item-row">
                         <text class="item-label">报修类型:</text>
@@ -71,6 +71,7 @@
                     </view>
                 </view>
             </scroll-view>
+            <view wx:if="{{nodata}}" style="color: #999999;width: 100%;text-align: center;margin-top: 50rpx;">暂无数据</view>
         </swiper-item>
     </swiper>
 </view>
@@ -88,49 +89,52 @@
     </view>
     <swiper class="swiperBox" bindchange="pagechange" current="{{currentIndex}}">
         <swiper-item class="swiperTtemBox">
-            <scroll-view class="viewBox" wx:for="{{list}}" wx:for-item="item" wx:key="index">
-                <view class="item" data-id="{{item.id}}" data-isuser="false"  bindtap="toDetail">
+            <scroll-view class="viewBox">
+                <view class="item" wx:for="{{repairList}}" wx:for-item="item" wx:key="index" data-id="{{item.id}}" data-isuser="false" bindtap="toDetail">
                     <view class="item-row">
                         <text class="item-label">报修类型:</text>
-                        <text class="item-value">{{item.type}}</text>
+                        <text class="item-value">{{item.repairType}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修地址:</text>
-                        <text class="item-value">{{item.address}}</text>
+                        <text class="item-value">{{item.maintenanceAddress}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">预约时间:</text>
-                        <text class="item-value">{{item.time}}</text>
+                        <text class="item-value">{{item.appointmentTime}}</text>
                     </view>
                 </view>
             </scroll-view>
+            <view wx:if="{{nodata}}" style="color: #999999;width: 100%;text-align: center;margin-top: 50rpx;">暂无数据</view>
         </swiper-item>
         <swiper-item class="swiperTtemBox">
-            <scroll-view class="viewBox" wx:for="{{list}}" wx:for-item="item" wx:key="index">
-                <view class="item" bindtap="toDetail">
-                    <image class="item-status" src="/pages/images/status-complete.png" mode="" />
+            <scroll-view class="viewBox">
+                <view class="item" wx:for="{{completeList}}" wx:for-item="item" wx:key="index" bindtap="toDetail">
+                    <image class="item-status" wx:if="{{item.status == 3}}" src="/pages/images/status-complete.png" mode="" />
+                    <image class="item-status" wx:if="{{item.status == -1}}" src="/pages/images/status-incomplete.png" mode="" />
                     <view class="item-row">
                         <text class="item-label">报修类型:</text>
-                        <text class="item-value">{{item.type}}</text>
+                        <text class="item-value">{{item.repairType}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修地址:</text>
-                        <text class="item-value">{{item.address}}</text>
+                        <text class="item-value">{{item.maintenanceAddress}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修结果:</text>
-                        <!-- <text class="item-value"></text> -->
-                        <view class="item-imgbox">
+                        <text class="item-value" wx:if="{{item.status == -1}}">维修失败</text>
+                        <view class="item-imgbox" wx:if="{{item.status == 3}}">
                             <image class="item-image" src="" mode="" />
                             <image class="item-image" src="" mode="" />
                         </view>
                     </view>
-                    <view class="item-row">
+                    <view class="item-row" wx:if="{{item.status == -1}}">
                         <text class="item-label">原因:</text>
-                        <text class="item-value">{{item.time}}</text>
+                        <text class="item-value">{{item.workerDescription}}</text>
                     </view>
                 </view>
             </scroll-view>
+            <view wx:if="{{nodata2}}" style="color: #999999;width: 100%;text-align: center;margin-top: 50rpx;">暂无数据</view>
         </swiper-item>
     </swiper>
 </view>

+ 6 - 1
nnzwminiapp/pagesPublic/pages/work-order/work-order.wxss

@@ -133,6 +133,10 @@ Page {
     border-radius: 0;
 }
 
+.viewBox {
+    margin-bottom: 100rpx;
+}
+
 .item {
     margin: 0 30rpx;
     border-bottom: solid 1rpx #C8C8C8;
@@ -144,7 +148,8 @@ Page {
     height: 146rpx;
     position: absolute;
     right: -20rpx;
-    top: -20rpx;
+    margin-top: -48rpx;
+    /* top: -20rpx; */
 }
 
 .item-row {