Skip to content

Commit 115c30e

Browse files
committed
✨ ERP:增加入库单的审批功能
1 parent 5bdf0fc commit 115c30e

File tree

4 files changed

+107
-23
lines changed

4 files changed

+107
-23
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,25 @@ export const StockInApi = {
3434
return await request.put({ url: `/erp/stock-in/update`, data })
3535
},
3636

37+
// 更新其它入库单的状态
38+
updateStockInStatus: async (id: number, status: number) => {
39+
return await request.put({
40+
url: `/erp/stock-in/update-status`,
41+
params: {
42+
id,
43+
status
44+
}
45+
})
46+
},
47+
3748
// 删除其它入库单
38-
deleteStockIn: async (id: number) => {
39-
return await request.delete({ url: `/erp/stock-in/delete?id=` + id })
49+
deleteStockIn: async (ids: number[]) => {
50+
return await request.delete({
51+
url: `/erp/stock-in/delete`,
52+
params: {
53+
ids: ids.join(',')
54+
}
55+
})
4056
},
4157

4258
// 导出其它入库单 Excel

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:rules="formRules"
77
label-width="100px"
88
v-loading="formLoading"
9+
:disabled="disabled"
910
>
1011
<el-row :gutter="20">
1112
<!-- TODO 芋艿:待接入 -->
@@ -63,12 +64,14 @@
6364
<ContentWrap>
6465
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
6566
<el-tab-pane label="入库产品清单" name="stockInItem">
66-
<StockInItemForm ref="stockInItemFormRef" :items="formData.items" />
67+
<StockInItemForm ref="stockInItemFormRef" :items="formData.items" :disabled="disabled" />
6768
</el-tab-pane>
6869
</el-tabs>
6970
</ContentWrap>
7071
<template #footer>
71-
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
72+
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
73+
确 定
74+
</el-button>
7275
<el-button @click="dialogVisible = false">取 消</el-button>
7376
</template>
7477
</Dialog>
@@ -87,7 +90,7 @@ const message = useMessage() // 消息弹窗
8790
const dialogVisible = ref(false) // 弹窗的是否展示
8891
const dialogTitle = ref('') // 弹窗的标题
8992
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
90-
const formType = ref('') // 表单的类型:create - 新增;update - 修改
93+
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
9194
const formData = ref({
9295
id: undefined,
9396
no: undefined,
@@ -101,6 +104,7 @@ const formRules = reactive({
101104
no: [{ required: true, message: '入库单号不能为空', trigger: 'blur' }],
102105
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }]
103106
})
107+
const disabled = computed(() => formType.value === 'detail')
104108
const formRef = ref() // 表单 Ref
105109
const supplierList = ref<SupplierVO[]>([]) // 供应商列表
106110

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
v-loading="formLoading"
77
label-width="0px"
88
:inline-message="true"
9+
:disabled="disabled"
910
>
1011
<el-table :data="formData" show-summary class="-mt-10px">
1112
<el-table-column label="序号" type="index" align="center" width="60" />
@@ -120,33 +121,34 @@
120121
</el-table-column>
121122
</el-table>
122123
</el-form>
123-
<el-row justify="center" class="mt-3">
124+
<el-row justify="center" class="mt-3" v-if="!disabled">
124125
<el-button @click="handleAdd" round>+ 添加入库产品</el-button>
125126
</el-row>
126127
</template>
127128
<script setup lang="ts">
128-
import { StockInApi } from '@/api/erp/stock/in'
129129
import { ProductApi, ProductVO } from '@/api/erp/product/product'
130130
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
131131
import { StockApi } from '@/api/erp/stock/stock'
132132
133133
const props = defineProps<{
134134
items: undefined
135+
disabled: false
135136
}>()
136137
const formLoading = ref(false) // 表单的加载中
137138
const formData = ref([])
138139
const formRules = reactive({
139140
inId: [{ required: true, message: '入库编号不能为空', trigger: 'blur' }],
140141
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
141142
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
143+
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
142144
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
143145
})
144146
const formRef = ref([]) // 表单 Ref
145147
const productList = ref<ProductVO[]>([]) // 产品列表
146148
const warehouseList = ref<WarehouseVO[]>([]) // 仓库列表
147149
const defaultWarehouse = ref<WarehouseVO>(undefined) // 默认仓库
148150
149-
/** 监听主表的关联字段的变化,加载对应的子表数据 */
151+
/** 初始化设置入库项 */
150152
watch(
151153
() => props.items,
152154
async (val) => {
@@ -164,16 +166,11 @@ watch(
164166
}
165167
// 循环处理
166168
val.forEach((item) => {
167-
// const product = productList.value.find((product) => product.id === item.productId)
168-
// if (product) {
169-
// item.productUnitName = product.unitName
170-
// item.productBarCode = product.barCode
171-
// item.productPrice = product.minPrice
172-
// // TODO 芋艿:加载库存
173-
// item.stockCount = 10
174-
// }
169+
// TODO 芋艿:后面处理下相乘问题;包括后端的;
175170
if (item.productPrice && item.count) {
176171
item.totalPrice = item.productPrice * item.count
172+
} else {
173+
item.totalPrice = undefined
177174
}
178175
})
179176
},
@@ -237,9 +234,12 @@ defineExpose({ validate })
237234
238235
/** 初始化 */
239236
onMounted(async () => {
240-
// 加载产品、仓库列表
241237
productList.value = await ProductApi.getProductSimpleList()
242238
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
243239
defaultWarehouse.value = warehouseList.value.find((item) => item.defaultStatus)
240+
// 默认添加一个
241+
if (formData.value.length === 0) {
242+
handleAdd()
243+
}
244244
})
245245
</script>

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

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,29 @@
127127
>
128128
<Icon icon="ep:download" class="mr-5px" /> 导出
129129
</el-button>
130+
<el-button
131+
type="danger"
132+
plain
133+
@click="handleDelete(selectionList.map((item) => item.id))"
134+
v-hasPermi="['erp:stock-in:delete']"
135+
:disabled="selectionList.length === 0"
136+
>
137+
<Icon icon="ep:delete" class="mr-5px" /> 删除
138+
</el-button>
130139
</el-form-item>
131140
</el-form>
132141
</ContentWrap>
133142

134143
<!-- 列表 -->
135144
<ContentWrap>
136-
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
145+
<el-table
146+
v-loading="loading"
147+
:data="list"
148+
:stripe="true"
149+
:show-overflow-tooltip="true"
150+
@selection-change="handleSelectionChange"
151+
>
152+
<el-table-column width="30" label="选择" type="selection" />
137153
<el-table-column label="入库单号" align="center" prop="no" />
138154
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
139155
<el-table-column label="供应商" align="center" prop="supplierName" />
@@ -146,14 +162,21 @@
146162
/>
147163
<el-table-column label="创建人" align="center" prop="creatorName" />
148164
<el-table-column label="数量" align="center" prop="totalCount" />
149-
<el-table-column label="金额合计" align="center" prop="totalPrice" />
165+
<el-table-column label="金额" align="center" prop="totalPrice" />
150166
<el-table-column label="状态" align="center" prop="status">
151167
<template #default="scope">
152168
<dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
153169
</template>
154170
</el-table-column>
155-
<el-table-column label="操作" align="center">
171+
<el-table-column label="操作" align="center" min-width="150">
156172
<template #default="scope">
173+
<el-button
174+
link
175+
@click="openForm('detail', scope.row.id)"
176+
v-hasPermi="['erp:stock-in:query']"
177+
>
178+
详情
179+
</el-button>
157180
<el-button
158181
link
159182
type="primary"
@@ -162,10 +185,28 @@
162185
>
163186
编辑
164187
</el-button>
188+
<el-button
189+
link
190+
type="primary"
191+
@click="handleUpdateStatus(scope.row.id, 20)"
192+
v-hasPermi="['erp:stock-in:update']"
193+
v-if="scope.row.status === 10"
194+
>
195+
审批
196+
</el-button>
165197
<el-button
166198
link
167199
type="danger"
168-
@click="handleDelete(scope.row.id)"
200+
@click="handleUpdateStatus(scope.row.id, 10)"
201+
v-hasPermi="['erp:stock-in:update']"
202+
v-else
203+
>
204+
反审批
205+
</el-button>
206+
<el-button
207+
link
208+
type="danger"
209+
@click="handleDelete([scope.row.id])"
169210
v-hasPermi="['erp:stock-in:delete']"
170211
>
171212
删除
@@ -197,6 +238,7 @@ import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
197238
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
198239
import { UserVO } from '@/api/system/user'
199240
import * as UserApi from '@/api/system/user'
241+
import * as BusinessApi from '@/api/crm/business'
200242
201243
/** ERP 其它入库单 列表 */
202244
defineOptions({ name: 'ErpStockIn' })
@@ -255,15 +297,29 @@ const openForm = (type: string, id?: number) => {
255297
}
256298
257299
/** 删除按钮操作 */
258-
const handleDelete = async (id: number) => {
300+
const handleDelete = async (ids: number[]) => {
259301
try {
260302
// 删除的二次确认
261303
await message.delConfirm()
262304
// 发起删除
263-
await StockInApi.deleteStockIn(id)
305+
await StockInApi.deleteStockIn(ids)
264306
message.success(t('common.delSuccess'))
265307
// 刷新列表
266308
await getList()
309+
selectionList.value = selectionList.value.filter((item) => !ids.includes(item.id))
310+
} catch {}
311+
}
312+
313+
/** 审批/反审批操作 */
314+
const handleUpdateStatus = async (id: number, status: number) => {
315+
try {
316+
// 审批的二次确认
317+
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该入库单吗?`)
318+
// 发起审批
319+
await StockInApi.updateStockInStatus(id, status)
320+
message.success(`${status === 20 ? '审批' : '反审批'}成功`)
321+
// 刷新列表
322+
await getList()
267323
} catch {}
268324
}
269325
@@ -282,6 +338,12 @@ const handleExport = async () => {
282338
}
283339
}
284340
341+
/** 选中操作 */
342+
const selectionList = ref<StockInVO[]>([])
343+
const handleSelectionChange = (rows: StockInVO[]) => {
344+
selectionList.value = rows
345+
}
346+
285347
/** 初始化 **/
286348
onMounted(async () => {
287349
await getList()
@@ -291,4 +353,6 @@ onMounted(async () => {
291353
supplierList.value = await SupplierApi.getSupplierSimpleList()
292354
userList.value = await UserApi.getSimpleUserList()
293355
})
356+
// TODO 芋艿:可优化功能:列表界面,支持导入
357+
// TODO 芋艿:可优化功能:详情界面,支持打印
294358
</script>

0 commit comments

Comments
 (0)