|
|
@@ -1,11 +1,15 @@
|
|
|
<script setup lang="tsx">
|
|
|
import { Document, Files } from "@element-plus/icons-vue";
|
|
|
import { useArchiveKey } from "@/views/archive/index";
|
|
|
-import { ElTree } from "element-plus";
|
|
|
-import MagicResizer from "@/components/cy/magic-resizer.vue";
|
|
|
+import { ElMessageBox, ElTree } from "element-plus";
|
|
|
+import * as archiveApi from "@/api/archive/archive-api";
|
|
|
import { PatientArchive } from "@/api/archive/archive-api";
|
|
|
import CyTreeInput from "@/components/cy/tree-input/src/CyTreeInput.vue";
|
|
|
import ContextMenu from "@imengyu/vue3-context-menu";
|
|
|
+import TabsResizer from "@/components/cy/cy-el-tabs/TabsResizer.vue";
|
|
|
+import TabPaneResizer from "@/components/cy/cy-el-tabs/TabPaneResizer.vue";
|
|
|
+import { xcMessage } from "@/utils/xiaochan-element-plus";
|
|
|
+import XEUtils from "xe-utils";
|
|
|
|
|
|
const root = inject(useArchiveKey);
|
|
|
const treeRef = ref(ElTree);
|
|
|
@@ -16,6 +20,7 @@ const defaultProps = {
|
|
|
};
|
|
|
|
|
|
function handleNodeClick(node: PatientArchive) {
|
|
|
+ if (node.isDir) return;
|
|
|
root.mutation.setPdfUrl(node.path);
|
|
|
}
|
|
|
|
|
|
@@ -23,6 +28,86 @@ function allowDrop(draggingNode, dropNode, type) {
|
|
|
return !(type === "inner" && dropNode.data.isDir === false);
|
|
|
}
|
|
|
|
|
|
+function innerSort(value: PatientArchive[], parentId) {
|
|
|
+ const tmp = XEUtils.map(value, (item, index) => {
|
|
|
+ item.parentId = parentId;
|
|
|
+
|
|
|
+ return {
|
|
|
+ isDir: item.isDir,
|
|
|
+ id: item.id,
|
|
|
+ parentId: parentId,
|
|
|
+ sort: index,
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ archiveApi
|
|
|
+ .sort({
|
|
|
+ archives: tmp,
|
|
|
+ patNo: root.store.patInfo.inpatientNo,
|
|
|
+ times: root.store.patInfo.admissTimes,
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ xcMessage.success("排序成功。");
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+async function nodeDrop(currentNode: any, dropNode: any, type, event) {
|
|
|
+ await nextTick();
|
|
|
+
|
|
|
+ if (type === "inner") {
|
|
|
+ innerSort(dropNode.data.children, dropNode.data.id);
|
|
|
+ } else {
|
|
|
+ const isarr = XEUtils.isArray(dropNode.parent.data);
|
|
|
+
|
|
|
+ innerSort(
|
|
|
+ isarr ? dropNode.parent.data : dropNode.parent.data.children,
|
|
|
+ isarr ? null : dropNode.parent.data.id
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function addDir(parentId: string) {
|
|
|
+ const name = await ElMessageBox.prompt("文件夹名称", "新增", {
|
|
|
+ type: "info",
|
|
|
+ inputErrorMessage: "名称不能为空",
|
|
|
+ inputPattern: /\S/,
|
|
|
+ }).then(({ value }) => value);
|
|
|
+
|
|
|
+ const tmpData = {
|
|
|
+ name: name,
|
|
|
+ isDir: true,
|
|
|
+ parentId: parentId,
|
|
|
+ id: null,
|
|
|
+ type: 3,
|
|
|
+ children: [],
|
|
|
+ ...root.mutation.getPatNoAndTimes(),
|
|
|
+ } as PatientArchive;
|
|
|
+ await archiveApi.addDir(tmpData);
|
|
|
+ await root.mutation.getData();
|
|
|
+}
|
|
|
+
|
|
|
+async function removeFile(data: PatientArchive) {
|
|
|
+ data.patNo = root.store.patInfo.inpatientNo;
|
|
|
+ data.times = root.store.patInfo.admissTimes;
|
|
|
+
|
|
|
+ await archiveApi.delFile({
|
|
|
+ ...data,
|
|
|
+ ...root.mutation.getPatNoAndTimes(),
|
|
|
+ });
|
|
|
+ await root.mutation.getData();
|
|
|
+}
|
|
|
+
|
|
|
+async function renameFile(data: PatientArchive) {
|
|
|
+ const name = await ElMessageBox.prompt("文件夹名称", "新增", {
|
|
|
+ type: "info",
|
|
|
+ inputErrorMessage: "名称不能为空",
|
|
|
+ inputPattern: /\S/,
|
|
|
+ }).then(({ value }) => value);
|
|
|
+
|
|
|
+ await archiveApi.rename(data.id, name);
|
|
|
+ data.name = name;
|
|
|
+}
|
|
|
+
|
|
|
function contextmenu(e: any, data: PatientArchive, _node: any, _n: any) {
|
|
|
e.preventDefault();
|
|
|
ContextMenu.showContextMenu({
|
|
|
@@ -33,23 +118,51 @@ function contextmenu(e: any, data: PatientArchive, _node: any, _n: any) {
|
|
|
label: "新增文件夹",
|
|
|
disabled: !data.isDir,
|
|
|
onClick: () => {
|
|
|
- console.log(data);
|
|
|
+ addDir(data.id);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "重命名",
|
|
|
+ disabled: data.id === null,
|
|
|
+ onClick: () => {
|
|
|
+ renameFile(data);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "上传文件",
|
|
|
+ disabled: !data.isDir,
|
|
|
+ onClick: () => {
|
|
|
+ root.mutation.uploadFiles(data.id);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "删除",
|
|
|
+ disabled: data.id === null || data.id === "tmpDir",
|
|
|
+ onClick: () => {
|
|
|
+ removeFile(data as PatientArchive);
|
|
|
},
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+function tabContestMenu(event) {
|
|
|
+ //@ts-ignore
|
|
|
+ contextmenu(event, { isDir: true, id: null }, null, null);
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div style="padding: 10px">
|
|
|
- <magic-resizer
|
|
|
- :value="300"
|
|
|
- :max="600"
|
|
|
- :min="300"
|
|
|
- direction="x"
|
|
|
- class="archive-resizer"
|
|
|
- @contextmenu="contextmenu($event, { isDir: true, id: null }, null, null)"
|
|
|
+ <tabs-resizer
|
|
|
+ :value="300"
|
|
|
+ :max="600"
|
|
|
+ :min="100"
|
|
|
+ v-model="root.store.asideValue"
|
|
|
+ >
|
|
|
+ <TabPaneResizer
|
|
|
+ label="目录"
|
|
|
+ name="archive"
|
|
|
+ @contextmenu="tabContestMenu($event)"
|
|
|
>
|
|
|
<cy-tree-input :tree-ref="treeRef" :remote-method="root.mutation.getData">
|
|
|
<template #default="{ handelFilter, treeProps }">
|
|
|
@@ -61,10 +174,12 @@ function contextmenu(e: any, data: PatientArchive, _node: any, _n: any) {
|
|
|
draggable
|
|
|
:allow-drop="allowDrop"
|
|
|
:filter-node-method="handelFilter"
|
|
|
+ default-expand-all
|
|
|
node-key="id"
|
|
|
:props="defaultProps"
|
|
|
@node-contextmenu="contextmenu"
|
|
|
@node-click="handleNodeClick"
|
|
|
+ @nodeDrop="nodeDrop"
|
|
|
>
|
|
|
<template #default="{ data }">
|
|
|
<el-icon>
|
|
|
@@ -76,8 +191,8 @@ function contextmenu(e: any, data: PatientArchive, _node: any, _n: any) {
|
|
|
</el-tree>
|
|
|
</template>
|
|
|
</cy-tree-input>
|
|
|
- </magic-resizer>
|
|
|
- </div>
|
|
|
+ </TabPaneResizer>
|
|
|
+ </tabs-resizer>
|
|
|
</template>
|
|
|
|
|
|
<style lang="scss">
|
|
|
@@ -87,7 +202,6 @@ function contextmenu(e: any, data: PatientArchive, _node: any, _n: any) {
|
|
|
}
|
|
|
|
|
|
.archive_aside {
|
|
|
- padding: 10px;
|
|
|
background: white;
|
|
|
width: 100%;
|
|
|
}
|