|
@@ -3,7 +3,12 @@
|
|
|
<div class="treeBox">
|
|
|
<h4>材料分类</h4>
|
|
|
<div>
|
|
|
- <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick">
|
|
|
+ <el-tree
|
|
|
+ :data="treeData"
|
|
|
+ :props="defaultProps"
|
|
|
+ :default-expand-all="true"
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ >
|
|
|
<template #default="{ data }">
|
|
|
<el-dropdown :hide-on-click="false" trigger="contextmenu">
|
|
|
<span class="custom-tree-node">
|
|
@@ -22,11 +27,13 @@
|
|
|
</span>
|
|
|
<template #dropdown>
|
|
|
<el-dropdown-menu>
|
|
|
- <el-dropdown-item v-if="data.type !== 3" @click="uploadClick(data)"
|
|
|
- >上传</el-dropdown-item
|
|
|
- >
|
|
|
- <el-dropdown-item>下载</el-dropdown-item>
|
|
|
- <el-dropdown-item v-if="data.type === 3" divided>删除</el-dropdown-item>
|
|
|
+ <el-dropdown-item v-if="data.type !== 3" @click="uploadClick(data)">
|
|
|
+ 上传
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item @click="downloadHandle(data)">下载</el-dropdown-item>
|
|
|
+ <el-dropdown-item v-if="data.type === 3" @click="deleteHandle(data)">
|
|
|
+ 删除
|
|
|
+ </el-dropdown-item>
|
|
|
</el-dropdown-menu>
|
|
|
</template>
|
|
|
</el-dropdown>
|
|
@@ -63,23 +70,29 @@ import '@vue-office/docx/lib/index.css'
|
|
|
|
|
|
defineOptions({ name: 'FjclComp' })
|
|
|
|
|
|
+const message = useMessage()
|
|
|
const defaultProps = {
|
|
|
children: 'children',
|
|
|
label: 'name'
|
|
|
}
|
|
|
const handleNodeClick = (data: Tree) => {
|
|
|
- if (data['nodeType'] === 1) {
|
|
|
- queryProjectMaterial(data['id'])
|
|
|
+ console.log(data['type'])
|
|
|
+ if (data['type'] === 3) {
|
|
|
+ queryProjectMaterial(data['id']).then((resultData) => {
|
|
|
+ fileInfo.value = resultData
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
-const fileInfo = ref<{
|
|
|
+
|
|
|
+interface FileType {
|
|
|
id: string
|
|
|
projectId: string
|
|
|
fileld: string
|
|
|
fileName: string
|
|
|
fileSuffix: string
|
|
|
fileUrl: string
|
|
|
-}>()
|
|
|
+}
|
|
|
+const fileInfo = ref<FileType>()
|
|
|
const renderedHandler: () => void = () => {
|
|
|
console.log('加载完成')
|
|
|
}
|
|
@@ -126,11 +139,12 @@ const queryProjectMaterialByTree = (): void => {
|
|
|
treeData.value = listToTree(resultData)
|
|
|
})
|
|
|
}
|
|
|
-const queryProjectMaterial = (fileId): void => {
|
|
|
+/***
|
|
|
+ * 获取材料
|
|
|
+ */
|
|
|
+const queryProjectMaterial = async (fileId): Promise<any> => {
|
|
|
const urlApi = `/project-material-get?id=${fileId}`
|
|
|
- request.get({ url: urlApi }, '/business').then((resultData) => {
|
|
|
- fileInfo.value = resultData
|
|
|
- })
|
|
|
+ return await request.get({ url: urlApi }, '/business')
|
|
|
}
|
|
|
|
|
|
/***
|
|
@@ -163,10 +177,26 @@ const uploadProjectMaterial = (file): void => {
|
|
|
formData.append('prePath', currentMaterialPath.value as string)
|
|
|
formData.append('flowMaterialsId', currentMaterialsId.value as string)
|
|
|
request.upload({ url: urlApi, data: formData }, '/business').then((resultData) => {
|
|
|
- fileInfo.value = resultData
|
|
|
+ message.success('上传成功!')
|
|
|
+ queryProjectMaterialByTree()
|
|
|
+ })
|
|
|
+}
|
|
|
+const downloadHandle = (data: any) => {
|
|
|
+ queryProjectMaterial(data['id']).then((result) => {
|
|
|
+ const downA = document.createElement('a')
|
|
|
+ downA.href = result.fileUrl
|
|
|
+ downA.download = result.name
|
|
|
+ downA.click()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const deleteHandle = (data: any) => {
|
|
|
+ const urlApi = `/project-material-delete?id=${data['id']}`
|
|
|
+ request.post({ url: urlApi }, '/business').then((result) => {
|
|
|
+ message.success('删除成功!')
|
|
|
+ queryProjectMaterialByTree()
|
|
|
})
|
|
|
}
|
|
|
-const downloadFile = (): void => {}
|
|
|
onMounted(() => {
|
|
|
queryProjectMaterialByTree()
|
|
|
})
|