ERP:增加 ERP 客户的实现

pull/379/MERGE
YunaiV 2024-02-07 15:41:07 +08:00
parent 616fd3f7ba
commit 896f9758ed
6 changed files with 480 additions and 11 deletions

View File

@ -0,0 +1,58 @@
import request from '@/config/axios'
// ERP 客户 VO
export interface CustomerVO {
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 CustomerApi = {
// 查询客户分页
getCustomerPage: async (params: any) => {
return await request.get({ url: `/erp/customer/page`, params })
},
// 查询客户精简列表
getCustomerSimpleList: async () => {
return await request.get({ url: `/erp/customer/simple-list` })
},
// 查询客户详情
getCustomer: async (id: number) => {
return await request.get({ url: `/erp/customer/get?id=` + id })
},
// 新增客户
createCustomer: async (data: CustomerVO) => {
return await request.post({ url: `/erp/customer/create`, data })
},
// 修改客户
updateCustomer: async (data: CustomerVO) => {
return await request.put({ url: `/erp/customer/update`, data })
},
// 删除客户
deleteCustomer: async (id: number) => {
return await request.delete({ url: `/erp/customer/delete?id=` + id })
},
// 导出客户 Excel
exportCustomer: async (params) => {
return await request.download({ url: `/erp/customer/export-excel`, params })
}
}

View File

@ -0,0 +1,210 @@
<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"
:precision="2"
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 { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
import { CommonStatusEnum } from '@/utils/constants'
/** ERP 客户 表单 */
defineOptions({ name: 'CustomerForm' })
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 CustomerApi.getCustomer(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 CustomerVO
if (formType.value === 'create') {
await CustomerApi.createCustomer(data)
message.success(t('common.createSuccess'))
} else {
await CustomerApi.updateCustomer(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:customer:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['erp:customer: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:customer:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['erp:customer: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>
<!-- 表单弹窗添加/修改 -->
<CustomerForm 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 { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
import CustomerForm from './CustomerForm.vue'
/** ERP 客户 列表 */
defineOptions({ name: 'ErpCustomer' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<CustomerVO[]>([]) //
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 CustomerApi.getCustomerPage(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 CustomerApi.deleteCustomer(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await CustomerApi.exportCustomer(queryParams)
download.excel(data, '客户.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -199,7 +199,7 @@
link
type="primary"
@click="handleUpdateStatus(scope.row.id, 20)"
v-hasPermi="['erp:stock-in:update']"
v-hasPermi="['erp:stock-in:update-status']"
v-if="scope.row.status === 10"
>
审批
@ -208,7 +208,7 @@
link
type="danger"
@click="handleUpdateStatus(scope.row.id, 10)"
v-hasPermi="['erp:stock-in:update']"
v-hasPermi="['erp:stock-in:update-status']"
v-else
>
反审批

View File

@ -34,7 +34,7 @@
class="!w-1/1"
>
<el-option
v-for="item in supplierList"
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
@ -79,6 +79,7 @@
import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
import StockOutItemForm from './components/StockOutItemForm.vue'
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
/** ERP 其它出库单表单 */
defineOptions({ name: 'StockOutForm' })
@ -103,7 +104,7 @@ const formRules = reactive({
})
const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref
const supplierList = ref<SupplierVO[]>([]) //
const customerList = ref<CustomerVO[]>([]) //
/** 子表的表单 */
const subTabsName = ref('item')
@ -125,7 +126,7 @@ const open = async (type: string, id?: number) => {
}
}
//
supplierList.value = await SupplierApi.getSupplierSimpleList()
customerList.value = await CustomerApi.getCustomerSimpleList()
}
defineExpose({ open }) // open

View File

@ -51,7 +51,7 @@
class="!w-240px"
>
<el-option
v-for="item in supplierList"
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
@ -152,7 +152,7 @@
<el-table-column width="30" label="选择" type="selection" />
<el-table-column min-width="140" label="出库单号" align="center" prop="no" />
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
<el-table-column label="客户" align="center" prop="supplierName" />
<el-table-column label="客户" align="center" prop="customerName" />
<el-table-column
label="出库时间"
align="center"
@ -199,7 +199,7 @@
link
type="primary"
@click="handleUpdateStatus(scope.row.id, 20)"
v-hasPermi="['erp:stock-out:update']"
v-hasPermi="['erp:stock-out:update-status']"
v-if="scope.row.status === 10"
>
审批
@ -208,7 +208,7 @@
link
type="danger"
@click="handleUpdateStatus(scope.row.id, 10)"
v-hasPermi="['erp:stock-out:update']"
v-hasPermi="['erp:stock-out:update-status']"
v-else
>
反审批
@ -249,6 +249,7 @@ import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
import { UserVO } from '@/api/system/user'
import * as UserApi from '@/api/system/user'
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
/** ERP 其它出库单列表 */
defineOptions({ name: 'ErpStockOut' })
@ -273,7 +274,7 @@ const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) //
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const supplierList = ref<SupplierVO[]>([]) // TODO
const customerList = ref<CustomerVO[]>([]) //
const userList = ref<UserVO[]>([]) //
/** 查询列表 */
@ -360,7 +361,7 @@ onMounted(async () => {
//
productList.value = await ProductApi.getProductSimpleList()
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
supplierList.value = await SupplierApi.getSupplierSimpleList()
customerList.value = await CustomerApi.getCustomerSimpleList()
userList.value = await UserApi.getSimpleUserList()
})
// TODO