mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 21:19:37 +08:00
1
This commit is contained in:
parent
02b008b481
commit
8e21c838ae
@ -40,7 +40,7 @@ export function selectRoomListRq(data) {
|
||||
// 保存工单
|
||||
export function repairSaveRq(data) {
|
||||
return request({
|
||||
url: '/repair/save',
|
||||
url: '/app/repair/flow/start',
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
|
@ -302,21 +302,4 @@ App({
|
||||
}
|
||||
})
|
||||
},
|
||||
selfUploadFile(url) {
|
||||
let _this = this
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: _this.DOMAIN_NAME + '/api/dfs/upload',
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
formData: {},
|
||||
success: res => {
|
||||
resolve(JSON.parse(res.data));
|
||||
},
|
||||
fail: err => {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
@ -3,7 +3,9 @@ let app = getApp();
|
||||
import Notify from '@vant/weapp/notify/notify';
|
||||
|
||||
import {
|
||||
selfFormatTimeYMDHMS
|
||||
selfFormatTimeYMDHMS,
|
||||
repairAttachUpload,
|
||||
uploadVoice
|
||||
} from "../../../utils/util.js"
|
||||
|
||||
import {
|
||||
@ -37,11 +39,9 @@ Page({
|
||||
}, {
|
||||
name: '三级',
|
||||
}, ],
|
||||
failureDateShow: false, // 故障时间show
|
||||
failureDate: new Date().getTime(), // 故障时间-当前
|
||||
failureMinDate: new Date().getTime(), // 故障时间-最小
|
||||
repairTimeVisible: false, // 故障时间show
|
||||
repairTime: new Date().getTime(), // 故障时间-当前
|
||||
typeVisible: false,
|
||||
typeName: '',
|
||||
typeColumns: [{
|
||||
values: [],
|
||||
className: 'column1',
|
||||
@ -52,7 +52,6 @@ Page({
|
||||
},
|
||||
],
|
||||
addressVisible: false,
|
||||
addressName: '',
|
||||
addressColumns: [{
|
||||
values: [],
|
||||
className: 'column1',
|
||||
@ -66,17 +65,19 @@ Page({
|
||||
detail: {
|
||||
"repairName": "", //维修名称
|
||||
"repairLevel": "", //维修等级
|
||||
"failureDate": null, //故障时间
|
||||
"repairTime": null, //故障时间
|
||||
"typeId": null, //故障类型
|
||||
"repairDevice": null, //维修设备
|
||||
"typeName": "", //故障名称
|
||||
"deviceId": null, //设备
|
||||
"deviceName": "", //设备名称
|
||||
"name": "", //用户名
|
||||
"phone": "", //手机号码
|
||||
"addressId": null, // 地点id
|
||||
"roomId": null, // 楼层id
|
||||
"area": "", // 门牌号
|
||||
"content": "", // 描述
|
||||
"repairVoice": "", // 语音文件
|
||||
"repairImages": "", //故障图片
|
||||
"address": null, // 地点
|
||||
"floorId": null, // 楼层id
|
||||
"floor": null, // 楼层id
|
||||
"room": "", // 门牌号
|
||||
"explain": "", // 描述
|
||||
},
|
||||
},
|
||||
|
||||
@ -141,30 +142,30 @@ Page({
|
||||
},
|
||||
|
||||
// 显示-故障时间
|
||||
showFailureDate() {
|
||||
showRepairTime() {
|
||||
let _this = this;
|
||||
_this.setData({
|
||||
failureDateShow: true
|
||||
repairTimeVisible: true
|
||||
})
|
||||
},
|
||||
|
||||
// 关闭-故障时间
|
||||
hideFailureDate() {
|
||||
hideRepairTime() {
|
||||
let _this = this;
|
||||
_this.setData({
|
||||
failureDateShow: false
|
||||
repairTimeVisible: false
|
||||
})
|
||||
},
|
||||
|
||||
// 确认-故障时间
|
||||
confirmFailureDate(e) {
|
||||
console.log('confirmFailureDate', e);
|
||||
confirmRepairTime(e) {
|
||||
console.log('confirmRepairTime', e);
|
||||
let _this = this;
|
||||
let detail = _this.data.detail;
|
||||
detail.failureDate = selfFormatTimeYMDHMS(e.detail);
|
||||
detail.repairTime = selfFormatTimeYMDHMS(e.detail);
|
||||
_this.setData({
|
||||
failureDateShow: false,
|
||||
failureDate: e.detail,
|
||||
repairTimeVisible: false,
|
||||
repairTime: e.detail,
|
||||
detail
|
||||
})
|
||||
},
|
||||
@ -253,11 +254,11 @@ Page({
|
||||
} = e.detail;
|
||||
let detail = _this.data.detail
|
||||
detail.typeId = value[0].id
|
||||
detail.repairDevice = value[1].id
|
||||
let typeName = value[0].text + '/' + value[1].text
|
||||
detail.typeName = value[0].text
|
||||
detail.deviceId = value[1].id
|
||||
detail.deviceName = value[1].text
|
||||
_this.setData({
|
||||
detail,
|
||||
typeName,
|
||||
typeVisible: false
|
||||
})
|
||||
},
|
||||
@ -347,11 +348,11 @@ Page({
|
||||
} = e.detail;
|
||||
let detail = _this.data.detail
|
||||
detail.addressId = value[0].id
|
||||
detail.roomId = value[1].id
|
||||
let addressName = value[0].text + '/' + value[1].text
|
||||
detail.address = value[0].text
|
||||
detail.floorId = value[1].id
|
||||
detail.floor = value[1].text
|
||||
_this.setData({
|
||||
detail,
|
||||
addressName,
|
||||
addressVisible: false
|
||||
})
|
||||
},
|
||||
@ -453,37 +454,34 @@ Page({
|
||||
},
|
||||
|
||||
// 文件-上传后
|
||||
fileAfterRead(event) {
|
||||
async fileAfterRead(event) {
|
||||
let _this = this;
|
||||
console.log('fileAfterRead', event);
|
||||
// 上传完成需要更新 fileList
|
||||
let fileList = _this.data.fileList;
|
||||
//
|
||||
const {
|
||||
file
|
||||
} = event.detail;
|
||||
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
||||
for (let i = 0; i < file.length; i++) {
|
||||
let url = file[i].url;
|
||||
wx.uploadFile({
|
||||
url: app.DOMAIN_NAME + '/api/dfs/upload',
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
formData: {},
|
||||
success(res) {
|
||||
console.log('upload file ', res);
|
||||
let fileData = JSON.parse(res.data)
|
||||
// 上传完成需要更新 fileList
|
||||
let fileList = _this.data.fileList;
|
||||
fileList.push({
|
||||
relativeUrl: fileData.fileName,
|
||||
url: app.IMG_NAME + fileData.fileName,
|
||||
name: fileData.fileName,
|
||||
deletable: true,
|
||||
})
|
||||
_this.setData({
|
||||
fileList
|
||||
})
|
||||
},
|
||||
});
|
||||
await repairAttachUpload({
|
||||
url,
|
||||
operate: 'repair'
|
||||
}).then(res => {
|
||||
console.log('upload file ', res);
|
||||
fileList.push({
|
||||
id: res.id,
|
||||
relativeUrl: res.url,
|
||||
url: app.IMG_NAME + res.url,
|
||||
deletable: true,
|
||||
})
|
||||
})
|
||||
}
|
||||
_this.setData({
|
||||
fileList
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@ -519,6 +517,7 @@ Page({
|
||||
// 数据
|
||||
let detail = _this.data.detail;
|
||||
//
|
||||
//
|
||||
// 校验数据
|
||||
//
|
||||
// 报修名称
|
||||
@ -532,7 +531,7 @@ Page({
|
||||
return;
|
||||
}
|
||||
// 故障时间
|
||||
if (!detail.failureDate) {
|
||||
if (!detail.repairTime) {
|
||||
_this.showErrMsg('请选择故障时间!')
|
||||
return;
|
||||
}
|
||||
@ -547,7 +546,7 @@ Page({
|
||||
return;
|
||||
}
|
||||
// 门牌号
|
||||
if (!detail.area) {
|
||||
if (!detail.room) {
|
||||
_this.showErrMsg('请输入门牌号!')
|
||||
return;
|
||||
}
|
||||
@ -567,33 +566,29 @@ Page({
|
||||
return;
|
||||
}
|
||||
// 故障描述
|
||||
if (!detail.content) {
|
||||
if (!detail.explain) {
|
||||
_this.showErrMsg('请输入故障描述!')
|
||||
return;
|
||||
}
|
||||
//
|
||||
let fileIdList = []
|
||||
// 图片上传
|
||||
if (fileList && fileList.length > 0) {
|
||||
detail.repairImages = JSON.stringify(fileList.map(item => {
|
||||
return {
|
||||
name: item.relativeUrl,
|
||||
url: item.relativeUrl,
|
||||
uid: item.relativeUrl,
|
||||
}
|
||||
}))
|
||||
fileIdList = fileList.map(item => item.id)
|
||||
}
|
||||
// 音频
|
||||
if (voiceObj && voiceObj.tempFilePath) {
|
||||
await app.selfUploadFile(voiceObj.tempFilePath).then(res => {
|
||||
console.log('selfUploadFile', res);
|
||||
detail.repairVoice = JSON.stringify({
|
||||
url: res.fileName,
|
||||
time: voiceObj.duration
|
||||
})
|
||||
await uploadVoice(voiceObj.tempFilePath).then(res => {
|
||||
console.log('uploadVoice', res);
|
||||
fileIdList.push(res.id)
|
||||
})
|
||||
}
|
||||
//
|
||||
// 添加数据
|
||||
repairSaveRq(detail).then(res => {
|
||||
repairSaveRq({
|
||||
repair: detail,
|
||||
files: fileIdList
|
||||
}).then(res => {
|
||||
console.log('visitorPersonRq', res);
|
||||
//
|
||||
if (res.code == 0) {
|
||||
|
@ -8,21 +8,21 @@
|
||||
<view class="label must">故障等级</view>
|
||||
<van-field value="{{ detail.repairLevel }}" input-class="input" is-link readonly placeholder="请选择" arrow-direction="down" border="{{ false }}" input-align="right" bind:tap="showFaultLevel" />
|
||||
</view>
|
||||
<view class="rowView" bind:tap="showFailureDate">
|
||||
<view class="rowView" bind:tap="showRepairTime">
|
||||
<view class="label must">故障时间</view>
|
||||
<van-field value="{{ detail.failureDate }}" input-class="input" is-link readonly placeholder="请选择" border="{{ false }}" arrow-direction="down" input-align="right" />
|
||||
<van-field value="{{ detail.repairTime }}" input-class="input" is-link readonly placeholder="请选择" border="{{ false }}" arrow-direction="down" input-align="right" />
|
||||
</view>
|
||||
<view class="rowView">
|
||||
<view class="label must">故障类型</view>
|
||||
<van-field value="{{ typeName }}" input-class="input" is-link readonly placeholder="请选择" arrow-direction="down" border="{{ false }}" input-align="right" bind:tap="showType" />
|
||||
<van-field value="{{ detail.typeName ? detail.typeName + '/' + detail.deviceName : '' }}" input-class="input" is-link readonly placeholder="请选择" arrow-direction="down" border="{{ false }}" input-align="right" bind:tap="showType" />
|
||||
</view>
|
||||
<view class="rowView">
|
||||
<view class="label must">故障地点</view>
|
||||
<van-field value="{{ addressName }}" input-class="input" is-link readonly placeholder="请选择" arrow-direction="down" border="{{ false }}" input-align="right" bind:tap="showAddress" />
|
||||
<van-field value="{{ detail.address ? detail.address + '/' + detail.floor : '' }}" input-class="input" is-link readonly placeholder="请选择" arrow-direction="down" border="{{ false }}" input-align="right" bind:tap="showAddress" />
|
||||
</view>
|
||||
<view class="rowView">
|
||||
<view class="label must">门牌号</view>
|
||||
<van-field value="{{ detail.area }}" bind:input="fieldInput" data-name="area" clearable input-class="input" placeholder="请输入" border="{{ false }}" input-align="right" />
|
||||
<van-field value="{{ detail.room }}" bind:input="fieldInput" data-name="room" clearable input-class="input" placeholder="请输入" border="{{ false }}" input-align="right" />
|
||||
</view>
|
||||
<view class="rowView">
|
||||
<view class="label must">联系电话</view>
|
||||
@ -35,7 +35,7 @@
|
||||
<view class="rowColumnView">
|
||||
<view class="label must">故障描述</view>
|
||||
<view class="contentView">
|
||||
<van-field model:value="{{ detail.content }}" bind:input="fieldInput" data-name="content" type="textarea" clearable placeholder="请输入" maxlength="{{100}}" show-word-limit border="{{false}}" autosize input-class="selfTextarea" />
|
||||
<van-field model:value="{{ detail.explain }}" bind:input="fieldInput" data-name="explain" type="textarea" clearable placeholder="请输入" maxlength="{{100}}" show-word-limit border="{{false}}" autosize input-class="selfTextarea" />
|
||||
<view class="voiceView1" bind:touchstart="startRecording" bind:touchend="stopRecording">
|
||||
<view class="voiceView2">
|
||||
<view class="voiceImg" style="background: no-repeat center/cover url({{IMG_NAME + '/profile/static/repair/index/voice.png'}});"></view>
|
||||
@ -71,8 +71,8 @@
|
||||
<van-action-sheet description="请选择故障等级" close-on-click-overlay="{{true}}" show="{{ faultLevelShow }}" actions="{{ faultLevelList }}" bind:select="selectFaultLevel" bind:close="closeFaultLevel" />
|
||||
|
||||
<!-- 选择-故障时间 -->
|
||||
<van-popup show="{{ failureDateShow }}" position="bottom" custom-style="height: 50vh;" bind:close="hideFailureDate">
|
||||
<van-datetime-picker type="datetime" value="{{ failureDate }}" bind:confirm="confirmFailureDate" bind:cancel="hideFailureDate" />
|
||||
<van-popup show="{{ repairTimeVisible }}" position="bottom" custom-style="height: 50vh;" bind:close="hideRepairTime">
|
||||
<van-datetime-picker type="datetime" value="{{ repairTime }}" bind:confirm="confirmRepairTime" bind:cancel="hideRepairTime" />
|
||||
</van-popup>
|
||||
|
||||
<!-- 故障类型 -->
|
||||
|
@ -1,3 +1,6 @@
|
||||
let app = getApp();
|
||||
|
||||
|
||||
//返回 例 2017
|
||||
const formatYear = data => {
|
||||
var date = data.date;
|
||||
@ -220,15 +223,15 @@ function getUrlParamsObj(url) {
|
||||
// 通过 ? 分割获取后面的参数字符串
|
||||
let urlStr = url.split('?')[1]
|
||||
// 创建空对象存储参数
|
||||
let obj = {};
|
||||
let obj = {};
|
||||
// 再通过 & 将每一个参数单独分割出来
|
||||
let paramsArr = urlStr.split('&')
|
||||
for(let i = 0,len = paramsArr.length;i < len;i++){
|
||||
let paramsArr = urlStr.split('&')
|
||||
for (let i = 0, len = paramsArr.length; i < len; i++) {
|
||||
// 再通过 = 将每一个参数分割为 key:value 的形式
|
||||
let arr = paramsArr[i].split('=')
|
||||
obj[arr[0]] = arr[1];
|
||||
}
|
||||
return obj
|
||||
let arr = paramsArr[i].split('=')
|
||||
obj[arr[0]] = arr[1];
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// 判断是否是图片
|
||||
@ -240,6 +243,82 @@ function checkIsImg(url) {
|
||||
}
|
||||
}
|
||||
|
||||
function uploadFile(url) {
|
||||
let _this = this
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: app.DOMAIN_NAME + '/api/dfs/upload',
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Authorization": 'Bearer ' + wx.getStorageSync('token')
|
||||
},
|
||||
formData: {},
|
||||
success: res => {
|
||||
resolve(JSON.parse(res.data));
|
||||
},
|
||||
fail: err => {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 报修上传图片视频
|
||||
// url: localhost:9227/app/repairAttach/upload?repairId=&operate=repair\feedback\eval
|
||||
// repairId : 工单id,报修人不传
|
||||
// operate : repair报修,feedback维修,eval评价
|
||||
function repairAttachUpload(data) {
|
||||
let _this = this
|
||||
let paramUrl = "?a=a"
|
||||
if (data.repairId) {
|
||||
paramUrl = paramUrl + '&repairId=' + data.repairId
|
||||
}
|
||||
if (data.operate) {
|
||||
paramUrl = paramUrl + '&operate=' + data.operate
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: app.DOMAIN_NAME + '/app/repairAttach/upload' + paramUrl,
|
||||
filePath: data.url,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Authorization": 'Bearer ' + wx.getStorageSync('token')
|
||||
},
|
||||
formData: {},
|
||||
success: res => {
|
||||
resolve(JSON.parse(res.data));
|
||||
},
|
||||
fail: err => {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 报修上传语音
|
||||
// url: localhost:9227/app/repairAttach/upload/voice
|
||||
function uploadVoice(url) {
|
||||
let _this = this
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.uploadFile({
|
||||
url: app.DOMAIN_NAME + '/app/repairAttach/upload/voice',
|
||||
filePath: url,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Authorization": 'Bearer ' + wx.getStorageSync('token')
|
||||
},
|
||||
formData: {},
|
||||
success: res => {
|
||||
resolve(JSON.parse(res.data));
|
||||
},
|
||||
fail: err => {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime,
|
||||
@ -258,5 +337,8 @@ module.exports = {
|
||||
twoTimeIntervalReturnHours,
|
||||
selfArrSum,
|
||||
getUrlParamsObj,
|
||||
checkIsImg
|
||||
checkIsImg,
|
||||
uploadFile,
|
||||
repairAttachUpload,
|
||||
uploadVoice
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user