Skip to content

Commit 616fd3f

Browse files
committed
✨ ERP:初始化其它出库的实现
1 parent 318d526 commit 616fd3f

File tree

7 files changed

+880
-9
lines changed

7 files changed

+880
-9
lines changed

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import request from '@/config/axios'
2+
3+
// ERP 其它出库单 VO
4+
export interface StockOutVO {
5+
id: number // 出库编号
6+
no: string // 出库单号
7+
customerId: number // 客户编号
8+
outTime: Date // 出库时间
9+
totalCount: number // 合计数量
10+
totalPrice: number // 合计金额,单位:元
11+
status: number // 状态
12+
remark: string // 备注
13+
}
14+
15+
// ERP 其它出库单 API
16+
export const StockOutApi = {
17+
// 查询其它出库单分页
18+
getStockOutPage: async (params: any) => {
19+
return await request.get({ url: `/erp/stock-out/page`, params })
20+
},
21+
22+
// 查询其它出库单详情
23+
getStockOut: async (id: number) => {
24+
return await request.get({ url: `/erp/stock-out/get?id=` + id })
25+
},
26+
27+
// 新增其它出库单
28+
createStockOut: async (data: StockOutVO) => {
29+
return await request.post({ url: `/erp/stock-out/create`, data })
30+
},
31+
32+
// 修改其它出库单
33+
updateStockOut: async (data: StockOutVO) => {
34+
return await request.put({ url: `/erp/stock-out/update`, data })
35+
},
36+
37+
// 更新其它出库单的状态
38+
updateStockOutStatus: async (id: number, status: number) => {
39+
return await request.put({
40+
url: `/erp/stock-out/update-status`,
41+
params: {
42+
id,
43+
status
44+
}
45+
})
46+
},
47+
48+
// 删除其它出库单
49+
deleteStockOut: async (ids: number[]) => {
50+
return await request.delete({
51+
url: `/erp/stock-out/delete`,
52+
params: {
53+
ids: ids.join(',')
54+
}
55+
})
56+
},
57+
58+
// 导出其它出库单 Excel
59+
exportStockOut: async (params) => {
60+
return await request.download({ url: `/erp/stock-out/export-excel`, params })
61+
}
62+
}

