@@ -273,7 +282,7 @@
- {{ formatFileSize(file.fileSize || file.size) }}
+ {{ formatFileListSize(file.fileSize || file.size) }}
@@ -613,6 +622,18 @@ const fileCurrentPage = ref(1);
const filePageSize = ref(10);
const totalFiles = ref(0);
+// 排序状态
+const sortField = ref('');
+const sortOrder = ref('');
+
+// 排序字段映射(前端显示名 -> 后端字段名)
+const sortFieldMap = {
+ 'fileName': 'file_name',
+ 'fileType': 'file_type',
+ 'fileSize': 'file_size',
+ 'uploadTime': 'upload_time'
+};
+
// 表单数据
const folderForm = reactive({
id: '',
@@ -638,7 +659,7 @@ const fileListTemp = ref([]);
const folderFormRef = ref(null);
const uploadFormRef = ref(null);
const uploadRef = ref(null);
-const folderColor = '#165DFF';
+const folderColor = 'var(--color-primary)';
const refreshing = ref(false);
const folderSubmitting = ref(false);
const uploading = ref(false);
@@ -941,6 +962,9 @@ const handleFileSearch = () => {
console.log('文件搜索关键词:', fileSearchKeyword.value);
// 重置到第一页并搜索
fileCurrentPage.value = 1;
+ // 搜索时重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
console.log('重置文件页码为:', fileCurrentPage.value);
if (currentFolderId.value) {
loadFiles(currentFolderId.value);
@@ -960,6 +984,9 @@ const handleFileSearchInput = (value) => {
searchTimeout.value = setTimeout(() => {
console.log('=== 防抖文件搜索执行 ===');
fileCurrentPage.value = 1;
+ // 搜索时重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
console.log('重置文件页码为:', fileCurrentPage.value);
if (currentFolderId.value) {
loadFiles(currentFolderId.value);
@@ -976,6 +1003,9 @@ const handleFileSearchClear = () => {
console.log('清除文件搜索定时器');
}
fileCurrentPage.value = 1;
+ // 清除搜索时重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
console.log('重置文件页码为:', fileCurrentPage.value);
if (currentFolderId.value) {
loadFiles(currentFolderId.value);
@@ -985,12 +1015,20 @@ const handleFileSearchClear = () => {
const loadFiles = async (folderId) => {
try {
loading.value = true;
- const res = await getFilesApi({
+ const apiParams = {
folderId: folderId,
page: fileCurrentPage.value,
pageSize: filePageSize.value,
fileName: fileSearchKeyword.value || undefined
- });
+ };
+
+ // 添加排序参数
+ if (sortField.value && sortOrder.value) {
+ apiParams.sortField = sortField.value;
+ apiParams.sortOrder = sortOrder.value;
+ }
+
+ const res = await getFilesApi(apiParams);
// 根据后端返回的数据结构处理
if (res.code === 200 && res.data) {
@@ -1012,6 +1050,26 @@ const loadFiles = async (folderId) => {
}
};
+// 排序处理函数
+const handleSortChange = (field) => {
+ const backendField = sortFieldMap[field];
+
+ if (!backendField) return;
+
+ // 切换排序方向
+ if (sortField.value === backendField) {
+ sortOrder.value = sortOrder.value === 'asc' ? 'desc' : 'asc';
+ } else {
+ // 新字段,默认降序
+ sortField.value = backendField;
+ sortOrder.value = 'desc';
+ }
+
+ // 重新加载文件列表
+ if (currentFolderId.value) {
+ loadFiles(currentFolderId.value);
+ }
+};
// 文件夹点击事件
// const handleFolderClick = (folderId) => {
@@ -1030,8 +1088,10 @@ const handleFolderSelect = (selectedKeys, info) => {
const folderId = selectedKeys[0];
if (currentFolderId.value !== folderId) {
fileCurrentPage.value = 1;
- // 切换文件夹时清空文件搜索关键词
+ // 切换文件夹时清空文件搜索关键词和排序状态
fileSearchKeyword.value = '';
+ sortField.value = '';
+ sortOrder.value = '';
}
currentFolderId.value = folderId;
loadFiles(folderId);
@@ -1136,6 +1196,9 @@ const handleBreadcrumbClick = (index) => {
if (index === 0) {
// 点击"知识库",回到根目录
currentFolderId.value = '0';
+ // 重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
loadFiles('0');
} else {
// 点击其他路径项,需要找到对应的文件夹ID
@@ -1146,6 +1209,9 @@ const handleBreadcrumbClick = (index) => {
const targetFolder = folderList.value.find(folder => folder.name === targetFolderName);
if (targetFolder) {
currentFolderId.value = targetFolder.id;
+ // 重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
loadFiles(targetFolder.id);
}
}
@@ -1307,6 +1373,9 @@ const refreshData = async () => {
// 强制清空搜索关键词,确保显示所有文件夹
searchKeyword.value = '';
currentPage.value = 1;
+ // 刷新时重置排序状态
+ sortField.value = '';
+ sortOrder.value = '';
await initData();
if (currentFolderId.value) {
@@ -1532,7 +1601,7 @@ const fileColor = (extension) => {
bmp: '#722ed1',
webp: '#13c2c2'
};
- return colorMap[extension.toLowerCase()] || '#8c8c8c';
+ return colorMap[extension.toLowerCase()] || 'var(--color-text-3)';
};
@@ -1789,8 +1858,8 @@ const showTextPreview = async (blob, fileName) => {
maxWidth: '100%',
maxHeight: '70vh',
overflow: 'auto',
- backgroundColor: '#f8f9fa',
- border: '1px solid #e9ecef',
+ backgroundColor: 'var(--color-fill-1)',
+ border: '1px solid var(--color-border)',
borderRadius: '8px',
padding: '20px',
fontFamily: "'Consolas', 'Monaco', 'Courier New', monospace",
@@ -1798,7 +1867,7 @@ const showTextPreview = async (blob, fileName) => {
lineHeight: '1.6',
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
- color: '#333',
+ color: 'var(--color-text-1)',
textAlign: 'left'
}
}, text)
@@ -2244,6 +2313,21 @@ const formatFileSize = (fileSize) => {
return `${(size / (1024 * 1024 * 1024)).toFixed(1)} GB`;
};
+// 专门用于文件列表的格式化函数(假设后端返回的是KB单位)
+const formatFileListSize = (fileSize) => {
+ const size = Number(fileSize);
+ if (isNaN(size) || size < 0) return '未知';
+
+ // 假设后端返回的是KB单位
+ if (size < 1024) {
+ return `${size} KB`;
+ } else if (size < 1024 * 1024) {
+ return `${(size / 1024).toFixed(1)} MB`;
+ } else {
+ return `${(size / (1024 * 1024)).toFixed(1)} GB`;
+ }
+};
+
const fileTypeText = (type) => {
@@ -2366,7 +2450,7 @@ onMounted(() => {
\ No newline at end of file
diff --git a/src/views/system-resource/device-management/procurement/components/ProcurementApplicationModal.vue b/src/views/system-resource/device-management/procurement/components/ProcurementApplicationModal.vue
index d77e9f5..da2510f 100644
--- a/src/views/system-resource/device-management/procurement/components/ProcurementApplicationModal.vue
+++ b/src/views/system-resource/device-management/procurement/components/ProcurementApplicationModal.vue
@@ -237,6 +237,7 @@ const rules = {
// 监听设备数据变化,填充表单
watch(() => props.equipmentData, (newData) => {
if (newData) {
+ console.log('采购申请弹窗 - 接收到设备数据:', newData)
// 填充设备数据到表单
Object.assign(formData, {
equipmentId: newData.equipmentId || '', // 添加设备ID
@@ -254,6 +255,7 @@ watch(() => props.equipmentData, (newData) => {
technicalRequirements: '',
businessJustification: ''
})
+ console.log('采购申请弹窗 - 填充后的表单数据:', formData)
}
}, { immediate: true })
@@ -291,10 +293,18 @@ const handleSubmit = async () => {
// 调试信息:打印提交的数据
console.log('提交的表单数据:', submitData)
+ console.log('设备ID:', submitData.equipmentId)
+ console.log('设备名称:', submitData.equipmentName)
console.log('applyReason 值:', submitData.applyReason)
console.log('applyReason 类型:', typeof submitData.applyReason)
console.log('applyReason 长度:', submitData.applyReason?.length)
+ // 确保设备ID存在
+ if (!submitData.equipmentId) {
+ Message.error('设备ID不能为空,请检查设备数据')
+ return
+ }
+
await equipmentApprovalApi.submitProcurementApplication(submitData)
// 添加采购申请通知
diff --git a/src/views/system-resource/device-management/procurement/index.vue b/src/views/system-resource/device-management/procurement/index.vue
index 6dc9934..1a235c7 100644
--- a/src/views/system-resource/device-management/procurement/index.vue
+++ b/src/views/system-resource/device-management/procurement/index.vue
@@ -128,6 +128,17 @@
+
+
+
+ {{ getProcurementStatusText(record.procurementStatus) }}
+
+ 未开始
+
+
@@ -175,7 +186,7 @@
编辑
-
+
申请采购
+
+
+ {{ getProcurementStatusText(record.procurementStatus) }}
+
{{ getApprovalStatusText(record.approvalStatus) }}
+
@@ -345,6 +364,14 @@ const columns = [
slotName: 'equipmentStatus',
width: 120,
},
+ {
+ title: '采购状态',
+ dataIndex: 'procurementStatus',
+ key: 'procurementStatus',
+ slotName: 'procurementStatus',
+ width: 120,
+ fixed: false,
+ },
{
title: '位置状态',
dataIndex: 'locationStatus',
@@ -403,6 +430,30 @@ const getEquipmentStatusText = (status: string) => {
return textMap[status] || '未知'
}
+// 获取采购状态颜色
+const getProcurementStatusColor = (status: string) => {
+ const colorMap: Record = {
+ NOT_STARTED: 'gray',
+ PENDING_APPROVAL: 'blue',
+ APPROVED: 'green',
+ REJECTED: 'red',
+ COMPLETED: 'purple',
+ }
+ return colorMap[status] || 'blue'
+}
+
+// 获取采购状态文本
+const getProcurementStatusText = (status: string) => {
+ const textMap: Record = {
+ NOT_STARTED: '未开始',
+ PENDING_APPROVAL: '待审批',
+ APPROVED: '已通过',
+ REJECTED: '已拒绝',
+ COMPLETED: '已完成',
+ }
+ return textMap[status] || '未知'
+}
+
// 获取位置状态颜色
const getLocationStatusColor = (status: string) => {
const colorMap: Record = {
@@ -530,6 +581,7 @@ const transformBackendData = (data: any[]): EquipmentResp[] => {
totalPrice: item.totalPrice,
inventoryBasis: item.inventoryBasis,
dynamicRecord: item.dynamicRecord,
+ procurementStatus: item.procurementStatus,
}))
}
@@ -572,6 +624,10 @@ const loadData = async (searchParams?: EquipmentListReq) => {
if (dataList.length > 0) {
const transformedData = transformBackendData(dataList)
console.log('转换后的数据:', transformedData)
+ // 调试采购状态字段
+ transformedData.forEach((item, index) => {
+ console.log(`设备 ${index + 1} - 名称: ${item.equipmentName}, 采购状态: ${item.procurementStatus}`)
+ })
tableData.value = transformedData
} else {
tableData.value = []
@@ -662,9 +718,15 @@ const handleModalSuccess = () => {
}
// 采购申请成功回调
-const handleApplicationSuccess = () => {
+const handleApplicationSuccess = async () => {
applicationModalVisible.value = false
- loadData(currentSearchParams.value)
+ console.log('采购申请成功,准备刷新数据...')
+ // 延迟刷新数据,确保后端状态更新完成
+ setTimeout(async () => {
+ console.log('开始刷新数据...')
+ await loadData(currentSearchParams.value)
+ message.success('采购申请已提交,请等待审批')
+ }, 1000)
}
// 刷新数据
@@ -714,8 +776,12 @@ const getTotalAmount = () => {
// 检查是否可以申请采购
const canApplyProcurement = (record: EquipmentResp) => {
- // 检查是否有审批状态,如果没有或者状态为待申请,则可以申请
- return !record.approvalStatus || record.approvalStatus === 'PENDING_APPLICATION'
+ // 根据采购状态判断是否可以申请采购
+ // 只有未开始、已拒绝、已完成的设备可以重新申请采购
+ const allowedStatuses = ['NOT_STARTED', 'REJECTED', 'COMPLETED', null, undefined]
+ const canApply = allowedStatuses.includes(record.procurementStatus)
+ console.log(`设备 ${record.equipmentName} 采购状态: ${record.procurementStatus}, 可申请: ${canApply}`)
+ return canApply
}
// 获取审批状态颜色