244 lines
6.7 KiB
Vue
244 lines
6.7 KiB
Vue
<template>
|
||
<scroll-view class="scroll-container" scroll-y v-if="receivingInfo">
|
||
<u-form :model="receivingInfo" :rules="rules" ref="infoFormRef" label-width="180rpx">
|
||
<view class="section">
|
||
<view class="section-title">基础信息</view>
|
||
|
||
<u-form-item label="收货单号">
|
||
<u-input v-model="receivingInfo.receiving_number" disabled />
|
||
<u-button style="width: 150rpx;" type="primary" @click="print">打印</u-button>
|
||
</u-form-item>
|
||
|
||
<u-form-item label="货主" prop="store_id">
|
||
<view>{{receivingInfo.store?receivingInfo.store.store_remask:'未设置'}}</view>
|
||
</u-form-item>
|
||
|
||
<u-form-item label="来货方式" prop="delivery_method">
|
||
<u-radio-group v-model="receivingInfo.delivery_method" disabled>
|
||
<u-radio v-for="item in deliveryMethods" :key="item.value" :name="item.value"
|
||
:label="item.label"></u-radio>
|
||
</u-radio-group>
|
||
</u-form-item>
|
||
|
||
<u-form-item v-if="receivingInfo.delivery_method === 'truck'" label="车牌号" prop="license_plate">
|
||
<u-input v-model="receivingInfo.license_plate" disabled placeholder="请输入车牌号" />
|
||
</u-form-item>
|
||
|
||
<u-form-item v-else-if="receivingInfo.delivery_method !== 'other'" label="物流单号" prop="tracking_number">
|
||
<u-input v-model="receivingInfo.tracking_number" placeholder="请输入物流单号" />
|
||
</u-form-item>
|
||
</view>
|
||
<view class="section" v-if="receivingInfo.id">
|
||
<view class="section-title">来货照片</view>
|
||
<uploadImgCos business_type="receiving" :value="receivingInfo.images" :business_id="receivingInfo.id" @change="$emit('change')"></uploadImgCos>
|
||
</view>
|
||
|
||
<view class="section">
|
||
<view class="section-title">装卸信息</view>
|
||
|
||
<u-form-item label="装卸方式" prop="loading_method">
|
||
<u-radio-group v-model="receivingInfo.loading_method" disabled>
|
||
<u-radio v-for="item in loadingMethods" :key="item.value" :name="item.value"
|
||
:label="item.label"></u-radio>
|
||
</u-radio-group>
|
||
</u-form-item>
|
||
|
||
<u-form-item label="总箱数" prop="total_boxes">
|
||
<u-input v-model="receivingInfo.total_boxes" disabled type="number" placeholder="请输入总箱数" />
|
||
</u-form-item>
|
||
|
||
<u-form-item label="总托盘数" prop="total_pallets">
|
||
<u-input v-model="receivingInfo.total_pallets" disabled type="number" placeholder="请输入总托盘数" />
|
||
</u-form-item>
|
||
|
||
<u-form-item label="录像设备">
|
||
<u-input v-model="receivingInfo.video_device_id" disabled placeholder="录像设备ID" />
|
||
</u-form-item>
|
||
</view>
|
||
|
||
<view class="section">
|
||
<view class="section-title">收货状态</view>
|
||
|
||
<u-form-item label="收货状态">
|
||
<u-tag :text="receivingInfo.status | statusFilter" :type="getStatusType(receivingInfo.status)" />
|
||
</u-form-item>
|
||
|
||
<u-form-item label="创建人">
|
||
<u-input v-model="receivingInfo.creator_name" disabled />
|
||
</u-form-item>
|
||
|
||
<u-form-item label="创建时间">
|
||
<u-input :value="formatDate(receivingInfo.created_at)" disabled />
|
||
</u-form-item>
|
||
</view>
|
||
|
||
<view class="section">
|
||
<view class="section-title">备注信息</view>
|
||
<u-form-item label="备注">
|
||
<u-input v-model="receivingInfo.remark" type="textarea" placeholder="请输入备注" height="120" />
|
||
</u-form-item>
|
||
</view>
|
||
<view class="section">
|
||
<view class="section-title">收货码</view>
|
||
<view style="width: 100%;display: flex;flex-direction: column;align-items: center;">
|
||
<canvas id="qrcode" canvas-id="qrcode" style="width: 200px;height: 200px;"></canvas>
|
||
</view>
|
||
</view>
|
||
</u-form>
|
||
</scroll-view>
|
||
</template>
|
||
|
||
<script>
|
||
import UQRCode from 'uqrcodejs'
|
||
export default {
|
||
name: 'InfoContainer',
|
||
props: {
|
||
receivingInfo: {
|
||
type: Object,
|
||
required: true
|
||
},
|
||
qrcodeUrl: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
saving: {
|
||
type: Boolean,
|
||
default: false
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
deliveryMethods: [{
|
||
value: 'truck',
|
||
label: '货车'
|
||
},
|
||
{
|
||
value: 'express',
|
||
label: '快递'
|
||
},
|
||
{
|
||
value: 'other',
|
||
label: '其他'
|
||
}
|
||
],
|
||
loadingMethods: [{
|
||
value: 'with_pallet',
|
||
label: '带托盘'
|
||
},
|
||
{
|
||
value: 'without_pallet',
|
||
label: '不带托盘'
|
||
}
|
||
],
|
||
rules: {}
|
||
};
|
||
},
|
||
mounted() {
|
||
console.log("onShow");
|
||
this.qrcode(this.receivingInfo.receiving_number);
|
||
},
|
||
filters: {
|
||
statusFilter(status) {
|
||
const map = {
|
||
'receiving': '收货中',
|
||
'completed': '已完成',
|
||
'cancelled': '已取消'
|
||
};
|
||
return map[status] || status;
|
||
}
|
||
},
|
||
watch:{
|
||
'receivingInfo.receiving_number':{
|
||
handler(newval){
|
||
console.log(newval);
|
||
this.qrcode(newval)
|
||
}
|
||
}
|
||
},
|
||
methods: {
|
||
qrcode(data){
|
||
var qr = new UQRCode();
|
||
qr.data = data;
|
||
qr.make();
|
||
var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件,this必须传入
|
||
// 设置uQRCode实例的canvas上下文
|
||
qr.canvasContext = canvasContext;
|
||
// 调用绘制方法将二维码图案绘制到canvas上
|
||
qr.drawCanvas();
|
||
},
|
||
formatDate(dateStr) {
|
||
if (!dateStr) return '-';
|
||
|
||
try {
|
||
const normalizedDateStr = typeof dateStr === 'string' ? dateStr.replace(/-/g, '/') : dateStr;
|
||
const date = new Date(normalizedDateStr);
|
||
|
||
if (Number.isNaN(date.getTime())) {
|
||
return dateStr;
|
||
}
|
||
|
||
const year = date.getFullYear();
|
||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||
const day = String(date.getDate()).padStart(2, '0');
|
||
const hour = String(date.getHours()).padStart(2, '0');
|
||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||
const second = String(date.getSeconds()).padStart(2, '0');
|
||
|
||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||
} catch (error) {
|
||
console.error('日期格式化错误:', error);
|
||
return dateStr;
|
||
}
|
||
},
|
||
getStatusType(status) {
|
||
const map = {
|
||
'receiving': 'primary',
|
||
'completed': 'success',
|
||
'cancelled': 'error'
|
||
};
|
||
return map[status] || 'default';
|
||
},
|
||
validateForm() {
|
||
return this.$refs.infoFormRef.validate();
|
||
},
|
||
print(){
|
||
this.$emit('print',{type:"STOCK",value:{product_barcode:this.receivingInfo.receiving_number,product_name:this.receivingInfo.creator_name}})
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.scroll-container {
|
||
height: 100%;
|
||
}
|
||
|
||
.section {
|
||
background-color: #fff;
|
||
border-radius: 16rpx;
|
||
padding: 30rpx;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
|
||
.section-title {
|
||
font-size: 32rpx;
|
||
font-weight: bold;
|
||
color: #333;
|
||
margin-bottom: 20rpx;
|
||
padding-bottom: 10rpx;
|
||
border-bottom: 2rpx solid #f0f0f0;
|
||
}
|
||
|
||
.action-buttons {
|
||
padding: 30rpx;
|
||
background: #fff;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
.qrcode-image {
|
||
width: 200rpx;
|
||
height: 200rpx;
|
||
display: block;
|
||
margin: 0 auto;
|
||
}
|
||
</style> |