src/views/erp/stock/in/StockInForm.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
<!-- 子表的表单 -->
6363
<ContentWrap>
6464
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
65-
<el-tab-pane label="入库产品清单" name="stockInItem">
66-
<StockInItemForm ref="stockInItemFormRef" :items="formData.items" :disabled="disabled" />
65+
<el-tab-pane label="入库产品清单" name="item">
66+
<StockInItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
6767
</el-tab-pane>
6868
</el-tabs>
6969
</ContentWrap>
@@ -106,8 +106,8 @@ const formRef = ref() // 表单 Ref
106106
const supplierList = ref<SupplierVO[]>([]) // 供应商列表
107107
108108
/** 子表的表单 */
109-
const subTabsName = ref('stockInItem')
110-
const stockInItemFormRef = ref()
109+
const subTabsName = ref('item')
110+
const itemFormRef = ref()
111111
112112
/** 打开弹窗 */
113113
const open = async (type: string, id?: number) => {
@@ -134,7 +134,7 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
134134
const submitForm = async () => {
135135
// 校验表单
136136
await formRef.value.validate()
137-
await stockInItemFormRef.value.validate()
137+
await itemFormRef.value.validate()
138138
// 提交请求
139139
formLoading.value = true
140140
try {

src/views/erp/stock/in/components/StockInItemForm.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ import {
142142
erpPriceMultiply,
143143
getSumValue
144144
} from '@/utils'
145-
import { fenToYuanFormat } from '@/utils/formatter'
146145
147146
const props = defineProps<{
148147
items: undefined

src/views/erp/stock/in/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239

240240
<script setup lang="ts">
241241
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
242-
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
242+
import { dateFormatter2 } from '@/utils/formatTime'
243243
import download from '@/utils/download'
244244
import { StockInApi, StockInVO } from '@/api/erp/stock/in'
245245
import StockInForm from './StockInForm.vue'
@@ -248,10 +248,9 @@ import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
248248
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
249249
import { UserVO } from '@/api/system/user'
250250
import * as UserApi from '@/api/system/user'
251-
import * as BusinessApi from '@/api/crm/business'
252251
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
253252
254-
/** ERP 其它入库单 列表 */
253+
/** ERP 其它入库单列表 */
255254
defineOptions({ name: 'ErpStockIn' })
256255
257256
const message = useMessage() // 消息弹窗
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<template>
2+
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1080">
3+
<el-form
4+
ref="formRef"
5+
:model="formData"
6+
:rules="formRules"
7+
label-width="100px"
8+
v-loading="formLoading"
9+
:disabled="disabled"
10+
>
11+
<el-row :gutter="20">
12+
<el-col :span="8">
13+
<el-form-item label="出库单号" prop="no">
14+
<el-input disabled v-model="formData.no" placeholder="保存时自动生成" />
15+
</el-form-item>
16+
</el-col>
17+
<el-col :span="8">
18+
<el-form-item label="出库时间" prop="outTime">
19+
<el-date-picker
20+
v-model="formData.outTime"
21+
type="date"
22+
value-format="x"
23+
placeholder="选择出库时间"
24+
class="!w-1/1"
25+
/>
26+
</el-form-item>
27+
</el-col>
28+
<el-col :span="8">
29+
<el-form-item label="客户" prop="customerId">
30+
<el-select
31+
v-model="formData.customerId"
32+
filterable
33+
placeholder="请选择客户"
34+
class="!w-1/1"
35+
>
36+
<el-option
37+
v-for="item in supplierList"
38+
:key="item.id"
39+
:label="item.name"
40+
:value="item.id"
41+
/>
42+
</el-select>
43+
</el-form-item>
44+
</el-col>
45+
<el-col :span="16">
46+
<el-form-item label="备注" prop="remark">
47+
<el-input
48+
type="textarea"
49+
v-model="formData.remark"
50+
:rows="1"
51+
placeholder="请输入备注"
52+
/>
53+
</el-form-item>
54+
</el-col>
55+
<el-col :span="8">
56+
<el-form-item label="附件" prop="fileUrl">
57+
<UploadFile :is-show-tip="false" v-model="formData.fileUrl" :limit="1" />
58+
</el-form-item>
59+
</el-col>
60+
</el-row>
61+
</el-form>
62+
<!-- 子表的表单 -->
63+
<ContentWrap>
64+
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
65+
<el-tab-pane label="出库产品清单" name="item">
66+
<StockOutItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
67+
</el-tab-pane>
68+
</el-tabs>
69+
</ContentWrap>
70+
<template #footer>
71+
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
72+
确 定
73+
</el-button>
74+
<el-button @click="dialogVisible = false">取 消</el-button>
75+
</template>
76+
</Dialog>
77+
</template>
78+
<script setup lang="ts">
79+
import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
80+
import StockOutItemForm from './components/StockOutItemForm.vue'
81+
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
82+
83+
/** ERP 其它出库单表单 */
84+
defineOptions({ name: 'StockOutForm' })
85+
86+
const { t } = useI18n() // 国际化
87+
const message = useMessage() // 消息弹窗
88+
89+
const dialogVisible = ref(false) // 弹窗的是否展示
90+
const dialogTitle = ref('') // 弹窗的标题
91+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
92+
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
93+
const formData = ref({
94+
id: undefined,
95+
customerId: undefined,
96+
outTime: undefined,
97+
remark: undefined,
98+
fileUrl: '',
99+
items: []
100+
})
101+
const formRules = reactive({
102+
outTime: [{ required: true, message: '出库时间不能为空', trigger: 'blur' }]
103+
})
104+
const disabled = computed(() => formType.value === 'detail')
105+
const formRef = ref() // 表单 Ref
106+
const supplierList = ref<SupplierVO[]>([]) // 客户列表
107+
108+
/** 子表的表单 */
109+
const subTabsName = ref('item')
110+
const itemFormRef = ref()
111+
112+
/** 打开弹窗 */
113+
const open = async (type: string, id?: number) => {
114+
dialogVisible.value = true
115+
dialogTitle.value = t('action.' + type)
116+
formType.value = type
117+
resetForm()
118+
// 修改时,设置数据
119+
if (id) {
120+
formLoading.value = true
121+
try {
122+
formData.value = await StockOutApi.getStockOut(id)
123+
} finally {
124+
formLoading.value = false
125+
}
126+
}
127+
// 加载客户列表
128+
supplierList.value = await SupplierApi.getSupplierSimpleList()
129+
}
130+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
131+
132+
/** 提交表单 */
133+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
134+
const submitForm = async () => {
135+
// 校验表单
136+
await formRef.value.validate()
137+
await itemFormRef.value.validate()
138+
// 提交请求
139+
formLoading.value = true
140+
try {
141+
const data = formData.value as unknown as StockOutVO
142+
if (formType.value === 'create') {
143+
await StockOutApi.createStockOut(data)
144+
message.success(t('common.createSuccess'))
145+
} else {
146+
await StockOutApi.updateStockOut(data)
147+
message.success(t('common.updateSuccess'))
148+
}
149+
dialogVisible.value = false
150+
// 发送操作成功的事件
151+
emit('success')
152+
} finally {
153+
formLoading.value = false
154+
}
155+
}
156+
157+
/** 重置表单 */
158+
const resetForm = () => {
159+
formData.value = {
160+
id: undefined,
161+
customerId: undefined,
162+
outTime: undefined,
163+
remark: undefined,
164+
fileUrl: undefined,
165+
items: []
166+
}
167+
formRef.value?.resetFields()
168+
}
169+
</script>

0 commit comments

Comments
 (0)