feat(biz): 添加采购管理相关业务模块

This commit is contained in:
zxy 2026-05-21 15:58:38 +08:00
parent 5b4c415051
commit ce75e605a6
6 changed files with 51 additions and 26 deletions

View File

@ -18,7 +18,7 @@ public interface PurOrderMapper extends BaseMapperX<PurOrderDO> {
default PageResult<PurOrderDO> selectPage(PurOrderPageReqVO reqVO) { default PageResult<PurOrderDO> selectPage(PurOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PurOrderDO>() return selectPage(reqVO, new LambdaQueryWrapperX<PurOrderDO>()
.betweenIfPresent(PurOrderDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(PurOrderDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PurOrderDO::getPurOrdNo, reqVO.getPurOrdNo()) .likeIfPresent(PurOrderDO::getPurOrdNo, reqVO.getPurOrdNo())
.betweenIfPresent(PurOrderDO::getPurDate, reqVO.getPurDate()) .betweenIfPresent(PurOrderDO::getPurDate, reqVO.getPurDate())
.eqIfPresent(PurOrderDO::getAttFile, reqVO.getAttFile()) .eqIfPresent(PurOrderDO::getAttFile, reqVO.getAttFile())
.eqIfPresent(PurOrderDO::getBillType, reqVO.getBillType()) .eqIfPresent(PurOrderDO::getBillType, reqVO.getBillType())

View File

@ -106,6 +106,45 @@ export const getDictLabel = (dictType: string, value: any): string => {
return dictLabel.value return dictLabel.value
} }
/**
* options value label
* @param options label value
* @param value
* @param defaultValue
* @return
*/
export const getDictLabelByOptions = (options: OptionsDataType[], value: any, defaultValue: string = '-'): string => {
if (!options || options.length === 0) {
return defaultValue
}
if (!value && value !== 0 && value !== false) {
return defaultValue
}
const item = options.find(opt => String(opt.value) === String(value))
return item ? item.label : defaultValue
}
/**
* 使
*
* 1. getUnitName(value)
* 2. Element Plus formatter 使:formatter="getUnitName"
* @param rowOrValue row formatter 使
* @param columnOrDefaultValue column
* @param cellValue formatter 使
* @return
*/
export const getUnitName = (rowOrValue: any, columnOrDefaultValue?: any, cellValue?: any): string => {
const options = getDictOptions('mat_unit')
// 判断是作为 formatter 使用还是直接调用
// 作为 formatter 使用时cellValue 是单元格的值
if (cellValue !== undefined) {
return getDictLabelByOptions(options, cellValue)
}
// 直接调用时rowOrValue 就是 value
return getDictLabelByOptions(options, rowOrValue, columnOrDefaultValue)
}
export enum DICT_TYPE { export enum DICT_TYPE {
USER_TYPE = 'user_type', USER_TYPE = 'user_type',
COMMON_STATUS = 'common_status', COMMON_STATUS = 'common_status',

View File

@ -39,11 +39,7 @@
<el-table-column label="产品编码" align="center" prop="matCode" /> <el-table-column label="产品编码" align="center" prop="matCode" />
<el-table-column label="产品名称" align="center" prop="matName" /> <el-table-column label="产品名称" align="center" prop="matName" />
<el-table-column label="规格型号" align="center" prop="spec" /> <el-table-column label="规格型号" align="center" prop="spec" />
<el-table-column label="单位" align="center" width="100px"> <el-table-column label="单位" align="center" width="100px" :formatter="getUnitName"/>
<template #default="scope">
{{ getUnitName(scope.row.unit) }}
</template>
</el-table-column>
<el-table-column label="物料类型" align="center" width="120px"> <el-table-column label="物料类型" align="center" width="120px">
<template #default="scope"> <template #default="scope">
{{ getMatTypeName(scope.row.matType) }} {{ getMatTypeName(scope.row.matType) }}
@ -72,7 +68,7 @@
import { ref, reactive, nextTick, onMounted } from 'vue' import { ref, reactive, nextTick, onMounted } from 'vue'
import * as MaterialApi from '@/api/biz/material' import * as MaterialApi from '@/api/biz/material'
import { Icon } from '@/components/Icon' import { Icon } from '@/components/Icon'
import { getDictOptions } from '@/utils/dict' import { getDictOptions, getDictLabelByOptions, getUnitName } from '@/utils/dict'
const message = useMessage() const message = useMessage()
const dialogVisible = ref(false) const dialogVisible = ref(false)
@ -84,8 +80,6 @@ const tableRef = ref()
// //
const matTypeOptions = ref([]) const matTypeOptions = ref([])
//
const unitOptions = ref([])
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
@ -103,23 +97,13 @@ const emit = defineEmits(['confirm'])
// //
const getMatTypeName = (matType: string | number) => { const getMatTypeName = (matType: string | number) => {
if (!matType && matType !== 0) return '-' return getDictLabelByOptions(matTypeOptions.value, matType)
const item = matTypeOptions.value.find(opt => String(opt.value) === String(matType))
return item ? item.label : matType
}
//
const getUnitName = (unit: string | number) => {
if (!unit && unit !== 0) return '-'
const item = unitOptions.value.find(opt => String(opt.value) === String(unit))
return item ? item.label : unit
} }
// //
const initDictOptions = () => { const initDictOptions = () => {
try { try {
matTypeOptions.value = getDictOptions('mat_type') matTypeOptions.value = getDictOptions('mat_type')
unitOptions.value = getDictOptions('mat_unit')
} catch (e) { } catch (e) {
console.error('获取数据字典失败', e) console.error('获取数据字典失败', e)
} }

View File

@ -41,7 +41,7 @@
<el-table-column label="物料编码" align="center" prop="matCode" width="120px" /> <el-table-column label="物料编码" align="center" prop="matCode" width="120px" />
<el-table-column label="物料名称" align="center" prop="matName" width="150px" /> <el-table-column label="物料名称" align="center" prop="matName" width="150px" />
<el-table-column label="规格型号" align="center" prop="spec" width="120px" /> <el-table-column label="规格型号" align="center" prop="spec" width="120px" />
<el-table-column label="单位" align="center" prop="unit" width="80px" /> <el-table-column label="单位" align="center" prop="unit" width="80px" :formatter="getUnitName" />
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
@ -77,7 +77,7 @@
<el-table-column label="物料编码" align="center" prop="matCode" width="120px" /> <el-table-column label="物料编码" align="center" prop="matCode" width="120px" />
<el-table-column label="物料名称" align="center" prop="matName" width="150px" /> <el-table-column label="物料名称" align="center" prop="matName" width="150px" />
<el-table-column label="规格型号" align="center" prop="spec" width="120px" /> <el-table-column label="规格型号" align="center" prop="spec" width="120px" />
<el-table-column label="单位" align="center" prop="unit" width="80px" /> <el-table-column label="单位" align="center" prop="unit" width="80px" :formatter="getUnitName" />
</el-table> </el-table>
</div> </div>
</div> </div>
@ -94,6 +94,7 @@
import { ref, reactive, nextTick } from 'vue' import { ref, reactive, nextTick } from 'vue'
import * as MaterialApi from '@/api/biz/material' import * as MaterialApi from '@/api/biz/material'
import { Icon } from '@/components/Icon' import { Icon } from '@/components/Icon'
import { getUnitName } from '@/utils/dict'
const message = useMessage() const message = useMessage()
const dialogVisible = ref(false) const dialogVisible = ref(false)

View File

@ -80,7 +80,7 @@
<el-table-column label="物料编码" prop="materialCode" align="center" /> <el-table-column label="物料编码" prop="materialCode" align="center" />
<el-table-column label="物料名称" prop="materialName" align="center" /> <el-table-column label="物料名称" prop="materialName" align="center" />
<el-table-column label="规格型号" prop="spec" align="center" /> <el-table-column label="规格型号" prop="spec" align="center" />
<el-table-column label="单位" prop="unit" align="center" /> <el-table-column label="单位" prop="unit" align="center" :formatter="getUnitName" />
<el-table-column label="采购数量" prop="purQty" align="center" /> <el-table-column label="采购数量" prop="purQty" align="center" />
<el-table-column label="要求到货日期" prop="reqDeliveryDate" align="center" /> <el-table-column label="要求到货日期" prop="reqDeliveryDate" align="center" />
<el-table-column label="含税单价" prop="priceTax" align="center"> <el-table-column label="含税单价" prop="priceTax" align="center">
@ -107,7 +107,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref, reactive } from 'vue'
import * as PurOrderApi from '@/api/biz/purorder' import * as PurOrderApi from '@/api/biz/purorder'
import * as PurOrderItemApi from '@/api/biz/purorderitem' import { getUnitName } from '@/utils/dict'
const message = useMessage() const message = useMessage()

View File

@ -16,7 +16,7 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="单据类型" prop="billType" > <el-form-item label="单据类型" prop="billType" >
<el-select v-model="formData.billType" placeholder="请选择" style="width: 100%" disabled> <el-select v-model="formData.billType" placeholder="请选择" style="width: 100%" >
<el-option label="标准采购申请" value="1" /> <el-option label="标准采购申请" value="1" />
<el-option label="设备采购申请" value="2" /> <el-option label="设备采购申请" value="2" />
</el-select> </el-select>
@ -24,7 +24,7 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="申请类型" prop="applyType"> <el-form-item label="申请类型" prop="applyType">
<el-select v-model="formData.applyType" placeholder="请选择" style="width: 100%" disabled> <el-select v-model="formData.applyType" placeholder="请选择" style="width: 100%" >
<el-option label="采购申请" value="1" /> <el-option label="采购申请" value="1" />
<el-option label="紧急采购" value="2" /> <el-option label="紧急采购" value="2" />
</el-select> </el-select>
@ -199,6 +199,7 @@
:decimal-places="2" :decimal-places="2"
:allow-negative="false" :allow-negative="false"
:show-prefix="false" :show-prefix="false"
@change="() => calculateTotal(scope.row)"
/> />
</template> </template>
</el-table-column> </el-table-column>