Skip to content

Commit 5bdf0fc

Browse files
committed
✨ ERP:增加供应商的实现
1 parent 9cbdfe0 commit 5bdf0fc

File tree

8 files changed

+559
-32
lines changed

8 files changed

+559
-32
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import request from '@/config/axios'
2+
3+
// ERP 供应商 VO
4+
export interface SupplierVO {
5+
id: number // 供应商编号
6+
name: string // 供应商名称
7+
contact: string // 联系人
8+
mobile: string // 手机号码
9+
telephone: string // 联系电话
10+
email: string // 电子邮箱
11+
fax: string // 传真
12+
remark: string // 备注
13+
status: number // 开启状态
14+
sort: number // 排序
15+
taxNo: string // 纳税人识别号
16+
taxPercent: number // 税率
17+
bankName: string // 开户行
18+
bankAccount: string // 开户账号
19+
bankAddress: string // 开户地址
20+
}
21+
22+
// ERP 供应商 API
23+
export const SupplierApi = {
24+
// 查询供应商分页
25+
getSupplierPage: async (params: any) => {
26+
return await request.get({ url: `/erp/supplier/page`, params })
27+
},
28+
29+
// 获得供应商精简列表
30+
getSupplierSimpleList: async () => {
31+
return await request.get({ url: `/erp/supplier/simple-list` })
32+
},
33+
34+
// 查询供应商详情
35+
getSupplier: async (id: number) => {
36+
return await request.get({ url: `/erp/supplier/get?id=` + id })
37+
},
38+
39+
// 新增供应商
40+
createSupplier: async (data: SupplierVO) => {
41+
return await request.post({ url: `/erp/supplier/create`, data })
42+
},
43+
44+
// 修改供应商
45+
updateSupplier: async (data: SupplierVO) => {
46+
return await request.put({ url: `/erp/supplier/update`, data })
47+
},
48+
49+
// 删除供应商
50+
deleteSupplier: async (id: number) => {
51+
return await request.delete({ url: `/erp/supplier/delete?id=` + id })
52+
},
53+
54+
// 导出供应商 Excel
55+
exportSupplier: async (params) => {
56+
return await request.download({ url: `/erp/supplier/export-excel`, params })
57+
}
58+
}

src/api/erp/stock/in/index.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,35 @@ export interface StockInVO {
1212
remark: string // 备注
1313
}
1414

15-
// TODO 芋艿:稍后清理字段
1615
// ERP 其它入库单 API
1716
export const StockInApi = {
18-
// 查询ERP 其它入库单分页
17+
// 查询其它入库单分页
1918
getStockInPage: async (params: any) => {
2019
return await request.get({ url: `/erp/stock-in/page`, params })
2120
},
2221

23-
// 查询ERP 其它入库单详情
22+
// 查询其它入库单详情
2423
getStockIn: async (id: number) => {
2524
return await request.get({ url: `/erp/stock-in/get?id=` + id })
2625
},
2726

28-
// 新增ERP 其它入库单
27+
// 新增其它入库单
2928
createStockIn: async (data: StockInVO) => {
3029
return await request.post({ url: `/erp/stock-in/create`, data })
3130
},
3231

33-
// 修改ERP 其它入库单
32+
// 修改其它入库单
3433
updateStockIn: async (data: StockInVO) => {
3534
return await request.put({ url: `/erp/stock-in/update`, data })
3635
},
3736

38-
// 删除ERP 其它入库单
37+
// 删除其它入库单
3938
deleteStockIn: async (id: number) => {
4039
return await request.delete({ url: `/erp/stock-in/delete?id=` + id })
4140
},
4241

43-
// 导出ERP 其它入库单 Excel
42+
// 导出其它入库单 Excel
4443
exportStockIn: async (params) => {
4544
return await request.download({ url: `/erp/stock-in/export-excel`, params })
46-
},
47-
48-
// ==================== 子表(ERP 其它入库单项) ====================
49-
50-
// 获得ERP 其它入库单项列表
51-
getStockInItemListByInId: async (inId) => {
52-
return await request.get({ url: `/erp/stock-in/stock-in-item/list-by-in-id?inId=` + inId })
5345
}
5446
}

