瀏覽代碼

1.修改报修记录item传参方式
2.报修记录详情界面
3.报修记录上传图片接口

FailedToRead 2 年之前
父節點
當前提交
2b366575be

+ 2 - 0
miniprogram/app.json

@@ -4,10 +4,12 @@
         "pages/login/login",
         "pages/logs/logs",
         "pages/register/register",
+        "pages/faultInfo/faultInfo",
         "pages/teacher/index/index",
         "pages/installer/index/index",
         "pages/repairman/index/index",
         "pages/itadministrator/index/index"
+
     ],
     "window": {
         "backgroundTextStyle": "light",

+ 4 - 0
miniprogram/component/fauleInfoItem/faultInfoItem.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 43 - 0
miniprogram/component/fauleInfoItem/faultInfoItem.ts

@@ -0,0 +1,43 @@
+// component/fauleInfoItem/faultInfoItem.ts
+import { TimeUtil } from '../../utils/TimeUtil'
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        itemData: null
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        myItemData: null,
+        itemTime: ''
+    },
+
+    lifetimes: {
+        attached: function () {
+            // 在组件实例被从页面节点树添加时执行
+            //创建节点选择器
+            console.log("this.properties.itemData:", this.properties.itemData)
+            this.setData({
+                myItemData: this.properties.itemData,
+                itemTime: TimeUtil.dateFormat(parseInt(this.properties.itemData.created), "yyyy-MM-dd HH:mm"),
+
+            })
+
+        },
+        detached: function () {
+            // 在组件实例被从页面节点树移除时执行
+
+        },
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+
+    }
+})

+ 20 - 0
miniprogram/component/fauleInfoItem/faultInfoItem.wxml

@@ -0,0 +1,20 @@
+<!--component/fauleInfoItem/faultInfoItem.wxml-->
+<view class="itemLayout" id="faultInfoItem">
+    <view class="itemTextLayout">
+        <view class="round"></view>
+        <text class="itemTitleText">{{myItemData.title}}</text>
+        <text class="itemTitleText">{{itemTime}}</text>
+    </view>
+
+    <view class="contentLayout">
+        <text class="contentLayoutText">{{myItemData.describe}}</text>
+    </view>
+
+    <scroll-view scroll-x class="itemImgScroll">
+        <view wx:for="{{6}}" class="itemScrollItem" wx:key="index">
+            <image class="itemScrollItemImg"></image>
+        </view>
+
+    </scroll-view>
+
+</view>

+ 61 - 0
miniprogram/component/fauleInfoItem/faultInfoItem.wxss

@@ -0,0 +1,61 @@
+/* component/fauleInfoItem/faultInfoItem.wxss */
+
+.round {
+    width: 18rpx;
+    height: 18rpx;
+    background: #c6c6c6;
+    border-radius: 50%;
+}
+
+.itemLayout {
+    width: 710rpx;
+    display: flex;
+    flex-direction: column;
+    margin-bottom: 30rpx;
+}
+
+.itemTextLayout {
+    flex-direction: row;
+    display: flex;
+    align-items: center;
+}
+
+.itemTitleText {
+    margin-left: 19rpx;
+    font-size: 30rpx;
+    font-weight: 500;
+    color: #666666;
+}
+
+
+.contentLayout {
+    width: 660rpx;
+    margin-left: 38rpx;
+}
+
+.contentLayoutText {
+    font-size: 24rpx;
+    color: #666666;
+    line-height: 40rpx
+}
+
+.itemImgScroll {
+    height: 87rpx;
+    width: 660rpx;
+    margin-left: 31rpx;
+    margin-top: 10rpx;
+    white-space: nowrap;
+}
+
+.itemScrollItem {
+    display: flex;
+    flex-direction: row;
+    display: inline-block;
+}
+
+.itemScrollItemImg {
+    width: 154rpx;
+    height: 87rpx;
+    background-color: teal;
+    margin-right: 10rpx;
+}

