feat(物资管理): 新增备件出入库总览功能并优化采购计划单

添加备件出入库总览API接口及前端展示
在采购计划单中增加设备类型字段及相关展示逻辑
优化文件上传组件处理逻辑
修复采购计划单表单验证及数据统计问题
移除备件管理页面多余操作按钮
This commit is contained in:
re-JZzzz
2025-09-30 17:40:31 +08:00
parent 6ee935ccb6
commit 94cd3f867d
8 changed files with 534 additions and 152 deletions

View File

@ -61,3 +61,16 @@ export const delBeipinBeijian = (id: string | number | Array<string | number>) =
method: 'delete'
});
};
/**
* 运维-物资-备件-查询总览
* @param query
* @returns {*}
*/
export const chuRuKuTotal = (data:any): AxiosPromise<any> => {
return request({
url: '/ops/beipinBeijian/getCount',
method: 'get',
params: data
});
};

View File

@ -186,6 +186,10 @@ export interface CaigouPlanVO {
* 供应商名称
*/
gonyingshangName?: string;
/**
* 设备类型
*/
shebeiType?: string;
}
@ -376,6 +380,10 @@ export interface CaigouPlanForm extends BaseEntity {
* 供应商名称
*/
gonyingshangName?: string;
/**
* 设备类型
*/
shebeiType?: string;
}
export interface CaigouPlanQuery extends PageQuery {
@ -567,6 +575,10 @@ export interface CaigouPlanQuery extends PageQuery {
* 供应商名称
*/
gonyingshangName?: string;
/**
* 设备类型
*/
shebeiType?: string;
}

View File

@ -100,3 +100,5 @@ export const getChanpinLists = (data:any): AxiosPromise<any> => {
params: data
});
};

View File

