Переглянути джерело

Merge branch 'master' of http://116.63.33.55/git/nazw

elis 2 роки тому
батько
коміт
851fa5044b

+ 2 - 0
nngkxxdp/src/main/resources/mapper/SRepairDao.xml

@@ -231,6 +231,7 @@
                 #{s}
             </foreach>
         </if>
+        ORDER BY appointment_time ASC
         limit #{page}, #{limit}
     </select>
 
@@ -239,6 +240,7 @@
         id, repair_type, user_description, repair_pic, phone_num, status, worker_description, result_pic, worker_id, create_time, update_time,user_id,appointment_time,maintenance_address
         from s_repair
         where user_id = #{userId} AND is_del = 0
+        ORDER BY appointment_time ASC
         limit #{page}, #{limit}
     </select>
 

+ 26 - 1
nnzwminiapp/pages/myCenter/myCenter.js

@@ -6,7 +6,12 @@ import {
 import {
     cacheGet
 } from "../../utils/cacheUtil"
+import {
+    baseUrl,
+    request
+} from "../../pages/api/canteen-request.js"
 let app = getApp();
+
 Page({
     /**
      * 页面的初始数据
@@ -17,7 +22,8 @@ Page({
         avatarUrl: "",
         hasUserInfo: false,
         imgUrl: imgUrl,
-        show: false
+        show: false,
+        showWorkOrder: false
     },
     // 自定义函数
     toCanteen: function (e) {
@@ -107,6 +113,25 @@ Page({
                 hasUserInfo: true
             })
         }
+
+        // 获取用户角色
+        request({
+            url: '/mini/worker/getUserType',
+            method: 'GET',
+            data: {
+                userId: wx.getStorageSync('userid')
+            }
+        }).then(res => {
+            if (res.result) {
+                let userType = res.data;
+                if ("0" == userType || "2" == userType) {
+                    // 显示工单维修菜单
+                    this.setData({
+                        showWorkOrder: true
+                    });
+                }
+            }
+        });
     },
 
     /**

+ 1 - 1
nnzwminiapp/pages/myCenter/myCenter.wxml

@@ -90,7 +90,7 @@
 				</view>
 			</view>
             <view class="line"></view>
-			<view class="list-item" bindtap="toWorkOrder">
+			<view class="list-item" bindtap="toWorkOrder" wx:if="{{showWorkOrder}}">
 				<view class="left">
 					<image src="../images/l-rwzx.png" alt=""></image>
 					<text>工单维修</text>

+ 169 - 86
nnzwminiapp/pagesPublic/pages/work-order-detail/work-order-detail.js

@@ -1,4 +1,5 @@
 // pagesPublic/pages/work-order-detail/work-order-detail.js
+const FormData = require('../../pages/menu/formData.js');
 import {
     imgUrl
 } from "../api/request"
@@ -22,7 +23,9 @@ Page({
         statusText2: '待审核',
         statusText3: '待上门',
         statusText4: '待确认',
-        tempFileList: []
+        tempFileList: [],
+        typeList: [],
+        infoId: ''
     },
 
     /**
@@ -31,113 +34,35 @@ Page({
     onLoad(options) {
         console.info(options);
         this.setData({
-            isUser: options.isuser
-        });
-        request({
-            url: '/mini/worker/orderInfo',
-            method: 'GET',
-            data: {
-                'id': options.id
-            }
-        }).then(res => {
-            console.info(res)
-            let data = res.data;
-            this.setData({
-                type: data.repairType,
-                address: data.maintenanceAddress,
-                phone: data.phoneNum,
-                arriveTime: data.appointmentTime,
-                description: data.userDescription
-            });
-
-            request({
-                url: '/food/getFoodPicByPicId',
-                method: 'GET',
-                data: {
-                    'picId': data.repairPic
-                }
-            }).then(re => {
-                console.info(re)
-                if (re.data && re.data.length > 0) {
-                    let arr = [];
-                    for (let i in re.data) {
-                        arr.push(baseUrl + '/' + re.data[i].path);
-                    }
-                    this.setData({
-                        image: arr
-                    });
-                }
-            });
-
-            if (data.status == 0) {
-                this.setData({
-                    checked2: '',
-                    checked3: '',
-                    checked4: '',
-                });
-            } else if (data.status == 1) {
-                this.setData({
-                    checked2: 'checked',
-                    checked3: '',
-                    checked4: '',
-                    statusText2: '已审核'
-                });
-            } else if (data.status == 2) {
-                this.setData({
-                    checked2: 'checked',
-                    checked3: 'checked',
-                    checked4: '',
-                    statusText2: '已审核',
-                    statusText3: '已上门'
-                });
-            } else if (data.status == 3) {
-                this.setData({
-                    checked2: 'checked',
-                    checked3: 'checked',
-                    checked4: 'checked',
-                    statusText2: '已审核',
-                    statusText3: '已上门',
-                    statusText4: '已确认'
-                });
-            } else {
-                this.setData({
-                    checked2: 'checked',
-                    checked3: 'checked',
-                    checked4: 'checked',
-                    statusText2: '已审核',
-                    statusText3: '已上门',
-                    statusText4: '已确认'
-                });
-            }
+            isUser: (options.isuser == 'true' ? true : false),
+            infoId: options.id
         });
+        // 设置所有报修类型
+        this.setRepairType(options.id);
     },
 
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
     onReady() {
-
     },
 
     /**
      * 生命周期函数--监听页面显示
      */
     onShow() {
-
     },
 
     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide() {
-
     },
 
     /**
      * 生命周期函数--监听页面卸载
      */
     onUnload() {
-
     },
 
     /**
@@ -169,15 +94,16 @@ Page({
      * 上传报修结果图片
      */
     uploadImage() {
+        let that = this;
         wx.chooseMedia({
             success(res) {
                 console.info(res);
                 if (res.errMsg == 'chooseMedia:ok') {
-                    let tempList = this.data.tempFileList;
+                    let tempList = that.data.tempFileList;
                     for (let i in res.tempFiles) {
                         tempList.push(res.tempFiles[i].tempFilePath);
                     }
-                    this.setData({
+                    that.setData({
                         tempFileList: tempList
                     });
                 }
@@ -185,9 +111,21 @@ Page({
         });
     },
 
+    /**
+     * 提交维修结果
+     * @param {*} e 
+     */
     submitReport(e) {
         console.info(e)
         let complete = this.data.complete;
+        let tempList = this.data.tempFileList;
+        if (complete && tempList.length == 0) {
+            wx.showToast({
+                title: '请上传维修结果照片',
+                icon: 'error'
+            });
+            return;
+        }
         if (!complete && !e.detail.value.reason) {
             wx.showToast({
                 title: '请填写失败原因',
@@ -202,7 +140,8 @@ Page({
         } else {
             formData.append('status', -1);
         }
-        formData.append('workerDescription', e.detail.value.reason);
+        formData.append('id', this.data.infoId);
+        formData.append('workerDescription', e.detail.value.reason ? e.detail.value.reason : '');
         // formData.append('userId', wx.getStorageSync('userid'));
         for (let i in tempList) {
             formData.appendFile('files', tempList[i]);
@@ -233,4 +172,148 @@ Page({
             }
         });
     },
+
+    /**
+     * 设置报修类型
+     */
+    setRepairType(id) {
+        request({
+            url: '/mini/worker/getDictByType',
+            method: 'GET',
+            data: {
+                types: 'repair_type',
+                codes: ''
+            }
+        }).then(res => {
+            // console.info(res)
+            if (res.result) {
+                let data = res.data;
+                this.setData({
+                    typeList: data
+                });
+                // 加载工单详情
+                this.loadWorkOrderInfo(id);
+            }
+        });
+    },
+
+    /**
+     * 加载工单详情
+     * @param {*} id 
+     */
+    loadWorkOrderInfo(id) {
+        wx.showLoading({
+            title: '加载中...'
+        });
+        request({
+            url: '/mini/worker/orderInfo',
+            method: 'GET',
+            data: {
+                'id': id
+            }
+        }).then(res => {
+            console.info(res)
+            let data = res.data;
+            this.setData({
+                type: data.repairType,
+                address: data.maintenanceAddress,
+                phone: data.phoneNum,
+                arriveTime: data.appointmentTime,
+                description: data.userDescription,
+                status: data.status,
+                workerDescription: data.workerDescription
+            });
+            let typeList = this.data.typeList;
+            for (let i in typeList) {
+                if (typeList[i].code == data.repairType) {
+                    this.setData({
+                        type: typeList[i].codeValue,
+                    });
+                    break;
+                }
+            }
+
+            request({
+                url: '/food/getFoodPicByPicId',
+                method: 'GET',
+                data: {
+                    'picId': data.repairPic
+                }
+            }).then(re => {
+                console.info(re)
+                if (re.data && re.data.length > 0) {
+                    let arr = [];
+                    for (let i in re.data) {
+                        arr.push(baseUrl + '/' + re.data[i].path);
+                    }
+                    this.setData({
+                        image: arr
+                    });
+                }
+            });
+
+            if (data.resultPic) {
+                request({
+                    url: '/food/getFoodPicByPicId',
+                    method: 'GET',
+                    data: {
+                        'picId': data.repairPic
+                    }
+                }).then(re => {
+                    console.info(re)
+                    if (re.data && re.data.length > 0) {
+                        let arr = [];
+                        for (let i in re.data) {
+                            arr.push(baseUrl + '/' + re.data[i].path);
+                        }
+                        this.setData({
+                            images: arr
+                        });
+                    }
+                });
+            }
+
+            if (data.status == 0) {
+                this.setData({
+                    checked2: '',
+                    checked3: '',
+                    checked4: '',
+                });
+            } else if (data.status == 1) {
+                this.setData({
+                    checked2: 'checked',
+                    checked3: '',
+                    checked4: '',
+                    statusText2: '已审核'
+                });
+            } else if (data.status == 2) {
+                this.setData({
+                    checked2: 'checked',
+                    checked3: 'checked',
+                    checked4: '',
+                    statusText2: '已审核',
+                    statusText3: '已上门'
+                });
+            } else if (data.status == 3) {
+                this.setData({
+                    checked2: 'checked',
+                    checked3: 'checked',
+                    checked4: 'checked',
+                    statusText2: '已审核',
+                    statusText3: '已上门',
+                    statusText4: '已确认'
+                });
+            } else {
+                this.setData({
+                    checked2: 'checked',
+                    checked3: 'checked',
+                    checked4: 'checked',
+                    statusText2: '已审核',
+                    statusText3: '已上门',
+                    statusText4: '已确认'
+                });
+            }
+            wx.hideLoading();
+        });
+    }
 })

+ 12 - 1
nnzwminiapp/pagesPublic/pages/work-order-detail/work-order-detail.wxml

@@ -33,6 +33,17 @@
                 <image class="item-image" src="{{item}}" mode="" />
             </view>
         </view>
+        <!-- <view class="item-row" style="align-items: flex-start;" wx:if="{{status == -1 || status == 3}}">
+            <text class="item-label">维修结果:</text>
+            <text class="item-value" wx:if="{{status == -1}}">维修失败</text>
+            <view class="item-image-box" wx:if="{{status == 3}}" wx:for="{{images}}" wx:key="cindex" wx:for-item="citem">
+                <image class="item-image" src="{{citem}}" mode="" />
+            </view>
+        </view>
+        <view class="item-row" wx:if="{{status == -1}}">
+            <text class="item-label">原因:</text>
+            <text class="item-value">{{workerDescription}}</text>
+        </view> -->
     </view>
 </view>
 
@@ -118,7 +129,7 @@
                 <label for="" class="report-label">维修结果:</label>
                 <image class="report-photo" src="/pages/images/photo2.png" mode="" bindtap="uploadImage" />
                 <view wx:for="{{tempFileList}}" wx:key="index" wx:for-item="item">
-                    <image class="form-image" src="{{item}}" mode="" />
+                    <image class="report-image" src="{{item}}" mode="" />
                 </view>
             </view>
             <view class="report-row" wx:else="{{complete}}">

+ 6 - 0
nnzwminiapp/pagesPublic/pages/work-order-detail/work-order-detail.wxss

@@ -246,6 +246,12 @@ radio-group label:nth-child(2) {
     padding: 36rpx 35rpx;
 }
 
+.report-image {
+    width: 112rpx;
+    height: 112rpx;
+    margin-left: 10rpx;
+}
+
 .report-input {
     width: 427rpx;
     border-bottom: solid 1rpx #999999;

+ 102 - 65
nnzwminiapp/pagesPublic/pages/work-order/work-order.js

@@ -40,83 +40,74 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-        // 获取完整的年月日 时分秒,以及默认显示的数组
-        let obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
-        // 精确到分的处理,将数组的秒去掉
-        let lastArray = obj.dateTimeArray.pop();
-        let lastTime = obj.dateTime.pop();
-        this.setData({
-            dateTime: obj.dateTime,
-            dateTimeArray: obj.dateTimeArray
-        });
-
-        // 设置所有报修类型
-        this.setRepairType();
-        let that = this;
+        // 查询用户所属角色
         request({
-          url: '/mini/worker/getUserType',
-          method: 'GET',
-          data: {
-            userId: wx.getStorageSync('userid')
-          }
+            url: '/mini/worker/getUserType',
+            method: 'GET',
+            data: {
+                userId: wx.getStorageSync('userid')
+            }
         }).then(res => {
-          if (res.result) {
-
-            let userType = res.data;
-            if ("0" == userType|| "1" == userType) {
-                // 普通用户
-                this.setData({
-                  isUser: true
-                });
-                // 初始化待维修工单
-                that.loadTobeRepair();
-                // 初始化已完成工单
-                // this.loadComplete();
-            }else{
-              this.setData({
-                isUser: false
-              });
+            if (res.result) {
+                let userType = res.data;
+                if ("0" == userType) {
+                    // 普通用户
+                    this.setData({
+                        isUser: true
+                    });
+                    // 获取完整的年月日 时分秒,以及默认显示的数组
+                    let obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
+                    // 精确到分的处理,将数组的秒去掉
+                    let lastArray = obj.dateTimeArray.pop();
+                    let lastTime = obj.dateTime.pop();
+                    this.setData({
+                        dateTime: obj.dateTime,
+                        dateTimeArray: obj.dateTimeArray
+                    });
+                    // 设置所有报修类型
+                    this.setRepairType();
+                } else if ('2' == userType) {
+                    this.setData({
+                        isUser: false
+                    });
+                    // 设置所有报修类型
+                    this.setRepairType();
+                    // 初始化待维修工单
+                    this.loadTobeRepair();
+                    // 初始化已完成工单
+                    // this.loadComplete();
+                } else {
+                    wx.navigateBack();
+                }
+            } else {
+                wx.navigateBack();
             }
-          
-          }else{
-          }
         });
-
-        // let isUser = this.data.isUser;
-        // if (!isUser) {
-        //     // 初始化待维修工单
-        //     this.loadTobeRepair();
-        //     // 初始化已完成工单
-        //     // this.loadComplete();
-        // }
     },
 
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
     onReady() {
-
     },
 
     /**
      * 生命周期函数--监听页面显示
      */
     onShow() {
-
+        this.onPullDownRefresh();
     },
 
     /**
      * 生命周期函数--监听页面隐藏
      */
     onHide() {
-
     },
 
     /**
      * 生命周期函数--监听页面卸载
      */
     onUnload() {
-
     },
 
     /**
@@ -416,9 +407,10 @@ Page({
                 isUser: true
             }
         }).then(res => {
-            console.info(res)
+            // console.info(res)
             let data = res.data;
             if (data && data.length > 0) {
+                let typeList = this.data.typeList;
                 for (let i in data) {
                     if (data[i].status == 3) {
                         data[i].image = 'status-complete.png';
@@ -427,6 +419,12 @@ Page({
                     } else {
                         data[i].image = 'status-repair.png';
                     }
+                    for (let j in typeList) {
+                        if (data[i].repairType == typeList[j].code) {
+                            data[i].typeName = typeList[j].codeValue;
+                            break;
+                        }
+                    }
                 }
                 if (ispullup) {
                     data = data.concat(this.data.list);
@@ -438,6 +436,7 @@ Page({
             } else {
                 if (!ispullup) {
                     this.setData({
+                        list: [],
                         nodata: true
                     });
                 }
@@ -462,9 +461,18 @@ Page({
                 todo: true
             }
         }).then(res => {
-            console.info(res)
+            // console.info(res)
             let data = res.data;
             if (data && data.length > 0) {
+                let typeList = this.data.typeList;
+                for (let i in data) {
+                    for (let j in typeList) {
+                        if (data[i].repairType == typeList[j].code) {
+                            data[i].typeName = typeList[j].codeValue;
+                            break;
+                        }
+                    }
+                }
                 if (ispullup) {
                     data = data.concat(this.data.repairList);
                 }
@@ -475,6 +483,7 @@ Page({
             } else {
                 if (!ispullup) {
                     this.setData({
+                        repairList: [],
                         nodata: true
                     });
                 }
@@ -499,33 +508,61 @@ Page({
                 close: true
             }
         }).then(res => {
-            console.info(res)
+            // console.info(res)
             let data = res.data;
             if (data && data.length > 0) {
+                let typeList = this.data.typeList;
+                for (let i in data) {
+                    if (data[i].resultPic) {
+                        request({
+                            url: '/food/getFoodPicByPicId',
+                            method: 'GET',
+                            data: {
+                                'picId': data[i].resultPic
+                            }
+                        }).then(re => {
+                            console.info(re)
+                            if (re.data && re.data.length > 0) {
+                                let arr = [];
+                                for (let j in re.data) {
+                                    arr.push(baseUrl + '/' + re.data[j].path);
+                                }
+                                data[i].images = arr;
+                            }
+                        });
+                    }
+                    for (let j in typeList) {
+                        if (data[i].repairType == typeList[j].code) {
+                            data[i].typeName = typeList[j].codeValue;
+                            break;
+                        }
+                    }
+                }
                 if (ispullup) {
                     data = data.concat(this.data.completeList);
                 }
-                this.setData({
-                    completeList: data,
-                    total2: res.count
-                });
+                setTimeout(() => {
+                    this.setData({
+                        completeList: data,
+                        total2: res.count
+                    });
+                    wx.hideLoading();
+                }, 1500);
             } else {
                 if (!ispullup) {
                     this.setData({
+                        completeList: [],
                         nodata2: true
                     });
                 }
+                wx.hideLoading();
             }
-            wx.hideLoading();
         });
     },
     /**
      * 设置报修类型
      */
     setRepairType() {
-      // this.setData({
-      //          typeList: [{"code": 1, "codeValue": "报修类型一"},{"code": 2, "codeValue": "报修类型二"},{"code": 3, "codeValue": "报修类型三"}]
-      //        });
         request({
             url: '/mini/worker/getDictByType',
             method: 'GET',
@@ -534,12 +571,12 @@ Page({
                 codes: ''
             }
         }).then(res => {
-            console.info(res)
+            // console.info(res)
             if (res.result) {
-              let data = res.data;
-              this.setData({
-                typeList: data
-              });
+                let data = res.data;
+                this.setData({
+                    typeList: data
+                });
             }
         });
     }

+ 7 - 8
nnzwminiapp/pagesPublic/pages/work-order/work-order.wxml

@@ -59,7 +59,7 @@
                     <image class="item-status" src="/pages/images/{{item.image}}" mode="" />
                     <view class="item-row">
                         <text class="item-label">报修类型:</text>
-                        <text class="item-value">{{item.repairType}}</text>
+                        <text class="item-value">{{item.typeName}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修地址:</text>
@@ -93,7 +93,7 @@
                 <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.repairType}}</text>
+                        <text class="item-value">{{item.typeName}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修地址:</text>
@@ -109,23 +109,22 @@
         </swiper-item>
         <swiper-item class="swiperTtemBox">
             <scroll-view class="viewBox">
-                <view class="item" wx:for="{{completeList}}" wx:for-item="item" wx:key="index" bindtap="toDetail">
+                <view class="item" wx:for="{{completeList}}" wx:for-item="item" wx:key="index" data-id="{{item.id}}" data-isuser="true" 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.repairType}}</text>
+                        <text class="item-value">{{item.typeName}}</text>
                     </view>
                     <view class="item-row">
                         <text class="item-label">维修地址:</text>
                         <text class="item-value">{{item.maintenanceAddress}}</text>
                     </view>
-                    <view class="item-row">
+                    <view class="item-row" style="align-items: flex-start;">
                         <text class="item-label">维修结果:</text>
                         <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 class="item-imgbox" wx:if="{{item.status == 3}}" wx:for="{{item.images}}" wx:key="cindex" wx:for-item="citem">
+                            <image class="item-image" src="{{citem}}" mode="" />
                         </view>
                     </view>
                     <view class="item-row" wx:if="{{item.status == -1}}">

+ 7 - 3
nnzwminiapp/pagesPublic/pages/work-order/work-order.wxss

@@ -100,7 +100,7 @@ Page {
 
 .form-input {
     font-size: 30rpx;
-    
+
     border-bottom: solid 1rpx #99999980;
     width: 68%;
     height: 70rpx;
@@ -177,7 +177,11 @@ Page {
     color: #333333;
 }
 
+.item-imgbox {
+    align-items: flex-start;
+}
+
 .item-image {
-    width: 50rpx;
-    height: 50rpx;
+    width: 112rpx;
+    height: 112rpx;
 }