|
@@ -4,7 +4,7 @@
|
|
|
<div class="w-1/4 border-gray-400 border h-full">
|
|
|
<header class="p-2 flex justify-between items-center h-12">
|
|
|
<div class="w-1/2">
|
|
|
- <BasicUpload
|
|
|
+ <!-- <BasicUpload
|
|
|
v-show="showUploadBtn"
|
|
|
:max-size="20"
|
|
|
:max-number="1"
|
|
@@ -13,7 +13,7 @@
|
|
|
:show-preview-number="false"
|
|
|
:empty-hide-preview="true"
|
|
|
:accept="['xlsx', 'xls', 'pdf']"
|
|
|
- />
|
|
|
+ /> -->
|
|
|
</div>
|
|
|
<div class="flex flex-row w-1/2 justify-end">
|
|
|
<span class="flex align-middle cursor-pointer" @click="handleTreeOpreate('upSerial')">
|
|
@@ -31,8 +31,8 @@
|
|
|
</header>
|
|
|
<div class="tree">
|
|
|
<Tree
|
|
|
- v-if="treeData.length"
|
|
|
- :tree-data="treeData"
|
|
|
+ v-if="treeData && treeData[0] && treeData[0].children"
|
|
|
+ :tree-data="treeData[0].children"
|
|
|
:replace-fields="replaceFields"
|
|
|
:show-line="true"
|
|
|
:default-expand-all="true"
|
|
@@ -42,29 +42,53 @@
|
|
|
</div>
|
|
|
<div class="w-3/4 ml-4 flex flex-col">
|
|
|
<header class="h-1/12 mt-2 flex justify-between items-center">
|
|
|
- <span class="text-3xl font-bold">{{ detail.name }}</span>
|
|
|
- <section>
|
|
|
- <AButton
|
|
|
- v-show="showExcel"
|
|
|
- type="primary"
|
|
|
- size="small"
|
|
|
- class="mr-4"
|
|
|
- @click="uploadExecl"
|
|
|
+ <div class="flex">
|
|
|
+ <span class="text-2xl font-bold">{{ detail.name }}</span>
|
|
|
+ <span v-show="showUploadBtn" class="flex ml-3">
|
|
|
+ <BasicUpload
|
|
|
+ :max-size="20"
|
|
|
+ :max-number="1"
|
|
|
+ @change="handleChange"
|
|
|
+ :api="uploadApi"
|
|
|
+ :show-preview-number="false"
|
|
|
+ :empty-hide-preview="true"
|
|
|
+ :accept="['pdf', 'PDF']"
|
|
|
+ btn-text="上传PDF"
|
|
|
+ />
|
|
|
+
|
|
|
+ <BasicUpload
|
|
|
+ :max-size="20"
|
|
|
+ :max-number="1"
|
|
|
+ @change="handleChange"
|
|
|
+ :api="uploadApi"
|
|
|
+ :show-preview-number="false"
|
|
|
+ :empty-hide-preview="true"
|
|
|
+ :accept="['xlsx', 'xls']"
|
|
|
+ btn-text="上传excel"
|
|
|
+ class="ml-2"
|
|
|
+ btn-type="success"
|
|
|
+ />
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <span class="mr-4" v-show="showExcelDownload">
|
|
|
+ <AButton v-if="detail.excelData.fid" type="primary" @click="uploadExecl"
|
|
|
>下载Excel</AButton
|
|
|
>
|
|
|
- <!-- <AButton type="primary" size="small" class="mx-1">下载PDF</AButton> -->
|
|
|
- <!-- <AButton type="primary" size="small" class="mx-1">编辑</AButton> -->
|
|
|
- <!-- <span class="h-full border-l-1 border-gray-400 mx-1"></span> -->
|
|
|
- <!-- <AButton type="primary" size="small" class="mx-1 mr-4">下载</AButton> -->
|
|
|
- </section>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <!-- <AButton type="primary" size="small" class="mx-1">下载PDF</AButton> -->
|
|
|
+ <!-- <AButton type="primary" size="small" class="mx-1">编辑</AButton> -->
|
|
|
+
|
|
|
+ <!-- <AButton type="primary" class="mx-1 mr-4">下载</AButton> -->
|
|
|
</header>
|
|
|
<section class="h-11/12 border-gray-400 border">
|
|
|
<!-- <PreviewPdf v-show="!showExcel" :url="pdfUrl" /> -->
|
|
|
<iframe v-if="showPdf" :src="pdfUrl" frameborder="0" width="100%" height="100%"></iframe>
|
|
|
<div
|
|
|
- v-if="detail.name && !detail.fid"
|
|
|
+ v-if="detail.name && !detail.pdfData.fid"
|
|
|
class="h-full flex justify-center items-center text-2xl"
|
|
|
- >暂未上传数据表</div
|
|
|
+ >暂未上传可供预览的pdf文件</div
|
|
|
>
|
|
|
</section>
|
|
|
</div>
|
|
@@ -72,17 +96,16 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { computed, defineComponent, ref, watch } from 'vue'
|
|
|
+ import { computed, defineComponent, onActivated, ref, watch } from 'vue'
|
|
|
import { saveSectionFileApi, sectionAllApi, treeDetailApi, treeResfulApi } from '/@/api/sys/tree'
|
|
|
import { useDesign } from '/@/hooks/web/useDesign'
|
|
|
- import { BasicTree } from '/@/components/Tree/index'
|
|
|
- import { Icon } from '/@/components/Icon'
|
|
|
import { message, Tree } from 'ant-design-vue'
|
|
|
import { TreeResultModel } from '/@/api/model/tree'
|
|
|
import { BasicUpload } from '/@/components/Upload'
|
|
|
import { uploadApi } from '/@/api/sys/upload'
|
|
|
import { TreeRow } from '/#/tree'
|
|
|
import { downloadByUrl } from '/@/utils/file/download'
|
|
|
+ import { Icon } from '/@/components/Icon'
|
|
|
interface ATreeRow extends TreeRow {
|
|
|
showUpload: boolean
|
|
|
}
|
|
@@ -104,10 +127,14 @@
|
|
|
createTime: '',
|
|
|
showUpload: false
|
|
|
})
|
|
|
- const detail = ref({ name: '', content: '', filepath: '', filename: '', ext: '', fid: '' })
|
|
|
+ const detail = ref({
|
|
|
+ name: '',
|
|
|
+ pdfData: { content: '', filepath: '', filename: '', ext: '', fid: '' },
|
|
|
+ excelData: { content: '', filepath: '', filename: '', ext: '', fid: '' }
|
|
|
+ })
|
|
|
async function initData() {
|
|
|
const result = await sectionAllApi()
|
|
|
- treeData.value = result.children || []
|
|
|
+ treeData.value = result
|
|
|
}
|
|
|
|
|
|
async function initSectionDetail(id: string) {
|
|
@@ -124,7 +151,7 @@
|
|
|
await treeResfulApi({ id, type: 'serial', operation })
|
|
|
await initData()
|
|
|
}
|
|
|
-
|
|
|
+ onActivated(() => initData())
|
|
|
const { prefixCls } = useDesign('catalog')
|
|
|
const replaceFields = { children: 'children', title: 'name', key: 'id' }
|
|
|
|
|
@@ -171,27 +198,20 @@
|
|
|
}
|
|
|
|
|
|
const showUploadBtn = computed(() => row.value.showUpload)
|
|
|
-
|
|
|
- const showExcel = computed(() => {
|
|
|
- return /.(excel)|(xls)|(xlsl)$/.test(detail.value.ext)
|
|
|
- })
|
|
|
+ const showExcelDownload = computed(() => detail.value.excelData.fid)
|
|
|
const showPdf = computed(() => {
|
|
|
- if (!detail.value.fid) {
|
|
|
- return false
|
|
|
- }
|
|
|
- const isPdf = /.(pdf)|(PDF)$/.test(detail.value.ext)
|
|
|
- if (!isPdf) {
|
|
|
+ if (!detail.value.pdfData.fid) {
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
|
})
|
|
|
const uploadExecl = () => {
|
|
|
downloadByUrl({
|
|
|
- url: 'http://localhost:7070' + detail.value.filepath
|
|
|
+ url: 'http://sj.6jlzf.cn/static' + detail.value.excelData.filepath
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- const pdfUrl = computed(() => 'http://localhost:7070' + detail.value.filepath)
|
|
|
+ const pdfUrl = computed(() => 'http://sj.6jlzf.cn/static' + detail.value.pdfData.filepath)
|
|
|
return {
|
|
|
treeData,
|
|
|
replaceFields,
|
|
@@ -203,7 +223,7 @@
|
|
|
handleChange,
|
|
|
row,
|
|
|
showUploadBtn,
|
|
|
- showExcel,
|
|
|
+ showExcelDownload,
|
|
|
uploadExecl,
|
|
|
pdfUrl,
|
|
|
showPdf
|