Browse Source

修改导入导出

zs 8 months ago
parent
commit
875d73c49c

+ 54 - 9
src/views/center/achievement.vue

@@ -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">
@@ -90,13 +89,37 @@
             <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>
 </template>
 
 <script setup>
-import axios from 'axios'
 import { Search } from '@element-plus/icons-vue'
 import { cloneDeep, get } from 'lodash-es'
 const $checkRes = inject('$checkRes')
@@ -166,6 +189,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
@@ -294,6 +320,8 @@ const toExam = async (row) => {
     .catch(() => {})
 }
 const toClose = () => {
+  importActive.value = 0
+  url.value = ''
   checkedExport.value = []
   checkAll.value = false
   form.value = { time: [] }
@@ -310,15 +338,32 @@ 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, '错误提示', {
@@ -327,7 +372,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)
@@ -335,10 +381,6 @@ const onSuccess = async (response, file) => {
     msgbox.close()
   }
 }
-// 导出数据
-const toDownload = () => {
-  dialog.value = { type: '3', show: true, title: '导出数据' }
-}
 
 // 导出数据
 const toFile = async () => {
@@ -410,4 +452,7 @@ const sizeChange = (limits) => {
     margin: 20px 0 0 0;
   }
 }
+.dialog_four {
+  padding: 20px;
+}
 </style>

+ 54 - 10
src/views/center/demand.vue

@@ -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>

+ 53 - 8
src/views/center/project.vue

@@ -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">
@@ -115,6 +114,31 @@
             <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>
@@ -205,6 +229,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
@@ -357,6 +384,8 @@ const getArea = (data) => {
   else return '暂无地区'
 }
 const toClose = () => {
+  importActive.value = 0
+  url.value = ''
   checkedExport.value = []
   checkAll.value = false
   form.value = { time: [] }
@@ -374,15 +403,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, '错误提示', {
@@ -391,7 +436,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)
@@ -399,10 +445,6 @@ const onSuccess = async (response, file) => {
     msgbox.close()
   }
 }
-// 导出数据
-const toDownload = () => {
-  dialog.value = { type: '3', show: true, title: '导出数据' }
-}
 
 // 导出数据
 const toFile = async () => {
@@ -559,4 +601,7 @@ const sizeChange = (limits) => {
     margin: 20px 0 0 0;
   }
 }
+.dialog_four {
+  padding: 20px;
+}
 </style>

+ 51 - 8
src/views/center/supply.vue

@@ -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">
@@ -107,6 +106,31 @@
             <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>
@@ -191,6 +215,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
@@ -364,15 +391,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, '错误提示', {
@@ -381,7 +424,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)
@@ -389,10 +433,6 @@ const onSuccess = async (response, file) => {
     msgbox.close()
   }
 }
-// 导出数据
-const toDownload = () => {
-  dialog.value = { type: '3', show: true, title: '导出数据' }
-}
 
 // 导出数据
 const toFile = async () => {
@@ -549,4 +589,7 @@ const sizeChange = (limits) => {
     margin: 20px 0 0 0;
   }
 }
+.dialog_four {
+  padding: 20px;
+}
 </style>