feat(biz): 添加采购管理相关业务模块
This commit is contained in:
parent
5b4c415051
commit
ce75e605a6
@ -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())
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
@ -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()
|
||||||
|
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user