ERP:初始化其它入库的表单 20%

pull/379/MERGE
YunaiV 2024-02-06 00:56:43 +08:00
parent 26343635e4
commit d92404f351
4 changed files with 632 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import request from '@/config/axios'
// ERP 其它入库单 VO
export interface StockInVO {
id: number // 入库编号
no: string // 入库单号
supplierId: number // 供应商编号
inTime: Date // 入库时间
totalCount: number // 合计数量
totalPrice: number // 合计金额,单位:元
status: number // 状态
remark: string // 备注
}
// TODO 芋艿:稍后清理字段
// ERP 其它入库单 API
export const StockInApi = {
// 查询ERP 其它入库单分页
getStockInPage: async (params: any) => {
return await request.get({ url: `/erp/stock-in/page`, params })
},
// 查询ERP 其它入库单详情
getStockIn: async (id: number) => {
return await request.get({ url: `/erp/stock-in/get?id=` + id })
},
// 新增ERP 其它入库单
createStockIn: async (data: StockInVO) => {
return await request.post({ url: `/erp/stock-in/create`, data })
},
// 修改ERP 其它入库单
updateStockIn: async (data: StockInVO) => {
return await request.put({ url: `/erp/stock-in/update`, data })
},
// 删除ERP 其它入库单
deleteStockIn: async (id: number) => {
return await request.delete({ url: `/erp/stock-in/delete?id=` + id })
},
// 导出ERP 其它入库单 Excel
exportStockIn: async (params) => {
return await request.download({ url: `/erp/stock-in/export-excel`, params })
},
// ==================== 子表ERP 其它入库单项) ====================
// 获得ERP 其它入库单项列表
getStockInItemListByInId: async (inId) => {
return await request.get({ url: `/erp/stock-in/stock-in-item/list-by-in-id?inId=` + inId })
}
}

View File

