|
@@ -1,19 +1,25 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useCompRef } from "@/utils/useCompRef";
|
|
|
-import { ElIcon, ElInput, ElTree } from "element-plus";
|
|
|
+import { ElIcon, ElInput, ElMessageBox, ElTree } from "element-plus";
|
|
|
import { h, ref } from "vue";
|
|
|
import { Document, Folder, Lock, Open, Sort } from "@element-plus/icons-vue";
|
|
|
import { stringIsBlank } from "@/utils/blank-utils";
|
|
|
-import RightClickMenu from "@/components/menu-item/RightClickMenu.vue";
|
|
|
import { xcMessage } from "@/utils/xiaochan-element-plus";
|
|
|
import {
|
|
|
emrMitt,
|
|
|
isCourse,
|
|
|
+ patientInfo,
|
|
|
} from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/emr-init";
|
|
|
-import { electronicMedicalRecordSequencing } from "@/api/zhu-yuan-yi-sheng/emr-patient";
|
|
|
+import {
|
|
|
+ delDir,
|
|
|
+ electronicMedicalRecordSequencing,
|
|
|
+ newDir,
|
|
|
+ rename,
|
|
|
+} from "@/api/zhu-yuan-yi-sheng/emr-patient";
|
|
|
import { useDialog } from "@/components/cy/CyDialog/index";
|
|
|
import AddEmrDialog from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/add-emr-dialog/AddEmrDialog.vue";
|
|
|
import { emrRootContextKey } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
|
|
|
+import ContextMenu from "@imengyu/vue3-context-menu";
|
|
|
|
|
|
const props = defineProps<{
|
|
|
treeData: any[];
|
|
@@ -21,11 +27,10 @@ const props = defineProps<{
|
|
|
|
|
|
const root = inject(emrRootContextKey);
|
|
|
|
|
|
-const emits = defineEmits(["nodeClick"]);
|
|
|
+const emits = defineEmits(["nodeClick", "refresh"]);
|
|
|
|
|
|
const inputValue = ref("");
|
|
|
const treeRef = useCompRef(ElTree);
|
|
|
-const mousePosition = ref();
|
|
|
|
|
|
const defaultProps = {
|
|
|
children: "children",
|
|
@@ -58,7 +63,7 @@ let drag = new Map();
|
|
|
const dragEnd = (moveNode, inNode, type, event) => {
|
|
|
if (type === "none") return;
|
|
|
let temp = {
|
|
|
- newParent: inNode.data._id,
|
|
|
+ newParent: inNode.data.emrDocumentId,
|
|
|
oldParent: moveNode.data.parent,
|
|
|
};
|
|
|
drag.set(moveNode.data.id, temp);
|
|
@@ -66,8 +71,8 @@ const dragEnd = (moveNode, inNode, type, event) => {
|
|
|
|
|
|
const dragLimit = (moveNode, inNode, type) => {
|
|
|
if (moveNode.data.jump) return false;
|
|
|
- if (inNode.data._id && type === "inner") {
|
|
|
- return true;
|
|
|
+ if (inNode.data.emrDocumentId && type === "inner") {
|
|
|
+ return inNode.data.type !== "category";
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -94,69 +99,126 @@ function isFiler(data) {
|
|
|
return data.type !== "group-category";
|
|
|
}
|
|
|
|
|
|
-const opt = [
|
|
|
- {
|
|
|
- name: "新建病历",
|
|
|
- click: data => {
|
|
|
- useDialog<any>(AddEmrDialog, {
|
|
|
- dialogProps: {
|
|
|
- title: `在【${data.name}】文件夹下面创建病历`,
|
|
|
- top: "2%",
|
|
|
+const getDirName = async (title: string): Promise<string> => {
|
|
|
+ return ElMessageBox.prompt("文件夹名称", title, {
|
|
|
+ type: "info",
|
|
|
+ inputErrorMessage: "名称不能为空",
|
|
|
+ inputPattern: /\S/,
|
|
|
+ }).then(({ value }) => {
|
|
|
+ return value;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const contextmenuItemV2 = (e, data) => {
|
|
|
+ e.preventDefault();
|
|
|
+ e.stopPropagation();
|
|
|
+
|
|
|
+ function createVerification() {
|
|
|
+ if (isCourse(data.code)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return !isFiler(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ const disabledChangeDir = data.data.parent === null;
|
|
|
+
|
|
|
+ ContextMenu.showContextMenu({
|
|
|
+ x: e.x,
|
|
|
+ y: e.y,
|
|
|
+ items: [
|
|
|
+ {
|
|
|
+ disabled: !createVerification(),
|
|
|
+ label: "新建文件夹",
|
|
|
+ onClick: async () => {
|
|
|
+ const name = await getDirName("新建文件夹");
|
|
|
+ await newDir({
|
|
|
+ parent: data.folderId,
|
|
|
+ patNo: patientInfo.value.inpatientNo,
|
|
|
+ times: patientInfo.value.admissTimes,
|
|
|
+ name: name,
|
|
|
+ });
|
|
|
+ emits("refresh");
|
|
|
},
|
|
|
- showConfirm: false,
|
|
|
- params: {
|
|
|
- templateData: [
|
|
|
- ...root.store.emrTemplate.value.emrTree,
|
|
|
- ...root.store.emrTemplate.value.deptTree,
|
|
|
- ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ disabled: !createVerification(),
|
|
|
+ label: "新建病历",
|
|
|
+ onClick: () => {
|
|
|
+ useDialog<any>(AddEmrDialog, {
|
|
|
+ dialogProps: {
|
|
|
+ title: `在【${data.name}】文件夹下面创建病历`,
|
|
|
+ top: "2%",
|
|
|
+ },
|
|
|
+ showConfirm: false,
|
|
|
+ params: {
|
|
|
+ templateData: [
|
|
|
+ ...root.store.emrTemplate.value.emrTree,
|
|
|
+ ...root.store.emrTemplate.value.deptTree,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ }).then(res => {
|
|
|
+ // @ts-ignore
|
|
|
+ emrMitt.emit("loadTemplate", { ...res, parent: data.folderId });
|
|
|
+ });
|
|
|
},
|
|
|
- }).then(res => {
|
|
|
- // @ts-ignore
|
|
|
- emrMitt.emit("loadTemplate", { ...res, parent: data.folderId });
|
|
|
- });
|
|
|
- },
|
|
|
- validator(data) {
|
|
|
- if (isCourse(data.code)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return !isFiler(data);
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: "打开(只读)",
|
|
|
- click: data => {
|
|
|
- if (!data.id) {
|
|
|
- xcMessage.error("请选中保存的病历。");
|
|
|
- return;
|
|
|
- }
|
|
|
- emrMitt.emit("只读病历", data.id);
|
|
|
- },
|
|
|
- icon: h(ElIcon, {}, () => h(Open)),
|
|
|
- validator: isFiler,
|
|
|
- },
|
|
|
- {
|
|
|
- name: "确认排序",
|
|
|
- click: () => {
|
|
|
- let temp = [];
|
|
|
- drag.forEach((value, key) => {
|
|
|
- if (value.newParent !== value.oldParent) {
|
|
|
- temp.push({ id: key, parent: value.newParent });
|
|
|
- }
|
|
|
- });
|
|
|
- if (temp.length === 0) {
|
|
|
- drag.clear();
|
|
|
- return xcMessage.error("文件夹没有变化,无需点击。");
|
|
|
- }
|
|
|
- electronicMedicalRecordSequencing(temp).then(() => {
|
|
|
- drag.clear();
|
|
|
- });
|
|
|
- },
|
|
|
- validator: () => {
|
|
|
- return drag.size > 0;
|
|
|
- },
|
|
|
- icon: h(ElIcon, {}, () => h(Sort)),
|
|
|
- },
|
|
|
-];
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "打开(只读)",
|
|
|
+ onClick: () => {
|
|
|
+ if (!data.id) {
|
|
|
+ xcMessage.error("请选中保存的病历。");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ emrMitt.emit("只读病历", data.id);
|
|
|
+ },
|
|
|
+ icon: h(ElIcon, {}, () => h(Open)),
|
|
|
+ disabled: !isFiler(data),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "确认排序",
|
|
|
+ onClick: () => {
|
|
|
+ let temp = [];
|
|
|
+ drag.forEach((value, key) => {
|
|
|
+ if (value.newParent !== value.oldParent) {
|
|
|
+ temp.push({ id: key, parent: value.newParent });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (temp.length === 0) {
|
|
|
+ drag.clear();
|
|
|
+ return xcMessage.error("文件夹没有变化,无需点击。");
|
|
|
+ }
|
|
|
+ electronicMedicalRecordSequencing(temp).then(() => {
|
|
|
+ drag.clear();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ disabled: drag.size === 0,
|
|
|
+ icon: h(ElIcon, {}, () => h(Sort)),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "修改文件夹名称",
|
|
|
+ onClick: async () => {
|
|
|
+ const name = await getDirName("重命名");
|
|
|
+ await rename(name, data.id);
|
|
|
+ emits("refresh");
|
|
|
+ },
|
|
|
+ disabled: disabledChangeDir,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "删除文件夹",
|
|
|
+ onClick: async () => {
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ "是否删除该文件夹,里面的病历并不会删除",
|
|
|
+ "删除",
|
|
|
+ { type: "error" }
|
|
|
+ );
|
|
|
+ await delDir(data.id);
|
|
|
+ emits("refresh");
|
|
|
+ },
|
|
|
+ disabled: disabledChangeDir,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+};
|
|
|
|
|
|
const contextmenuItem = (event, data) => {
|
|
|
let tempData = {
|
|
@@ -167,14 +229,10 @@ const contextmenuItem = (event, data) => {
|
|
|
name: data.name ? data.name : data.emrName,
|
|
|
parent: data.parent,
|
|
|
type: data.type,
|
|
|
- folderId: data.id,
|
|
|
+ folderId: data.emrDocumentId,
|
|
|
data: data,
|
|
|
};
|
|
|
- mousePosition.value = {
|
|
|
- event,
|
|
|
- index: 0,
|
|
|
- data: tempData,
|
|
|
- };
|
|
|
+ contextmenuItemV2(event, tempData);
|
|
|
};
|
|
|
|
|
|
const nullToEmpty = val => {
|
|
@@ -187,7 +245,6 @@ const fileName = val => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <right-click-menu :mouse-position="mousePosition" :config="opt" />
|
|
|
<div class="layout_container">
|
|
|
<div>
|
|
|
<el-input
|
|
@@ -203,7 +260,7 @@ const fileName = val => {
|
|
|
:data="props.treeData"
|
|
|
:props="defaultProps"
|
|
|
@node-click="handleNodeClick"
|
|
|
- node-key="_id"
|
|
|
+ node-key="emrDocumentId"
|
|
|
ref="treeRef"
|
|
|
draggable
|
|
|
@node-drag-end="dragEnd"
|