471615499@qq.com b4417bee7b 20240825代码提交
windows下部分内容与mac不一致,全量提交;
功能改动:
- 去掉“我的报修”页面的“报修名称”、“故障等级”、“故障时间”三个字段
- 派单员页面添加“故障等级”字段,故障等级由派单员选择设置
- “我的报修”页面,“门牌号”修改为“门牌号(地点)”
- 维修人员不允许评价
- 首页加入请求“我的报修”,可以直接点击进入
- 去掉语音输入,必填描述
- 派单列表页调整
- 维修人员退回工单需要必填理由
2024-08-25 18:17:00 +08:00

408 lines
8.7 KiB
JavaScript

const app = getApp()
import Notify from '@vant/weapp/notify/notify';
import Dialog from '@vant/weapp/dialog/dialog';
import {
selfFormatTimeYMDHMS,
repairAttachUpload,
} from "../../../../utils/util.js"
import {
getDetailRq,
getStatusName,
flowHandleRq,
faultTypeListRq
} from "../../../../api/repair/repair.js"
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
id: '',
detail: {},
files: [],
innerAudioContext: null, // 音频对象
innerAudioContextIsPlay: false, // 音频对象-是否播放
form: {
cause: "",
solution: "",
failureTypeId: null,
failureTypeName: "",
resolve: null,
fileList: [],
},
solveList: [{
name: '已解决',
status: 1,
isSelect: false,
},
{
name: '未解决',
status: 0,
isSelect: false,
}
],
failureTypeList: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('onLoad', options);
let _this = this
_this.setData({
...options
})
// 详情
_this.getDetail(options.id)
// 查询故障原因-字典
_this.getFaultTypeList()
},
getDetail(id) {
let _this = this
getDetailRq({
id
}).then(res => {
console.log("getDetailRq", res);
// 详情
let detail = res.repair
detail.statusName = getStatusName(detail.status)
// 附件
let files = res.files
files.repair = files.repair.map(item => {
item.url = app.IMG_NAME + item.url
return item
})
files.voice = files.voice.map(item => {
item.url = app.IMG_NAME + item.url
return item
})
_this.setData({
detail,
files
})
})
},
// 播放语音
startAudio() {
console.log('startAudio');
let _this = this
// 获取innerAudioContext实例
let innerAudioContext = _this.data.innerAudioContext
let innerAudioContextIsPlay = _this.data.innerAudioContextIsPlay
if (!innerAudioContext) {
// 全局设置播放声音
wx.setInnerAudioOption({
obeyMuteSwitch: false
});
innerAudioContext = wx.createInnerAudioContext()
// 设置音频文件的路径
innerAudioContext.src = _this.data.files.voice[0].url
innerAudioContextIsPlay = false
innerAudioContext.onEnded(() => {
_this.setData({
innerAudioContextIsPlay: false
})
})
}
if (innerAudioContextIsPlay) { // 播放中
innerAudioContext.stop()
innerAudioContextIsPlay = false
} else { // 未播放
innerAudioContext.play()
innerAudioContextIsPlay = true
}
//
_this.setData({
innerAudioContext,
innerAudioContextIsPlay
})
},
// 接收/退回-提交
receiveSubmit(e) {
console.log('receiveSubmit', e);
let _this = this
let status = e.currentTarget.dataset.status
let data = {
"repair": {
"id": _this.data.id
},
"content": "",
"operate": ""
}
if (status == 'yes') {
data.content = "接收工单"
data.operate = "NEXT"
flowHandleRq(data).then(res => {
console.log('flowHandleRq', res);
if (res.code == 0) {
app.vantNotifySuccess(Notify, res.msg)
_this.getDetail(_this.data.id)
} else {
app.vantNotifyErr(Notify, res.msg)
}
})
} else {
data.content = "退回工单"
data.operate = "BACK"
let _this = this
wx.navigateTo({
url: `/pages/reportRepair/assign/feedback/feedback?id=${_this.data.id}`,
})
// 退回工单
// Dialog.confirm({
// title: '请确认',
// message: '退回工单后将由派单员重新派单,请确认是否退回?',
// })
// .then(() => {
// // 确认退回
// flowHandleRq(data).then(res => {
// console.log('flowHandleRq', res);
// if (res.code == 0) {
// // 跳回维修入口页面
// wx.navigateBack()
// } else {
// app.vantNotifyErr(Notify, res.msg)
// }
// })
// })
// .catch(() => {
// // on cancel
// })
}
},
// input输入内容监听
fieldInput(e) {
console.log('fieldInput', e);
let _this = this;
let form = _this.data.form;
form[e.currentTarget.dataset.name] = e.detail
_this.setData({
form
})
},
// 查询故障原因-字典
getFaultTypeList() {
let _this = this
faultTypeListRq().then(res => {
console.log('getFaultTypeList', res);
let failureTypeList = res.rows.map(item => {
return {
id: item.id,
name: item.name,
isSelect: false,
}
})
_this.setData({
failureTypeList
})
})
},
// 选择故障类型
selectFaultType(e) {
console.log('selectFaultType', e);
let _this = this
let obj = e.currentTarget.dataset.obj
let failureTypeList = _this.data.failureTypeList.map(item => {
if (item.id == obj.id) {
item.isSelect = !item.isSelect
let form = _this.data.form
if (item.isSelect) {
form.failureTypeId = item.id
form.failureTypeName = item.name
} else {
form.failureTypeId = null
form.failureTypeName = ''
}
_this.setData(form)
} else {
item.isSelect = false
}
return item
})
_this.setData({
failureTypeList
})
},
// 选择-是否解决
selectSolve(e) {
console.log('selectSolve', e);
let _this = this
let obj = e.currentTarget.dataset.obj
let solveList = _this.data.solveList.map(item => {
if (item.status == obj.status) {
item.isSelect = !item.isSelect
let form = _this.data.form
if (item.isSelect) {
form.resolve = item.status
} else {
form.resolve = null
}
_this.setData(form)
} else {
item.isSelect = false
}
return item
})
_this.setData({
solveList
})
},
// 文件-上传后
async fileAfterRead(event) {
let _this = this;
console.log('fileAfterRead', event);
// 上传完成需要更新 fileList
let fileList = _this.data.form.fileList;
//
const {
file
} = event.detail;
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
for (let i = 0; i < file.length; i++) {
let url = file[i].url;
await repairAttachUpload({
url,
repairId: _this.data.id,
operate: 'feedback',
}).then(res => {
console.log('upload file ', res);
fileList.push({
id: res.id,
relativeUrl: res.url,
url: app.IMG_NAME + res.url,
deletable: true,
})
})
}
let form = _this.data.form
form.fileList = fileList
_this.setData({
form
})
},
// 删除图片
deleteImg(event) {
console.log('deleteImg', event);
let _this = this;
let fileList = _this.data.form.fileList;
fileList.splice(event.detail.index, 1);
//
let form = _this.data.form
form.fileList = fileList
_this.setData({
form
})
},
// 反馈-提交
feedbackSubmit() {
console.log('feedbackSubmit');
let _this = this
let form = _this.data.form
// 校验数据
//
// 报修名称
if (form.resolve == null) {
app.vantNotifyErr(Notify, '请选择是否解决!')
return;
}
//
let files = form.fileList.map(item => item.id)
let data = {
"repair": {
"id": _this.data.id,
...form,
},
files,
"content": "维修-提交反馈",
"operate": "NEXT"
}
flowHandleRq(data).then(res => {
console.log('flowHandleRq', res);
if (res.code == 0) {
app.vantNotifySuccess(Notify, res.msg)
_this.getDetail(_this.data.id)
} else {
app.vantNotifyErr(Notify, res.msg)
}
})
},
back() {
wx.navigateBack()
},
jumpDetail() {
let _this = this
wx.navigateTo({
url: `/pages/reportRepair/assign/detail/detail?id=${_this.data.id}`,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})