This commit is contained in:
zc
2026-03-17 10:47:57 +08:00
parent 5554cf1548
commit 722fbd988c
16 changed files with 700 additions and 27 deletions

View File

@@ -19,6 +19,8 @@ import { useWindowSize } from '@vueuse/core'
import { addMaterialInfo, getMaterialInfo, updateMaterialInfo } from '@/apis/material/materialInfo'
import { type ColumnItem, GiForm } from '@/components/GiForm'
import { useResetReactive } from '@/hooks'
import { materialType } from "@/hooks/app/materialType";
import {materialProcess} from "@/hooks/app/materialProcess";
const emit = defineEmits<{
(e: 'save-success'): void
@@ -32,6 +34,11 @@ const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改物料管理' : '新增物料管理'))
const formRef = ref<InstanceType<typeof GiForm>>()
const { materialTypeList, getMaterialTypeSelect } = materialType()
const { materialProcessList, getMaterialProcessSelect } = materialProcess()
const [form, resetForm] = useResetReactive({
// todo 待补充
})
@@ -56,6 +63,31 @@ const columns: ColumnItem[] = reactive([
field: 'unitWeight',
type: 'input-number',
span: 24,
required: true,
},
{
label: '物料品类',
field: 'materialTypeId',
type: 'select',
span: 24,
required: true,
props: {
options: materialTypeList,
allowClear: true,
allowSearch: true,
},
},
{
label: '物料流程编码',
field: 'materialProcessId',
type: 'select',
span: 24,
required: true,
props: {
options: materialProcessList,
allowClear: true,
allowSearch: true,
},
},
{
label: '物料规格',
@@ -69,6 +101,7 @@ const columns: ColumnItem[] = reactive([
type: 'image',
savePath: 'material/',
span: 24,
required: true,
},
])
@@ -101,6 +134,12 @@ const save = async () => {
const onAdd = async () => {
reset()
dataId.value = ''
if (!materialTypeList.value.length) {
await getMaterialTypeSelect()
}
if (!materialProcessList.value.length) {
await getMaterialProcessSelect();
}
visible.value = true
}
@@ -109,6 +148,12 @@ const onUpdate = async (id: string) => {
reset()
dataId.value = id
const { data } = await getMaterialInfo(id)
if (!materialTypeList.value.length) {
await getMaterialTypeSelect()
}
if (!materialProcessList.value.length) {
await getMaterialProcessSelect();
}
Object.assign(form, data)
visible.value = true
}

View File

@@ -99,8 +99,6 @@ import has from '@/utils/has'
defineOptions({ name: 'MaterialInfo' })
// 扩展类型定义,允许动态添加 photoLoadError 属性
// 如果 TS 报错,可以在 MaterialInfoResp 接口定义中添加 photoLoadError?: boolean;
interface MaterialInfoRespWithStatus extends MaterialInfoResp {
photoLoadError?: boolean;
}
@@ -108,7 +106,7 @@ interface MaterialInfoRespWithStatus extends MaterialInfoResp {
const queryForm = reactive<MaterialInfoQuery>({
materialName: undefined,
encoding: undefined,
sort: ['id,desc'],
sort: ['mi.id,desc'],
})
const {
@@ -123,6 +121,7 @@ const columns = ref<TableInstanceColumns[]>([
{ title: '物料名称', dataIndex: 'materialName', slotName: 'materialName' },
{ title: '物料编码', dataIndex: 'encoding', slotName: 'encoding' },
{ title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' },
{ title: '物料品类', dataIndex: 'typeName' },
{ title: '物料规格', dataIndex: 'materialSpec', slotName: 'materialSpec' },
{ title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },