ERP:增加入库单的审批功能

pull/379/MERGE
YunaiV 2024-02-06 23:28:48 +08:00
parent 5bdf0fc0ff
commit 115c30ea40
4 changed files with 107 additions and 23 deletions

View File

@ -34,9 +34,25 @@ export const StockInApi = {
return await request.put({ url: `/erp/stock-in/update`, data })
},
// 更新其它入库单的状态
updateStockInStatus: async (id: number, status: number) => {
return await request.put({
url: `/erp/stock-in/update-status`,
params: {
id,
status
}
})
},
// 删除其它入库单
deleteStockIn: async (id: number) => {
return await request.delete({ url: `/erp/stock-in/delete?id=` + id })
deleteStockIn: async (ids: number[]) => {
return await request.delete({
url: `/erp/stock-in/delete`,
params: {
ids: ids.join(',')
}
})
},
// 导出其它入库单 Excel

View File

@ -6,6 +6,7 @@
:rules="formRules"
label-width="100px"
v-loading="formLoading"
:disabled="disabled"
>
<el-row :gutter="20">
<!-- TODO 芋艿待接入 -->
@ -63,12 +64,14 @@
<ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
<el-tab-pane label="入库产品清单" name="stockInItem">
<StockInItemForm ref="stockInItemFormRef" :items="formData.items" />
<StockInItemForm ref="stockInItemFormRef" :items="formData.items" :disabled="disabled" />
</el-tab-pane>
</el-tabs>
</ContentWrap>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
</el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
@ -87,7 +90,7 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formType = ref('') // create - update - detail -
const formData = ref({
id: undefined,
no: undefined,
@ -101,6 +104,7 @@ const formRules = reactive({
no: [{ required: true, message: '入库单号不能为空', trigger: 'blur' }],
inTime: [{ required: true, message: '入库时间不能为空', trigger: 'blur' }]
})
const disabled = computed(() => formType.value === 'detail')
const formRef = ref() // Ref
const supplierList = ref<SupplierVO[]>([]) //

View File

@ -6,6 +6,7 @@
v-loading="formLoading"
label-width="0px"
:inline-message="true"
:disabled="disabled"
>
<el-table :data="formData" show-summary class="-mt-10px">
<el-table-column label="序号" type="index" align="center" width="60" />
@ -120,18 +121,18 @@
</el-table-column>
</el-table>
</el-form>
<el-row justify="center" class="mt-3">
<el-row justify="center" class="mt-3" v-if="!disabled">
<el-button @click="handleAdd" round>+ 添加入库产品</el-button>
</el-row>
</template>
<script setup lang="ts">
import { StockInApi } from '@/api/erp/stock/in'
import { ProductApi, ProductVO } from '@/api/erp/product/product'
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
import { StockApi } from '@/api/erp/stock/stock'
const props = defineProps<{
items: undefined
disabled: false
}>()
const formLoading = ref(false) //
const formData = ref([])
@ -139,6 +140,7 @@ const formRules = reactive({
inId: [{ required: true, message: '入库编号不能为空', trigger: 'blur' }],
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
})
const formRef = ref([]) // Ref
@ -146,7 +148,7 @@ const productList = ref<ProductVO[]>([]) // 产品列表
const warehouseList = ref<WarehouseVO[]>([]) //
const defaultWarehouse = ref<WarehouseVO>(undefined) //
/** 监听主表的关联字段的变化,加载对应的子表数据 */
/** 初始化设置入库项 */
watch(
() => props.items,
async (val) => {
@ -164,16 +166,11 @@ watch(
}
//
val.forEach((item) => {
// const product = productList.value.find((product) => product.id === item.productId)
// if (product) {
// item.productUnitName = product.unitName
// item.productBarCode = product.barCode
// item.productPrice = product.minPrice
// // TODO
// item.stockCount = 10
// }
// TODO
if (item.productPrice && item.count) {
item.totalPrice = item.productPrice * item.count
} else {
item.totalPrice = undefined
}
})
},
@ -237,9 +234,12 @@ defineExpose({ validate })
/** 初始化 */
onMounted(async () => {
//
productList.value = await ProductApi.getProductSimpleList()
warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
defaultWarehouse.value = warehouseList.value.find((item) => item.defaultStatus)
//
if (formData.value.length === 0) {
handleAdd()
}
})
</script>

View File

@ -127,13 +127,29 @@
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
<el-button
type="danger"
plain
@click="handleDelete(selectionList.map((item) => item.id))"
v-hasPermi="['erp:stock-in:delete']"
:disabled="selectionList.length === 0"
>
<Icon icon="ep:delete" 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
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
@selection-change="handleSelectionChange"
>
<el-table-column width="30" label="选择" type="selection" />
<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="supplierName" />
@ -146,14 +162,21 @@
/>
<el-table-column label="创建人" align="center" prop="creatorName" />
<el-table-column label="数量" align="center" prop="totalCount" />
<el-table-column label="金额合计" align="center" prop="totalPrice" />
<el-table-column label="金额" align="center" prop="totalPrice" />
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<el-table-column label="操作" align="center" min-width="150">
<template #default="scope">
<el-button
link
@click="openForm('detail', scope.row.id)"
v-hasPermi="['erp:stock-in:query']"
>
详情
</el-button>
<el-button
link
type="primary"
@ -162,10 +185,28 @@
>
编辑
</el-button>
<el-button
link
type="primary"
@click="handleUpdateStatus(scope.row.id, 20)"
v-hasPermi="['erp:stock-in:update']"
v-if="scope.row.status === 10"
>
审批
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
@click="handleUpdateStatus(scope.row.id, 10)"
v-hasPermi="['erp:stock-in:update']"
v-else
>
反审批
</el-button>
<el-button
link
type="danger"
@click="handleDelete([scope.row.id])"
v-hasPermi="['erp:stock-in:delete']"
>
删除
@ -197,6 +238,7 @@ 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'
import * as BusinessApi from '@/api/crm/business'
/** ERP 其它入库单 列表 */
defineOptions({ name: 'ErpStockIn' })
@ -255,15 +297,29 @@ const openForm = (type: string, id?: number) => {
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
const handleDelete = async (ids: number[]) => {
try {
//
await message.delConfirm()
//
await StockInApi.deleteStockIn(id)
await StockInApi.deleteStockIn(ids)
message.success(t('common.delSuccess'))
//
await getList()
selectionList.value = selectionList.value.filter((item) => !ids.includes(item.id))
} catch {}
}
/** 审批/反审批操作 */
const handleUpdateStatus = async (id: number, status: number) => {
try {
//
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该入库单吗?`)
//
await StockInApi.updateStockInStatus(id, status)
message.success(`${status === 20 ? '审批' : '反审批'}成功`)
//
await getList()
} catch {}
}
@ -282,6 +338,12 @@ const handleExport = async () => {
}
}
/** 选中操作 */
const selectionList = ref<StockInVO[]>([])
const handleSelectionChange = (rows: StockInVO[]) => {
selectionList.value = rows
}
/** 初始化 **/
onMounted(async () => {
await getList()
@ -291,4 +353,6 @@ onMounted(async () => {
supplierList.value = await SupplierApi.getSupplierSimpleList()
userList.value = await UserApi.getSimpleUserList()
})
// TODO
// TODO
</script>