Commit c6122b30 by zhuzhequan

ts 报错

parent aeb4f4a5
......@@ -7,8 +7,11 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
CardPods: typeof import('./src/components/CardPods.vue')['default']
CardWrapper: typeof import('./src/components/CardWrapper.vue')['default']
ElButton: typeof import('element-plus/es')['ElButton']
ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCol: typeof import('element-plus/es')['ElCol']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
......@@ -49,7 +52,6 @@ declare module 'vue' {
RouterView: typeof import('vue-router')['RouterView']
ShipmentOrderDetail: typeof import('./src/components/ShipmentOrderDetail.vue')['default']
SplitDiv: typeof import('./src/components/splitDiv/splitDiv.vue')['default']
TableColumn: typeof import('./src/components/TableColumn.vue')['default']
TableView: typeof import('./src/components/TableView.vue')['default']
UploadImage: typeof import('./src/components/UploadImage.vue')['default']
WangEditor: typeof import('./src/components/WangEditor.vue')['default']
......
......@@ -3,7 +3,7 @@
<div class="commodity-card-image">
<div class="before"></div>
<div class="image">
<img :src="cardItem.variantImage" />
<img :src="typeof cardItem.variantImage === 'string' ? cardItem.variantImage : ''" />
</div>
<div class="img_top_left">
<span class="select-icon"></span>
......@@ -27,10 +27,10 @@
<script setup lang="ts">
import { PropType } from 'vue'
import { PodProductList } from '@/types/api/podOrder'
import { PodProductList, CardOrderData } from '@/types/api/podOrder'
defineProps({
cardItem: {
type: Object as PropType<PodProductList>,
type: Object as PropType<PodProductList | CardOrderData>,
required: true,
},
})
......
......@@ -47,11 +47,11 @@ export interface CardOrderData {
lanshouPost: string | null
manuscriptUrl: string | null
manuscriptStatus: number | null
createTime: string | null
updateTime: string | null
createTime: string | undefined
updateTime: string | undefined
remark: string | null
userMark: string | null
namespace: string | null
namespace: string | undefined
productList: PodProductList[]
internalMemoList: string | null
[propName: string]: string | number | boolean | undefined | unknown
......@@ -68,31 +68,31 @@ export interface imageAryInter {
}
export interface PodProductList {
id: number
podOrderId: number
podOrderId?: number
thirdSubOrderNumber?: string
factorySubOrderNumber?: string
factoryOrderNumber?: string | null
factoryOrderNumber?: string | undefined
shopNumber?: string
supplierItemNo?: string | null
baseSku?: string
productName?: string
variantSku?: string
variantImage?: string
imageAry?: string | imageAryInter[] | null
images?: cardImages[] | null
designImages?: string | null
process?: string | null
podProcessName?: string | null
productionFileId?: string | null
imageAry?: string | imageAryInter[] | undefined
images?: cardImages[] | undefined
designImages?: string | undefined
process?: string | undefined
podProcessName?: string | undefined
productionFileId?: string | undefined
customizedQuantity?: number
num?: number | string
shipmentNu?: number
costPrice?: number
price?: number
processPrice?: number
weight?: number | null
version?: number | null
remark?: string | null
weight?: number | undefined
version?: number | undefined
remark?: string | undefined
createTime?: string
updateTime?: string
[propName: string]: string | number | boolean | undefined | unknown
......
......@@ -163,9 +163,12 @@
</div>
<div class="order-list-expand_item_info_title">
<span class="order-list-expand_item_label">未发数:</span>
<span class="order-list-expand_item_value">{{
<span v-if="!isPod" class="order-list-expand_item_value">{{
(item.num || 0) - ((item.shipmentNum || 0) - (item.notPassNum || 0))
}}</span>
<span v-else class="order-list-expand_item_value">{{
(item.num || 0) - (item.shipmentNum || 0)
}}</span>
</div>
<div class="order-list-expand_item_info_title">
<span class="order-list-expand_item_label">工艺:</span>
......
......@@ -291,6 +291,7 @@
>
<ProductInfo
:row="row"
:is-pod="false"
:status="statusCode"
@update-remark="handleUpdateRemark"
@again-generated="handleAgainGenerated"
......
......@@ -196,7 +196,7 @@
v-if="cardItem?.factorySubOrderNumber"
title="生产单号"
class="base_sku"
@click.stop="copy(cardItem?.factorySubOrderNumber)"
@click.stop="copy(String(cardItem?.factorySubOrderNumber || ''))"
>
{{ cardItem?.factorySubOrderNumber }}
</span>
......@@ -204,7 +204,7 @@
<template #operations>
<Icon
name="caozuorizhi"
@click.stop="openLog(cardItem.podOrderId)"
@click.stop="openLog(Number(cardItem.podOrderId) || undefined)"
>
<template #title>
<title>操作日志</title>
......@@ -223,36 +223,36 @@
<div class="flex-between">
<div class="images-position">
<div
v-for="(item, index) in cardItem.images"
v-for="(item, index) in getSafeImages(cardItem)"
:key="index"
:title="
item.ename
item?.ename
? item.ename === 'front'
? '正面图片'
: '反面图片'
: ''
"
:style="
currentImage === item.image && currentId === cardItem.id
currentImage === item?.image && currentId === cardItem.id
? 'border-color: red'
: ''
"
class="item-image"
@click="changeImages(item, cardItem)"
@click="handleChangeImages(item, cardItem)"
>
<img :src="item.image" height="28" />
<img :src="item?.image" height="28" />
</div>
</div>
<b
v-if="cardItem"
:style="{
color:
(cardItem.customizedQuantity || 0) > 1
(Number(cardItem.customizedQuantity) || 0) > 1
? 'red'
: '#67C23A',
}"
>
{{ (cardItem.customizedQuantity || 0) > 1 ? '多' : '单' }}
{{ (Number(cardItem.customizedQuantity) || 0) > 1 ? '多' : '单' }}
</b>
</div>
</template>
......@@ -519,7 +519,7 @@
<div class="order-operate_info">
<div
v-if="
status === 'IN_PRODUCTION' || status === 'PART_SHIPPING'
status === 'TO_BE_CONFIRMED'
"
class="order-list-expand_item_info_title"
>
......@@ -746,7 +746,7 @@ import TableView from '@/components/TableView.vue'
import {
// OrderData,
// ProductList,
LogisticsData,
LogisticsData, OrderData,
ShipmentForm,
} from '@/types/api/order'
import fastProduction from '../fastProduction.vue'
......@@ -874,7 +874,7 @@ const openDetail = async (id: number) => {
//showError(e)
}
}
const CardOrderList = ref<PodProductList[]>([])
const CardOrderList = ref<(PodProductList | CardOrderData)[]>([])
const loadCardList = async () => {
try {
const res = await getCardOrderList(
......@@ -894,7 +894,7 @@ const loadCardList = async () => {
currentPage.value,
pageSize.value,
)
CardOrderList.value = res.data.records.map((item) => {
CardOrderList.value = res.data.records.map((item: any) => {
if (!item.imageAry) {
const images = []
if (typeof item.variantImage === 'string') {
......@@ -935,7 +935,7 @@ const loadCardList = async () => {
}
const currentImage = ref('')
const currentId = ref(-1)
const changeImages = (item: cardImages, data: PodProductList) => {
const changeImages = (item: cardImages, data: PodProductList | CardOrderData) => {
currentImage.value = item.image
// data.designId = item.designId
currentId.value = data.id
......@@ -944,6 +944,11 @@ const changeImages = (item: cardImages, data: PodProductList) => {
// data.productList[0].variantImage = item.image
// }
}
// 包装函数,用于处理类型转换
const handleChangeImages = (item: any, data: PodProductList | CardOrderData) => {
changeImages(item as cardImages, data)
}
const fastTitle = ref('')
const detailData = ref({})
const detailVisible = ref(false)
......@@ -954,16 +959,16 @@ const fastToProduction = (title: string, type: number) => {
fastTitle.value = title
fastType.value = type
}
const cardClick = (data: PodProductList) => {
const cardClick = (data: PodProductList | CardOrderData) => {
const status = isSelectStatused(data)
if (status) {
selection.value = selection.value.filter((item) => item.id !== data.id)
selection.value = selection.value.filter((item: CardOrderData | PodProductList) => item.id !== data.id)
} else {
selection.value.push(data)
selection.value.push(data as any)
}
}
const isSelectStatused = (data: PodProductList) => {
const index = selection.value.findIndex((item) => item.id === data.id)
const isSelectStatused = (data: PodProductList | CardOrderData) => {
const index = selection.value.findIndex((item: CardOrderData | PodProductList) => item.id === data.id)
return index !== -1
}
const changeTab = (item: Tab) => {
......@@ -1048,7 +1053,7 @@ const {
refresh: search,
onCurrentPageChange: handleCurrentChange,
onPageSizeChange: handleSizeChange,
} = usePageList({
} = usePageList<OrderData | CardOrderData>({
query: (page, pageSize) => {
const commonParams = {
...searchForm.value,
......@@ -1066,46 +1071,7 @@ const {
// 动态选择接口
const fetchData =
status.value === 'IN_PRODUCTION' ? getCardOrderList : getOrderList
return fetchData(commonParams, page, pageSize).then((res) => {
// if (status.value === 'IN_PRODUCTION') {
// const cardList = res.data.records.map((item: PodProductList) => {
// if (!item.imageAry) {
// const images = []
// if (item.variantImage) {
// images.push({
// ename: 'front',
// cname: '正面',
// image: item.variantImage,
// })
// }
// if (item.negativeImage) {
// images.push({
// ename: 'back',
// cname: '反面',
// image: item.negativeImage,
// })
// }
// item.images = images
// } else {
// if (item.imageAry) {
// const images = JSON.parse(item.imageAry)
// item.images = images.map((e) => {
// return {
// ename: '',
// cname: '',
// image: e.url,
// }
// })
// }
// }
// return item
// })
// res.data.records = cardList
// return res.data
// } else {
return res.data
// }
})
return fetchData(commonParams, page, pageSize).then((res: { data: any }) => res.data)
},
})
// 发货
......@@ -1196,7 +1162,7 @@ const openAll = (row: CardOrderData) => {
row.moreable = !row.moreable
}
// 表格和卡片的选中值:有两种约束
const selection = ref<CardOrderData[] | PodProductList[]>([])
const selection = ref<(CardOrderData | PodProductList)[]>([])
const handleSelectionChange = (s: CardOrderData[]) => {
selection.value = s
}
......@@ -1218,7 +1184,7 @@ const confirmProduce = async () => {
} catch {
return
}
const ids = selection.value.map((item) => item.id)
const ids = selection.value.map((item: CardOrderData | PodProductList) => item.id)
try {
const res = await confirmProductionOrder(ids)
loadDiffList()
......@@ -1239,11 +1205,11 @@ const downloadMaterial = async () => {
}
const ids = []
if (status.value === 'IN_PRODUCTION' || status.value === 'WAIT_SHIPMENT') {
ids.push(...selection.value.map((item) => item.id))
ids.push(...selection.value.map((item: CardOrderData | PodProductList) => item.id))
} else {
ids.push(
...selection.value.flatMap(
(item) => item.productList?.map((sub:PodProductList) => sub.id) || [],
(item: CardOrderData | PodProductList) => (Array.isArray(item.productList) ? item.productList.map((sub:PodProductList) => sub.id) : []),
),
)
}
......@@ -1280,7 +1246,7 @@ const copy = (text: string): void => {
}
document.body.removeChild(oInput)
}
const onChangeCurrentRow = (item) => {
const onChangeCurrentRow = (item: OrderData) => {
currentRow.value = item
}
const cancelOrder = async (id: number) => {
......@@ -1322,10 +1288,10 @@ const addInternalTag = async () => {
inputPlaceholder: '请输入内部便签',
inputPattern: /.+/,
inputErrorMessage: '内部便签不能为空',
}).then(async ({ value }) => {
}).then(async ({ value }: { value: string }) => {
try {
const res = await addInternalTagApi(
selection.value.map((item) => item.id),
selection.value.map((item: CardOrderData | PodProductList) => item.id),
value,
)
ElMessage.success(res.message)
......@@ -1365,6 +1331,7 @@ const addInternalTag = async () => {
// })
// }
const printManuscript = async () => {
if (selection.value.length === 0) {
return ElMessage({
message: '请选择订单',
......@@ -1374,11 +1341,11 @@ const printManuscript = async () => {
}
const ids = []
if (status.value === 'IN_PRODUCTION' || status.value === 'WAIT_SHIPMENT') {
ids.push(...selection.value.map((item) => item.id))
ids.push(...selection.value.map((item: CardOrderData | PodProductList) => item.id))
} else {
ids.push(
...selection.value.flatMap(
(item) => item.productList?.map((sub:PodProductList) => sub.id) || [],
(item: CardOrderData | PodProductList) => (Array.isArray(item.productList) ? item.productList.map((sub:PodProductList) => sub.id) : []),
),
)
}
......@@ -1415,7 +1382,7 @@ const exportManuscript = async () => {
})
}
const ids = selection.value.map((item) => item.id)
const ids = selection.value.map((item: CardOrderData | PodProductList) => item.id)
try {
await showConfirm('是否导出生产单', {
confirmButtonText: '确认',
......@@ -1443,7 +1410,8 @@ const exportManuscript = async () => {
const logVisible = ref(false)
const logList = ref<LogListData[]>([])
// 操作日志
const openLog = async (id: number) => {
const openLog = async (id?: number) => {
if(!id )return
try {
const res = await getLogList(id)
logList.value = res.data
......@@ -1472,6 +1440,11 @@ const handleUpdateRemark = (payload: { id: number; remark: string }) => {
}
})
}
// 添加一个函数来安全地获取图片列表
const getSafeImages = (item: PodProductList | CardOrderData): cardImages[] => {
if (!item.images) return [];
return item.images as cardImages[];
}
onMounted(() => {
getLogisticsList()
loadTabData()
......
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