123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- // pagesPublic/pages/work-order-detail/work-order-detail.js
- const FormData = require('../../pages/menu/formData.js');
- import {
- imgUrl
- } from "../api/request"
- import {
- baseUrl,
- request
- } from "../../../pages/api/canteen-request.js"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: imgUrl,
- isUser: true,
- colorComplete: '#508FF4',
- colorIncomplete: '#999999',
- complete: true,
- statusText2: '待审核',
- statusText3: '待上门',
- statusText4: '待确认',
- tempFileList: [],
- typeList: [],
- infoId: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.info(options);
- this.setData({
- isUser: (options.isuser == 'true' ? true : false),
- infoId: options.id
- });
- // 设置所有报修类型
- this.setRepairType(options.id);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 点击返回上一层页面
- */
- backTap() {
- wx.navigateBack();
- },
- radioChange(e) {
- console.info(e)
- // e.detail.value
- if (e.detail.value == '已完成') {
- this.setData({
- colorComplete: '#508FF4',
- colorIncomplete: '#999999',
- complete: true
- });
- } else {
- this.setData({
- colorComplete: '#999999',
- colorIncomplete: '#508FF4',
- complete: false
- });
- }
- },
- /**
- * 上传报修结果图片
- */
- uploadImage() {
- let that = this;
- wx.chooseMedia({
- success(res) {
- console.info(res);
- if (res.errMsg == 'chooseMedia:ok') {
- let tempList = that.data.tempFileList;
- for (let i in res.tempFiles) {
- tempList.push(res.tempFiles[i].tempFilePath);
- }
- that.setData({
- tempFileList: tempList
- });
- }
- }
- });
- },
- /**
- * 提交维修结果
- * @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: '请填写失败原因',
- icon: 'error'
- });
- return;
- }
- let formData = new FormData();
- if (complete) {
- formData.append('status', 3);
- } else {
- formData.append('status', -1);
- }
- 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]);
- }
- let data = formData.getData();
- request({
- url: '/mini/worker/closeOrder',
- method: 'POST',
- data: data.buffer,
- contentType: data.contentType
- }).then(res => {
- console.info(res)
- if (res.result) {
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- mask: true,
- });
- setTimeout(() => {
- wx.navigateBack();
- }, 1500);
- } else {
- wx.showToast({
- title: '提交失败',
- icon: 'error',
- mask: true
- });
- }
- });
- },
- /**
- * 设置报修类型
- */
- 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.resultPic
- }
- }).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();
- });
- },
- /**
- * 预览图片
- */
- previewImg(e) {
- wx.previewImage({
- urls: this.data.image,
- current: e.currentTarget.dataset.src
- });
- },
- previewResultImg(e) {
- wx.previewImage({
- urls: this.data.images,
- current: e.currentTarget.dataset.src
- });
- },
- })
|