dingdong-master/pages/order-manage/modal/apply-extra-charge.vue

151 lines
4.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="cu-modal" :class="show?'show':''">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end solid-bottom">
<view class="content">附加费用申请</view>
<view class="action" data-modal="applyExtraChargeModal" @click="hideModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="bg-white padding text-left">
<view class="text-lg padding-top flex justify-start align-center">
<text>金额</text>
<input type="digit" class="radius-input inline-input" v-model="moneyAmount"></input>
</view>
<view class="text-lg padding-top flex justify-start align-center">
<text>原因</text>
<input type="text" class="radius-input inline-input" v-model="reason" disabled value="配件费"></input>
</view>
<view>
<view class="padding-tb-sm">上传图片</view>
<view class="grid col-3 grid-square">
<view class="bg-img" v-for="(item,index) in imgList" :key="index"
@tap="viewImage($event, imgList)" :data-url="item">
<image :src="item" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="delImg($event, imgList)" :data-index="index">
<text class='cuIcon-close'></text>
</view>
</view>
<view class="solids" @tap="chooseImage" v-if="imgList.length < 1">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
</view>
<view>
<view class="padding-tb-sm">申请原因</view>
<view class="solid">
<textarea style="width: 100%; height: 200rpx;" fixed="true" class="radius text-left padding-sm"
v-model="remark" maxlength="-1"></textarea>
</view>
</view>
</view>
<view class="cu-bar bg-white solid-top">
<view class="action margin-0 flex-sub text-black" data-modal="applyExtraChargeModal"
@click="hideModal">取消</view>
<view class="action margin-0 flex-sub text-main-color solid-left" data-modal="applyExtraChargeModal"
@click="submit">确认</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'applyExtraCharge',
props: {
show: {
type: Boolean,
default: false
},
data: {
type: Object,
default: {}
}
},
data() {
return {
imgList: [],
moneyAmount: '',
reason: ''
}
},
methods: {
hideModal(e) {
this.$emit('close', e);
},
chooseImage(e) {
uni.chooseMedia({
count: 1, //默认9
mediaType: ['image'],
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
let tempFilePaths = [];
res.tempFiles.forEach((fileObj) => {
tempFilePaths.push(fileObj.tempFilePath)
})
if (this.imgList.length != 0) {
this.imgList = this.imgList.concat(tempFilePaths)
} else {
this.imgList = tempFilePaths
}
}
});
},
viewImage(e, imgList) {
uni.previewImage({
urls: imgList,
current: e.currentTarget.dataset.url
});
},
delImg(e, imgList) {
uni.showModal({
title: '',
content: '确定要删除这张图片吗?',
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
imgList.splice(e.currentTarget.dataset.index, 1)
}
}
})
},
async submit(e) {
if (!this.moneyAmount) {
uni.showToast({
title: '请输入金额',
icon: 'none'
});
return;
}
// 调用后端接口,添加附加费
let res = await this.$request.addOrderAttach({
orderDetailId: this.data.orderDetailId,
attachMoney: this.moneyAmount,
type: '01'
});
if (res.code === 0) {
uni.showToast({
title: '操作成功',
icon: 'success'
});
this.hideModal(e);
}
}
}
}
</script>
<style scoped>
.grid.col-3.grid-square>view {
padding-bottom: calc((100% - 40rpx)/3);
height: 0;
width: calc((100% - 40rpx)/3);
}
.inline-input {
flex-basis: 75%;
}
</style>