优化代码

This commit is contained in:
Your Name 2023-01-16 12:00:49 +08:00
parent 34cc6bb6da
commit 41394af19e
3 changed files with 456 additions and 0 deletions

View File

@ -150,6 +150,11 @@
src: this.imgUrl + '/h5/images/serve/order4.png',
href: '/pages/reserve/reserveService'
},
{
name: '物品放行',
src: this.imgUrl + '/h5/images/serve/order4.png',
href: '/pages/itemRelease/itemRelease'
},
// {
// name: '',

View File

@ -721,6 +721,15 @@
}
}
,{
"path" : "pages/itemRelease/itemRelease",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"tabBar": {
"color": "#272636",

View File

@ -0,0 +1,442 @@
<template>
<view>
<view class="block__title">基础信息</view>
<view class="cu-form-group">
<view class="title">报修类型</view>
<picker id="complaintType" bindchange="PickerChange" :value="repairTypeIndex" :range-key="'repairTypeName'"
:range="repairTypes" v-if="repairTypes.length>0" @change="repairTypeChange">
<view class="picker">
{{repairTypes.length==0 ? "请选择" : repairTypes[repairTypeIndex].repairTypeName}}
</view>
</picker>
</view>
<view class="cu-form-group" v-if="priceScope !=''">
<view class="title">收费标准</view>
<input disabled="disable" v-model="priceScope" class="text-right"></input>
</view>
<view class="cu-form-group">
<view class="title">报修人</view>
<input v-model="bindRepairName" placeholder="请输入报修人" class="text-right"></input>
</view>
<view class="cu-form-group">
<view class="title">手机号</view>
<input v-model="bindTel" placeholder="请输入手机号" class="text-right"></input>
</view>
<view class="cu-form-group arrow">
<view class="title">预约日期</view>
<picker mode="date" :value="bindDate" :start="todayDate" end="2050-09-01" @change="dateChange">
<view class="picker">
{{bindDate}}
</view>
</picker>
</view>
<view class="cu-form-group arrow">
<view class="title">预约时间</view>
<picker mode="time" :value="bindTime" :start="todayDateTime" end="22:00" @change="timeChange">
<view class="picker">
{{bindTime}}
</view>
</picker>
</view>
<view class="cu-form-group margin-top">
<textarea v-model="context" placeholder="请输入报修内容"></textarea>
</view>
<view class="block__title">相关图片</view>
<uploadImageAsync ref="vcUploadRef" :communityId="communityId" :maxPhotoNum="uploadImage.maxPhotoNum"
:canEdit="uploadImage.canEdit" :title="uploadImage.imgTitle" @sendImagesData="sendImagesData">
</uploadImageAsync>
<view class="button_up_blank"></view>
<view class="flex flex-direction">
<button class="cu-btn bg-green margin-tb-sm lg" @click="submitRepair()">提交</button>
</view>
</view>
</template>
<script>
// pages/enterCommunity/enterCommunity.js
import {
checkPhoneNumber,
checkStrLength
} from '../../lib/java110/utils/StringUtil.js'
import context from '../../lib/java110/Java110Context.js'
const constant = context.constant;
const factory = context.factory;
import {
formatDate,
formatHourAndMin
} from '@/lib/java110/utils/DateUtil.js'
export default {
data() {
return {
typeId: '',
applyCompany: '',
applyPerson: '',
idCard: '',
applyTel: '',
passTime: '',
resNames: [],
state: '',
carNum: '',
remark: '',
itemReleaseTypes: [],
communityId:'',
todayDate:'',
todayDateTime:'',
audit: {
assignee: '',
staffId: '',
staffName: '',
taskId: ''
},
};
},
components: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this;
context.onLoad(options);
context.getRooms().then(res => {
that.userId = res.data.owner.userId;
that.applyCompany = res.data.owner.appUserName;
that.applyPerson = that.userName;
that.applyTel = res.data.owner.link;
that.communityId = res.data.owner.communityId;
});
//
this._loadRepairTypes();
this.todayDate = formatDate(new Date());
this.todayDateTime = formatHourAndMin(new Date())
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let _floor = uni.getStorageSync("_selectFloor");
if (_floor != null && _floor != undefined && _floor != '') {
this.floorNum = _floor.floorNum + "栋";
this.floorId = _floor.floorId;
}
let _unit = uni.getStorageSync("_selectUnit");
if (_unit != null && _unit != undefined && _unit != '') {
this.unitNum = _unit.unitNum + "单元";
this.unitId = _unit.unitId;
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
//
uni.removeStorageSync('_selectFloor');
uni.removeStorageSync('_unitFloor');
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {},
methods: {
sendImagesData: function(e) {
this.photos = [];
if (e.length > 0) {
e.forEach((img) => {
this.photos.push(img.fileId);
})
}
},
formatter(type, value) {
if (type === 'year') {
return `${value}`;
} else if (type === 'month') {
return `${value}`;
} else if (type === 'day') {
return `${value}`;
}
return value;
},
submitRepair: function(e) {
let obj = {
"repairName": this.bindRepairName,
"repairType": this.repairType,
"appointmentTime": this.bindDate + " " + this.bindTime + ":00",
"tel": this.bindTel,
"roomId": this.roomId,
"photos": this.photos,
"context": this.context,
"userId": this.userId,
"userName": this.userName,
"communityId": this.communityId,
"bindDate": this.bindDate,
"bindTime": this.bindTime,
"repairObjType": this.repairObjType,
"repairChannel": 'Z'
}
if (this.repairObjType == '001') {
obj.repairObjId = this.communityId;
obj.repairObjName = this.communityName;
} else if (this.repairObjType == '002') {
obj.repairObjId = this.floorId;
obj.repairObjName = this.floorNum;
} else if (this.repairObjType == '003') {
obj.repairObjId = this.unitId;
obj.repairObjName = this.floorNum + this.unitNum;
} else {
obj.repairObjId = this.roomId;
obj.repairObjName = this.roomName;
}
// let _photos = this.photos;
// _photos.forEach(function(_item) {
// obj.photos.push({
// "photo": _item
// });
// });
//
let oppoTime = Date.parse(new Date(obj.appointmentTime.replace(/-/g, '/'))),
now = Date.parse(new Date());
let msg = "";
if (obj.repairType == "") {
msg = "请选择报修类型";
} else if (obj.repairName == "") {
msg = "请填写报修人";
} else if (checkStrLength(obj.repairName) > 10) {
msg = "报修人长度不能超过5位";
} else if (obj.tel == "") {
msg = "请填写手机号";
} else if (!checkPhoneNumber(obj.tel)) {
msg = "手机号有误";
} else if (obj.bindDate == "请选择") {
msg = "请选择预约日期";
} else if (obj.bindTime == "请选择") {
msg = "请选择预约时间";
} else if (now - oppoTime > 1800 * 1000) {
msg = "预约时间有误";
} else if (obj.context == "") {
msg = "请填写报修内容";
} else if (obj.repairObjId == '') {
msg = "请选择报修位置";
}
if (msg != "") {
wx.showToast({
title: msg,
icon: 'none',
duration: 2000
});
} else {
context.request({
url: constant.url
.saveOwnerRepair, // http://hc.demo.winqi.cn:8012/appApi/ownerRepair.saveOwnerRepair
header: context.getHeaders(),
method: "POST",
data: obj, //
success: function(res) {
let _json = res.data;
if (_json.code == 0) {
// wx.redirectTo({
// url: '/pages/repair/myRepair',
// });
uni.navigateTo({
url: "/pages/successPage/successPage?msg=提交成功&objType=4004"
})
return;
}
wx.showToast({
title: _json.msg,
icon: 'none',
duration: 2000
})
},
fail: function(e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
}
},
afterRead: function(event) {
const {
file
} = event.detail;
let _that = this;
const {
photoList = []
} = this;
photoList.push(file);
this.photoList = photoList;
factory.base64.urlTobase64(file.path).then(function(_baseInfo) {
_that.photos.push(_baseInfo);
});
},
roomChange: function(e) {
this.roomId = this.roomIdArr[e.detail.value];
this.roomName = this.roomCloums[e.detail.value];
},
repairScopeChange: function(e) {
this.repairScopeIndex = e.target.value //
let selected = this.repairScopes[this.repairScopeIndex] //
this.repairObjType = selected.id //id
this._loadRepairTypes();
},
repairChange: function(e) {
this.typeName = this.columns[e.detail.value];
this.typeId = this.repairIdAttr[e.detail.value];
},
repairTypeChange: function(e) {
this.repairTypeIndex = e.target.value //
let selected = this.repairTypes[this.repairTypeIndex] //
if (selected == undefined) {
return;
}
this.repairType = selected.repairType //id
let _payFeeFlag = selected.payFeeFlag;
if (_payFeeFlag == 'T') {
this.priceScope = selected.priceScope;
} else {
this.priceScope = '';
}
},
dateChange: function(e) {
this.bindDate = e.detail.value;
if (this.bindDate == formatDate(new Date()).replaceAll('/', '-')) {
this.todayDateTime = formatHourAndMin(new Date());
} else {
this.todayDateTime = '8:30';
}
},
timeChange: function(e) {
this.bindTime = e.detail.value;
},
chooseFloor: function(e) {
context.navigateTo({
url: '/pages/selectFloor/selectFloor'
});
},
chooseUnit: function(e) {
if (this.floorId == null || this.floorId == '') {
uni.showToast({
title: "请先选择楼栋"
});
return;
}
context.navigateTo({
url: '/pages/selectUnit/selectUnit?floorId=' + this.floorId
});
},
_loadRepairTypes: function() {
let _communityInfo = context.getCurrentCommunity();
let _that = this;
//
let publicArea = _that.repairObjType == '004' ? 'F' : 'T';
//
_that.repairTypeIndex = 0;
let dataObj = {
page: 1,
row: 50,
communityId: _communityInfo.communityId,
publicArea: publicArea
};
uni.request({
url: constant.url.listRepairSettings,
header: context.getHeaders(),
method: "GET",
data: dataObj,
//
success: function(res) {
let _json = res.data;
if (_json.code == 0 && _json.data.length > 0) {
_that.repairTypes = _json.data;
let selected = _that.repairTypes[_that.repairTypeIndex] //
_that.repairType = selected.repairType //id
let _payFeeFlag = selected.payFeeFlag;
if (_payFeeFlag == 'T') {
_that.priceScope = selected.priceScope;
} else {
_that.priceScope = '';
}
} else {
uni.showToast({
icon: "none",
title: "未配置报修设置"
})
}
},
fail: function(e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
});
}
});
}
}
};
</script>
<style>
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69, 90, 100, .6);
padding: 40rpx 30rpx 20rpx;
}
.button_up_blank {
height: 40rpx;
}
</style>