|
|
|
@ -93,7 +93,13 @@
|
|
|
|
<ContentWrap>
|
|
|
|
<ContentWrap>
|
|
|
|
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
|
|
|
|
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
|
|
|
|
<el-tab-pane :label="t('MoldManagement.MoldGet.moldGroupListTitle')" name="item">
|
|
|
|
<el-tab-pane :label="t('MoldManagement.MoldGet.moldGroupListTitle')" name="item">
|
|
|
|
<el-table :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
|
|
|
|
<StockOutItemFormComp
|
|
|
|
|
|
|
|
v-if="!disabled"
|
|
|
|
|
|
|
|
ref="itemFormRef"
|
|
|
|
|
|
|
|
:items="formData.items"
|
|
|
|
|
|
|
|
:disabled="disabled"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<el-table v-else :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
|
|
|
|
<el-table-column type="expand" width="48">
|
|
|
|
<el-table-column type="expand" width="48">
|
|
|
|
<template #default="{ row: itemRow }">
|
|
|
|
<template #default="{ row: itemRow }">
|
|
|
|
<div class="p-12px">
|
|
|
|
<div class="p-12px">
|
|
|
|
@ -144,7 +150,7 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
|
|
|
|
import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
|
|
|
|
import {DICT_TYPE, getBoolDictOptions, getStrDictOptions} from "@/utils/dict";
|
|
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
|
|
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
|
|
|
|
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
|
|
|
|
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
|
|
|
|
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,11 +161,40 @@ const { t } = useI18n() // 国际化
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
|
|
|
|
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface MoldGetItem {
|
|
|
|
|
|
|
|
id?: number
|
|
|
|
|
|
|
|
moldSetId?: number
|
|
|
|
|
|
|
|
productId?: number
|
|
|
|
|
|
|
|
warehouseId?: number
|
|
|
|
|
|
|
|
moldSetName?: string
|
|
|
|
|
|
|
|
productBarCode?: string
|
|
|
|
|
|
|
|
count?: number
|
|
|
|
|
|
|
|
remark?: string
|
|
|
|
|
|
|
|
moldList?: any[]
|
|
|
|
|
|
|
|
[key: string]: any
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface MoldGetFormData {
|
|
|
|
|
|
|
|
id?: number
|
|
|
|
|
|
|
|
no?: string
|
|
|
|
|
|
|
|
customerId?: number
|
|
|
|
|
|
|
|
outTime?: number | string
|
|
|
|
|
|
|
|
remark?: string
|
|
|
|
|
|
|
|
outType?: string
|
|
|
|
|
|
|
|
fileUrl: string
|
|
|
|
|
|
|
|
items: MoldGetItem[]
|
|
|
|
|
|
|
|
warehouseId?: number
|
|
|
|
|
|
|
|
[key: string]: any
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const StockOutItemFormComp = defineAsyncComponent(() => import('./components/StockOutItemForm.vue') as any)
|
|
|
|
|
|
|
|
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
|
|
|
|
const formData = ref({
|
|
|
|
const formData = ref<MoldGetFormData>({
|
|
|
|
id: undefined,
|
|
|
|
id: undefined,
|
|
|
|
|
|
|
|
no: undefined,
|
|
|
|
customerId: undefined,
|
|
|
|
customerId: undefined,
|
|
|
|
outTime: undefined,
|
|
|
|
outTime: undefined,
|
|
|
|
remark: undefined,
|
|
|
|
remark: undefined,
|
|
|
|
@ -190,6 +225,7 @@ const options = [
|
|
|
|
]
|
|
|
|
]
|
|
|
|
/** 子表的表单 */
|
|
|
|
/** 子表的表单 */
|
|
|
|
const subTabsName = ref('item')
|
|
|
|
const subTabsName = ref('item')
|
|
|
|
|
|
|
|
const itemFormRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const ensureWarehouseId = () => {
|
|
|
|
const ensureWarehouseId = () => {
|
|
|
|
if (formData.value.warehouseId !== undefined && formData.value.warehouseId !== null) return
|
|
|
|
if (formData.value.warehouseId !== undefined && formData.value.warehouseId !== null) return
|
|
|
|
@ -199,6 +235,32 @@ const ensureWarehouseId = () => {
|
|
|
|
|
|
|
|
|
|
|
|
const getTodayTimestamp = () => new Date().setHours(0, 0, 0, 0)
|
|
|
|
const getTodayTimestamp = () => new Date().setHours(0, 0, 0, 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getSelectedItemRows = (): any[] => {
|
|
|
|
|
|
|
|
const selectedRows = itemFormRef.value?.selectedRows
|
|
|
|
|
|
|
|
if (Array.isArray(selectedRows)) return selectedRows
|
|
|
|
|
|
|
|
if (Array.isArray(selectedRows?.value)) return selectedRows.value
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const buildSubmitItems = (rows: any[]): MoldGetItem[] => {
|
|
|
|
|
|
|
|
const existingItemMap = new Map(
|
|
|
|
|
|
|
|
(formData.value.items || []).map((item) => [item.productId ?? item.id, item])
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rows.map((row: any) => {
|
|
|
|
|
|
|
|
const existing = existingItemMap.get(row.id) || {}
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...existing,
|
|
|
|
|
|
|
|
moldSetId: existing.moldSetId ?? row.id,
|
|
|
|
|
|
|
|
productId: row.id,
|
|
|
|
|
|
|
|
warehouseId: formData.value.warehouseId,
|
|
|
|
|
|
|
|
moldSetName: existing.moldSetName ?? row.name,
|
|
|
|
|
|
|
|
productBarCode: existing.productBarCode ?? row.code,
|
|
|
|
|
|
|
|
count: existing.count ?? row.childMoldCount ?? 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
|
/** 打开弹窗 */
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
@ -234,6 +296,12 @@ const emit = defineEmits(['success', 'closed']) // 定义 success 和 closed 事
|
|
|
|
const submitForm = async () => {
|
|
|
|
const submitForm = async () => {
|
|
|
|
// 校验表单
|
|
|
|
// 校验表单
|
|
|
|
await formRef.value.validate()
|
|
|
|
await formRef.value.validate()
|
|
|
|
|
|
|
|
const selectedRows = getSelectedItemRows()
|
|
|
|
|
|
|
|
if (!selectedRows.length) {
|
|
|
|
|
|
|
|
message.warning('请选择模具组')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
formData.value.items = buildSubmitItems(selectedRows)
|
|
|
|
// 提交请求
|
|
|
|
// 提交请求
|
|
|
|
formLoading.value = true
|
|
|
|
formLoading.value = true
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -258,12 +326,13 @@ const resetForm = () => {
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
formData.value = {
|
|
|
|
formData.value = {
|
|
|
|
id: undefined,
|
|
|
|
id: undefined,
|
|
|
|
|
|
|
|
no: undefined,
|
|
|
|
customerId: undefined,
|
|
|
|
customerId: undefined,
|
|
|
|
outTime: getTodayTimestamp(),
|
|
|
|
outTime: getTodayTimestamp(),
|
|
|
|
remark: undefined,
|
|
|
|
remark: undefined,
|
|
|
|
fileUrl: undefined,
|
|
|
|
fileUrl: '',
|
|
|
|
items: [],
|
|
|
|
items: [],
|
|
|
|
outType: "模具出库",
|
|
|
|
outType: '模具出库',
|
|
|
|
warehouseId: undefined
|
|
|
|
warehouseId: undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|