@ -89,17 +89,6 @@ const showTip = computed(() => props.isShowTip && (props.fileType || props.fileS
const fileUploadRef = ref<ElUploadInstance>();
// 暴露方法给父组件
defineExpose({
// 清空所有文件
clearAllFiles: () => {
fileList.value = [];
emit('update:modelValue', '');
emit('update:fileList', []);
}
});
// 监听 fileType 变化,更新 fileAccept
const fileAccept = computed(() => props.fileType.map((type) => `.${type}`).join(','));
@ -110,28 +99,18 @@ watch(
let temp = 1;
// 首先将值转为数组
let list: any[] = [];
if (Array.isArray(val)) {
// 如果是数组,检查第一个元素的格式
if (val.length > 0 && val[0].fileName && val[0].fileId && val[0].fileUrl) {
// 处理后端返回的格式 [{fileName,fileId,fileUrl}]
list = val.map(item => ({
name: item.fileName,
url: item.fileUrl,
ossId: item.fileId
}));
} else {
// 处理组件内部格式 [{name,url,ossId}]
list = val;
}
list = val;
} else {
// 处理字符串格式逗号分隔的ossId
const res = await listByIds(val);
list = res.data.map((oss) => {
return { name: oss.originalName, url: oss.url, ossId: oss.ossId };
return {
name: oss.originalName,
url: oss.url,
ossId: oss.ossId
};
});
}
// 然后将数组转为对象数组
fileList.value = list.map((item) => {
item = { name: item.name, url: item.url, ossId: item.ossId };
@ -210,15 +189,7 @@ const handleDelete = (index: number) => {
const ossId = fileList.value[index].ossId;
delOss(ossId);
fileList.value.splice(index, 1);
// 转换为后端需要的格式 [{fileName,fileId,fileUrl}]
const formattedList = fileList.value.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
emit('update:modelValue', formattedList);
emit('update:modelValue', listToString(fileList.value));
};
// 上传结束处理
@ -227,16 +198,7 @@ const uploadedSuccessfully = () => {
fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value);
uploadList.value = [];
number.value = 0;
// 转换为后端需要的格式 [{fileName,fileId,fileUrl}]
const formattedList = fileList.value.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
emit('update:modelValue', formattedList);
emit('update:fileList', fileList.value);
emit('update:modelValue', listToString(fileList.value));
proxy?.$modal.closeLoading();
}
};

View File

@ -25,6 +25,11 @@
<el-table :data="props.detailInfo.opsCaigouPlanChanpinVos || []" border style="width: 100%">
<el-table-column prop="chanpinName" label="产品名称" />
<el-table-column prop="chanpinType" label="产品型号" />
<el-table-column prop="shebeiType" label="设备类型">
<template #default="scope">
{{ getTagLabel(wz_device_type, scope.row.shebeiType) }}
</template>
</el-table-column>
<el-table-column prop="chanpinMonovalent" label="产品单价" align="center"
:cell-style="{ background: 'pink' }" />
<el-table-column prop="goumaiNumber" label="购买数量" align="center" :cell-style="{ background: 'pink' }" />
@ -80,7 +85,7 @@ const props = defineProps<{
}>();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { wz_invoicing_way, wz_payment_terms, wz_purchase_type, wz_contract_type } = toRefs<any>(proxy?.useDict('wz_invoicing_way', 'wz_payment_terms', 'wz_purchase_type', 'wz_contract_type', 'wz_caigou_examine'));
const { wz_invoicing_way, wz_payment_terms, wz_purchase_type, wz_contract_type, wz_device_type } = toRefs<any>(proxy?.useDict('wz_device_type','wz_invoicing_way', 'wz_payment_terms', 'wz_purchase_type', 'wz_contract_type', 'wz_caigou_examine', 'wz_device_type'));

View File

@ -0,0 +1,278 @@
<template>
<div class="upload-file">
<!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li v-for="(file, index) in fileList" :key="file.uid" class="el-upload-list__item ele-upload-list__item-content">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-button type="danger" v-if="!disabled" link @click="handleDelete(index)">删除</el-button>
</div>
</li>
</transition-group>
<el-upload
ref="fileUploadRef"
multiple
:drag="isDrag"
:action="uploadFileUrl"
:before-upload="handleBeforeUpload"
:file-list="fileList"
:limit="limit"
:accept="fileAccept"
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-success="handleUploadSuccess"
:show-file-list="false"
:headers="headers"
class="upload-file-uploader"
v-if="!disabled"
>
<!-- 上传按钮 -->
<el-button type="primary" v-if="!isDrag">选取文件</el-button>
<div v-else>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">
拖拽文件到此处 <em>点击上传</em>
</div>
</div>
</el-upload>
<!-- 上传提示 -->
<div v-if="showTip && !disabled" class="el-upload__tip">
请上传
<template v-if="fileSize">
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
</template>
<template v-if="fileType">
格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b>
</template>
的文件
</div>
</div>
</template>
<script setup lang="ts">
import { propTypes } from '@/utils/propTypes';
import { delOss, listByIds } from '@/api/system/oss';
import { globalHeaders } from '@/utils/request';
import { ref } from 'vue';
const props = defineProps({
modelValue: {
type: [String, Object, Array],
default: () => []
},
// 数量限制
limit: propTypes.number.def(5),
// 大小限制(MB)
fileSize: propTypes.number.def(5),
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: propTypes.array.def(['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf']),
// 是否显示提示
isShowTip: propTypes.bool.def(true),
// 禁用组件(仅查看文件)
disabled: propTypes.bool.def(false),
// 是否开启拖拽上传
isDrag: propTypes.bool.def(false)
});
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const emit = defineEmits(['update:modelValue', 'update:fileList']);
const number = ref(0);
const uploadList = ref<any[]>([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(baseUrl + '/resource/oss/upload'); // 上传文件服务器地址
const headers = ref(globalHeaders());
const fileList = ref<any[]>([]);
const showTip = computed(() => props.isShowTip && (props.fileType || props.fileSize));
const fileUploadRef = ref<ElUploadInstance>();
// 暴露方法给父组件
defineExpose({
// 清空所有文件
clearAllFiles: () => {
fileList.value = [];
emit('update:modelValue', '');
emit('update:fileList', []);
}
});
// 监听 fileType 变化,更新 fileAccept
const fileAccept = computed(() => props.fileType.map((type) => `.${type}`).join(','));
watch(
() => props.modelValue,
async (val) => {
if (val) {
let temp = 1;
// 首先将值转为数组
let list: any[] = [];
if (Array.isArray(val)) {
// 如果是数组,检查第一个元素的格式
if (val.length > 0 && val[0].fileName && val[0].fileId && val[0].fileUrl) {
// 处理后端返回的格式 [{fileName,fileId,fileUrl}]
list = val.map(item => ({
name: item.fileName,
url: item.fileUrl,
ossId: item.fileId
}));
} else {
// 处理组件内部格式 [{name,url,ossId}]
list = val;
}
} else {
// 处理字符串格式逗号分隔的ossId
const res = await listByIds(val);
list = res.data.map((oss) => {
return { name: oss.originalName, url: oss.url, ossId: oss.ossId };
});
}
// 然后将数组转为对象数组
fileList.value = list.map((item) => {
item = { name: item.name, url: item.url, ossId: item.ossId };
item.uid = item.uid || new Date().getTime() + temp++;
return item;
});
} else {
fileList.value = [];
return [];
}
},
{ deep: true, immediate: true }
);
// 上传前校检格式和大小
const handleBeforeUpload = (file: any) => {
// 校检文件类型
if (props.fileType.length) {
const fileName = file.name.split('.');
const fileExt = fileName[fileName.length - 1];
const isTypeOk = props.fileType.indexOf(fileExt) >= 0;
if (!isTypeOk) {
proxy?.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join('/')}格式文件!`);
return false;
}
}
// 校检文件名是否包含特殊字符
if (file.name.includes(',')) {
proxy?.$modal.msgError('文件名不正确,不能包含英文逗号!');
return false;
}
// 校检文件大小
if (props.fileSize) {
const isLt = file.size / 1024 / 1024 < props.fileSize;
if (!isLt) {
proxy?.$modal.msgError(`上传文件大小不能超过 ${props.fileSize} MB!`);
return false;
}
}
proxy?.$modal.loading('正在上传文件,请稍候...');
number.value++;
return true;
};
// 文件个数超出
const handleExceed = () => {
proxy?.$modal.msgError(`上传文件数量不能超过 ${props.limit} 个!`);
};
// 上传失败
const handleUploadError = () => {
proxy?.$modal.msgError('上传文件失败');
};
// 上传成功回调
const handleUploadSuccess = (res: any, file: UploadFile) => {
if (res.code === 200) {
uploadList.value.push({
name: res.data.fileName,
url: res.data.url,
ossId: res.data.ossId
});
uploadedSuccessfully();
} else {
number.value--;
proxy?.$modal.closeLoading();
proxy?.$modal.msgError(res.msg);
fileUploadRef.value?.handleRemove(file);
uploadedSuccessfully();
}
};
// 删除文件
const handleDelete = (index: number) => {
const ossId = fileList.value[index].ossId;
delOss(ossId);
fileList.value.splice(index, 1);
// 转换为后端需要的格式 [{fileName,fileId,fileUrl}]
const formattedList = fileList.value.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
emit('update:modelValue', formattedList);
};
// 上传结束处理
const uploadedSuccessfully = () => {
if (number.value > 0 && uploadList.value.length === number.value) {
fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value);
uploadList.value = [];
number.value = 0;
// 转换为后端需要的格式 [{fileName,fileId,fileUrl}]
const formattedList = fileList.value.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
emit('update:modelValue', formattedList);
emit('update:fileList', fileList.value);
proxy?.$modal.closeLoading();
}
};
// 获取文件名称
const getFileName = (name: string) => {
// 如果是url那么取最后的名字 如果不是直接返回
if (name.lastIndexOf('/') > -1) {
return name.slice(name.lastIndexOf('/') + 1);
} else {
return name;
}
};
</script>
<style lang="scss" scoped>
.upload-file-uploader {
margin-bottom: 5px;
}
.upload-file-list .el-upload-list__item {
border: 1px solid #e4e7ed;
line-height: 2;
margin-bottom: 10px;
position: relative;
}
.upload-file-list .ele-upload-list__item-content {
display: flex;
justify-content: space-between;
align-items: center;
color: inherit;
}
.ele-upload-list__item-content-action .el-link {
margin-right: 10px;
}
</style>

View File

@ -136,6 +136,7 @@
</el-card>
</el-col>
</el-row>
<!-- 添加修改弹窗 -->
<el-dialog v-model="isDialogVisible" :title="dialogTitle" width="60%" :close-on-click-modal="false">
<div class="new-procurement-form">
<!-- 基础信息 -->
@ -221,6 +222,14 @@
<template #default="scope">
<el-input v-model="scope.row.chanpinType" placeholder="请填写" />
</template>
</el-table-column>
<el-table-column prop="shebeiType" label="设备类型">
<template #default="scope">
<el-select v-model="scope.row.shebeiType" placeholder="请选择">
<el-option v-for="option in wz_device_type" :key="option.value"
:label="option.label" :value="option.value" />
</el-select>
</template>
</el-table-column>
<el-table-column prop="chanpinMonovalent" label="产品单价">
<template #default="scope">
@ -285,27 +294,7 @@
<!-- 附件上传 -->
<div class="form-section">
<h3>附件上传</h3>
<!-- 附件 -->
<!-- <el-table :data="form.opsCaigouPlanFilesBos || []" border v-if="currentOperation === 'update'">
<el-table-column prop="fileName" label="文件名" align="center" />
<el-table-column label="文件类型" align="center">
<template #default="scope">
{{ getFileType(scope.row.fileName) }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button type="text" @click="handlePreview(scope.row)">
预览
</el-button>
<el-button type="text" @click="handleDelete(scope.row)">
删除
</el-button>
</template>
</el-table-column>
</el-table> -->
<file-upload ref="fileUploadRef" :isDrag="true" v-model="form.opsCaigouPlanFilesBos"
<FileUpload ref="fileUploadRef" :isDrag="true" v-model="form.opsCaigouPlanFilesBos"
:is-show-tip="false"
:file-type="['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'png', 'jpg', 'jpeg']" />
</div>
@ -322,7 +311,7 @@
</el-dialog>
</div>
</template>
<style sc oped lang="scss">
<style scoped lang="scss">
.procurementPlan {
background-color: #F2F8FC;
padding: 20px;
@ -399,8 +388,9 @@
import { ref, reactive, computed, getCurrentInstance, onUnmounted } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useProcurementDraftStore } from '@/store/modules/procurementDraft';
import { } from '@/views/materialManagement/components/upload.vue'
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { wz_invoicing_way, wz_payment_terms, wz_purchase_type, wz_contract_type, wz_caigou_examine } = toRefs<any>(proxy?.useDict('wz_invoicing_way', 'wz_payment_terms', 'wz_purchase_type', 'wz_contract_type', 'wz_caigou_examine'));
const { wz_invoicing_way, wz_payment_terms, wz_purchase_type, wz_contract_type, wz_caigou_examine,wz_device_type } = toRefs<any>(proxy?.useDict('wz_device_type','wz_invoicing_way', 'wz_payment_terms', 'wz_purchase_type', 'wz_contract_type', 'wz_caigou_examine'));
import { listCaigouPlan, getSupplierList, addCaigouPlan, caigouPlanDetail, updateCaigouPlan,getCount } from '@/api/wuziguanli/caigouPlan';
import { CaigouPlanVO, CaigouPlanQuery, CaigouPlanForm } from '@/api/wuziguanli/caigouPlan/types';
@ -408,7 +398,7 @@ import { CaigouPlanVO, CaigouPlanQuery, CaigouPlanForm } from '@/api/wuziguanli/
import { useRouter } from 'vue-router';
const router = useRouter();
import FileUpload from '@/components/FileUpload/index.vue';
import FileUpload from '@/views/materialManagement/components/upload.vue';
// 导入用户store
@ -530,13 +520,41 @@ const yearlyAmount=ref({
})
const getYearlyAmount = async () => {
try {
// 检查项目ID是否存在
if (!queryParams.value.projectId) {
ElMessage({ message: '项目ID不能为空', type: 'warning' });
// 重置年度金额数据
yearlyAmount.value = {
yujiJine: 0,
shijiJine: 0
};
return;
}
const res = await getCount(queryParams.value.projectId);
if (res.code === 200) {
yearlyAmount.value.shijiJine = res.data.shijiJine;
yearlyAmount.value.yujiJine = res.data.yujiJine;
// 检查响应数据结构
if (res && res.code === 200 && res.data) {
// 确保金额数据有效
yearlyAmount.value.shijiJine = res.data.shijiJine || 0;
yearlyAmount.value.yujiJine = res.data.yujiJine || 0;
} else {
ElMessage({ message: '获取年度金额数据格式异常', type: 'error' });
console.error('获取年度金额响应数据异常:', res);
// 重置年度金额数据
yearlyAmount.value = {
yujiJine: 0,
shijiJine: 0
};
}
} catch (error) {
console.error('获取年度金额失败:', error);
ElMessage({ message: '获取年度金额失败,请重试', type: 'error' });
// 重置年度金额数据,避免显示错误数据
yearlyAmount.value = {
yujiJine: 0,
shijiJine: 0
};
}
}
/** 查询运维-物资-采购计划单列表 */
@ -555,23 +573,67 @@ const getList = async () => {
}
try {
// 检查项目ID是否存在
if (!queryParamsCopy.projectId) {
ElMessage({ message: '项目ID不能为空', type: 'warning' });
// 重置统计数据
pendingCount.value = 0;
purchasingCount.value = 0;
rejectedCount.value = 0;
approvedCount.value = 0;
completedCount.value = 0;
total.value = 0;
caigouPlanList.value = [];
return;
}
// 先查询所有数据来统计各状态数量
const allDataRes = await listCaigouPlan({ ...queryParamsCopy, status: undefined });
// 统计各状态数量
pendingCount.value = allDataRes.rows.filter(item => item.status === '3').length;
purchasingCount.value = allDataRes.rows.filter(item => item.status === '5').length;
rejectedCount.value = allDataRes.rows.filter(item => item.status === '7').length;
approvedCount.value = allDataRes.rows.filter(item => item.status === '9').length;
completedCount.value = allDataRes.rows.filter(item => item.status === '11').length;
total.value = allDataRes.total;
// 然后查询当前标签页的数据
const filteredRes = await listCaigouPlan(queryParamsCopy);
caigouPlanList.value = filteredRes.rows;
// 检查响应数据结构
if (allDataRes && allDataRes.code === 200 && Array.isArray(allDataRes.rows)) {
// 统计各状态数量
pendingCount.value = allDataRes.rows.filter(item => item.status === '3').length;
purchasingCount.value = allDataRes.rows.filter(item => item.status === '5').length;
rejectedCount.value = allDataRes.rows.filter(item => item.status === '7').length;
approvedCount.value = allDataRes.rows.filter(item => item.status === '9').length;
completedCount.value = allDataRes.rows.filter(item => item.status === '11').length;
total.value = allDataRes.total || 0;
// 然后查询当前标签页的数据
const filteredRes = await listCaigouPlan(queryParamsCopy);
// 检查过滤后的数据结构
if (filteredRes && filteredRes.code === 200 && Array.isArray(filteredRes.rows)) {
caigouPlanList.value = filteredRes.rows;
} else {
ElMessage({ message: '获取过滤后的数据格式异常', type: 'error' });
console.error('获取过滤后的数据响应异常:', filteredRes);
caigouPlanList.value = [];
}
} else {
ElMessage({ message: '获取统计数据格式异常', type: 'error' });
console.error('获取统计数据响应异常:', allDataRes);
// 重置统计数据
pendingCount.value = 0;
purchasingCount.value = 0;
rejectedCount.value = 0;
approvedCount.value = 0;
completedCount.value = 0;
total.value = 0;
caigouPlanList.value = [];
}
} catch (error) {
console.error('获取采购计划列表失败:', error);
ElMessage({ message: '获取数据失败,请重试', type: 'error' });
// 重置统计数据,避免显示错误数据
pendingCount.value = 0;
purchasingCount.value = 0;
rejectedCount.value = 0;
approvedCount.value = 0;
completedCount.value = 0;
total.value = 0;
caigouPlanList.value = [];
} finally {
loading.value = false;
}
@ -579,63 +641,69 @@ const getList = async () => {
// 新增采购计划单提交函数
const addCaigouPlanSubmit = async () => {
buttonLoading.value = true; // 显示按钮加载状态
const submitData = JSON.parse(JSON.stringify(form.value));
// 转换文件列表格式为后端期望的格式:[{fileName, fileId, fileUrl}]
if (submitData.opsCaigouPlanFilesBos && submitData.opsCaigouPlanFilesBos.length > 0) {
submitData.opsCaigouPlanFilesBos = submitData.opsCaigouPlanFilesBos.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
}
const res = await addCaigouPlan(submitData);
try {
// 创建表单数据的深拷贝,避免直接修改原表单数据
const submitData = JSON.parse(JSON.stringify(form.value));
// 转换文件列表格式为后端期望的格式:[{fileName, fileId, fileUrl}]
if (submitData.opsCaigouPlanFilesBos && submitData.opsCaigouPlanFilesBos.length > 0) {
submitData.opsCaigouPlanFilesBos = submitData.opsCaigouPlanFilesBos.map(file => ({
fileName: file.name,
fileId: file.ossId,
fileUrl: file.url
}));
// 数据完整性检查
if (!submitData || !submitData.projectId) {
ElMessage({ message: '项目信息不完整,无法提交', type: 'error' });
return;
}
// 提交数据前确保文件列表格式正确
if (submitData.opsCaigouPlanFilesBos === undefined) {
submitData.opsCaigouPlanFilesBos = [];
}
const res = await addCaigouPlan(submitData);
if (res.code === 200) {
// 检查响应数据结构
if (res && res.code === 200) {
ElMessage({ message: '采购申请单已成功提交,等待审批!', type: 'success' });
// 提交成功后,删除相关的草稿
const procurementDraftStore = useProcurementDraftStore();
const draftList = procurementDraftStore.getDraftList();
// 查找并删除与当前计划名称匹配的草稿
if (form.value.jihuaName && draftList && draftList.length > 0) {
const matchingDraft = draftList.find(draft =>
draft.name === form.value.jihuaName
);
try {
// 提交成功后,删除相关的草稿
const procurementDraftStore = useProcurementDraftStore();
const draftList = procurementDraftStore.getDraftList();
if (matchingDraft) {
procurementDraftStore.deleteDraft(matchingDraft.id);
// 查找并删除与当前计划名称匹配的草稿
if (form.value.jihuaName && draftList && draftList.length > 0) {
const matchingDraft = draftList.find(draft =>
draft.name === form.value.jihuaName
);
if (matchingDraft) {
procurementDraftStore.deleteDraft(matchingDraft.id);
}
}
} catch (draftError) {
console.error('删除草稿时发生错误:', draftError);
// 草稿删除失败不应影响主流程
}
// 刷新列表数据
getList();
await getList();
// 关闭对话框并重置表单
resetNewProcurementForm();
isDialogVisible.value = false;
} else {
// 显示详细的错误信息
console.error('新增采购计划单失败:', res);
ElMessage({
message: res.msg || '新增采购计划单失败,请重试',
message: res?.msg || '新增采购计划单失败,请重试',
type: 'error'
});
}
} catch (error) {
ElMessage({ message: '操作失败', type: 'error' });
console.error('新增采购计划单操作异常:', error);
// 根据错误类型提供更具体的错误信息
let errorMessage = '操作失败';
if (error.message) {
errorMessage = `操作失败: ${error.message}`;
}
ElMessage({ message: errorMessage, type: 'error' });
} finally {
buttonLoading.value = false; // 无论成功失败,都关闭加载状态
}
@ -647,23 +715,46 @@ const updateCaigouPlanSubmit = async () => {
try {
// 创建表单数据的深拷贝,避免直接修改原表单数据
const submitData = JSON.parse(JSON.stringify(form.value));
// 数据完整性检查
if (!submitData || !submitData.id || !submitData.projectId) {
ElMessage({ message: '计划ID或项目信息不完整无法更新', type: 'error' });
return;
}
// 提交数据前确保文件列表格式正确
if (submitData.opsCaigouPlanFilesBos === undefined) {
submitData.opsCaigouPlanFilesBos = [];
}
const res = await updateCaigouPlan(submitData);
if (res.code === 200) {
// 检查响应数据结构
if (res && res.code === 200) {
ElMessage({ message: '采购申请单已成功更新!', type: 'success' });
// 刷新列表数据
getList();
await getList();
// 关闭对话框并重置表单
resetNewProcurementForm();
isDialogVisible.value = false;
} else {
// 显示详细的错误信息
console.error('更新采购计划单失败:', res);
ElMessage({
message: res.msg || '更新采购计划单失败,请重试',
message: res?.msg || '更新采购计划单失败,请重试',
type: 'error'
});
}
} catch (error) {
ElMessage({ message: '操作失败', type: 'error' });
console.error('更新采购计划单操作异常:', error);
// 根据错误类型提供更具体的错误信息
let errorMessage = '操作失败';
if (error.message) {
errorMessage = `操作失败: ${error.message}`;
}
ElMessage({ message: errorMessage, type: 'error' });
} finally {
buttonLoading.value = false; // 无论成功失败,都关闭加载状态
}
@ -674,31 +765,31 @@ const updateCaigouPlanSubmit = async () => {
// 采购商列表
const supplierList = ref([]);
const getSupplierLists = async () => {
const res = await getSupplierList({
projectId: userStore.selectedProject.id
});
supplierList.value = res.data;
try {
// 检查项目ID是否存在
if (!userStore.selectedProject || !userStore.selectedProject.id) {
ElMessage({ message: '请先选择项目', type: 'warning' });
return;
}
const res = await getSupplierList({
projectId: userStore.selectedProject.id
});
// 检查响应数据结构
if (res && res.code === 200 && Array.isArray(res.data)) {
supplierList.value = res.data;
} else {
ElMessage({ message: '获取供应商列表数据格式异常', type: 'error' });
console.error('获取供应商列表响应数据异常:', res);
}
} catch (error) {
console.error('获取供应商列表失败:', error);
ElMessage({ message: '获取供应商列表失败,请重试', type: 'error' });
// 在严重错误情况下清空列表,避免显示错误数据
supplierList.value = [];
}
}
// 获取文件类型(后缀名)
const getFileType = (fileName: string): string => {
if (!fileName) return '';
const lastDotIndex = fileName.lastIndexOf('.');
if (lastDotIndex === -1) return '';
return fileName.substring(lastDotIndex + 1).toLowerCase();
};
// 预览文件
const handlePreview = (file) => {
// 实际场景可在这里处理文件预览逻辑,如打开新窗口等
window.open(file.fileUrl, '_blank');
};
// 删除文件
const handleDelete = (file) => {
// 这里简单地从表格数据中移除该文件
form.value.opsCaigouPlanFilesBos = form.value.opsCaigouPlanFilesBos.filter(f => f !== file);
};
onMounted(() => {
getList();
@ -715,6 +806,7 @@ watch(() => userStore.selectedProject, (newProject) => {
}
// 调用getList刷新数据
getList();
getYearlyAmount();
}
}, { immediate: true, deep: true });
// 对话框是否可见
@ -987,6 +1079,10 @@ const validateForm = () => {
ElMessage({ message: `${i + 1}行产品:请填写购买数量`, type: 'error' });
return false;
}
if (!product.shebeiType) {
ElMessage({ message: `${i + 1}行产品:请填写设备类型`, type: 'error' });
return false;
}
if (parseInt(product.goumaiNumber) <= 0) {
ElMessage({ message: `${i + 1}行产品购买数量必须大于0`, type: 'error' });
return false;

View File

@ -214,7 +214,7 @@
<dict-tag :options="wz_inventory_type" :value="scope.row.kucunStatus"></dict-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button type="text" @click="handleUpdate(scope.row)"
v-hasPermi="['personnel:beipinBeijian:edit']">编辑</el-button>
@ -223,7 +223,7 @@
<el-button type="text" @click="handleDelete(scope.row)"
v-hasPermi="['personnel:beipinBeijian:remove']">删除</el-button>
</template>
</el-table-column>
</el-table-column> -->
</el-table>
<div class="pagination-section">
<div class="pagination-info">
@ -260,12 +260,12 @@
:value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备类型" prop="shebeiType">
<!-- <el-form-item label="设备类型" prop="shebeiType">
<el-select v-model="form.shebeiType" placeholder="请选择设备类型">
<el-option v-for="dict in wz_device_type" :key="dict.value" :label="dict.label"
:value="dict.value"></el-option>
</el-select>
</el-form-item>
</el-form-item> -->
</el-form>
<template #footer>
<div class="dialog-footer">
@ -408,7 +408,7 @@ const userStore = useUserStore();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { listBeipinBeijian, getBeipinBeijian, delBeipinBeijian, updateBeipinBeijian } from '@/api/wuziguanli/beijian';
import { listBeipinBeijian, getBeipinBeijian, delBeipinBeijian, updateBeipinBeijian,chuRuKuTotal } from '@/api/wuziguanli/beijian';
import { BeipinBeijianVO, BeipinBeijianQuery, BeipinBeijianForm } from '@/api/wuziguanli/beijian/types';
@ -502,6 +502,18 @@ const getDictLabel = (dictType, value) => {
return option?.label || value;
};
//查询总览
const getTotalView= async () => {
try {
const res = await chuRuKuTotal({projectId: queryParams.value.projectId});
console.log(res);
total.value = res.total;
} catch (error) {
proxy?.$modal.msgError('获取数据失败,请重试');
}
}
/** 查询运维-物资-备品配件列表 */
const getList = async () => {
loading.value = true;
@ -639,6 +651,8 @@ watch(() => userStore.selectedProject, (newProject) => {
onMounted(() => {
getList();
// 初始化查询总览
getTotalView();
});
// 组件卸载时清空projectId