fix mes stock in and out type

main
chenshuichuan 2 years ago
parent 7623da29e0
commit 7c4ab845b1

@ -6,6 +6,7 @@ export interface StockInVO {
no: string // 入库单号
supplierId: number // 供应商编号
inTime: Date // 入库时间
inType: string //入库类型
totalCount: number // 合计数量
totalPrice: number // 合计金额,单位:元
status: number // 状态
@ -58,5 +59,15 @@ export const StockInApi = {
// 导出其它入库单 Excel
exportStockIn: async (params) => {
return await request.download({ url: `/erp/stock-in/export-excel`, params })
}
},
// 查询其它入库单分页
getMesStockInPage: async (params: any) => {
return await request.get({ url: `/erp/stock-in/pageMesStockIn`, params })
},
// 新增其它入库单
createMesStockIn: async (data: StockInVO) => {
return await request.post({ url: `/erp/stock-in/createMesStockIn`, data })
},
}

@ -6,6 +6,7 @@ export interface StockOutVO {
no: string // 出库单号
customerId: number // 客户编号
outTime: Date // 出库时间
outType: string //出库类型
totalCount: number // 合计数量
totalPrice: number // 合计金额,单位:元
status: number // 状态

@ -14,6 +14,25 @@
<el-input disabled v-model="formData.no" placeholder="保存时自动生成" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="入库类型" prop="inType">
<el-select
v-model="formData.inType"
clearable
filterable
placeholder="请选择入库类型"
class="!w-1/1"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
:disabled="item.disabled"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="入库时间" prop="inTime">
<el-date-picker
@ -43,7 +62,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="16">
<el-col :span="8">
<el-form-item label="备注" prop="remark">
<el-input
type="textarea"
@ -95,17 +114,43 @@ const formData = ref({
id: undefined,
supplierId: undefined,
inTime: undefined,
inType: undefined,
remark: undefined,
fileUrl: '',
items: []
})
const formRules = reactive({
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }]
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }],
inType: [{ required: true, message: '入库类型不能为空', trigger: 'blur' }]
})
const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref
const supplierList = ref<SupplierVO[]>([]) //
const options = [
{
value: '其他入库',
label: '其他入库',
},
{
value: '关键件入库',
label: '关键件入库',
},
{
value: '原料入库',
label: '原料入库',
},
{
value: '产品入库',
label: '产品入库',
},
{
value: '生产入库',
label: '生产入库',
disabled: true,
},
]
/** 子表的表单 */
const subTabsName = ref('item')
const itemFormRef = ref()

@ -147,6 +147,13 @@
<!-- 列表 -->
<ContentWrap>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane label="产品" name="产品入库" />
<el-tab-pane label="原料" name="原料入库" />
<el-tab-pane label="关键件" name="关键件入库" />
<el-tab-pane label="其他" name="其他入库" />
</el-tabs>
<el-table
v-loading="loading"
:data="list"
@ -372,4 +379,9 @@ onMounted(async () => {
})
// TODO
// TODO
let activeName = '产品入库'
const handleTabClick = (tab: TabsPaneContext) => {
queryParams.outType = tab.paneName
handleQuery()
}
</script>

