|
@@ -36,20 +36,30 @@
|
|
|
<span>{{ tableTempExcelProps.title }}</span>
|
|
|
<i class="i-iconoir-check-circle-solid" />
|
|
|
</div>
|
|
|
- <el-button hc-btn type="primary">重新上传</el-button>
|
|
|
- <el-button hc-btn type="danger">删除</el-button>
|
|
|
- <el-button hc-btn type="success">下载Excel</el-button>
|
|
|
+ <el-upload
|
|
|
+ ref="file1Ref" :auto-upload="false" :show-file-list="false" action="#"
|
|
|
+ :limit="1" :file-list="fileList" accept=".xls,.xlsx" :on-change="uploadChange"
|
|
|
+ >
|
|
|
+ <el-button hc-btn type="primary">重新上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ <el-button class="ml-2" hc-btn type="danger" @click="delectExcelMS">删除</el-button>
|
|
|
+ <el-button hc-btn type="success" @click="downloadExcel">下载Excel</el-button>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <el-button hc-btn type="primary">上传Excel</el-button>
|
|
|
+ <el-upload
|
|
|
+ ref="file2Ref" :auto-upload="false" :show-file-list="false" action="#" :limit="1"
|
|
|
+ :file-list="fileList" accept=".xls,.xlsx" :on-change="uploadChange"
|
|
|
+ >
|
|
|
+ <el-button hc-btn type="primary">上传Excel</el-button>
|
|
|
+ </el-upload>
|
|
|
</template>
|
|
|
<template v-if="excelInfo.templateExtension">
|
|
|
<div class="table-temp-name truncate">
|
|
|
<span>{{ excelInfo.templateExtension }}</span>
|
|
|
<i class="i-iconoir-check-circle-solid" />
|
|
|
</div>
|
|
|
- <el-button hc-btn type="danger">删除</el-button>
|
|
|
- <el-button hc-btn type="success">下载模板</el-button>
|
|
|
+ <el-button hc-btn type="danger" @click="delectExcelMSModel">删除</el-button>
|
|
|
+ <el-button hc-btn type="success" @click="downloadExcelModel">下载模板</el-button>
|
|
|
</template>
|
|
|
</template>
|
|
|
<template v-else>
|
|
@@ -78,7 +88,8 @@ import { ref, watch } from 'vue'
|
|
|
import { useAppStore } from '~src/store'
|
|
|
import screenfull from 'screenfull'
|
|
|
import { HcDelMsg } from 'hc-vue3-ui'
|
|
|
-import { getArrValue, getObjValue, getRandom, isNullES } from 'js-fast-way'
|
|
|
+import { ElLoading } from 'element-plus'
|
|
|
+import { getArrValue, getObjValue, getRandom, isNullES, newDownBlob } from 'js-fast-way'
|
|
|
import HcAddExcel from './add-excel.vue'
|
|
|
import HcTreeSort from './tree-sort.vue'
|
|
|
import HcExcelUpload from './excel-upload.vue'
|
|
@@ -301,6 +312,87 @@ const getDetailExcel = async (dataId) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//上传
|
|
|
+const file1Ref = ref(null)
|
|
|
+const file2Ref = ref(null)
|
|
|
+const fileList = ref([])
|
|
|
+
|
|
|
+//文件选择
|
|
|
+const uploadChange = async (file) => {
|
|
|
+ const loading = ElLoading.service({
|
|
|
+ text: '上传文件中...',
|
|
|
+ })
|
|
|
+ const form = excelInfo.value
|
|
|
+ fileList.value = [file.raw]
|
|
|
+ let formData = new FormData()
|
|
|
+ formData.append('file', ...fileList.value)
|
|
|
+ formData.append('nodeId', form.id)
|
|
|
+ const temp = tableTempExcelProps.value
|
|
|
+ if (temp.file && temp.file.length >= 2) {
|
|
|
+ formData.append('type', 2)
|
|
|
+ } else {
|
|
|
+ formData.append('type', 1)
|
|
|
+ }
|
|
|
+ const { code } = await mainApi.uploadExcel(formData)
|
|
|
+ loading.close()
|
|
|
+ if (code === 200) {
|
|
|
+ window.$message.success('保存成功')
|
|
|
+ pseudoRefresh()
|
|
|
+ }
|
|
|
+ if (file1Ref.value) {
|
|
|
+ file1Ref.value?.clearFiles()
|
|
|
+ }
|
|
|
+ if (file2Ref.value) {
|
|
|
+ file2Ref.value?.clearFiles()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//删除
|
|
|
+const delectExcelMS = () => {
|
|
|
+ HcDelMsg(async (resolve) => {
|
|
|
+ const form = excelInfo.value
|
|
|
+ const { code } = await mainApi.deleteExcel({
|
|
|
+ id: form.id,
|
|
|
+ fileUrl: '',
|
|
|
+ })
|
|
|
+ resolve() //关闭弹窗的回调
|
|
|
+ if (code === 200) {
|
|
|
+ window.$message.success('删除成功')
|
|
|
+ pseudoRefresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//下载Excel
|
|
|
+const downloadExcel = async () => {
|
|
|
+ const form = excelInfo.value
|
|
|
+ const { val } = await mainApi.downExcelFile(form.id)
|
|
|
+ newDownBlob(val).then()
|
|
|
+}
|
|
|
+
|
|
|
+//删除
|
|
|
+const delectExcelMSModel = () => {
|
|
|
+ HcDelMsg(async (resolve) => {
|
|
|
+ const form = excelInfo.value
|
|
|
+ const { code } = await mainApi.deleteExcelModel({
|
|
|
+ id: form.id,
|
|
|
+ fileUrl: '',
|
|
|
+ })
|
|
|
+ resolve() //关闭弹窗的回调
|
|
|
+ if (code === 200) {
|
|
|
+ window.$message.success('删除成功')
|
|
|
+ pseudoRefresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+//下载模板
|
|
|
+const downloadExcelModel = async () => {
|
|
|
+ const form = excelInfo.value
|
|
|
+ const { val } = await mainApi.downExcelFileModel(form.id)
|
|
|
+ newDownBlob(val).then()
|
|
|
+}
|
|
|
+
|
|
|
//全屏显示
|
|
|
const fullScreenClick = () => {
|
|
|
// 判断是否支持
|