| | |
| | | |
| | | |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-row :gutter="12" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | |
| | | @click="handleExport" |
| | | v-hasPermi="['system:materials:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | |
| | | @click="handleImport" |
| | | v-hasPermi="['system:materials:edit']" |
| | | >全部附件导入</el-button> |
| | | |
| | | |
| | | <!-- 在按钮下方添加导入对话框 --> |
| | | <el-dialog title="批量导入附件" :visible.sync="importDialogVisible" width="50%"> |
| | | <el-upload |
| | |
| | | > |
| | | <el-button slot="trigger" size="small" type="primary">选择文件</el-button> |
| | | <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> |
| | | <div slot="tip" class="el-upload__tip">可上传PDF/DOC/XLS/JPG等格式文件,单个文件不超过50MB</div> |
| | | <div slot="tip" class="el-upload__tip">可上传JPG等格式文件,单个文件不超过50MB</div> |
| | | </el-upload> |
| | | </el-dialog> |
| | | </el-col> |
| | | |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | @click="handleExportTemplate" |
| | | v-hasPermi="['system:materials:edit']" |
| | | >导入模板下载</el-button> |
| | | </el-col> |
| | | |
| | | <el-col :span="1.5"> |
| | | |
| | | <el-upload |
| | | action="" |
| | | |
| | | class="upload-demo" |
| | | :show-file-list="false" |
| | | :http-request="handleImportData" |
| | | accept=".xlsx,.xls" |
| | | |
| | | > |
| | | <el-button size="mini" type="primary" |
| | | plain |
| | | icon="el-icon-top">导入</el-button> |
| | | |
| | | </el-upload> |
| | | </el-col> |
| | | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listMaterials, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials" |
| | | import { listMaterials, enload, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials" |
| | | import { getToken } from '@/utils/auth' |
| | | |
| | | export default { |
| | |
| | | this.download('system/materials/export', { |
| | | ...this.queryParams |
| | | }, `materials_${new Date().getTime()}.xlsx`) |
| | | } |
| | | }, |
| | | |
| | | /** 导入模板下载操作*/ |
| | | handleExportTemplate() |
| | | { |
| | | this.download('/system/materials/model', { |
| | | |
| | | }, `materials_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | /** 导入操作*/ |
| | | async handleImportData({file}){ |
| | | // 检查文件类型是否为xlsx |
| | | // if (!params.file.name.endsWith('.xlsx')) { |
| | | // this.$message.error('请上传.xlsx格式的文件'); |
| | | // return; |
| | | // } |
| | | const formData = new FormData(); |
| | | formData.append('file', file); |
| | | formData.append('recordId', this.recordId) |
| | | alert(this.recordId) |
| | | console.log(file) |
| | | |
| | | // 显示加载中状态 |
| | | const loading = this.$loading({ |
| | | lock: true, |
| | | text: '上传中...', |
| | | spinner: 'el-icon-loading', |
| | | background: 'rgba(0, 0, 0, 0.7)' |
| | | }); |
| | | |
| | | enload(formData, { |
| | | headers: { |
| | | 'Content-Type': 'multipart/form-data' |
| | | } |
| | | }).then(response => { |
| | | loading.close(); |
| | | this.$message.success('导入成功'); |
| | | this.getList(); |
| | | }).catch(error => { |
| | | loading.close(); |
| | | this.$message.error('导入失败: ' + (error.message || '未知错误')); |
| | | }); |
| | | |
| | | } |
| | | } |
| | | } |
| | | </script> |