Commit e90edaec by zhuzhequan

Merge remote-tracking branch 'origin/dev' into dev

parents 2c0cf812 01458b31
......@@ -370,9 +370,13 @@ export function updateSelfLogistics(params: {
}
// 更改物流
export function composingDesignImages(data: number[], type: string) {
export function composingDesignImages(
data: number[],
type?: string,
templateWidth?: number,
) {
return axios.post<never, BaseRespData<never>>(
`factory/podJomallOrderUs/composingDesignImages?type=${type}`,
`factory/podJomallOrderUs/composingDesignImages?type=${type}&templateWidth=${templateWidth}`,
data,
)
}
......@@ -436,10 +440,14 @@ export function toOutOfStockApi(ids: number[]) {
}
// 排单完成
export function arrangeFinishApi(ids: number[]) {
export function arrangeFinishApi(params: {
productIdList: number[]
templateWidth?: number
type?: string
}) {
return axios.post<never, BaseRespData<never>>(
`factory/podJomallOrderProductUs/arrangeFinish`,
ids,
params,
)
}
......@@ -482,7 +490,11 @@ export function batchDownloadDeleteApi(params: { ids?: string }) {
}
// 批量下载 重新排版
export function batchDownloadRecomposingApi(params: { id: number }) {
export function batchDownloadRecomposingApi(params: {
id: number
type?: string
templateWidth?: number
}) {
return axios.get<never, BaseRespData<never>>(
`factory/podBatchDownload/reComposingDesignImages`,
{
......
......@@ -15,7 +15,8 @@ export interface ExportParams extends SearchForm {
export interface SearchForm {
timeType?: number | null
shopNumber?: string
shipmentType?: string
shipmentType?: string | number
replaceShipment?: string | number
userMark?: string
processNumber?: string
trackingNumber?: string
......
......@@ -33,6 +33,7 @@ export interface SearchForm {
supplierProductNo?: string
batchArrangeNumber?: string
craftCode?: string
craftCodeArr?: string[]
thirdStockSku?: string
interceptStatus?: number | string
trackRegisterSelect?: string | number
......
......@@ -493,7 +493,17 @@ const getOrderListFn = async () => {
const { currentPage, pageSize } = pagination.value
try {
const { data } = await getOrderList(
{ ...searchForm.value },
{
...searchForm.value,
startTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[0]
: null,
endTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[1]
: null,
},
currentPage,
pageSize,
)
......
......@@ -221,7 +221,46 @@
style="width: 150px"
></ElInput>
</ElFormItem>
<ElFormItem label="物流类型">
<ElFormItem label="是否代发">
<ElSelect
v-model="searchForm.replaceShipment"
placeholder="是否代发"
clearable
:teleported="false"
style="width: 150px"
@change="changeReplaceShipment"
>
<ElOption
v-for="(item, index) in ['不代发', '代发']"
:key="index"
:value="index"
:label="item"
></ElOption>
</ElSelect>
</ElFormItem>
<ElFormItem
v-if="searchForm.replaceShipment === 0"
label="物流类型"
>
<ElSelect
v-model="searchForm.shipmentType"
placeholder="物流类型"
clearable
:teleported="false"
style="width: 150px"
>
<ElOption
v-for="(item, index) in ['自提', '快递']"
:key="index"
:value="index"
:label="item"
></ElOption>
</ElSelect>
</ElFormItem>
<ElFormItem
v-if="searchForm.replaceShipment === 1"
label="物流类型"
>
<ElSelect
v-model="searchForm.shipmentType"
placeholder="物流类型"
......@@ -2299,6 +2338,7 @@ const detailData = ref({})
const [searchForm, resetSearchForm] = useValue<SearchForm>({
timeType: 1,
shopNumber: '',
replaceShipment: '',
shipmentType: '',
userMark: '',
processNumber: '',
......@@ -2579,6 +2619,9 @@ const updateOrder = async () => {
loading.close()
}
}
const changeReplaceShipment = () => {
searchForm.value.shipmentType = ''
}
const assignOrder = async () => {
if (selection.value.length === 0) {
return ElMessage.warning('请选择数据')
......
......@@ -47,11 +47,14 @@
<ElFormItem label="工艺">
<ElSelect
v-model="searchForm.craftCode"
v-model="searchForm.craftCodeArr"
clearable
filterable
multiple
collapse-tags
collapse-tags-tooltip
placeholder="请输入工艺"
style="width: 150px"
style="width: 230px"
>
<el-option
v-for="item in craftList"
......@@ -262,7 +265,7 @@
<ElButton type="primary" @click="search">查询</ElButton>
</span>
</ElFormItem>
<!-- <ElFormItem
<ElFormItem
v-if="
status === 'PICKING' ||
status === 'TO_BE_REPLENISHMENT' ||
......@@ -277,19 +280,29 @@
<ElDropdownMenu>
<ElDropdownItem
:loading="tifDownloadLoading"
@click="downloadTif('png')"
>TIF排版</ElDropdownItem
@click="downloadTif('tiff', 40)"
>TIF(40cm)</ElDropdownItem
>
<ElDropdownItem
:loading="tifDownloadLoading"
@click="downloadTif('tiff', 60)"
>TIF(60cm)</ElDropdownItem
>
<ElDropdownItem
:loading="pngDownloadLoading"
@click="downloadTif('png')"
>PNG排版</ElDropdownItem
@click="downloadTif('png', 40)"
>PNG(40cm)</ElDropdownItem
>
<ElDropdownItem
:loading="pngDownloadLoading"
@click="downloadTif('png', 60)"
>PNG(60cm)</ElDropdownItem
>
</ElDropdownMenu></template
></ElDropdown
></ElFormItem
> -->
<ElFormItem
>
<!-- <ElFormItem
v-if="
status === 'PICKING' ||
status === 'TO_BE_REPLENISHMENT' ||
......@@ -322,7 +335,7 @@
PNG排版
</ElButton>
</span>
</ElFormItem>
</ElFormItem> -->
<ElFormItem v-if="status === 'TO_BE_CONFIRMED'">
<span class="item">
<ElButton type="success" @click="confirmProduct">
......@@ -544,7 +557,7 @@
</ElFormItem>
<ElFormItem v-if="status === 'TO_BE_ARRANGE'">
<span class="item">
<ElButton type="warning" @click="arrangeFinish">排单完成</ElButton>
<ElButton type="warning" @click="showArrange(2)">排单完成</ElButton>
</span>
</ElFormItem>
<ElFormItem
......@@ -1243,21 +1256,14 @@
@click="downloadMaterialItem(item)"
>下载素材
</el-button>
<el-button
link
size="small"
type="warning"
style="height: 23px; margin: 0"
@click="downloadTifItem('tiff', item.id)"
>TIF排版
</el-button>
<el-button
link
size="small"
type="warning"
style="height: 23px; margin: 0"
@click="downloadTifItem('png', item.id)"
>PNG排版
@click="showArrange(3, item)"
>排版
</el-button>
</div>
</div>
......@@ -1554,7 +1560,7 @@
</span>
<span class="operate-item">
<ElButton
disabled
:disabled="!row.tiffUrl"
link
type="primary"
@click="handleDownload(row, 'tiff')"
......@@ -1585,7 +1591,7 @@
link
type="warning"
:loading="reComposingLoadingMap[row.id]"
@click="handleReComposingDesign(row)"
@click="showArrange(1, row)"
>
重新排版
</ElButton>
......@@ -2417,6 +2423,31 @@
</el-timeline-item>
</el-timeline>
</el-dialog>
<ElDialog
v-model="typesettingVisible"
title="选择排版类型和宽度"
width="500px"
:close-on-click-modal="false"
>
<el-form :model="typesettingForm" label-width="100px">
<el-form-item label="排版类型:" prop="type">
<el-checkbox-group v-model="typesettingForm.typeArr">
<el-checkbox label="tiff">tiff排版</el-checkbox>
<el-checkbox label="png">png排版</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="排版宽度:" prop="type">
<el-radio-group v-model="typesettingForm.templateWidth">
<el-radio :value="40">40cm</el-radio>
<el-radio :value="60">60cm</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="typesettingVisible = false">取消</el-button>
<el-button type="primary" @click="submitTypesetting">确认</el-button>
</template>
</ElDialog>
</template>
<script setup lang="ts">
import { getUserMarkList } from '@/api/common'
......@@ -2703,6 +2734,7 @@ const [searchForm, resetSearchForm] = useValue<SearchForm>({
supplierProductNo: '',
batchArrangeNumber: '',
craftCode: '',
craftCodeArr: [],
thirdStockSku: '',
})
const exceptionStatus = ref(1)
......@@ -2924,20 +2956,26 @@ const handleBatchDelete = async (type: string, id?: string) => {
}
}
// 批量下载 重新排版
const handleReComposingDesign = async (row: PodUsOrderListData) => {
try {
await showConfirm('确定重新排版吗?', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
} catch {
return
}
const handleReComposingDesign = async () => {
const row = { ...(typesettingRow.value as PodUsOrderListData) }
reComposingLoadingMap[row.id] = true
typesettingVisible.value = false
const params: {
id: number
templateWidth?: number
type?: string
} = {
id: row.id,
}
const { templateWidth, typeArr } = typesettingForm.value
if (templateWidth && typeArr?.length) {
params.templateWidth = templateWidth
params.type = typeArr.join(',')
}
try {
const res = await batchDownloadRecomposingApi({ id: row.id })
const res = await batchDownloadRecomposingApi(params)
if (res.code !== 200) return
ElMessage.success(res.message)
search()
......@@ -2946,6 +2984,8 @@ const handleReComposingDesign = async (row: PodUsOrderListData) => {
console.error(e)
} finally {
reComposingLoadingMap[row.id] = false
typesettingRow.value = undefined
}
}
const tableColumns = computed(() => {
......@@ -3293,48 +3333,50 @@ const {
status.value !== 'TO_BE_REPLENISHMENT' &&
status.value !== 'TO_BE_ARRANGE'
) {
return getOrderList(
{
...searchForm.value,
startTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[0]
: null,
endTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[1]
: null,
status: status.value === 'INTERCEPTED' ? '' : status.value,
exceptionHandling:
status.value === 'EXCEPTION_ORDER'
? exceptionStatus.value || undefined
: undefined,
interceptStatus:
status.value === 'INTERCEPTED' ? interceptStatus.value : '',
trackRegisterSelect:
status.value === 'WAIT_TRACK' ? waitTrackStatus.value : '',
},
page,
pageSize,
).then((res) => res.data) as never
const params = {
...searchForm.value,
startTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[0]
: null,
endTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[1]
: null,
status: status.value === 'INTERCEPTED' ? '' : status.value,
exceptionHandling:
status.value === 'EXCEPTION_ORDER'
? exceptionStatus.value || undefined
: undefined,
interceptStatus:
status.value === 'INTERCEPTED' ? interceptStatus.value : '',
trackRegisterSelect:
status.value === 'WAIT_TRACK' ? waitTrackStatus.value : '',
craftCode: searchForm.value?.craftCodeArr?.join(',') || '',
}
params.craftCodeArr && delete params.craftCodeArr
return getOrderList(params, page, pageSize).then(
(res) => res.data,
) as never
} else {
return getCardOrderList(
{
...searchForm.value,
startTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[0]
: null,
endTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[1]
: null,
status: status.value,
interceptStatus: '',
},
page,
pageSize,
).then((res) => res.data) as never
const params = {
...searchForm.value,
startTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[0]
: null,
endTime:
timeRange.value && timeRange.value.length > 0
? timeRange.value[1]
: null,
status: status.value,
interceptStatus: '',
craftCode: searchForm.value?.craftCodeArr?.join(',') || '',
}
params.craftCodeArr && delete params.craftCodeArr
return getCardOrderList(params, page, pageSize).then(
(res) => res.data,
) as never
}
},
})
......@@ -3541,7 +3583,7 @@ const productionClientVisible = ref(false)
// productionClientVisible.value = true
// }
const downloadTif = async (type: string) => {
const downloadTif = async (type: string, templateWidth: number) => {
if (!cardSelection.value.length) {
return ElMessage.warning('请选择数据')
}
......@@ -3550,10 +3592,16 @@ const downloadTif = async (type: string) => {
} else {
pngDownloadLoading.value = true
}
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await composingDesignImages(
cardSelection.value.map((el) => el.id),
type,
templateWidth,
)
const url =
type === 'tiff'
......@@ -3594,53 +3642,188 @@ const downloadTif = async (type: string) => {
} else {
pngDownloadLoading.value = false
}
} finally {
loading.close()
}
}
const downloadTifItem = async (type: string, id: number) => {
const downloadTifItem = async () => {
const row = { ...(typesettingRow.value as PodUsOrderListData) }
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await composingDesignImages([id], type)
const url =
type === 'tiff'
? `https://ps.jomalls.com/tiff/` + res.message
: filePath + res.message
if (type === 'tiff') {
window.open(url, '_blank')
const { templateWidth, typeArr } = typesettingForm.value
const type = typeArr?.join(',') || ''
typesettingVisible.value = false
// 处理下载逻辑
if ((typeArr as string[]).length > 1) {
// 并行处理多个类型
await Promise.allSettled(
(typeArr as string[]).map((el) =>
downloadSingleType(row.id, el, templateWidth),
),
)
} else {
fetch(url)
.then((response) => {
// 确保响应是 OK
if (!response.ok) {
throw new Error('网络响应错误')
}
// 返回图片的二进制数据(Blob)
return response.blob()
})
.then((blob) => {
const a = document.createElement('a')
a.href = window.URL.createObjectURL(blob)
a.target = '_blank'
a.download = (res.message as string).split('/')[
(res.message as string).split('/').length - 1
]
a.click()
pngDownloadLoading.value = false
})
.catch((error) => {
console.error('下载图片时出错:', error)
pngDownloadLoading.value = false
})
// 处理单个类型
await downloadSingleType(row.id, type, templateWidth)
}
} catch (e) {
console.log(e)
} catch (error) {
console.error('下载过程中出错:', error)
} finally {
typesettingRow.value = undefined
loading.close()
}
}
// 提取下载单个类型的逻辑为独立函数
const downloadSingleType = async (
id: number,
type: string,
templateWidth?: number,
) => {
try {
const res = await composingDesignImages([id], type, templateWidth)
const isTiff = type === 'tiff'
const url = isTiff
? `https://ps.jomalls.com/tiff/${res.message}`
: `${filePath}${res.message}`
if (isTiff) {
// 对于tiff类型,直接在新窗口打开
window.open(url, '_blank')
} else {
// 对于其他类型,使用下载方式
await downloadFile(url, res.message as string)
}
} catch (error) {
console.error(`下载类型 ${type} 时出错:`, error)
throw error // 重新抛出错误以便外部捕获
}
}
// 提取文件下载逻辑为独立函数
const downloadFile = async (url: string, message: string) => {
try {
const response = await fetch(url)
const blob = await response.blob()
const filename = message.split('/').pop() || 'download'
// 创建下载链接
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = filename
a.target = '_blank'
// 模拟点击下载
document.body.appendChild(a)
a.click()
// 清理
setTimeout(() => {
document.body.removeChild(a)
URL.revokeObjectURL(a.href)
}, 100)
} catch (error) {
console.error('下载文件时出错:', error)
throw error // 重新抛出错误
} finally {
pngDownloadLoading.value = false
}
}
// const downloadTifItem = async () => {
// const row = { ...(typesettingRow.value as PodUsOrderListData) }
// const loading = ElLoading.service({
// fullscreen: true,
// text: '操作中...',
// background: 'rgba(0, 0, 0, 0.3)',
// })
// const { templateWidth, typeArr } = typesettingForm.value
// const type = (typeArr?.join(',') as string) || ''
// typesettingVisible.value = false
// try {
// if ((typeArr as string[]).length > 1) {
// typeArr?.forEach(async (el) => {
// const res = await composingDesignImages([row.id], el, templateWidth)
// const url =
// type === 'tiff'
// ? `https://ps.jomalls.com/tiff/` + res.message
// : filePath + res.message
// if (el === 'tiff') {
// window.open(url, '_blank')
// } else {
// fetch(url)
// .then((response) => {
// // 确保响应是 OK
// if (!response.ok) {
// throw new Error('网络响应错误')
// }
// // 返回图片的二进制数据(Blob)
// return response.blob()
// })
// .then((blob) => {
// const a = document.createElement('a')
// a.href = window.URL.createObjectURL(blob)
// a.target = '_blank'
// a.download = (res.message as string).split('/')[
// (res.message as string).split('/').length - 1
// ]
// a.click()
// pngDownloadLoading.value = false
// })
// .catch((error) => {
// console.error('下载图片时出错:', error)
// pngDownloadLoading.value = false
// })
// }
// })
// } else {
// const res = await composingDesignImages([row.id], type, templateWidth)
// const url =
// type === 'tiff'
// ? `https://ps.jomalls.com/tiff/` + res.message
// : filePath + res.message
// if (type === 'tiff') {
// window.open(url, '_blank')
// } else {
// fetch(url)
// .then((response) => {
// // 确保响应是 OK
// if (!response.ok) {
// throw new Error('网络响应错误')
// }
// // 返回图片的二进制数据(Blob)
// return response.blob()
// })
// .then((blob) => {
// const a = document.createElement('a')
// a.href = window.URL.createObjectURL(blob)
// a.target = '_blank'
// a.download = (res.message as string).split('/')[
// (res.message as string).split('/').length - 1
// ]
// a.click()
// pngDownloadLoading.value = false
// })
// .catch((error) => {
// console.error('下载图片时出错:', error)
// pngDownloadLoading.value = false
// })
// }
// }
// } catch (e) {
// console.log(e)
// } finally {
// typesettingRow.value = undefined
// loading.close()
// }
// }
const loadProductionClient = async () => {
try {
const res = await getProductionClientApi()
......@@ -4095,32 +4278,93 @@ const downloadMaterialItem = async (data: PodUsOrderListData) => {
}
// 排单完成
const arrangeFinish = async () => {
const selectedIds = cardSelection.value.map((item) => item.id)
if (selectedIds.length === 0) {
return ElMessage({
message: '请选择订单',
type: 'warning',
offset: window.innerHeight / 2,
})
const typesettingForm = ref<{
typeArr?: string[]
type?: string
templateWidth?: number
}>({})
const typesettingVisible = ref(false)
const typesettingType = ref<number>()
const typesettingRow = ref<PodUsOrderListData>()
const showArrange = async (type: number, data?: PodUsOrderListData) => {
typesettingType.value = type
typesettingForm.value = {}
if (type === 1 || type === 3) {
typesettingRow.value = data
} else if (type === 2) {
const selectedIds = cardSelection.value.map((item) => item.id)
if (selectedIds.length === 0) {
return ElMessage({
message: '请选择订单',
type: 'warning',
offset: window.innerHeight / 2,
})
}
const bool = hasDifferentCraftCodeWithSet(cardSelection.value)
if (bool) {
try {
await ElMessageBox.confirm(
'选中排单的生产单存在多个工艺, 是否继续排单?',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
},
)
typesettingVisible.value = true
} catch (error) {
return (typesettingVisible.value = false)
}
}
}
try {
await ElMessageBox.confirm('确定排单完成吗?', '提示', {
cancelButtonText: '取消',
confirmButtonText: '确认',
type: 'warning',
})
} catch {
return
typesettingVisible.value = true
}
function hasDifferentCraftCodeWithSet(items: ProductList[]) {
if (items.length <= 1) return false
const seen = new Set()
for (const item of items) {
if (seen.has(item.craftCode)) {
if (seen.size > 1) return true
} else {
seen.add(item.craftCode)
if (seen.size > 1) return true
}
}
return false
}
const arrangeFinish = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
const selectedIds = cardSelection.value.map((item) => item.id)
const params: {
productIdList: number[]
templateWidth?: number
type?: string
} = {
productIdList: selectedIds,
}
const { templateWidth, typeArr } = typesettingForm.value
if (templateWidth && typeArr?.length) {
params.templateWidth = templateWidth
params.type = typeArr.join(',')
}
console.log(4233, params)
typesettingVisible.value = false
try {
const res = await arrangeFinishApi(selectedIds)
const res = await arrangeFinishApi(params)
if (res.code !== 200) return
ElMessage.success('操作成功')
search()
......@@ -4132,6 +4376,26 @@ const arrangeFinish = async () => {
}
}
const submitTypesetting = () => {
const { templateWidth, typeArr } = typesettingForm.value
if (templateWidth && !typeArr?.length) {
return ElMessage.warning('请选择排版类型')
} else if (!templateWidth && typeArr?.length) {
return ElMessage.warning('请选择排版宽度')
}
if (typesettingType.value == 3) {
if (!templateWidth && !typeArr?.length) {
return ElMessage.warning('排版类型和排版宽度为必选项')
}
}
return typesettingType.value == 1
? handleReComposingDesign()
: typesettingType.value == 2
? arrangeFinish()
: downloadTifItem()
}
interface timeLineType {
time_iso?: string
time_utc?: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment