|
@@ -5,8 +5,7 @@
|
|
|
<el-col :span="24" class="one">
|
|
|
<div class="one_left">
|
|
|
<div class="button" @click="toAdd">发布需求</div>
|
|
|
- <div class="button" @click="toTemplate">下载导入模板</div>
|
|
|
- <el-upload class="button" action="/files/web/cxyy_import/upload" :show-file-list="false" :on-success="onSuccess" accept=".xlsx"> 选择导入文件 </el-upload>
|
|
|
+ <div class="button" @click="toExpert">导入数据</div>
|
|
|
<div class="button" @click="toDownload">导出数据</div>
|
|
|
</div>
|
|
|
<div class="one_right">
|
|
@@ -104,9 +103,34 @@
|
|
|
</el-checkbox-group>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="btn">
|
|
|
- <el-button type="primary" size="mini" @click="toFile()">导出</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="toFile()">确定导出</el-button>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
+ <el-col :span="24" class="dialog_four" v-if="dialog.type == '4'">
|
|
|
+ <el-row justify="center">
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-steps style="max-width: 600px" :active="importActive" align-center>
|
|
|
+ <el-step title="下载导入模板">
|
|
|
+ <template #description v-if="importActive == 0">
|
|
|
+ <el-button type="primary" size="mini" @click="toTemplate">下载导入模板</el-button>
|
|
|
+ </template>
|
|
|
+ </el-step>
|
|
|
+ <el-step title="上传导入模板" description="上传导入模板">
|
|
|
+ <template #description v-if="importActive == 1">
|
|
|
+ <el-upload action="/files/web/cxyy_import/upload" :show-file-list="false" :on-success="onSuccess" accept=".xlsx">
|
|
|
+ <el-button type="primary" size="mini">上传导入文件</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </template>
|
|
|
+ </el-step>
|
|
|
+ <el-step title="确定导入" description="确定导入">
|
|
|
+ <template #description v-if="importActive == 2">
|
|
|
+ <el-button type="primary" size="mini" @click="onImport">确定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-step>
|
|
|
+ </el-steps>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-col>
|
|
|
</el-row>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
@@ -198,6 +222,9 @@ const rules = reactive({ name: [{ required: true, message: '请输入需求名
|
|
|
const checkAll = ref(false)
|
|
|
const checkedExport = ref([])
|
|
|
const isIndeterminate = ref(true)
|
|
|
+// 导入文件
|
|
|
+const importActive = ref(0)
|
|
|
+const url = ref('')
|
|
|
// 请求
|
|
|
onMounted(async () => {
|
|
|
loading.value = true
|
|
@@ -349,6 +376,8 @@ const toView = (item) => {
|
|
|
router.push({ path: '/supply/detail', query: { id: item.id || item._id } })
|
|
|
}
|
|
|
const toClose = () => {
|
|
|
+ importActive.value = 0
|
|
|
+ url.value = ''
|
|
|
checkedExport.value = []
|
|
|
checkAll.value = false
|
|
|
form.value = { time: [] }
|
|
@@ -366,15 +395,31 @@ const checkedExportChange = (value) => {
|
|
|
checkAll.value = checkedCount === formFields.value.length
|
|
|
isIndeterminate.value = checkedCount > 0 && checkedCount < formFields.value.length
|
|
|
}
|
|
|
+// 导入数据
|
|
|
+const toExpert = () => {
|
|
|
+ dialog.value = { type: '4', show: true, title: '导入数据' }
|
|
|
+}
|
|
|
+// 导出数据
|
|
|
+const toDownload = () => {
|
|
|
+ dialog.value = { type: '3', show: true, title: '导出数据' }
|
|
|
+}
|
|
|
+
|
|
|
// 下载导入模板
|
|
|
const toTemplate = () => {
|
|
|
+ importActive.value = importActive.value + 1
|
|
|
window.open('/cxyyWeb/产学研用需求模板.xlsx')
|
|
|
}
|
|
|
+
|
|
|
// 上传Excel
|
|
|
const onSuccess = async (response, file) => {
|
|
|
+ importActive.value = importActive.value + 1
|
|
|
+ url.value = response.uri
|
|
|
+}
|
|
|
+// 确定导出
|
|
|
+const onImport = async () => {
|
|
|
const msgbox = ElMessage({ message: '正在导入中,请稍后...', center: true, duration: 0 })
|
|
|
try {
|
|
|
- const res = await utilStore.toImport({ url: response.uri })
|
|
|
+ const res = await utilStore.toImport({ url: url.value })
|
|
|
if (res.errcode == '0') {
|
|
|
if (res.data[0].errorList) {
|
|
|
ElMessageBox.alert(res.data[0].errorList, '错误提示', {
|
|
@@ -383,7 +428,8 @@ const onSuccess = async (response, file) => {
|
|
|
} else {
|
|
|
ElMessage({ message: '导入成功', type: 'success' })
|
|
|
}
|
|
|
- search({ skip, limit })
|
|
|
+ await search({ skip, limit })
|
|
|
+ await toClose()
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error(error)
|
|
@@ -391,11 +437,6 @@ const onSuccess = async (response, file) => {
|
|
|
msgbox.close()
|
|
|
}
|
|
|
}
|
|
|
-// 导出数据
|
|
|
-const toDownload = () => {
|
|
|
- dialog.value = { type: '3', show: true, title: '导出数据' }
|
|
|
-}
|
|
|
-
|
|
|
// 导出数据
|
|
|
const toFile = async () => {
|
|
|
if (checkedExport.value.length > 0) {
|
|
@@ -551,4 +592,7 @@ const sizeChange = (limits) => {
|
|
|
margin: 20px 0 0 0;
|
|
|
}
|
|
|
}
|
|
|
+.dialog_four {
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
</style>
|