|
@@ -6,7 +6,7 @@
|
|
|
<div class="one_left">
|
|
|
<div class="button" @click="toAdd">发布成果</div>
|
|
|
<div class="button" @click="toTemplate">下载导出模板</div>
|
|
|
- <el-upload class="button" :action="url" :show-file-list="false" :on-error="onError" :http-request="httpRequse" accept=".xlsx"> 选择excel模板文件 </el-upload>
|
|
|
+ <el-upload class="button" action="/files/web/cxyy_import/upload" :show-file-list="false" :on-success="onSuccess" accept=".xlsx"> 选择excel模板文件 </el-upload>
|
|
|
<div class="button" @click="toDownload">下载Excel</div>
|
|
|
</div>
|
|
|
<div class="one_right">
|
|
@@ -96,6 +96,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+import axios from 'axios'
|
|
|
import { Search } from '@element-plus/icons-vue'
|
|
|
import { cloneDeep, get } from 'lodash-es'
|
|
|
const $checkRes = inject('$checkRes')
|
|
@@ -311,26 +312,23 @@ const checkedExportChange = (value) => {
|
|
|
}
|
|
|
// 下载导出模板
|
|
|
const toTemplate = () => {
|
|
|
- window.open('/cxyyWeb/导入模板.xlsx')
|
|
|
+ window.open('/cxyyWeb/产学研用成果模板.xlsx')
|
|
|
}
|
|
|
// 上传Excel
|
|
|
-const httpRequse = async (param) => {
|
|
|
+const onSuccess = async (response, file) => {
|
|
|
const msgbox = ElMessage({ message: '正在导入中,请稍后...', center: true, duration: 0 })
|
|
|
try {
|
|
|
- let fileObj = param.file
|
|
|
- let fd = new FormData()
|
|
|
- fd.append('file', fileObj, fileObj.name)
|
|
|
- const res = await utilStore.toImport(fd)
|
|
|
- // let list
|
|
|
- console.log(res)
|
|
|
- // if (res.status !== 200) {
|
|
|
- // list = [{ key: '请求发生错误' }]
|
|
|
- // } else if (res.data.errcode !== 0) {
|
|
|
- // list = [{ key: '请求发生错误', num: res.data.errmsg }]
|
|
|
- // } else {
|
|
|
- // list = res.data.data
|
|
|
- // }
|
|
|
- // console.log(list)
|
|
|
+ const res = await utilStore.toImport({ url: response.uri })
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ if (res.data[0].errorList) {
|
|
|
+ ElMessageBox.alert(res.data[0].errorList, '错误提示', {
|
|
|
+ confirmButtonText: 'OK'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ElMessage({ message: '导入成功', type: 'success' })
|
|
|
+ }
|
|
|
+ search({ skip, limit })
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
console.error(error)
|
|
|
} finally {
|