style:模具出库-详情-出库模具清单

main
黄伟杰 3 weeks ago
parent f7ce6117d6
commit fd1c214acb

@ -1,5 +1,5 @@
<template> <template>
<div class="device-ledger-layout"> <div v-if="!props.disabled" class="device-ledger-layout">
<div class="device-ledger-right"> <div class="device-ledger-right">
<ContentWrap> <ContentWrap>
<el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
@ -49,6 +49,17 @@ v-model="queryParams.name" :placeholder="t('MoldManagement.Mold.name')" clearabl
</ContentWrap> </ContentWrap>
</div> </div>
</div> </div>
<div v-else>
<ContentWrap>
<el-table :data="props.items || []" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="产品名称" prop="productName" />
<el-table-column label="产品条码" prop="productBarCode" />
<el-table-column label="数量" prop="count" />
<el-table-column label="单价" prop="productPrice" />
<el-table-column label="备注" prop="remark" />
</el-table>
</ContentWrap>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -57,6 +68,10 @@ import { dateFormatter } from '@/utils/formatTime'
import { MoldBrandApi, MoldVO } from '@/api/erp/mold' import { MoldBrandApi, MoldVO } from '@/api/erp/mold'
import { useDictStoreWithOut } from '@/store/modules/dict' import { useDictStoreWithOut } from '@/store/modules/dict'
const props = defineProps<{
items?: any[]
disabled?: boolean
}>()
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -81,6 +96,7 @@ const dictReady = ref(false)
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
ignoreSelectionChange.value = true
try { try {
const data = await MoldBrandApi.getMoldPage({ const data = await MoldBrandApi.getMoldPage({
pageNo: queryParams.pageNo, pageNo: queryParams.pageNo,
@ -94,6 +110,8 @@ const getList = async () => {
total.value = data.total total.value = data.total
} finally { } finally {
loading.value = false loading.value = false
await nextTick()
ignoreSelectionChange.value = false
} }
} }
@ -111,12 +129,36 @@ const resetQuery = () => {
const tableRef = ref() const tableRef = ref()
const selectedRows = ref<any[]>([]) const selectedRows = ref<any[]>([])
const ignoreSelectionChange = ref(false)
watch(list, async () => { watch(list, async () => {
await nextTick() await nextTick()
restoreSelection() restoreSelection()
}) })
watch(
() => props.items,
async (val) => {
if (!val || !Array.isArray(val) || val.length === 0) {
selectedRows.value = []
await nextTick()
restoreSelection()
return
}
const ids = (val as any[])
.map((item) => item.productId ?? item.id)
.filter((id) => id !== undefined && id !== null)
const uniqIds = Array.from(new Set(ids))
selectedRows.value = uniqIds.map((id) => ({ id }))
await nextTick()
restoreSelection()
},
{ immediate: true, deep: true }
)
const restoreSelection = () => { const restoreSelection = () => {
if (!tableRef.value || selectedRows.value.length === 0) return if (!tableRef.value || selectedRows.value.length === 0) return
tableRef.value.clearSelection?.() tableRef.value.clearSelection?.()
@ -129,7 +171,19 @@ const restoreSelection = () => {
} }
const handleSelectionChange = (rows: any[]) => { const handleSelectionChange = (rows: any[]) => {
selectedRows.value = rows if (ignoreSelectionChange.value) return
const currentPageIds = list.value.map((row) => row.id)
const currentSelectedIdSet = new Set(rows.map((row) => row.id))
selectedRows.value = selectedRows.value.filter(
(row) => !currentPageIds.includes(row.id) || currentSelectedIdSet.has(row.id)
)
rows.forEach((row) => {
if (!selectedRows.value.some((r) => r.id === row.id)) {
selectedRows.value.push(row)
}
})
} }
const validate = async (): Promise<boolean> => { const validate = async (): Promise<boolean> => {

Loading…
Cancel
Save