src/utils/dict.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,6 @@ export enum DICT_TYPE {
206206
CRM_FOLLOW_UP_TYPE = 'crm_follow_up_type', // 跟进方式
207207

208208
// ========== ERP - 企业资源计划模块 ==========
209+
ERP_AUDIT_STATUS = 'erp_audit_status', // ERP 审批状态
209210
ERP_STOCK_RECORD_BIZ_TYPE = 'erp_stock_record_biz_type' // 库存明细的业务类型
210211
}
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
<template>
2+
<Dialog :title="dialogTitle" v-model="dialogVisible">
3+
<el-form
4+
ref="formRef"
5+
:model="formData"
6+
:rules="formRules"
7+
label-width="100px"
8+
v-loading="formLoading"
9+
>
10+
<el-row :gutter="20">
11+
<el-col :span="12">
12+
<el-form-item label="名称" prop="name">
13+
<el-input v-model="formData.name" placeholder="请输入名称" />
14+
</el-form-item>
15+
</el-col>
16+
<el-col :span="12">
17+
<el-form-item label="联系人" prop="contact">
18+
<el-input v-model="formData.contact" placeholder="请输入联系人" />
19+
</el-form-item>
20+
</el-col>
21+
<el-col :span="12">
22+
<el-form-item label="手机号码" prop="mobile">
23+
<el-input v-model="formData.mobile" placeholder="请输入手机号码" />
24+
</el-form-item>
25+
</el-col>
26+
<el-col :span="12">
27+
<el-form-item label="联系电话" prop="telephone">
28+
<el-input v-model="formData.telephone" placeholder="请输入联系电话" />
29+
</el-form-item>
30+
</el-col>
31+
<el-col :span="12">
32+
<el-form-item label="电子邮箱" prop="email">
33+
<el-input v-model="formData.email" placeholder="请输入电子邮箱" />
34+
</el-form-item>
35+
</el-col>
36+
<el-col :span="12">
37+
<el-form-item label="传真" prop="fax">
38+
<el-input v-model="formData.fax" placeholder="请输入传真" />
39+
</el-form-item>
40+
</el-col>
41+
<el-col :span="12">
42+
<el-form-item label="开启状态" prop="status">
43+
<el-radio-group v-model="formData.status">
44+
<el-radio
45+
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
46+
:key="dict.value"
47+
:label="dict.value"
48+
>
49+
{{ dict.label }}
50+
</el-radio>
51+
</el-radio-group>
52+
</el-form-item>
53+
</el-col>
54+
<el-col :span="12">
55+
<el-form-item label="排序" prop="sort">
56+
<el-input-number
57+
v-model="formData.sort"
58+
placeholder="请输入排序"
59+
class="!w-1/1"
60+
:precision="0"
61+
/>
62+
</el-form-item>
63+
</el-col>
64+
<el-col :span="12">
65+
<el-form-item label="纳税人识别号" prop="taxNo">
66+
<el-input v-model="formData.taxNo" placeholder="请输入纳税人识别号" />
67+
</el-form-item>
68+
</el-col>
69+
<el-col :span="12">
70+
<el-form-item label="税率(%)" prop="taxPercent">
71+
<el-input-number
72+
v-model="formData.taxPercent"
73+
:min="0"
74+
placeholder="请输入税率"
75+
class="!w-1/1"
76+
/>
77+
</el-form-item>
78+
</el-col>
79+
<el-col :span="12">
80+
<el-form-item label="开户行" prop="bankName">
81+
<el-input v-model="formData.bankName" placeholder="请输入开户行" />
82+
</el-form-item>
83+
</el-col>
84+
<el-col :span="12">
85+
<el-form-item label="开户账号" prop="bankAccount">
86+
<el-input v-model="formData.bankAccount" placeholder="请输入开户账号" />
87+
</el-form-item>
88+
</el-col>
89+
<el-col :span="12">
90+
<el-form-item label="开户地址" prop="bankAddress">
91+
<el-input v-model="formData.bankAddress" placeholder="请输入开户地址" />
92+
</el-form-item>
93+
</el-col>
94+
<el-col :span="24">
95+
<el-form-item label="备注" prop="remark">
96+
<el-input type="textarea" v-model="formData.remark" placeholder="请输入备注" />
97+
</el-form-item>
98+
</el-col>
99+
</el-row>
100+
</el-form>
101+
<template #footer>
102+
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
103+
<el-button @click="dialogVisible = false">取 消</el-button>
104+
</template>
105+
</Dialog>
106+
</template>
107+
<script setup lang="ts">
108+
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
109+
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
110+
import { CommonStatusEnum } from '@/utils/constants'
111+
112+
/** ERP 表单 */
113+
defineOptions({ name: 'SupplierForm' })
114+
115+
const { t } = useI18n() // 国际化
116+
const message = useMessage() // 消息弹窗
117+
118+
const dialogVisible = ref(false) // 弹窗的是否展示
119+
const dialogTitle = ref('') // 弹窗的标题
120+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
121+
const formType = ref('') // 表单的类型:create - 新增;update - 修改
122+
const formData = ref({
123+
id: undefined,
124+
name: undefined,
125+
contact: undefined,
126+
mobile: undefined,
127+
telephone: undefined,
128+
email: undefined,
129+
fax: undefined,
130+
remark: undefined,
131+
status: undefined,
132+
sort: undefined,
133+
taxNo: undefined,
134+
taxPercent: undefined,
135+
bankName: undefined,
136+
bankAccount: undefined,
137+
bankAddress: undefined
138+
})
139+
const formRules = reactive({
140+
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
141+
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }],
142+
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }]
143+
})
144+
const formRef = ref() // 表单 Ref
145+
146+
/** 打开弹窗 */
147+
const open = async (type: string, id?: number) => {
148+
dialogVisible.value = true
149+
dialogTitle.value = t('action.' + type)
150+
formType.value = type
151+
resetForm()
152+
// 修改时,设置数据
153+
if (id) {
154+
formLoading.value = true
155+
try {
156+
formData.value = await SupplierApi.getSupplier(id)
157+
} finally {
158+
formLoading.value = false
159+
}
160+
}
161+
}
162+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
163+
164+
/** 提交表单 */
165+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
166+
const submitForm = async () => {
167+
// 校验表单
168+
await formRef.value.validate()
169+
// 提交请求
170+
formLoading.value = true
171+
try {
172+
const data = formData.value as unknown as SupplierVO
173+
if (formType.value === 'create') {
174+
await SupplierApi.createSupplier(data)
175+
message.success(t('common.createSuccess'))
176+
} else {
177+
await SupplierApi.updateSupplier(data)
178+
message.success(t('common.updateSuccess'))
179+
}
180+
dialogVisible.value = false
181+
// 发送操作成功的事件
182+
emit('success')
183+
} finally {
184+
formLoading.value = false
185+
}
186+
}
187+
188+
/** 重置表单 */
189+
const resetForm = () => {
190+
formData.value = {
191+
id: undefined,
192+
name: undefined,
193+
contact: undefined,
194+
mobile: undefined,
195+
telephone: undefined,
196+
email: undefined,
197+
fax: undefined,
198+
remark: undefined,
199+
status: CommonStatusEnum.ENABLE,
200+
sort: undefined,
201+
taxNo: undefined,
202+
taxPercent: undefined,
203+
bankName: undefined,
204+
bankAccount: undefined,
205+
bankAddress: undefined
206+
}
207+
formRef.value?.resetFields()
208+
}
209+
</script>

0 commit comments

Comments
 (0)