<template>
|
<view class="">
|
|
<u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="120"
|
:labelStyle="{fontSize:'28rpx'}">
|
<view class="flex j-c-s-b a-i-c bgc-ff" style="padding:24rpx; margin: 20rpx 30rpx;">
|
<!-- <view class="box-title" style="width:50%;">
|
<box-title title="房东信息"></box-title>
|
</view> -->
|
<!-- #ifdef MP-WEIXIN -->
|
<ocr-navigator @onSuccess="recognizeSuccess($event)" certificateType="idCard" :opposite="false">
|
<view class="recognize-btn flex a-i-c">
|
<u-icon name="scan" color="#fff" size="24"></u-icon>
|
<text class="f-26 c-ff" style="margin-left: 10rpx;">身份证信息识别</text>
|
</view>
|
</ocr-navigator>
|
<!-- #endif -->
|
</view>
|
|
<view class="content">
|
<u-form-item label="场所名称" prop="districtName" borderBottom required>
|
<u-input v-model="info.districtName" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="物品名称" prop="transactionObject" borderBottom required>
|
<u-input v-model="info.transactionObject" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="请输入交易人姓名" prop="owner" borderBottom required>
|
<u-input v-model="info.owner" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="请输入交易人电话" prop="phoneNumber" borderBottom required>
|
<u-input v-model="info.phoneNumber" type="number" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="身份证号" prop="idCard" borderBottom required>
|
<u-input v-model="info.idCard" type="idcard" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="交易金额" prop="transactionMoney" borderBottom required>
|
<u-input type="digit" v-model="info.transactionMoney" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="物品数量" prop="goodsNums" borderBottom required>
|
<u-input v-model="info.goodsNums" type="number" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
<u-form-item label="交易位置" prop="localtion" borderBottom ref="localtion" required>
|
<!-- <u-input v-model="info.location" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
|
inputAlign="right"></u-input> -->
|
<view class="address-row flex">
|
<view class="address-content f-28" v-if="info.localtion">
|
{{info.localtion}}
|
</view>
|
<view class="address-content f-28 c-99" v-if="!info.localtion">
|
请选择位置
|
</view>
|
<view class="location-btn c-main f-24" @click="getLocation()">
|
获取地址
|
</view>
|
</view>
|
</u-form-item>
|
<u-form-item label="交易过程" prop="transactionProcess" borderBottom>
|
<u-input v-model="info.transactionProcess" border="none" placeholder="请输入"
|
placeholderClass="f-28 c-99" inputAlign="right"></u-input>
|
</u-form-item>
|
</view>
|
|
<view class="upload bgc-ff">
|
<view class="f-28 mb-20">手持身份证</view>
|
<view class="mt-20">
|
<u-upload :fileList="imageUrls" :previewFullImage="uploadConfig.previewFullImage"
|
:accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
|
:maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
|
@afterRead="afterReadImgs($event,'imageUrls')" @delete="deletePics($event,'imageUrls')">
|
<view class="upload-item upload-icon flex_base">
|
<u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
|
</view>
|
</u-upload>
|
</view>
|
</view>
|
<view class="upload bgc-ff">
|
<view class="f-28 mb-20">物品照片</view>
|
<view class="mt-20">
|
<u-upload :fileList="goodsImageUrls" :previewFullImage="uploadConfig.previewFullImage"
|
:accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
|
:maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
|
@afterRead="afterReadImgs($event,'goodsImageUrls')"
|
@delete="deletePics($event,'goodsImageUrls')">
|
<view class="upload-item upload-icon flex_base">
|
<u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
|
</view>
|
</u-upload>
|
</view>
|
</view>
|
|
</u-form>
|
|
<button class="submit-btn" @click="sumitInfo">提交</button>
|
<button class="list-btn mb-20" @click="navigatorPage">我上报的事件</button>
|
</view>
|
</template>
|
|
|
<script>
|
import uploadMixin from "@/mixin/uploadMixin";
|
import {
|
saveLabelReporting,
|
getLabelReportingDetail,
|
setLabelReporting
|
} from "@/api/reporting/reporting";
|
import {
|
getPlaceDetail
|
} from "@/api/place/place"
|
export default {
|
mixins: [uploadMixin],
|
data() {
|
return {
|
info: {
|
transactionObject: "",
|
owner: "",
|
phoneNumber: "",
|
idCard: "",
|
transactionObjectTel: "",
|
transactionMoney: "",
|
goodsNums: "",
|
localtion: "",
|
transactionProcess: "",
|
houseCode: "",
|
districtName: "",
|
userId: "",
|
reportType: ""
|
},
|
rules: {
|
districtName: {
|
required: true,
|
message: '请输入场所名称',
|
trigger: ['blur', 'change']
|
},
|
transactionObject: {
|
required: true,
|
message: '请输入物品名称',
|
trigger: ['blur', 'change']
|
},
|
owner: {
|
required: true,
|
message: '请输入交易人姓名',
|
trigger: ['blur', 'change']
|
},
|
goodsNums: [{
|
type: 'number',
|
required: true,
|
message: '请输入物品数量',
|
trigger: ['blur', 'change']
|
}],
|
phoneNumber: [{
|
type: 'number',
|
required: true,
|
message: '请输入交易人手机号',
|
trigger: ['blur', 'change']
|
},
|
{
|
validator: (rule, value, callback) => {
|
return uni.$u.test.mobile(value);
|
},
|
message: '手机号码不正确',
|
trigger: ['change', 'blur']
|
}
|
],
|
idCard: [{
|
// type: 'string',
|
required: false,
|
message: '请输入身份证号码',
|
trigger: ['change', 'blur']
|
},
|
{
|
validator: (rule, value, callback) => {
|
// const idCardRegex = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
|
return uni.$u.test.idCard(value)
|
// return idCardRegex.test(value)
|
},
|
message: '身份证号码有误',
|
trigger: ['change', 'blur']
|
}
|
],
|
transactionMoney: {
|
required: true,
|
message: '请输入交易金额',
|
trigger: ['blur', 'change']
|
},
|
localtion: {
|
type: 'string',
|
required: true,
|
message: '请输入交易位置',
|
trigger: ['blur', 'change']
|
},
|
transactionProcess: {
|
type: 'string',
|
required: false,
|
message: '请输入交易过程',
|
trigger: ['blur', 'change']
|
}
|
},
|
imageUrls: [],
|
goodsImageUrls: [],
|
eventType: 1,
|
isEdit: false,
|
id: "",
|
status: ""
|
}
|
},
|
onLoad(option) {
|
console.log(option, 99999);
|
const {
|
houseCode
|
} = option;
|
if (option.id) {
|
this.isEdit = true;
|
this.id = option.id;
|
this.getDetail(option.id);
|
} else {
|
if (option.type != 1) {
|
this.eventType = option.type;
|
uni.setNavigationBarTitle({
|
title: this.setTitle(option.type)
|
})
|
}
|
this.$set(this.info, "eventType", option.type);
|
if (option.type == 1) {
|
this.$set(this.info, "reportType", 3);
|
} else if (option.type == 2) {
|
this.$set(this.info, "reportType", 4);
|
} else {
|
this.$set(this.info, "reportType", 5);
|
}
|
|
let siteInfo = uni.getStorageSync("siteInfo");
|
let userInfo = uni.getStorageSync("userInfo");
|
this.$set(this.info, "houseCode", siteInfo.houseCode);
|
this.$set(this.info, "districtName", siteInfo.name);
|
this.$set(this.info, "userId", userInfo.user_id);
|
}
|
|
if (houseCode) {
|
// 获取地址
|
this.getPlaceDetail(houseCode)
|
}
|
},
|
onReady() {
|
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
|
this.$refs.form.setRules(this.rules)
|
},
|
methods: {
|
//识别成功
|
recognizeSuccess(e, key) {
|
let {
|
detail: {
|
name,
|
id
|
}
|
} = e;
|
|
this.info.owner = name.text;
|
this.info.idCard = id.text;
|
},
|
|
getPlaceDetail(houseCode) {
|
getPlaceDetail({
|
houseCode: houseCode
|
}).then(res => {
|
if (res.code == 200) {
|
let data = res.data;
|
this.info.localtion = data.location;
|
}
|
})
|
},
|
getDetail(id) {
|
getLabelReportingDetail({
|
taskId: id
|
}).then(res => {
|
if (res.code == 200) {
|
let data = res.data;
|
this.status = data.confirmFlag;
|
uni.setNavigationBarTitle({
|
title: data.labelName
|
})
|
for (let i in this.info) {
|
this.info[i] = data[i]
|
}
|
this.imageUrls = this.$setImageUrl(data.imageUrls, 2);
|
this.goodsImageUrls = this.$setImageUrl(data.goodsImageUrls, 2);
|
this.eventType = data.eventType;
|
this.info.eventType = data.eventType;
|
if (data.checkTime) {
|
this.checkTime = Number(new Date(data.checkTime));
|
}
|
this.info.id = data.id;
|
this.info.taskId = data.taskId;
|
|
if (data.eventType == 1) {
|
this.$set(this.info, "reportType", 3);
|
} else if (data.eventType == 2) {
|
this.$set(this.info, "reportType", 4);
|
} else {
|
this.$set(this.info, "reportType", 5);
|
}
|
}
|
})
|
},
|
|
setTitle(type) {
|
if (type == 2) {
|
return "二手手机维修"
|
} else if (type == 3) {
|
return "二手车交易"
|
}
|
},
|
|
getLocation() {
|
uni.chooseLocation({
|
success: (res) => {
|
this.$set(this.info, "localtion", res.address);
|
}
|
})
|
},
|
confirmDate(e) {
|
console.log(e);
|
this.showSelectDate = false;
|
this.info.checkTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
|
},
|
|
async afterReadImgs(event, key) {
|
this.showLoading()
|
let lists = [].concat(event.file)
|
let fileListLen = this[key].length
|
lists.map((item) => {
|
this[key].push({
|
...item,
|
status: 'uploading',
|
message: '上传中'
|
})
|
})
|
for (let i = 0; i < lists.length; i++) {
|
const result = await this.uploadFilePromise(lists[i].url)
|
this[key].splice(fileListLen, 1, Object.assign({}, {
|
url: result.data.link,
|
name: result.data.name
|
}))
|
fileListLen++
|
}
|
this.loadingClose()
|
},
|
|
checkImages() {
|
if (this.imageUrls.length) {
|
this.$set(this.info, "imageUrls", this.setImages(this.imageUrls))
|
}
|
if (this.goodsImageUrls.length) {
|
this.$set(this.info, "goodsImageUrls", this.setImages(this.goodsImageUrls))
|
}
|
|
},
|
|
setImages(key) {
|
let urls = [];
|
for (let i of key) {
|
urls.push(i.name);
|
}
|
return urls.join(",")
|
},
|
|
sumitInfo() {
|
this.$refs.form.validate().then(valid => {
|
this.checkImages()
|
if (this.isEdit) {
|
this.info.status = 1;
|
this.setRequest()
|
} else {
|
this.addRequest()
|
}
|
})
|
},
|
|
addRequest() {
|
saveLabelReporting(this.info).then(res => {
|
uni.showToast({
|
icon: 'success',
|
title: '提交成功',
|
success() {
|
setTimeout(() => {
|
uni.navigateBack()
|
}, 300)
|
}
|
})
|
})
|
},
|
setRequest() {
|
setLabelReporting(this.info).then(res => {
|
uni.showToast({
|
icon: 'success',
|
title: '保存成功'
|
})
|
setTimeout(() => {
|
if (this.status == 4) {
|
this.reLoadPrePage()
|
} else {
|
uni.navigateBack();
|
}
|
}, 300)
|
})
|
},
|
|
//刷新上一页数据后返回
|
reLoadPrePage() {
|
let pages = getCurrentPages();
|
let prePage = pages[pages.length - 2];
|
prePage.$vm.currentPage = 1;
|
prePage.$vm.list = [];
|
prePage.$vm.getList();
|
uni.navigateBack();
|
},
|
|
navigatorPage() {
|
this.$u.func.globalNavigator(`formList?type=${this.eventType}`, "navTo")
|
}
|
}
|
}
|
</script>
|
|
<style lang="less">
|
page {
|
background-color: #F5F5F5;
|
}
|
|
.recognize-btn {
|
padding: 12rpx;
|
border-radius: 6rpx;
|
background-color: #3c9cff;
|
margin-left: 30rpx;
|
}
|
|
.content {
|
margin: 20rpx 30rpx;
|
padding: 0 30rpx;
|
background-color: #fff;
|
}
|
|
/deep/.u-radio-group--row {
|
justify-content: flex-end;
|
}
|
|
.site-box {
|
padding: 30rpx;
|
margin: 20rpx 30rpx;
|
border-radius: 4rpx;
|
|
.c-aa {
|
color: #aaa;
|
}
|
|
.address {
|
width: 60%;
|
margin-left: 25rpx;
|
}
|
}
|
|
.upload-item {
|
width: 140rpx;
|
height: 140rpx;
|
border: 1px solid #EEEEEE;
|
}
|
|
.upload {
|
margin: 0 30rpx 20rpx;
|
padding: 30rpx;
|
|
|
}
|
|
.submit-btn {
|
width: 690rpx;
|
height: 78rpx;
|
line-height: 78rpx;
|
background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
font-size: 32rpx;
|
color: #fff;
|
margin-top: 50rpx;
|
}
|
|
.list-btn {
|
width: 690rpx;
|
height: 78rpx;
|
line-height: 78rpx;
|
background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
font-size: 32rpx;
|
color: #fff;
|
margin-top: 50rpx;
|
}
|
|
.address-row {
|
flex: 1;
|
justify-content: flex-end;
|
align-items: center;
|
}
|
|
.address-content {
|
width: calc(100% - 116rpx - 20rpx);
|
margin-right: 20rpx;
|
text-align: right;
|
}
|
|
.location-btn {
|
width: 116rpx;
|
height: 46rpx;
|
line-height: 46rpx;
|
border-radius: 4rpx;
|
border: 1px solid currentColor;
|
padding: 0;
|
background-color: #fff;
|
text-align: center;
|
}
|
</style>
|