+ 25 - 30
miniprogram/component/faultItem/faultItem.ts

@@ -1,4 +1,5 @@
 // component/faultItem/faultItem.ts
+import { httpUtil } from '../../utils/restful';
 import { TimeUtil } from '../../utils/TimeUtil'
 Component({
     /**
@@ -6,30 +7,8 @@ Component({
      */
     properties: {
         //0=待维修 1=维修中 2=已完成
-        faultStatus: {
-            type: Number,
-            value: 0
-        },
-        faultRepairNo: {
-            type: String,
-            value: ''
-        },
-        faultReportTime: {
-            type: String,
-            value: ''
-        },
-        faultProvinceCity: {
-            type: String,
-            value: ''
-        },
-        faultSchoolName: {
-            type: String,
-            value: ''
-        },
-        faultClassName: {
-            type: String,
-            value: ''
-        }
+
+        itemData: null
     },
 
     /**
@@ -39,13 +18,14 @@ Component({
         status: 0,
         statusText: "",
         faultTime: '',
+        myItemData: null,
     },
     lifetimes: {
         attached: function () {
             // 在组件实例被从页面节点树添加时执行
-
             let text = "";
-            switch (Number(this.properties.faultStatus)) {
+
+            switch (Number(this.properties.itemData.processType)) {
                 case 0:
                     text = "待维修";
                     break;
@@ -57,12 +37,12 @@ Component({
                     break;
             }
             this.setData({
-                status: this.properties.faultStatus,
+                status: this.properties.itemData.processType,
                 statusText: text,
-                faultTime: TimeUtil.dateFormat(parseInt(this.properties.faultReportTime), "yyyy-MM-dd HH:mm")
+                faultTime: TimeUtil.dateFormat(parseInt(this.properties.itemData.reportTime), "yyyy-MM-dd HH:mm"),
+                myItemData: this.properties.itemData
             })
-            console.log("status:", this.data.status)
-            console.log("propertiesstatus:", this.properties.faultStatus)
+
         },
         detached: function () {
             // 在组件实例被从页面节点树移除时执行
@@ -74,6 +54,21 @@ Component({
      * 组件的方法列表
      */
     methods: {
+        toFaultInfoPage: function () {
+            console.log("去故障详情界面")
+            httpUtil.wxGet(httpUtil.interfaces.getFaultInfoByDevId + this.data.itemData.id, null).then((res: any) => {
+                console.log("获取故障详情成功:", res)
+
+                let item = JSON.stringify(res.data.data)
+
+                wx.navigateTo({
+                    url: '../../faultInfo/faultInfo?item=' + item
+                })
 
+            }).catch((res: any) => {
+                console.log("获取故障详情失败:", res)
+            })
+
+        }
     }
 })

+ 4 - 4
miniprogram/component/faultItem/faultItem.wxml

@@ -1,6 +1,6 @@
 <!--component/faultItem/faultItem.wxml-->
 
-<view class="item_bg">
+<view class="item_bg" bindtap="toFaultInfoPage">
     <view class="{{status==0?'fault_status_wait':''}} {{status==1?'fault_status_over':''}}  {{status==1?'fault_status_repair':''}}">
         <text class="fault_status_text">{{statusText}}</text>
     </view>
@@ -9,18 +9,18 @@
         <view class="fault_info_layout_item_bg">
             <image src="../../image/fault/fault_time.png" class="fault_info_layout_item_icon"></image>
             <text class="fault_info_layout_item_text">提交时间:</text>
-            <text class="fault_info_layout_item_text" style="flex: 1;">{{faultTime}}</text>
+            <text class="fault_info_layout_item_text" style="flex: 1;">{{myItemData.reportTime}}</text>
         </view>
         <view class="fault_info_layout_item_bg">
             <image src=" ../../image/fault/fault_number.png" class="fault_info_layout_item_icon">
             </image>
             <text class=" fault_info_layout_item_text">报修单号:</text>
