ERP:增加供应商的实现

This commit is contained in:
YunaiV 2024-02-06 18:00:08 +08:00
parent 9cbdfe0ecb
commit 5bdf0fc0ff
8 changed files with 561 additions and 34 deletions

View File

@ -0,0 +1,58 @@
import request from '@/config/axios'
// ERP 供应商 VO
export interface SupplierVO {
id: number // 供应商编号
name: string // 供应商名称
contact: string // 联系人
mobile: string // 手机号码
telephone: string // 联系电话
email: string // 电子邮箱
fax: string // 传真
remark: string // 备注
status: number // 开启状态
sort: number // 排序
taxNo: string // 纳税人识别号
taxPercent: number // 税率
bankName: string // 开户行
bankAccount: string // 开户账号
bankAddress: string // 开户地址
}
// ERP 供应商 API
export const SupplierApi = {
// 查询供应商分页
getSupplierPage: async (params: any) => {
return await request.get({ url: `/erp/supplier/page`, params })
},
// 获得供应商精简列表
getSupplierSimpleList: async () => {
return await request.get({ url: `/erp/supplier/simple-list` })
},
// 查询供应商详情
getSupplier: async (id: number) => {
return await request.get({ url: `/erp/supplier/get?id=` + id })
},
// 新增供应商
createSupplier: async (data: SupplierVO) => {
return await request.post({ url: `/erp/supplier/create`, data })
},
// 修改供应商
updateSupplier: async (data: SupplierVO) => {
return await request.put({ url: `/erp/supplier/update`, data })
},
// 删除供应商
deleteSupplier: async (id: number) => {
return await request.delete({ url: `/erp/supplier/delete?id=` + id })
},
// 导出供应商 Excel
exportSupplier: async (params) => {
return await request.download({ url: `/erp/supplier/export-excel`, params })
}
}

View File

