u
This commit is contained in:
1 parent
b7f2efc7c3
commit
cc88205cba
23 files changed
+1239
-799
No files matched your search
@@ -14,7 +14,8 @@ const form = ref<any>({
|
||||
b_container_img: '',
|
||||
})
|
||||
|
||||
const subFileList = ref([])
|
||||
const subFileList = ref([]) // 装货照片
|
||||
const subFileList2 = ref([]) // 发货单、签收单、过磅单
|
||||
|
||||
onLoad((options) => {
|
||||
const id = options.id
|
||||
@@ -34,7 +35,7 @@ async function loadMainData() {
|
||||
try {
|
||||
const orgUrl = await getOrgBaseUrl(userStore.userInfo.orgid)
|
||||
|
||||
// 并发请求(提升性能)
|
||||
// ================= 并发请求 =================
|
||||
const [res, fileRes] = await Promise.all([
|
||||
loadDataApi({
|
||||
viewName: 'v_container',
|
||||
@@ -42,7 +43,7 @@ async function loadMainData() {
|
||||
}),
|
||||
loadDataApi({
|
||||
viewName: 'bf_file',
|
||||
searchCondition: `father = '${form.value.b_id}' AND mx_cate_id = '1'`,
|
||||
searchCondition: `father = '${form.value.b_id}'`,
|
||||
}),
|
||||
])
|
||||
|
||||
@@ -60,19 +61,46 @@ async function loadMainData() {
|
||||
form.value = mainData
|
||||
}
|
||||
else {
|
||||
console.warn('未获取到主数据')
|
||||
uni.showToast({
|
||||
title: '当前数据无效',
|
||||
icon: 'none',
|
||||
duration: 1500,
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
const pages = getCurrentPages()
|
||||
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
}
|
||||
else {
|
||||
uni.reLaunch({
|
||||
url: '/',
|
||||
})
|
||||
}
|
||||
}, 1500)
|
||||
return
|
||||
}
|
||||
|
||||
// ================= 子表 =================
|
||||
// ================= 子表统一处理 =================
|
||||
if (fileRes.success) {
|
||||
const files = (fileRes.data || []).map(file => ({
|
||||
const allFiles = fileRes.data || []
|
||||
|
||||
const formatFile = file => ({
|
||||
...file,
|
||||
mx_mapfilename: buildPubicUrl(orgUrl, file.mx_mapfilename),
|
||||
name: file.mx_filename,
|
||||
url: buildPubicUrl(orgUrl, file.mx_mapfilename),
|
||||
}))
|
||||
})
|
||||
|
||||
subFileList.value = files
|
||||
// 按分类拆分
|
||||
subFileList.value = allFiles
|
||||
.filter(f => f.mx_cate_id === '1')
|
||||
.map(formatFile)
|
||||
|
||||
subFileList2.value = allFiles
|
||||
.filter(f => f.mx_cate_id === '2')
|
||||
.map(formatFile)
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
@@ -150,48 +178,68 @@ async function handleConfirm() {
|
||||
})
|
||||
|
||||
const fileInserts = []
|
||||
const fileUpdates = []
|
||||
|
||||
// 子表
|
||||
for (let index = 0; index < subFileList.value.length; index++) {
|
||||
const fileItem = subFileList.value[index]
|
||||
const allFiles = [
|
||||
...subFileList.value.map(item => ({ ...item, cate: '1' })),
|
||||
...subFileList2.value.map(item => ({ ...item, cate: '2' })),
|
||||
]
|
||||
|
||||
if (fileItem.subid) {
|
||||
// 已上传的文件,无需重复上传
|
||||
continue
|
||||
}
|
||||
const grouped = allFiles.reduce((acc, item) => {
|
||||
if (!acc[item.cate])
|
||||
acc[item.cate] = []
|
||||
acc[item.cate].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
const res = await uploadContainerFileApi(fileItem.file.path, {
|
||||
jobId: form.value.b_id,
|
||||
containerNo: form.value.b_container_no,
|
||||
fileName: fileItem.name,
|
||||
})
|
||||
for (const cate in grouped) {
|
||||
let index = 1
|
||||
|
||||
const maxIndexNumber = Math.max(
|
||||
0,
|
||||
...subFileList.value.map(item => item.mx_xh || 0),
|
||||
)
|
||||
for (const fileItem of grouped[cate]) {
|
||||
const mx_xh = index++
|
||||
|
||||
if (res.success) {
|
||||
const indexNumber = maxIndexNumber + 1
|
||||
// 已存在 → update
|
||||
if (fileItem.subid) {
|
||||
fileUpdates.push({
|
||||
subid: fileItem.subid,
|
||||
mx_xh,
|
||||
mx_cate_id: cate,
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
// 新增 → upload
|
||||
const res = await uploadContainerFileApi(fileItem.file.path, {
|
||||
jobId: form.value.b_id,
|
||||
containerNo: form.value.b_container_no,
|
||||
fileName: fileItem.name,
|
||||
})
|
||||
|
||||
if (!res.success)
|
||||
continue
|
||||
|
||||
fileInserts.push({
|
||||
subid: res.data.uid,
|
||||
father: form.value.b_id,
|
||||
mx_xh: indexNumber,
|
||||
mx_xh,
|
||||
mx_filename: res.data.fileName,
|
||||
mx_filesize: fileItem.file.size,
|
||||
mx_fileext: getFileExtension(fileItem.file.name),
|
||||
mx_mapfilename: res.data.path,
|
||||
mx_moduleid: 'b_container',
|
||||
mx_cate_id: '1',
|
||||
mx_cate_id: cate,
|
||||
})
|
||||
|
||||
fileItem.subid = res.data.uid
|
||||
}
|
||||
}
|
||||
|
||||
if (fileInserts.length === 0) {
|
||||
if (fileInserts.length === 0 && fileUpdates.length === 0) {
|
||||
toast.success('保存成功')
|
||||
|
||||
setTimeout(() => {
|
||||
loadMainData()
|
||||
}, 1000)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -200,7 +248,7 @@ async function handleConfirm() {
|
||||
tableName: 'bf_file',
|
||||
keyField: 'subid',
|
||||
inserts: fileInserts,
|
||||
updates: [],
|
||||
updates: fileUpdates,
|
||||
deletes: [],
|
||||
},
|
||||
]
|
||||
@@ -208,6 +256,10 @@ async function handleConfirm() {
|
||||
saveObjectApi(reqData).then((res) => {
|
||||
if (res.success) {
|
||||
toast.success('保存成功')
|
||||
|
||||
setTimeout(() => {
|
||||
loadMainData()
|
||||
}, 1000)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -225,6 +277,7 @@ function validateContainerNo(containerNo) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
const templateCollapse = ref<string[]>(['template1'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -272,12 +325,62 @@ function validateContainerNo(containerNo) {
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-collapse v-model="templateCollapse" style="margin-top: 32rpx;">
|
||||
<wd-collapse-item name="template1">
|
||||
<template #title>
|
||||
<view class="template-header">
|
||||
<view class="title">
|
||||
<sar-icon
|
||||
name="file"
|
||||
size="38rpx"
|
||||
style="margin-right: 16rpx;"
|
||||
/>
|
||||
<text>
|
||||
上传模板(参考)
|
||||
</text>
|
||||
</view>
|
||||
<sar-icon
|
||||
:name="templateCollapse.includes('template1') ? 'up' : 'down'"
|
||||
size="38rpx"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
<view class="template-container">
|
||||
<view class="item">
|
||||
<text class="title">
|
||||
1、提空箱拍照模版
|
||||
</text>
|
||||
|
||||
<wd-img
|
||||
style="width:100%;height:400rpx;"
|
||||
src="/static/images/D21304CD0CDAB09EE3349E8B7D078CC9.jpg"
|
||||
:enable-preview="true"
|
||||
@click.stop
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-left:16rpx">
|
||||
<text class="title">
|
||||
2、装箱拍照模版
|
||||
</text>
|
||||
|
||||
<wd-img
|
||||
style="width:100%;height:400rpx;"
|
||||
src="/static/images/027C52B0A3986905F161127336244D72.jpg"
|
||||
:enable-preview="true"
|
||||
@click.stop
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</wd-collapse-item>
|
||||
</wd-collapse>
|
||||
|
||||
<wd-cell-group custom-class="group" border use-slot style="margin-top: 32rpx;">
|
||||
<template #title>
|
||||
<view style="display:flex;align-items: center;">
|
||||
<sar-icon family="iconfont" name="tupian" size="38rpx" color="var(--sar-primary)" style="margin-right: 16rpx;" />
|
||||
<text>
|
||||
其他图片
|
||||
装货照片
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
@@ -292,6 +395,27 @@ function validateContainerNo(containerNo) {
|
||||
/>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-cell-group custom-class="group" border use-slot style="margin-top: 32rpx;">
|
||||
<template #title>
|
||||
<view style="display:flex;align-items: center;">
|
||||
<sar-icon family="iconfont" name="tupian" size="38rpx" color="var(--sar-primary)" style="margin-right: 16rpx;" />
|
||||
<text>
|
||||
发货单、签收单、过磅单
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="step-content">
|
||||
<sar-upload
|
||||
v-model="subFileList2"
|
||||
multiple
|
||||
:before-read="beforeRead"
|
||||
:before-remove="beforeRemove"
|
||||
@item-click="onItemClick"
|
||||
@remove="onRemove"
|
||||
/>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
<view class="g3-footer">
|
||||
<view class="footer-main">
|
||||
@@ -465,4 +589,34 @@ page {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 3rpx 6rpx rgba(58, 110, 232, 0.15);
|
||||
}
|
||||
|
||||
.template-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
font-weight: 500;
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.template-container {
|
||||
display: flex;
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 50%;
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
padding-left: 10rpx;
|
||||
border-left: 6rpx solid var(--sar-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -19,7 +19,8 @@ const form = ref({
|
||||
ocrNo: '',
|
||||
})
|
||||
|
||||
const subFileList = ref([])
|
||||
const subFileList = ref([]) // 装货照片
|
||||
const subFileList2 = ref([]) // 发货单、签收单、过磅单
|
||||
|
||||
const tipContainerNo = ref('')
|
||||
|
||||
@@ -167,7 +168,7 @@ async function handleConfirm() {
|
||||
b_ocr_score: form.value.ocrScore || 0.00,
|
||||
}
|
||||
const fileInserts = []
|
||||
|
||||
|
||||
// 主表
|
||||
await uploadContainerFileApi(boxImage.value.path, {
|
||||
jobId: form.value.b_id,
|
||||
@@ -191,31 +192,47 @@ async function handleConfirm() {
|
||||
}
|
||||
})
|
||||
|
||||
// 子表
|
||||
for (let index = 0; index < subFileList.value.length; index++) {
|
||||
const fileItem = subFileList.value[index]
|
||||
const indexMap = {}
|
||||
|
||||
const getNextIndex = (cate) => {
|
||||
if (!indexMap[cate]) {
|
||||
indexMap[cate] = 1
|
||||
}
|
||||
return indexMap[cate]++
|
||||
}
|
||||
|
||||
const allFiles = [
|
||||
...subFileList.value.map(item => ({
|
||||
...item,
|
||||
cate: '1',
|
||||
})),
|
||||
...subFileList2.value.map(item => ({
|
||||
...item,
|
||||
cate: '2',
|
||||
})),
|
||||
]
|
||||
|
||||
for (const fileItem of allFiles) {
|
||||
const res = await uploadContainerFileApi(fileItem.file.path, {
|
||||
jobId: form.value.b_id,
|
||||
containerNo: form.value.b_container_no,
|
||||
fileName: fileItem.name,
|
||||
})
|
||||
|
||||
if (res.success) {
|
||||
const indexNumber = index + 2
|
||||
if (!res.success)
|
||||
continue
|
||||
|
||||
fileInserts.push({
|
||||
subid: res.data.uid,
|
||||
father: form.value.b_id,
|
||||
mx_xh: indexNumber,
|
||||
mx_filename: res.data.fileName,
|
||||
mx_filesize: fileItem.file.size,
|
||||
mx_fileext: getFileExtension(fileItem.file.name),
|
||||
mx_mapfilename: res.data.path,
|
||||
mx_moduleid: 'b_container',
|
||||
mx_cate_id: '1',
|
||||
})
|
||||
}
|
||||
fileInserts.push({
|
||||
subid: res.data.uid,
|
||||
father: form.value.b_id,
|
||||
mx_xh: getNextIndex(fileItem.cate),
|
||||
mx_filename: res.data.fileName,
|
||||
mx_filesize: fileItem.file.size,
|
||||
mx_fileext: getFileExtension(fileItem.file.name),
|
||||
mx_mapfilename: res.data.path,
|
||||
mx_moduleid: 'b_container',
|
||||
mx_cate_id: fileItem.cate,
|
||||
})
|
||||
}
|
||||
|
||||
const reqData = [
|
||||
@@ -271,11 +288,15 @@ async function continueAdd() {
|
||||
form.value.b_id = idRes.data
|
||||
|
||||
subFileList.value = []
|
||||
subFileList2.value = []
|
||||
|
||||
showResult.value = false
|
||||
|
||||
tipContainerNo.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const templateCollapse = ref<string[]>(['template1'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -359,12 +380,62 @@ async function continueAdd() {
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
|
||||
<wd-collapse v-model="templateCollapse" style="margin-top: 32rpx;">
|
||||
<wd-collapse-item name="template1">
|
||||
<template #title>
|
||||
<view class="template-header">
|
||||
<view class="title">
|
||||
<sar-icon
|
||||
name="file"
|
||||
size="38rpx"
|
||||
style="margin-right: 16rpx;"
|
||||
/>
|
||||
<text>
|
||||
上传模板(参考)
|
||||
</text>
|
||||
</view>
|
||||
<sar-icon
|
||||
:name="templateCollapse.includes('template1') ? 'up' : 'down'"
|
||||
size="38rpx"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
<view class="template-container">
|
||||
<view class="item">
|
||||
<text class="title">
|
||||
1、提空箱拍照模版
|
||||
</text>
|
||||
|
||||
<wd-img
|
||||
style="width:100%;height:400rpx;"
|
||||
src="/static/images/D21304CD0CDAB09EE3349E8B7D078CC9.jpg"
|
||||
:enable-preview="true"
|
||||
@click.stop
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-left:16rpx">
|
||||
<text class="title">
|
||||
2、装箱拍照模版
|
||||
</text>
|
||||
|
||||
<wd-img
|
||||
style="width:100%;height:400rpx;"
|
||||
src="/static/images/027C52B0A3986905F161127336244D72.jpg"
|
||||
:enable-preview="true"
|
||||
@click.stop
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</wd-collapse-item>
|
||||
</wd-collapse>
|
||||
|
||||
<wd-cell-group custom-class="group" border use-slot style="margin-top: 32rpx;">
|
||||
<template #title>
|
||||
<view style="display:flex;align-items: center;">
|
||||
<sar-icon family="iconfont" name="tupian" size="38rpx" color="var(--sar-primary)" style="margin-right: 16rpx;" />
|
||||
<text>
|
||||
其他图片
|
||||
装货照片
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
@@ -378,6 +449,25 @@ async function continueAdd() {
|
||||
/>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
<wd-cell-group custom-class="group" border use-slot style="margin-top: 32rpx;">
|
||||
<template #title>
|
||||
<view style="display:flex;align-items: center;">
|
||||
<sar-icon family="iconfont" name="tupian" size="38rpx" color="var(--sar-primary)" style="margin-right: 16rpx;" />
|
||||
<text>
|
||||
发货单、签收单、过磅单
|
||||
</text>
|
||||
</view>
|
||||
</template>
|
||||
<view class="step-content">
|
||||
<sar-upload
|
||||
v-model="subFileList2"
|
||||
multiple
|
||||
:before-read="beforeRead"
|
||||
:before-remove="beforeRemove"
|
||||
@item-click="onItemClick"
|
||||
/>
|
||||
</view>
|
||||
</wd-cell-group>
|
||||
</view>
|
||||
<view class="g3-footer">
|
||||
<view class="footer-main">
|
||||
@@ -568,4 +658,34 @@ page {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 3rpx 6rpx rgba(58, 110, 232, 0.15);
|
||||
}
|
||||
|
||||
.template-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
font-weight: 500;
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.template-container {
|
||||
display: flex;
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 50%;
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
padding-left: 10rpx;
|
||||
border-left: 6rpx solid var(--sar-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 467 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Reference in new issue
Block a user