diff --git a/frontend/src/views/MaterialManage.vue b/frontend/src/views/MaterialManage.vue
index 96897b6..e6a18ae 100644
--- a/frontend/src/views/MaterialManage.vue
+++ b/frontend/src/views/MaterialManage.vue
@@ -10,20 +10,11 @@
查询
-
- {{ importing ? '导入中...' : '导入数据' }}
-
+
+ {{ importing ? '导入中...' : '导入数据' }}
+
新增材料
-
- 模板
-
@@ -206,6 +197,25 @@
保存
+
+
+
+
请先下载模板,按模板填写后上传 `.xlsx` 文件。
+
+
+ 模板下载
+
+
+ {{ importing ? '导入中...' : '上传文件' }}
+
+
+
+
@@ -229,11 +239,14 @@ const pagination = reactive({
})
const factories = ref([])
const dialogVisible = ref(false)
+const importDialogVisible = ref(false)
const dialogTitle = ref('')
const isEdit = ref(false)
const currentId = ref(null)
const uploading = ref(false)
const importing = ref(false)
+const apiBaseUrl = (import.meta.env.VITE_API_BASE_URL || '/api').replace(/\/$/, '')
+const templateDownloadUrl = `${apiBaseUrl}/material/template/`
const filters = reactive({
name: '',
@@ -457,6 +470,7 @@ const handleImportExcel = async (options) => {
const result = await importMaterialsExcel(options.file)
pagination.page = 1
await loadMaterials()
+ importDialogVisible.value = false
ElMessage.success(`导入完成:新增 ${result.created} 条,更新 ${result.updated} 条,跳过 ${result.skipped} 条,新建工厂 ${result.created_factory || 0} 条`)
} catch (error) {
ElMessage.error(error.response?.data?.detail || '导入失败')
@@ -527,6 +541,18 @@ onMounted(() => {
flex: 1 1 auto;
}
+.import-dialog__text {
+ color: #606266;
+ line-height: 1.6;
+}
+
+.import-dialog__actions {
+ margin-top: 20px;
+ display: flex;
+ justify-content: flex-end;
+ gap: 12px;
+}
+
.pagination {
margin-top: 16px;
display: flex;