This commit is contained in:
zjf committed 2025-02-20 19:29:48 +08:00
commit 0d320a98ef
5 files changed
+174 -77

No files matched your search

+32 -24
View File
@@ -1,41 +1,49 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: '/supermarket/smErpCgDd/page',
method: 'get',
params: query
})
return request({
url: "/supermarket/smErpCgDd/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: '/supermarket/smErpCgDd',
method: 'post',
data: obj
})
return request({
url: "/supermarket/smErpCgDd",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: '/supermarket/smErpCgDd/' + id,
method: 'get'
})
return request({
url: "/supermarket/smErpCgDd/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: '/supermarket/smErpCgDd',
method: 'delete',
data: ids
})
return request({
url: "/supermarket/smErpCgDd",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: '/supermarket/smErpCgDd',
method: 'put',
data: obj
})
return request({
url: "/supermarket/smErpCgDd",
method: "put",
data: obj,
})
}
// 采购申请单分页查询
export function getCgsqPage(query?: Object) {
return request({
url: "/supermarket/smErpCgDd/cgsq/page",
method: "get",
params: query,
})
}
+1 -1
View File
@@ -234,7 +234,7 @@ const resetQuery = () => {
}
// 树节点选择时
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: boolean) => {
state.queryForm.deptId = curClickedNode.id
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
state.queryForm.isDeepDept = isDeepTree
@@ -17,10 +17,15 @@
</el-select>
</el-form-item>
<el-form-item label="关联补货申请" prop="handlerUserId">
<el-select v-model="baseDataForm.handlerUserId" placeholder="请选择补货申请单" style="width: 200px">
<el-option label="请选择" value="0" />
</el-select>
<el-form-item label="关联补货申请" prop="linkCode">
<el-input
v-model="baseDataForm.linkCode"
:suffix-icon="Search"
@click="openLinkCodeDialog"
readonly
placeholder="请选择补货申请单"
style="width: 200px"
/>
</el-form-item>
<el-form-item label="审批状态" prop="checkStatus">
@@ -28,7 +33,9 @@
</el-form-item>
<el-form-item label="货商" prop="supplierId">
<el-input v-model="baseDataForm.supplierId" placeholder="请输入货商" style="width: 200px" />
<el-select v-model="baseDataForm.supplierId" placeholder="请选择货商" style="width: 200px">
<el-option v-for="item in supplierTypeDict" :key="item?.id" :label="item?.typeName" :value="item?.id" />
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
@@ -99,7 +106,7 @@
<vxe-column field="productName" title="库存商品">
<template #default="{ row }">
<span v-if="row.productName">{{ row.productName }}</span>
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId).productName }}</span>
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId)?.productName }}</span>
</template>
</vxe-column>
@@ -116,7 +123,7 @@
</el-select>
</template>
<template #default="{ row }">
<span v-if="row.unitId">{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
<span v-if="row.unitId">{{ row.unit ?? row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
<span v-else style="color: #c0c4cf">请选择</span>
</template>
</vxe-column>
@@ -129,7 +136,7 @@
<vxe-column field="unitPrice" title="进价">
<template #default="{ row }">
{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
{{ row.purchasePrice ?? row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
</template>
</vxe-column>
@@ -242,6 +249,53 @@
</div>
</template>
</el-dialog>
<!-- 关联采购申请单对话框 -->
<el-dialog v-model="state.linkCodeVisible" title="选择商品" width="70%" :close-on-click-modal="false" draggable @close="">
<!-- <el-row>
<el-form :model="foodQueryForm" ref="queryRef" :inline="true" @keyup.enter="getDataListAndSelect">
<el-form-item label="商品名称" prop="name">
<el-input placeholder="请输入商品名称" v-model="foodQueryForm.name" />
</el-form-item>
<el-form-item label="商品分类" prop="categoryId">
<select-ctcg v-model="foodQueryForm.categoryId" style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="getDataListAndSelect">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-row> -->
<vxe-table
ref="linkCodeTableRef"
border
v-loading="linkCodeLoading"
:row-config="{ isCurrent: true, isHover: true }"
:radio-config="{ labelField: '', trigger: 'row' }"
:data="state.cgsqPage"
>
<vxe-column type="radio" width="60" align="center"></vxe-column>
<vxe-column field="id" title="id" align="center" width="200"></vxe-column>
<vxe-column field="planCode" title="编号" align="center" width="200"></vxe-column>
<vxe-column field="planDate" title="单据日期" align="center" width="200"></vxe-column>
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
<vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
</vxe-table>
<!-- <pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
v-model:current-page="foodQueryForm.current"
v-model:page-size="foodQueryForm.size"
:total="total"
/> -->
<template #footer>
<el-button @click="state.linkCodeVisible = false">取消</el-button>
<el-button type="primary" @click="getRadioEvent" :disabled="linkCodeLoading">确认</el-button>
</template>
</el-dialog>
</div>
</div>
</template>
@@ -250,12 +304,13 @@
import { ref, reactive, computed, onMounted } from "vue"
import { useRouter, useRoute } from "vue-router"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgDd"
import { getObj, addObj, putObj, getCgsqPage } from "/@/api/supermarketerp/smErpCgDd"
import { getPlanCode, getCgPlanSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
import { storePrice } from "/@/utils/formatMoney"
import { formatDate } from "/@/utils/formatTime"
import { Search } from "@element-plus/icons-vue"
// 基本表单数据类型
interface FormVO {
@@ -264,6 +319,7 @@ interface FormVO {
dDate: string
warehouseId: string
handlerUserId: string
linkCode: string
checkStatus: string
checkUserId: string
checkTime: string
@@ -293,9 +349,11 @@ const router = useRouter()
const route = useRoute()
const loading = ref(false) // 采购计划加载
const spuListLoading = ref(false) // 对话框商品列表加载
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
const baseDataFormRef = ref() // 基本数据表单ref
const editableTableRef = ref<VxeTableInstance<RowVO>>() // 可编辑表格ref
const spuMultipleTableRef = ref() // 对话框多选表格ref
const linkCodeTableRef = ref() // 关联补货单对话框表格ref
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
// 基本信息表单数据
@@ -305,6 +363,7 @@ const baseDataForm = reactive<FormVO>({
dDate: formatDate(new Date(), "YYYY-mm-dd"),
warehouseId: "",
handlerUserId: "",
linkCode: "",
checkStatus: "",
checkUserId: "",
checkTime: "",
@@ -326,6 +385,8 @@ const state = reactive<{
spuSelectDialogVisible: boolean
spuDataList: any[]
selectedSpuObjs: any[]
linkCodeVisible: boolean
cgsqPage: any[]
}>({
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
@@ -336,6 +397,9 @@ const state = reactive<{
spuSelectDialogVisible: false, // 商品选择对话框开关
spuDataList: [], // 商品列表
selectedSpuObjs: [], // 已选中的商品列表项
linkCodeVisible: false, // 关联采购申请单对话框开关
cgsqPage: [], // 对话框采购申请单分页数据
})
// 基本信息表单校验规则
@@ -358,34 +422,56 @@ const getInitData = async () => {
if (id) {
loading.value = true
// 获取采购计划数据 & 获取简要商品列表
const [cgPlanData, erpSpuSimpleAll] = await Promise.allSettled([getObj(id), getErpSpuSimpleAll()])
const [cgPlanData] = await Promise.allSettled([getObj(id)])
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
.finally(() => (loading.value = false))
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, {
id: cgPlanData.data.id,
planCode: cgPlanData.data.planCode,
orderNumber: cgPlanData.data.orderNumber,
planDate: cgPlanData.data.planDate,
supplierId: cgPlanData.data.supplierId,
handlerUserId: cgPlanData.data.handlerUserId,
remark: cgPlanData.data.remark,
})
Object.assign(baseDataForm, cgPlanData.data)
state.editableTableData = cgPlanData.data.items
state.erpSpuItemsMemo = cgPlanData.data.items
}
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
}
// 获取货商选项 & 获取采购计划编号
const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode({ type: 2 })]).then((results) =>
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
)
const [erpSpuSimpleAll, supplierTypeOptions, planCode] = await Promise.allSettled([
getErpSpuSimpleAll(),
getSupplierTypeOptions(),
getPlanCode({ type: 2 }),
]).then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
supplierTypeOptions && supplierTypeOptions.code === 0 && (supplierTypeDict.value = supplierTypeOptions.data)
planCode && planCode.code === 0 && (baseDataForm.code = planCode.data)
}
// 打开关联补货单对话框
const openLinkCodeDialog = async () => {
state.linkCodeVisible = true
linkCodeLoading.value = true
try {
const res = await getCgsqPage().finally(() => (linkCodeLoading.value = false))
if (res.code === 0) {
state.cgsqPage = res.data.records
}
} catch (error) {
state.cgsqPage = []
linkCodeLoading.value = false
}
}
// 获取关联补货单对话框表格被单选行
const getRadioEvent = () => {
const $table = linkCodeTableRef.value
if ($table) {
const currRow = $table.getRadioRecord()
console.log("currRadioRow", currRow)
baseDataForm.linkCode = currRow.planCode
state.editableTableData = currRow.items
state.erpSpuItemsMemo = currRow.items
state.linkCodeVisible = false
}
}
// 可编辑表格行勾选
const selectChangeEvent: VxeTableEvents.CheckboxChange<RowVO> = ({ checked }) => {
const $table = editableTableRef.value
@@ -547,7 +633,8 @@ const handleSelectDialogConfirm = () => {
const addedItems = state.selectedSpuObjs
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
.map((addItem) => {
if (state.erpSpuItemsMemo.some((item: any) => item.erpSpuId === addItem.erpSpuId)) return addItem
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
if (index !== -1) return state.erpSpuItemsMemo[index]
return { ...addItem, isNew: true }
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
// 仅添加新勾选的项
@@ -575,15 +662,27 @@ const handleSelectDialogConfirm = () => {
// 整理数据
const cgPlanSpuItems = computed(() => {
return state.editableTableData.map((item: any) => {
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
return {
id: item.isNew ? undefined : item.id,
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
remark: item.remark,
unitId: item.unitId,
if (item.erpUnitVos) {
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
return {
id: item.isNew ? undefined : item.id,
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
remark: item.remark,
unitId: item.unitId,
}
} else {
return {
id: item.isNew ? undefined : item.id,
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: item.unitPrice ? storePrice(item.unitPrice) : 0,
totalAmount: Number(item.unitPrice || 0) * item.quantity,
remark: item.remark,
unitId: item.unitId,
}
}
})
})
@@ -219,10 +219,8 @@
/> -->
<template #footer>
<div class="dialog-footer">
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
</div>
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
</template>
</el-dialog>
</div>
@@ -512,7 +510,8 @@ const handleSelectDialogConfirm = () => {
const addedItems = state.selectedSpuObjs
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
.map((addItem) => {
if (state.erpSpuItemsMemo.some((item: any) => item.erpSpuId === addItem.erpSpuId)) return addItem
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
if (index !== -1) return state.erpSpuItemsMemo[index]
return { ...addItem, isNew: true }
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
// 仅添加新勾选的项
@@ -234,10 +234,8 @@
/> -->
<template #footer>
<div class="dialog-footer">
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
</div>
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
</template>
</el-dialog>
</div>
@@ -362,15 +360,7 @@ const getInitData = async () => {
.finally(() => (loading.value = false))
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, {
id: cgPlanData.data.id,
planCode: cgPlanData.data.planCode,
orderNumber: cgPlanData.data.orderNumber,
planDate: cgPlanData.data.planDate,
supplierId: cgPlanData.data.supplierId,
handlerUserId: cgPlanData.data.handlerUserId,
remark: cgPlanData.data.remark,
})
Object.assign(baseDataForm, cgPlanData.data)
state.editableTableData = cgPlanData.data.items
state.erpSpuItemsMemo = cgPlanData.data.items
}
@@ -546,7 +536,8 @@ const handleSelectDialogConfirm = () => {
const addedItems = state.selectedSpuObjs
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
.map((addItem) => {
if (state.erpSpuItemsMemo.some((item: any) => item.erpSpuId === addItem.erpSpuId)) return addItem
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
if (index !== -1) return state.erpSpuItemsMemo[index]
return { ...addItem, isNew: true }
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
// 仅添加新勾选的项