@ -12,43 +12,35 @@ export interface StockInVO {
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
// 导出其它入库单 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

@ -206,5 +206,6 @@ export enum DICT_TYPE {
CRM_FOLLOW_UP_TYPE = 'crm_follow_up_type', // 跟进方式
// ========== ERP - 企业资源计划模块 ==========
ERP_AUDIT_STATUS = 'erp_audit_status', // ERP 审批状态
ERP_STOCK_RECORD_BIZ_TYPE = 'erp_stock_record_biz_type' // 库存明细的业务类型
}

View File

@ -0,0 +1,209 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<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="name">
<el-input v-model="formData.name" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系人" prop="contact">
<el-input v-model="formData.contact" placeholder="请输入联系人" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="手机号码" prop="mobile">
<el-input v-model="formData.mobile" placeholder="请输入手机号码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="telephone">
<el-input v-model="formData.telephone" placeholder="请输入联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电子邮箱" prop="email">
<el-input v-model="formData.email" placeholder="请输入电子邮箱" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="传真" prop="fax">
<el-input v-model="formData.fax" placeholder="请输入传真" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开启状态" prop="status">
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序" prop="sort">
<el-input-number
v-model="formData.sort"
placeholder="请输入排序"
class="!w-1/1"
:precision="0"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="纳税人识别号" prop="taxNo">
<el-input v-model="formData.taxNo" placeholder="请输入纳税人识别号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="税率(%)" prop="taxPercent">
<el-input-number
v-model="formData.taxPercent"
:min="0"
placeholder="请输入税率"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开户行" prop="bankName">
<el-input v-model="formData.bankName" placeholder="请输入开户行" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开户账号" prop="bankAccount">
<el-input v-model="formData.bankAccount" placeholder="请输入开户账号" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="开户地址" prop="bankAddress">
<el-input v-model="formData.bankAddress" placeholder="请输入开户地址" />
</el-form-item>
</el-col>
<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>
<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 { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
import { CommonStatusEnum } from '@/utils/constants'
/** ERP 表单 */
defineOptions({ name: 'SupplierForm' })
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,
name: undefined,
contact: undefined,
mobile: undefined,
telephone: undefined,
email: undefined,
fax: undefined,
remark: undefined,
status: undefined,
sort: undefined,
taxNo: undefined,
taxPercent: undefined,
bankName: undefined,
bankAccount: undefined,
bankAddress: undefined
})
const formRules = reactive({
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
})
const formRef = ref() // 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 SupplierApi.getSupplier(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as SupplierVO
if (formType.value === 'create') {
await SupplierApi.createSupplier(data)
message.success(t('common.createSuccess'))
} else {
await SupplierApi.updateSupplier(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
contact: undefined,
mobile: undefined,
telephone: undefined,
email: undefined,
fax: undefined,
remark: undefined,
status: CommonStatusEnum.ENABLE,
sort: undefined,
taxNo: undefined,
taxPercent: undefined,
bankName: undefined,
bankAccount: undefined,
bankAddress: undefined
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,199 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="手机号码" prop="mobile">
<el-input
v-model="queryParams.mobile"
placeholder="请输入手机号码"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="联系电话" prop="telephone">
<el-input
v-model="queryParams.telephone"
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:supplier:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['erp:supplier: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="name" />
<el-table-column label="联系人" align="center" prop="contact" />
<el-table-column label="手机号码" align="center" prop="mobile" />
<el-table-column label="联系电话" align="center" prop="telephone" />
<el-table-column label="电子邮箱" align="center" prop="email" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_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:supplier:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['erp:supplier: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>
<!-- 表单弹窗添加/修改 -->
<SupplierForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
import SupplierForm from './SupplierForm.vue'
/** ERP 供应商 列表 */
defineOptions({ name: 'ErpSupplier' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<SupplierVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: undefined,
mobile: undefined,
telephone: undefined
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await SupplierApi.getSupplierPage(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 SupplierApi.deleteSupplier(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await SupplierApi.exportSupplier(queryParams)
download.excel(data, 'ERP 供应商.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -25,10 +25,21 @@
/>
</el-form-item>
</el-col>
<!-- TODO 芋艿待接入 -->
<el-col :span="8">
<el-form-item label="供应商" prop="supplierId">
<el-input v-model="formData.supplierId" placeholder="请输入供应商" />
<el-select
v-model="formData.supplierId"
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">
@ -63,9 +74,9 @@
</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'
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
/** ERP 其它入库单 表单 */
defineOptions({ name: 'StockInForm' })
@ -91,6 +102,7 @@ const formRules = reactive({
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const supplierList = ref<SupplierVO[]>([]) //
/** 子表的表单 */
const subTabsName = ref('stockInItem')
@ -111,6 +123,8 @@ const open = async (type: string, id?: number) => {
formLoading.value = false
}
}
//
supplierList.value = await SupplierApi.getSupplierSimpleList()
}
defineExpose({ open }) // open

View File

@ -17,7 +17,21 @@
class="!w-240px"
/>
</el-form-item>
<!-- TODO 芋艿产品信息 -->
<el-form-item label="产品" prop="productId">
<el-select
v-model="queryParams.productId"
filterable
placeholder="请选择产品"
class="!w-240px"
>
<el-option
v-for="item in productList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="入库时间" prop="inTime">
<el-date-picker
v-model="queryParams.inTime"
@ -30,23 +44,49 @@
/>
</el-form-item>
<el-form-item label="供应商" prop="supplierId">
<el-input
<el-select
v-model="queryParams.supplierId"
placeholder="请输入供应商"
clearable
@keyup.enter="handleQuery"
filterable
placeholder="请选择供应商"
class="!w-240px"
/>
>
<el-option
v-for="item in supplierList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- TODO 芋艿仓库信息 -->
<el-form-item label="创建人" prop="creator">
<el-input
v-model="queryParams.creator"
placeholder="请输入创建人"
clearable
@keyup.enter="handleQuery"
<el-form-item label="仓库" prop="warehouseId">
<el-select
v-model="queryParams.warehouseId"
filterable
placeholder="请选择仓库"
class="!w-240px"
/>
>
<el-option
v-for="item in warehouseList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="创建人" prop="creator">
<el-select
v-model="queryParams.creator"
filterable
placeholder="请选择创建人"
class="!w-240px"
>
<el-option
v-for="item in userList"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
@ -96,7 +136,7 @@
<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="productNames" min-width="200" />
<el-table-column label="供应商" align="center" prop="supplierId" />
<el-table-column label="供应商" align="center" prop="supplierName" />
<el-table-column
label="入库时间"
align="center"
@ -152,6 +192,11 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { StockInApi, StockInVO } from '@/api/erp/stock/in'
import StockInForm from './StockInForm.vue'
import { ProductApi, ProductVO } from '@/api/erp/product/product'
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
import { UserVO } from '@/api/system/user'
import * as UserApi from '@/api/system/user'
/** ERP 其它入库单 列表 */
defineOptions({ name: 'ErpStockIn' })
@ -174,6 +219,10 @@ const queryParams = reactive({
})
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 () => {
@ -234,7 +283,12 @@ const handleExport = async () => {
}
/** 初始化 **/
onMounted(() => {
getList()
onMounted(async () => {
await getList()
//
productList.value = await ProductApi.getProductSimpleList()
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
supplierList.value = await SupplierApi.getSupplierSimpleList()
userList.value = await UserApi.getSimpleUserList()
})
</script>