@ -0,0 +1,168 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1080">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="入库单号" prop="no">
<el-input v-model="formData.no" placeholder="请输入入库单号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="入库时间" prop="inTime">
<el-date-picker
v-model="formData.inTime"
type="date"
value-format="x"
placeholder="选择入库时间"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供应商" prop="supplierId">
<el-input v-model="formData.supplierId" placeholder="请输入供应商编号" />
</el-form-item>
</el-col>
<!-- TODO 芋艿附件 -->
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 子表的表单 -->
<el-tabs v-model="subTabsName">
<el-tab-pane label="入库产品清单" name="stockInItem">
<StockInItemForm ref="stockInItemFormRef" :in-id="formData.id" />
</el-tab-pane>
</el-tabs>
<el-form
ref="formRef2"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="合计数量" prop="totalCount">
<el-input v-model="formData.totalCount" placeholder="请输入合计数量" />
</el-form-item>
<el-form-item label="合计金额" prop="totalPrice">
<el-input v-model="formData.totalPrice" placeholder="请输入合计金额,单位:元" />
</el-form-item>
</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 { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { StockInApi, StockInVO } from '@/api/erp/stock/in'
import StockInItemForm from './components/StockInItemForm.vue'
/** ERP 其它入库单 表单 */
defineOptions({ name: 'StockInForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
no: undefined,
supplierId: undefined,
inTime: undefined,
totalCount: undefined,
totalPrice: undefined,
remark: undefined
})
const formRules = reactive({
no: [{ required: true, message: '入库单号不能为空', trigger: 'blur' }],
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }],
totalCount: [{ required: true, message: '合计数量不能为空', trigger: 'blur' }],
totalPrice: [{ required: true, message: '合计金额,单位:元不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const formRef2 = ref() // Ref TODO
/** 子表的表单 */
const subTabsName = ref('stockInItem')
const stockInItemFormRef = ref()
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await StockInApi.getStockIn(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
await formRef2.value.validate() // TODO
//
try {
await stockInItemFormRef.value.validate()
} catch (e) {
subTabsName.value = 'stockInItem'
return
}
//
formLoading.value = true
try {
const data = formData.value as unknown as StockInVO
//
data.stockInItems = stockInItemFormRef.value.getData()
if (formType.value === 'create') {
await StockInApi.createStockIn(data)
message.success(t('common.createSuccess'))
} else {
await StockInApi.updateStockIn(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
no: undefined,
supplierId: undefined,
inTime: undefined,
totalCount: undefined,
totalPrice: undefined,
remark: undefined
}
formRef.value?.resetFields()
formRef2.value?.resetFields() // TODO
}
</script>

View File

@ -0,0 +1,163 @@
<template>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="0px"
:inline-message="true"
>
<el-table :data="formData" show-summary class="-mt-10px">
<el-table-column label="序号" type="index" width="60" />
<el-table-column label="仓库名称" min-width="150">
<template #default="{ row, $index }">
<el-form-item
:prop="`${$index}.warehouseId`"
:rules="formRules.warehouseId"
class="mb-0px!"
>
<el-input v-model="row.warehouseId" placeholder="请输入仓库编号" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="产品名称" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
<el-input v-model="row.productId" placeholder="请输入产品编号" />
</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.productId" placeholder="请输入条码" />
</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.productUnitId" placeholder="请输入单位编号" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数量" prop="count" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
<el-input v-model="row.count" placeholder="请输入商品数量" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="商品单价" min-width="150">
<template #default="{ row, $index }">
<el-form-item
:prop="`${$index}.productPrice`"
:rules="formRules.productPrice"
class="mb-0px!"
>
<el-input v-model="row.productPrice" placeholder="请输入商品单价" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="合计金额" min-width="150">
<template #default="{ row, $index }">
<el-form-item
:prop="`${$index}.totalPrice`"
:rules="formRules.totalPrice"
class="mb-0px!"
>
<el-input v-model="row.totalPrice" placeholder="请输入合计金额,单位:元" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="备注" min-width="150">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.remark`" :rules="formRules.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">
<el-button @click="handleAdd" round>+ 添加入库产品</el-button>
</el-row>
</template>
<script setup lang="ts">
import { StockInApi } from '@/api/erp/stock/in'
const props = defineProps<{
inId: undefined //
}>()
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' }],
productUnitId: [{ required: true, message: '商品单位编号不能为空', trigger: 'blur' }],
productPrice: [{ required: true, message: '商品单价不能为空', trigger: 'blur' }],
count: [{ required: true, message: '商品数量不能为空', trigger: 'blur' }],
totalPrice: [{ required: true, message: '合计金额,单位:元不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 监听主表的关联字段的变化,加载对应的子表数据 */
watch(
() => props.inId,
async (val) => {
// 1.
formData.value = []
// 2. val
if (!val) {
return
}
try {
formLoading.value = true
formData.value = await StockInApi.getStockInItemListByInId(val)
} finally {
formLoading.value = false
}
},
{ immediate: true }
)
/** 新增按钮操作 */
const handleAdd = () => {
const row = {
id: undefined,
inId: undefined,
warehouseId: undefined,
productId: undefined,
productUnitId: undefined,
productPrice: undefined,
count: undefined,
totalPrice: undefined,
remark: undefined
}
row.inId = props.inId
formData.value.push(row)
}
/** 删除按钮操作 */
const handleDelete = (index) => {
formData.value.splice(index, 1)
}
/** 表单校验 */
const validate = () => {
return formRef.value.validate()
}
/** 表单值 */
const getData = () => {
return formData.value
}
defineExpose({ validate, getData })
</script>

View File

@ -0,0 +1,247 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="入库单号" prop="no">
<el-input
v-model="queryParams.no"
placeholder="请输入入库单号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<!-- TODO 芋艿商品信息 -->
<el-form-item label="入库时间" prop="inTime">
<el-date-picker
v-model="queryParams.inTime"
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="supplierId">
<el-input
v-model="queryParams.supplierId"
placeholder="请输入供应商"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<!-- TODO 芋艿仓库信息 -->
<el-form-item label="创建人" prop="creator">
<el-input
v-model="queryParams.creator"
placeholder="请输入创建人"
clearable
@keyup.enter="handleQuery"
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.ERP_AUDIT_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="queryParams.remark"
placeholder="请输入备注"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</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="['erp:stock-in:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['erp:stock-in: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="no" />
<el-table-column label="供应商" align="center" prop="supplierId" />
<!-- TODO 商品信息 -->
<el-table-column
label="入库时间"
align="center"
prop="inTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column
label="入库时间"
align="center"
prop="inTime"
:formatter="dateFormatter"
width="180px"
/>
<!-- TODO 芋艿创建人 -->
<el-table-column label="数量" align="center" prop="totalCount" />
<el-table-column label="金额合计" align="center" prop="totalPrice" />
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['erp:stock-in:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['erp:stock-in:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<StockInForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { StockInApi, StockInVO } from '@/api/erp/stock/in'
import StockInForm from './StockInForm.vue'
/** ERP 其它入库单 列表 */
defineOptions({ name: 'ErpStockIn' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<StockInVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
no: undefined,
supplierId: undefined,
inTime: [],
status: undefined,
remark: undefined,
creator: undefined
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await StockInApi.getStockInPage(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 formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await StockInApi.deleteStockIn(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await StockInApi.exportStockIn(queryParams)
download.excel(data, 'ERP 其它入库单.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>