@ -15,16 +15,21 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="出库品类" prop="outType">
<el-radio-group v-model="formData.outType">
<el-radio
v-for="dict in getStrDictOptions(DICT_TYPE.MES_STOCK_OUT_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
<el-form-item label="客户" prop="customerId">
<el-select
v-model="formData.customerId"
clearable
filterable
placeholder="请选择客户"
class="!w-1/1"
>
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
@ -39,23 +44,26 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="客户" prop="customerId">
<el-form-item label="出库类型" prop="outType">
<el-select
v-model="formData.customerId"
v-model="formData.outType"
clearable
filterable
placeholder="请选择客户"
placeholder="请选择出库类型"
class="!w-1/1"
>
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
:disabled="item.disabled"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="备注" prop="remark">
<el-input
@ -122,7 +130,31 @@ const formRules = reactive({
const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref
const customerList = ref<CustomerVO[]>([]) //
const options = [
{
value: '其他出库',
label: '其他出库',
},
{
value: '关键件出库',
label: '关键件出库',
},
{
value: '原料出库',
label: '原料出库',
},
{
value: '产品出库',
label: '产品出库',
},
{
value: '领料出库',
label: '领料出库',
disabled: true,
},
]
/** 子表的表单 */
const subTabsName = ref('item')
const itemFormRef = ref()

@ -25,24 +25,6 @@
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="供应商" prop="supplierId">
<el-select
v-model="formData.supplierId"
clearable
filterable
placeholder="请选择供应商"
class="!w-1/1"
>
<el-option
v-for="item in supplierList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="备注" prop="remark">
<el-input
@ -104,7 +86,7 @@ const formRules = reactive({
})
const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref
const supplierList = ref<SupplierVO[]>([]) //
/** 子表的表单 */
const subTabsName = ref('item')
@ -125,8 +107,6 @@ const open = async (type: string, id?: number) => {
formLoading.value = false
}
}
//
supplierList.value = await SupplierApi.getSupplierSimpleList()
}
defineExpose({ open }) // open
@ -141,7 +121,7 @@ const submitForm = async () => {
try {
const data = formData.value as unknown as StockInVO
if (formType.value === 'create') {
await StockInApi.createStockIn(data)
await StockInApi.createMesStockIn(data)
message.success(t('common.createSuccess'))
} else {
await StockInApi.updateStockIn(data)

@ -0,0 +1,267 @@
<template>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="0px"
:inline-message="true"
:disabled="disabled"
>
<el-table :data="formData" show-summary :summary-method="getSummaries" class="-mt-10px">
<el-table-column label="序号" type="index" align="center" width="60" />
<el-table-column label="仓库名称" min-width="125">
<template #default="{ row, $index }">
<el-form-item
:prop="`${$index}.warehouseId`"
:rules="formRules.warehouseId"
class="mb-0px!"
>
<el-select
v-model="row.warehouseId"
clearable
filterable
placeholder="请选择仓库"
@change="onChangeWarehouse($event, row)"
>
<el-option
v-for="item in warehouseList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="产品名称" min-width="180">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
<el-select
v-model="row.productId"
clearable
filterable
@change="onChangeProduct($event, row)"
placeholder="请选择产品"
>
<el-option
v-for="item in productList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="库存" min-width="100">
<template #default="{ row }">
<el-form-item class="mb-0px!">
<el-input disabled v-model="row.stockCount" :formatter="erpCountInputFormatter" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="条码" min-width="150">
<template #default="{ row }">
<el-form-item class="mb-0px!">
<el-input disabled v-model="row.productBarCode" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="单位" min-width="80">
<template #default="{ row }">
<el-form-item class="mb-0px!">
<el-input disabled v-model="row.productUnitName" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数量" prop="count" fixed="right" min-width="140">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
<el-input-number
v-model="row.count"
controls-position="right"
:min="0.001"
:precision="3"
class="!w-100%"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="产品单价" fixed="right" min-width="120">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
<el-input-number
v-model="row.productPrice"
controls-position="right"
:min="0.01"
:precision="2"
class="!w-100%"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="合计金额" prop="totalPrice" fixed="right" min-width="100">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="备注" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
<el-input v-model="row.remark" placeholder="请输入备注" />
</el-form-item>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="60">
<template #default="{ $index }">
<el-button @click="handleDelete($index)" link></el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<el-row justify="center" class="mt-3" v-if="!disabled">
<el-button @click="handleAdd" round>+ 添加入库产品</el-button>
</el-row>
</template>
<script setup lang="ts">
import { ProductApi, ProductVO } from '@/api/erp/product/product'
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
import { StockApi } from '@/api/erp/stock/stock'
import {
erpCountInputFormatter,
erpPriceInputFormatter,
erpPriceMultiply,
getSumValue
} from '@/utils'
const props = defineProps<{
items: undefined
disabled: false
}>()
const formLoading = ref(false) //
const formData = ref([])
const formRules = reactive({
inId: [{ required: true, message: '入库编号不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
})
const formRef = ref([]) // Ref
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const defaultWarehouse = ref<WarehouseVO>(undefined) //
/** 初始化设置入库项 */
watch(
() => props.items,
async (val) => {
formData.value = val
},
{ immediate: true }
)
/** 监听合同产品变化,计算合同产品总价 */
watch(
() => formData.value,
(val) => {
if (!val || val.length === 0) {
return
}
//
val.forEach((item) => {
item.totalPrice = erpPriceMultiply(item.productPrice, item.count)
})
},
{ deep: true }
)
/** 合计 */
const getSummaries = (param: SummaryMethodProps) => {
const { columns, data } = param
const sums: string[] = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
}
if (['count', 'totalPrice'].includes(column.property)) {
const sum = getSumValue(data.map((item) => Number(item[column.property])))
sums[index] =
column.property === 'count' ? erpCountInputFormatter(sum) : erpPriceInputFormatter(sum)
} else {
sums[index] = ''
}
})
return sums
}
/** 新增按钮操作 */
const handleAdd = () => {
const row = {
id: undefined,
warehouseId: defaultWarehouse.value?.id,
productId: undefined,
productUnitName: undefined, //
productBarCode: undefined, //
productPrice: undefined,
stockCount: undefined,
count: 1,
totalPrice: undefined,
remark: undefined
}
formData.value.push(row)
}
/** 删除按钮操作 */
const handleDelete = (index) => {
formData.value.splice(index, 1)
}
/** 处理仓库变更 */
const onChangeWarehouse = (warehouseId, row) => {
//
setStockCount(row)
}
/** 处理产品变更 */
const onChangeProduct = (productId, row) => {
const product = productList.value.find((item) => item.id === productId)
if (product) {
row.productUnitName = product.unitName
row.productBarCode = product.barCode
row.productPrice = product.minPrice
}
//
setStockCount(row)
}
/** 加载库存 */
const setStockCount = async (row) => {
if (!row.productId || !row.warehouseId) {
return
}
const stock = await StockApi.getStock2(row.productId, row.warehouseId)
row.stockCount = stock ? stock.count : 0
}
/** 表单校验 */
const validate = () => {
return formRef.value.validate()
}
defineExpose({ validate })
/** 初始化 */
onMounted(async () => {
productList.value = await ProductApi.getMesProductSimpleList()
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
defaultWarehouse.value = warehouseList.value.find((item) => item.defaultStatus)
//
if (formData.value.length === 0) {
handleAdd()
}
})
</script>

@ -240,14 +240,13 @@ const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) //
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const supplierList = ref<SupplierVO[]>([]) //
const userList = ref<UserVO[]>([]) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await StockInApi.getStockInPage(queryParams)
const data = await StockInApi.getMesStockInPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
@ -325,10 +324,9 @@ const handleSelectionChange = (rows: StockInVO[]) => {
onMounted(async () => {
await getList()
//
productList.value = await ProductApi.getProductSimpleList()
productList.value = await ProductApi.getMesProductSimpleList()
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
supplierList.value = await SupplierApi.getSupplierSimpleList()
userList.value = await UserApi.getSimpleUserList()
})
// TODO
// TODO

Loading…
Cancel
Save