-            <text class="fault_info_layout_item_text" style="flex: 1;">{{faultRepairNo}}</text>
+            <text class="fault_info_layout_item_text" style="flex: 1;">{{myItemData.repairNo}}</text>
         </view>
         <view class="fault_info_layout_item_bg">
             <image src="../../image/fault/fault_address.png" class="fault_info_layout_item_icon"></image>
             <text class="fault_info_layout_item_text">详细地址:</text>
-            <text class="fault_info_layout_item_text" style="flex: 1;">{{faultProvinceCity}} {{faultSchoolName}} {{faultClassName}}</text>
+            <text class="fault_info_layout_item_text" style="flex: 1;">{{myItemData.provinceCity}} {{myItemData.schoolName}} {{myItemData.className}}</text>
         </view>
     </view>
 

+ 48 - 0
miniprogram/component/teacher/teacherFault/teacherFault.ts

@@ -45,6 +45,8 @@ Component({
         initFirst: true,
         deviceId: '',
         describe: "",
+        postFaultListImg: [],
+        postImg: [],
         //报修记录用到的参数
         faultList: []
 
@@ -346,6 +348,41 @@ Component({
             })
         },
 
+        //从本机相册获取图片
+        getFaultImg: function () {
+
+            let that = this;
+            wx.chooseImage({
+                count: 9, // 默认9
+                sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
+                sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
+                success: function (res) {
+                    // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
+
+                    that.setData({
+                        postFaultListImg: that.data.postFaultListImg.concat(res.tempFilePaths)
+                    })
+                    res.tempFilePaths.forEach((item, index) => {
+                        httpUtil.wxUploadFile(httpUtil.interfaces.uploadImageList, item, index.toString(), {
+                            'userId': httpUtil.httpData.userId,
+                            'deviceId': that.data.deviceId
+                        }).then((res: any) => {
+                            //拿不到data
+                            console.log("上传图片成功:", res)
+                            console.log("上传图片成功:", res.data)
+                            that.setData({
+                                postImg: that.data.postImg.concat(res.data)
+                            })
+                            console.log(" that.data.postImg:", that.data.postImg)
+                        }).catch((res => {
+                            console.log("上传图片失败:", res)
+                        }))
+                    })
+                }
+            })
+
+        },
+
         //提交故障
         submitFault: function (event: any) {
             if (!this.data.deviceId) {
@@ -373,6 +410,15 @@ Component({
                 return;
             }
 
+            let img = '';
+            this.data.postImg.forEach((res, index) => {
+                if (index < this.data.postImg.length) {
+                    img = img + res + ","
+                } else {
+                    img = img + res
+                }
+            })
+
             let params = {
                 city: this.data.cityValue,
                 classId: this.data.classId,
@@ -414,6 +460,8 @@ Component({
 
 
 
+
+
         },
 
         getFaultByUserId: function () {

+ 4 - 3
miniprogram/component/teacher/teacherFault/teacherFault.wxml

@@ -76,9 +76,10 @@
         <view class="fault_info_layout">
             <textarea bindinput="bindFaultText" class="fault_info_textarea" placeholder="故障描述:请描述故障情况请描述故障情况,\n请描述故障情况请描述故障情况" value="{{describe}}"></textarea>
             <scroll-view scroll-x class="fault_info_scroll">
-                <view wx:for="{{1}}" wx:key="index" style="display:inline-block;">
-                    <image class="fault_info_scroll_item"></image>
+                <view wx:for="{{postFaultListImg}}" wx:key="index" style="display:inline-block;">
+                    <image class="fault_info_scroll_item" src="{{item}}"></image>
                 </view>
+                <image class="fault_info_scroll_item" style="background-color: red;" bindtap="getFaultImg"></image>
             </scroll-view>
         </view>
 
@@ -94,7 +95,7 @@
     <!-- 报修记录-->
     <scroll-view wx:if="{{pageState==1}}" scroll-y="true" class="scrollview">
         <view wx:for="{{faultList}}" class="scroll_item_bg" wx:key="key" wx:for-index="idx" wx:for-item="item">
-            <fauleItem faultStatus="{{item.processType}}" faultRepairNo="{{item.repairNo}}" faultProvinceCity="{{item.provinceCity}}" faultSchoolName="{{item.schoolName}}" faultClassName="{{item.className}}" faultReportTime="{{item.reportTime}}"></fauleItem>
+            <fauleItem itemData="{{item}}" ></fauleItem>
         </view>
     </scroll-view>
     <!-- 报修记录-->

+ 1 - 1
miniprogram/component/teacher/teacherFile/teacherFile.wxml

@@ -12,7 +12,7 @@
     </view>
 
     <scroll-view scroll-y="true" class="scrollview">
-        <view wx:for="{{20}}" class="scroll_item_bg" wx:key="index">
+        <view wx:for="{{5}}" class="scroll_item_bg" wx:key="index">
             <fileItem></fileItem>
         </view>
 

+ 7 - 0
miniprogram/pages/faultInfo/faultInfo.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+
+    "faultInfoItem": "../../component/fauleInfoItem/faultInfoItem"
+
+  }
+}

+ 82 - 0
miniprogram/pages/faultInfo/faultInfo.ts

@@ -0,0 +1,82 @@
+// pages/faultInfo/faultInfo.ts
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        //是否隐藏评价按钮
+        showAppraise: false,
+        contentLineHeight: 0,
+        itemData: null,
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+        let obj = JSON.parse(options.item);
+        console.log("obnj-----", obj)
+        this.setData({
+            itemData: obj
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+        let that = this;
+        //创建节点选择器
+        var query = wx.createSelectorQuery();
+        //选择id
+        query.select('#contentView').boundingClientRect()
+        query.exec(function (res) {
+            that.setData({
+                contentLineHeight: res[0].height
+            })
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 59 - 0
miniprogram/pages/faultInfo/faultInfo.wxml

@@ -0,0 +1,59 @@
+<!--pages/faultInfo/faultInfo.wxml-->
+<view class="container">
+    <view style="display: flex;flex-direction: column;height: 100%;">
+        <scroll-view class="pageScroll" scroll-y enable-flex="{{true}}">
+            <view class="pageScrollLayout">
+                <view>
+                    <view>
+                        <text class="numberText">报修单号:{{itemData.repairNo}}</text>
+                    </view>
+                    <view class="centerInfoLayout">
+
+                        <view id="contentView" style="display: flex;flex-direction: column;justify-content: start;  align-items: center;">
+                            <view class="centerInfoLayout_Line" style="height: {{contentLineHeight}}px;"></view>
+                            <view wx:for="{{itemData.faultProcessList}}" wx:key="index">
+                                <faultInfoItem itemData="{{item}}"></faultInfoItem>
+                            </view>
+                        </view>
+                        <view class="centerFaultDeviceLayout">
+                            <text class="centerFaultDeviceLayout_Title">设备详情</text>
+                            <view class="centerFaultDeviceLayout_ItemLayout">
+                                <view class="centerFaultDeviceLayout_ItemLayout2">
+                                    <view class="centerFaultDeviceLayout_ItemLayout3">
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Left">故障级别</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.faultLevel}}</text>
+                                    </view>
+                                    <view class="centerFaultDeviceLayout_ItemLayout3">
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Left">地区:</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.provinceCity}}</text>
+                                    </view>
+                                    <view class="centerFaultDeviceLayout_ItemLayout3">
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Left">学校:</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.schoolName}}</text>
+                                    </view>
+                                    <view class="centerFaultDeviceLayout_ItemLayout3">
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Left">班级:</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.className}}</text>
+                                    </view>
+                                    <view class="centerFaultDeviceLayout_ItemLayout3">
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Left">设备ID:</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.deviceId}}</text>
+                                    </view>
+                                </view>
+                            </view>
+                        </view>
+
+                    </view>
+
+
+                </view>
+            </view>
+        </scroll-view>
+
+
+        <view class="appraiseLayout" hidden="{{showAppraise}}">
+            <text style="font-size: 31rpx;color: #ffffff;">评价</text>
+        </view>
+    </view>
+
+</view>

+ 93 - 0
miniprogram/pages/faultInfo/faultInfo.wxss

@@ -0,0 +1,93 @@
+/* pages/faultInfo/faultInfo.wxss */
+
+
+
+.pageScroll {
+    width: 100%;
+    flex: 1;
+    height: 0;
+    display: flex;
+    flex-direction: column
+}
+
+.pageScrollLayout {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+}
+
+.numberText {
+    font-size: 30rpx;
+    color: #474747;
+    margin-top: 17rpx;
+    margin-left: 28rpx;
+}
+
+.centerInfoLayout {
+    width: 100%;
+    margin-top: 21rpx;
+}
+
+.centerInfoLayout_Line {
+    width: 1rpx;
+    background-color: #979797;
+    height: 100%;
+    position: absolute;
+    justify-self: start;
+    left: 29rpx;
+}
+
+.centerFaultDeviceLayout {
+    width: 100%;
+    margin-top: 54rpx;
+}
+
+.centerFaultDeviceLayout_Title {
+    font-size: 30rpx;
+    color: #474747;
+    margin-left: 28rpx;
+}
+
+.centerFaultDeviceLayout_ItemLayout {
+    width: 100%;
+    display: flex;
+    flex-direction: column;
+    justify-content: center;
+    align-items: center;
+}
+
+.centerFaultDeviceLayout_ItemLayout2 {
+    width: 674rpx;
+    height: 404rpx;
+    padding-top: 41rpx;
+}
+
+.centerFaultDeviceLayout_ItemLayout3 {
+    height: 80rpx;
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    margin-left: 43rpx;
+    margin-right: 43rpx;
+}
+
+.centerFaultDeviceLayout_ItemLayout3_Left {
+    font-size: 30rpx;
+    color: #333333;
+}
+
+.centerFaultDeviceLayout_ItemLayout3_Rgiht {
+    font-size: 30rpx;
+    color: #999999;
+}
+
+.appraiseLayout {
+    width: 100%;
+    height: 85rpx;
+    background-color: #629CF7;
+    text-align: center;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}

+ 31 - 0
miniprogram/utils/restful.ts

@@ -53,9 +53,15 @@ const interfaces = {
     //提交设备报修
     postDeviceFault: '/tch/fault',
 
+    //上传单个图片
+    uploadImageList: '/file/upload',
+
+
     //根据userId获取提交的报修记录
     getDeviceFault: '/tch/fault',
 
+    //根据故障ID获取故障详情(后面拼接ID)
+    getFaultInfoByDevId: '/tch/fault/'
 
 
 
@@ -97,6 +103,28 @@ function fun(url: String, type: any, data: any, otherType: any) {
     })
     return promise
 }
+
+
+function uploadFile(url: String, filePath: string, fileName: string, formData: any) {
+    let promise = new Promise((resolve, reject) => {
+        wx.uploadFile({
+            url: HOST + url,
+            filePath: filePath,
+            name: fileName,
+            formData: formData,
+            success(res) {
+                resolve(res.data)
+                // const data = res.data
+                //do something
+            },
+            fail(res) {
+                reject(res)
+            }
+        })
+    })
+    return promise;
+}
+
 export const httpUtil = {
     httpData,
     interfaces,
@@ -114,5 +142,8 @@ export const httpUtil = {
     },
     wxDel: function (url: String, data: any) {
         return fun(url, 'DELETE', data, null)
+    },
+    wxUploadFile: function (url: String, filePath: string, fileName: string, formData: any) {
+        return uploadFile(url, filePath, fileName, formData)
     }
 }