✨ feat(mes): 添加杂项入库单及行相关请求和响应 VO
parent
16394f3f94
commit
8948a76f63
|
|
@ -0,0 +1,64 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
// MES 杂项入库单 VO
|
||||||
|
export interface WmMiscReceiptVO {
|
||||||
|
id: number
|
||||||
|
code: string
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
sourceDocId: number
|
||||||
|
sourceDocCode: string
|
||||||
|
sourceDocType: string
|
||||||
|
receiptDate: string
|
||||||
|
status: number
|
||||||
|
remark: string
|
||||||
|
createTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// MES 杂项入库单 API
|
||||||
|
export const WmMiscReceiptApi = {
|
||||||
|
// 查询杂项入库单分页
|
||||||
|
getMiscReceiptPage: async (params: any) => {
|
||||||
|
return await request.get({ url: '/mes/wm/misc-receipt/page', params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询杂项入库单详情
|
||||||
|
getMiscReceipt: async (id: number) => {
|
||||||
|
return await request.get({ url: '/mes/wm/misc-receipt/get?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增杂项入库单
|
||||||
|
createMiscReceipt: async (data: WmMiscReceiptVO) => {
|
||||||
|
return await request.post({ url: '/mes/wm/misc-receipt/create', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改杂项入库单
|
||||||
|
updateMiscReceipt: async (data: WmMiscReceiptVO) => {
|
||||||
|
return await request.put({ url: '/mes/wm/misc-receipt/update', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除杂项入库单
|
||||||
|
deleteMiscReceipt: async (id: number) => {
|
||||||
|
return await request.delete({ url: '/mes/wm/misc-receipt/delete?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 提交审批
|
||||||
|
submitMiscReceipt: async (id: number) => {
|
||||||
|
return await request.put({ url: '/mes/wm/misc-receipt/submit?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 执行入库
|
||||||
|
finishMiscReceipt: async (id: number) => {
|
||||||
|
return await request.put({ url: '/mes/wm/misc-receipt/finish?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 取消杂项入库单
|
||||||
|
cancelMiscReceipt: async (id: number) => {
|
||||||
|
return await request.put({ url: '/mes/wm/misc-receipt/cancel?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出杂项入库单 Excel
|
||||||
|
exportMiscReceipt: async (params: any) => {
|
||||||
|
return await request.download({ url: '/mes/wm/misc-receipt/export-excel', params })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
// MES 杂项入库单行 VO
|
||||||
|
// TODO @AI:搞到:line/index.ts 里;
|
||||||
|
export interface WmMiscReceiptLineVO {
|
||||||
|
id: number
|
||||||
|
receiptId: number
|
||||||
|
itemId: number
|
||||||
|
quantity: number
|
||||||
|
batchCode: string
|
||||||
|
warehouseId: number
|
||||||
|
locationId: number
|
||||||
|
areaId: number
|
||||||
|
productionDate: string
|
||||||
|
expireDate: string
|
||||||
|
productionBatchNumber: string
|
||||||
|
remark: string
|
||||||
|
createTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// MES 杂项入库单行 API
|
||||||
|
export const WmMiscReceiptLineApi = {
|
||||||
|
// 查询杂项入库单行详情
|
||||||
|
getMiscReceiptLine: async (id: number) => {
|
||||||
|
return await request.get({ url: '/mes/wm/misc-receipt-line/get?id=' + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询杂项入库单行列表
|
||||||
|
getMiscReceiptLineListByReceiptId: async (receiptId: number) => {
|
||||||
|
return await request.get({ url: '/mes/wm/misc-receipt-line/list-by-receipt-id?receiptId=' + receiptId })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增杂项入库单行
|
||||||
|
createMiscReceiptLine: async (data: WmMiscReceiptLineVO) => {
|
||||||
|
return await request.post({ url: '/mes/wm/misc-receipt-line/create', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改杂项入库单行
|
||||||
|
updateMiscReceiptLine: async (data: WmMiscReceiptLineVO) => {
|
||||||
|
return await request.put({ url: '/mes/wm/misc-receipt-line/update', data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除杂项入库单行
|
||||||
|
deleteMiscReceiptLine: async (id: number) => {
|
||||||
|
return await request.delete({ url: '/mes/wm/misc-receipt-line/delete?id=' + id })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,216 @@
|
||||||
|
<!-- TODO @AI:每行三个: -->
|
||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="110px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库单编号" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.code"
|
||||||
|
placeholder="请输入入库单编号"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="generateCode" :disabled="formType !== 'create'">
|
||||||
|
生成
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库单名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.name"
|
||||||
|
placeholder="请输入入库单名称"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<!-- TODO @AI:业务类型 -->
|
||||||
|
<el-form-item label="杂项类型" prop="type">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.type"
|
||||||
|
placeholder="请选择杂项类型"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="来源单据编码" prop="sourceDocCode">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.sourceDocCode"
|
||||||
|
placeholder="请输入来源单据编码"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="来源单据类型" prop="sourceDocType">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.sourceDocType"
|
||||||
|
placeholder="请输入来源单据类型"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库日期" prop="receiptDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="formData.receiptDate"
|
||||||
|
type="date"
|
||||||
|
value-format="x"
|
||||||
|
placeholder="请选择入库日期"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<!-- 非新建模式展示行项目信息(入库物料) -->
|
||||||
|
<template v-if="formData.id">
|
||||||
|
<el-divider content-position="center">物料信息</el-divider>
|
||||||
|
<MiscReceiptLineList :receipt-id="formData.id" :form-type="formType" />
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<el-button v-if="isUpdate" @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
|
确 定
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { generateRandomStr } from '@/utils'
|
||||||
|
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { WmMiscReceiptApi, WmMiscReceiptVO } from '@/api/mes/wm/miscreceipt'
|
||||||
|
import MiscReceiptLineList from './MiscReceiptLineList.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MiscReceiptForm' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const formType = ref<string>('create') // create / update / detail
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined as number | undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
type: undefined,
|
||||||
|
sourceDocId: undefined,
|
||||||
|
sourceDocCode: undefined,
|
||||||
|
sourceDocType: undefined,
|
||||||
|
receiptDate: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
code: [{ required: true, message: '入库单编号不能为空', trigger: 'blur' }],
|
||||||
|
name: [{ required: true, message: '入库单名称不能为空', trigger: 'blur' }],
|
||||||
|
// TODO @AI:type、receiptDate 选填;
|
||||||
|
type: [{ required: true, message: '杂项类型不能为空', trigger: 'change' }],
|
||||||
|
receiptDate: [{ required: true, message: '入库日期不能为空', trigger: 'change' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(formType.value))
|
||||||
|
const isHeaderReadonly = computed(() => formType.value === 'detail')
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
const titles = {
|
||||||
|
create: '新增杂项入库单',
|
||||||
|
update: '编辑杂项入库单',
|
||||||
|
detail: '杂项入库单详情'
|
||||||
|
}
|
||||||
|
return titles[formType.value] || formType.value
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 生成入库单编号 */
|
||||||
|
const generateCode = () => {
|
||||||
|
formData.value.code = 'MR' + generateRandomStr(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await WmMiscReceiptApi.getMiscReceipt(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as WmMiscReceiptVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
const res = await WmMiscReceiptApi.createMiscReceipt(data)
|
||||||
|
message.success('新增成功')
|
||||||
|
formData.value.id = res
|
||||||
|
formType.value = 'update'
|
||||||
|
} else {
|
||||||
|
await WmMiscReceiptApi.updateMiscReceipt(data)
|
||||||
|
message.success('修改成功')
|
||||||
|
}
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
type: undefined,
|
||||||
|
sourceDocId: undefined,
|
||||||
|
sourceDocCode: undefined,
|
||||||
|
sourceDocType: undefined,
|
||||||
|
receiptDate: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,273 @@
|
||||||
|
<!-- MES 杂项入库单行列表子组件 -->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-button v-if="isUpdate" type="primary" plain @click="openForm('create')" class="mb-10px">
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 添加物料
|
||||||
|
</el-button>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
border
|
||||||
|
>
|
||||||
|
<el-table-column label="物料编码" align="center" prop="itemCode" min-width="120" />
|
||||||
|
<el-table-column label="物料名称" align="center" prop="itemName" min-width="140" />
|
||||||
|
<el-table-column label="规格型号" align="center" prop="specification" min-width="120" />
|
||||||
|
<el-table-column label="单位" align="center" prop="unitMeasureName" width="80" />
|
||||||
|
<el-table-column label="入库数量" align="center" prop="quantity" width="100" />
|
||||||
|
<el-table-column label="批次号" align="center" prop="batchCode" min-width="120" />
|
||||||
|
<el-table-column label="仓库" align="center" prop="warehouseName" min-width="100" />
|
||||||
|
<el-table-column label="库区" align="center" prop="locationName" min-width="100" />
|
||||||
|
<el-table-column label="库位" align="center" prop="areaName" min-width="100" />
|
||||||
|
<el-table-column
|
||||||
|
v-if="isUpdate"
|
||||||
|
label="操作"
|
||||||
|
align="center"
|
||||||
|
width="160"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="openForm('update', scope.row.id)">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button link type="danger" @click="handleDelete(scope.row.id)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加/编辑行弹窗 -->
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="110px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="物料" prop="itemId">
|
||||||
|
<MdItemSelect
|
||||||
|
v-model="formData.itemId"
|
||||||
|
placeholder="请选择物料"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库数量" prop="quantity">
|
||||||
|
<el-input-number
|
||||||
|
v-model="formData.quantity"
|
||||||
|
:precision="2"
|
||||||
|
:min="0.01"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="批次号" prop="batchCode">
|
||||||
|
<el-input v-model="formData.batchCode" placeholder="请输入批次号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="仓库" prop="warehouseId">
|
||||||
|
<WmWarehouseSelect
|
||||||
|
v-model="formData.warehouseId"
|
||||||
|
placeholder="请选择仓库"
|
||||||
|
class="!w-1/1"
|
||||||
|
@change="handleWarehouseChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="库区" prop="locationId">
|
||||||
|
<WmWarehouseLocationSelect
|
||||||
|
v-model="formData.locationId"
|
||||||
|
:warehouse-id="formData.warehouseId"
|
||||||
|
placeholder="请选择库区"
|
||||||
|
class="!w-1/1"
|
||||||
|
@change="handleLocationChange"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="库位" prop="areaId">
|
||||||
|
<WmWarehouseAreaSelect
|
||||||
|
v-model="formData.areaId"
|
||||||
|
:location-id="formData.locationId"
|
||||||
|
placeholder="请选择库位"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { WmMiscReceiptLineApi, WmMiscReceiptLineVO } from '@/api/mes/wm/miscreceipt/line'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
|
import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue'
|
||||||
|
import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue'
|
||||||
|
import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MiscReceiptLineList' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
receiptId: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
formType: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const list = ref<WmMiscReceiptLineVO[]>([])
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const lineFormType = ref<string>('create')
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined as number | undefined,
|
||||||
|
receiptId: props.receiptId,
|
||||||
|
itemId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
locationId: undefined,
|
||||||
|
areaId: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
|
||||||
|
quantity: [
|
||||||
|
{ required: true, message: '入库数量不能为空', trigger: 'blur' },
|
||||||
|
{ type: 'number', min: 0.01, message: '入库数量必须大于 0', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(props.formType))
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
return lineFormType.value === 'create' ? '添加物料' : '编辑物料'
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
list.value = await WmMiscReceiptLineApi.getMiscReceiptLineListByReceiptId(props.receiptId)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 仓库变化时,清空库区和库位 */
|
||||||
|
const handleWarehouseChange = () => {
|
||||||
|
formData.value.locationId = undefined
|
||||||
|
formData.value.areaId = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 库区变化时,清空库位 */
|
||||||
|
const handleLocationChange = () => {
|
||||||
|
formData.value.areaId = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开表单 */
|
||||||
|
const openForm = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
lineFormType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await WmMiscReceiptLineApi.getMiscReceiptLine(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as WmMiscReceiptLineVO
|
||||||
|
if (lineFormType.value === 'create') {
|
||||||
|
await WmMiscReceiptLineApi.createMiscReceiptLine(data)
|
||||||
|
message.success('新增成功')
|
||||||
|
} else {
|
||||||
|
await WmMiscReceiptLineApi.updateMiscReceiptLine(data)
|
||||||
|
message.success('修改成功')
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await getList()
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await WmMiscReceiptLineApi.deleteMiscReceiptLine(id)
|
||||||
|
message.success('删除成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
receiptId: props.receiptId,
|
||||||
|
itemId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
locationId: undefined,
|
||||||
|
areaId: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.receiptId,
|
||||||
|
() => {
|
||||||
|
if (props.receiptId) {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,308 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="100px"
|
||||||
|
>
|
||||||
|
<el-form-item label="入库单编号" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.code"
|
||||||
|
placeholder="请输入入库单编号"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入库单名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入入库单名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- TODO @AI:咋想类型,改成业务类型; -->
|
||||||
|
<el-form-item label="杂项类型" prop="type">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.type"
|
||||||
|
placeholder="请选择杂项类型"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<!-- TODO @AI:需呀在 DICT_TYPE 枚举下; -->
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getStrDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入库日期" prop="receiptDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.receiptDate"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="单据状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="请选择单据状态"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="入库单编号" align="center" prop="code" min-width="160" />
|
||||||
|
<el-table-column label="入库单名称" align="center" prop="name" min-width="150" />
|
||||||
|
<el-table-column label="杂项类型" align="center" prop="type" min-width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE" :value="scope.row.type" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- TODO @芋艿:【待定】来源单据编号、来源单据类型 -->
|
||||||
|
<el-table-column
|
||||||
|
label="入库日期"
|
||||||
|
align="center"
|
||||||
|
prop="receiptDate"
|
||||||
|
:formatter="dateFormatter2"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="单据状态" align="center" prop="status" min-width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" width="240" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<!-- 草稿:编辑、提交、删除 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:update']"
|
||||||
|
v-if="scope.row.status === MesWmMiscReceiptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="warning"
|
||||||
|
@click="handleSubmit(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:submit']"
|
||||||
|
v-if="scope.row.status === MesWmMiscReceiptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
提交
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:delete']"
|
||||||
|
v-if="scope.row.status === MesWmMiscReceiptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<!-- 已审批:执行入库、取消 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="handleFinish(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:finish']"
|
||||||
|
v-if="scope.row.status === MesWmMiscReceiptStatusEnum.APPROVED"
|
||||||
|
>
|
||||||
|
执行入库
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleCancel(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:cancel']"
|
||||||
|
v-if="scope.row.status === MesWmMiscReceiptStatusEnum.APPROVED"
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
<!-- 已完成/已取消:查看详情 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('detail', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm:misc-receipt:query']"
|
||||||
|
v-if="
|
||||||
|
[MesWmMiscReceiptStatusEnum.FINISHED, MesWmMiscReceiptStatusEnum.CANCELED].includes(
|
||||||
|
scope.row.status
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
详情
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<MiscReceiptForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter2 } from '@/utils/formatTime'
|
||||||
|
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { WmMiscReceiptApi, WmMiscReceiptVO } from '@/api/mes/wm/miscreceipt'
|
||||||
|
import MiscReceiptForm from './MiscReceiptForm.vue'
|
||||||
|
import { MesWmMiscReceiptStatusEnum } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MesWmMiscReceipt' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<WmMiscReceiptVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
type: undefined,
|
||||||
|
status: undefined,
|
||||||
|
receiptDate: undefined
|
||||||
|
})
|
||||||
|
const queryFormRef = ref()
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await WmMiscReceiptApi.getMiscReceiptPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await WmMiscReceiptApi.deleteMiscReceipt(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮操作 */
|
||||||
|
const handleSubmit = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认提交该杂项入库单吗?')
|
||||||
|
await WmMiscReceiptApi.submitMiscReceipt(id)
|
||||||
|
message.success('提交成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行入库按钮操作 */
|
||||||
|
const handleFinish = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认执行入库吗?')
|
||||||
|
await WmMiscReceiptApi.finishMiscReceipt(id)
|
||||||
|
message.success('入库成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消按钮操作 */
|
||||||
|
const handleCancel = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认取消该杂项入库单吗?')
|
||||||
|
await WmMiscReceiptApi.cancelMiscReceipt(id)
|
||||||
|
message.success('取消成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await WmMiscReceiptApi.exportMiscReceipt(queryParams)
|
||||||
|
download.excel(data, '杂项入库单.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue