mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-22 05:29:37 +08:00
255 lines
5.5 KiB
JavaScript
255 lines
5.5 KiB
JavaScript
const app = getApp()
|
|
|
|
import Notify from '@vant/weapp/notify/notify';
|
|
|
|
import {
|
|
deviceTypeListRq,
|
|
deviceListRq,
|
|
getDetailRq,
|
|
getStatusName,
|
|
flowHandleRq
|
|
} from "../../../../api/repair/repair.js"
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
IMG_NAME: app.IMG_NAME,
|
|
id: '',
|
|
detail: {},
|
|
currentLog: {},
|
|
typeVisible: false,
|
|
typeColumns: [{
|
|
values: [],
|
|
className: 'column1',
|
|
},
|
|
{
|
|
values: [],
|
|
className: 'column2',
|
|
},
|
|
],
|
|
"typeId": null, //故障类型
|
|
"typeName": "", //故障名称
|
|
"deviceId": null, //设备
|
|
"deviceName": "", //设备名称
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
console.log('onLoad', options);
|
|
let _this = this
|
|
_this.setData({
|
|
...options
|
|
})
|
|
_this.getDetail(options.id)
|
|
// 查询设备类型
|
|
_this.queryDeviceType()
|
|
},
|
|
|
|
back() {
|
|
wx.navigateBack()
|
|
},
|
|
|
|
getDetail(id) {
|
|
let _this = this
|
|
getDetailRq({
|
|
id
|
|
}).then(res => {
|
|
console.log("getDetailRq", res);
|
|
// 详情
|
|
let detail = res.repair
|
|
detail.statusName = getStatusName(detail.status)
|
|
|
|
// 日志
|
|
if (detail.logId) {
|
|
let firstLog = res.log.find(item => item.id == detail.logId)
|
|
if (firstLog) {
|
|
let preLog = res.log.find(item => item.id == firstLog.pid)
|
|
_this.setData({
|
|
currentLog: preLog
|
|
})
|
|
}
|
|
}
|
|
|
|
_this.setData({
|
|
detail,
|
|
})
|
|
})
|
|
},
|
|
|
|
showType() {
|
|
this.setData({
|
|
typeVisible: true,
|
|
})
|
|
},
|
|
|
|
hideType() {
|
|
this.setData({
|
|
typeVisible: false,
|
|
})
|
|
},
|
|
|
|
// 查询设备类型
|
|
queryDeviceType() {
|
|
let _this = this
|
|
deviceTypeListRq().then(res => {
|
|
console.log('deviceTypeListRq', res);
|
|
let list = res.rows.map(item => {
|
|
return {
|
|
id: item.id,
|
|
text: item.name
|
|
}
|
|
})
|
|
let typeColumns = _this.data.typeColumns
|
|
typeColumns[0].values = list
|
|
_this.setData({
|
|
typeColumns
|
|
})
|
|
// 查询设备
|
|
_this.queryDevice(list[0].id)
|
|
})
|
|
},
|
|
|
|
// 查询设备
|
|
queryDevice(id) {
|
|
let _this = this
|
|
|
|
deviceListRq({
|
|
typeId: id
|
|
}).then(res => {
|
|
console.log('deviceListRq', res);
|
|
let list = res.rows.map(item => {
|
|
return {
|
|
id: item.id,
|
|
text: item.name
|
|
}
|
|
})
|
|
let typeColumns = _this.data.typeColumns
|
|
typeColumns[1].values = list
|
|
_this.setData({
|
|
typeColumns
|
|
})
|
|
})
|
|
},
|
|
|
|
// 选择设备类型
|
|
typeColumnsChange(e) {
|
|
console.log('typeColumnsChange', e.detail);
|
|
let _this = this
|
|
const {
|
|
picker,
|
|
value,
|
|
index
|
|
} = e.detail;
|
|
if (index == 0) { // 选择类型
|
|
let obj = value[index]
|
|
_this.queryDevice(obj.id)
|
|
|
|
} else if (index == 1) { // 选择设备
|
|
let obj = value[index]
|
|
}
|
|
},
|
|
|
|
// 确认设备
|
|
typeColumnsConfirm(e) {
|
|
console.log('typeColumnsConfirm', e.detail);
|
|
let _this = this
|
|
const {
|
|
picker,
|
|
value,
|
|
index
|
|
} = e.detail;
|
|
|
|
_this.setData({
|
|
typeId: value[0].id,
|
|
typeName: value[0].text,
|
|
deviceId: value[1].id,
|
|
deviceName: value[1].text,
|
|
typeVisible: false
|
|
})
|
|
},
|
|
|
|
submit() {
|
|
let _this = this
|
|
// 参数校验
|
|
if (!_this.data.typeId) {
|
|
// 危险通知
|
|
app.vantNotifyErrTop(Notify, '请选择故障类型!')
|
|
return
|
|
}
|
|
// 提交参数
|
|
let data = {
|
|
"repair": {
|
|
id: _this.data.id,
|
|
typeId: _this.data.typeId,
|
|
typeName: _this.data.typeName,
|
|
deviceId: _this.data.deviceId,
|
|
deviceName: _this.data.deviceName,
|
|
},
|
|
"content": '重新指派设备类型',
|
|
"operate": "NEXT"
|
|
}
|
|
flowHandleRq(data).then(res => {
|
|
console.log('flowHandleRq', res);
|
|
if (res.code == 0) {
|
|
app.vantNotifySuccessTop(Notify, res.msg)
|
|
app.selfBackPage(2)
|
|
} else {
|
|
app.vantNotifyErrTop(Notify, res.msg)
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |