xiaochan 1 месяц назад
Родитель
Сommit
c0bd8c5956

+ 10 - 8
public/static/editor.html

@@ -42,6 +42,8 @@
   let handleSaveFunc = () => {
   };
 
+  let copy = false;
+
   function handleSave(cb) {
     handleSaveFunc = cb;
   }
@@ -74,23 +76,23 @@
   `,
     forced_root_block: "div",
     plugins: "table autoresize save",
-    toolbar: "save | undo redo | table | tablemergecells tablesplitcells | tableprops tablerowprops tablecellprops",
-    setup: function(editor) {
-      editor.on("keydown", function(e, ...tmp) {
-        console.log(e, tmp);
-        // handleEnter(e);
-      });
-    },
+    toolbar: "save | undo redo | table | tablemergecells tablesplitcells | tableprops tablerowprops tablecellprops | alignleft aligncenter alignright",
     save_onsavecallback: function() {
       const editor = tinymce.activeEditor;
       const table = editor.dom.select("table")[0];
       handleSaveFunc(table.outerHTML);
     },
     paste_preprocess: (plugin, args) => {
-      args.content = "";
+      if (!copy) {
+        args.content = "";
+      }
     },
   });
 
+  function changeCopy(value) {
+    copy = value;
+  }
+
   function addTable({ rows, cols }) {
     tinymce.activeEditor.execCommand("mceInsertTable", false, { rows: rows, columns: cols });
     tinymce.activeEditor.undoManager.clear();

+ 6 - 1
src/api/dashboardEditor/dashboardEditor.ts

@@ -9,14 +9,19 @@ export interface TDashboardTemplate {
   createCode: string; // createCode
   updateTime: Date; // updateTime
   updateCode: string; // updateCode
+  templateType: number;
 }
 
-export function getDashboardTemplateByWardCode(wardCode: string) {
+export function getDashboardTemplateByWardCode(
+  wardCode: string,
+  templateType: number
+) {
   return requestV2<TDashboardTemplate | null>({
     method: "get",
     url: "/dashboardEditor/getDashboardTemplateByWardCode",
     params: {
       wardCode,
+      templateType,
     },
   });
 }

+ 17 - 29
src/components/nursing-dashboard/RenderTable.vue

@@ -1,23 +1,22 @@
 <script setup lang="ts">
-import { magicApi } from "@/utils/database/magic-api-request";
 import { useResizeObserver } from "@vueuse/core";
 import { stringIsBlank } from "@/utils/blank-utils";
-import {
-  InpatientBoardKey,
-  type InpatientBoardType,
-} from "@/views/single-page/InpatientBoardV2/index";
 import XEUtils from "xe-utils";
 
 defineOptions({
   name: "RenderTable",
 });
 
-const root = inject(InpatientBoardKey) as InpatientBoardType;
-
-const props = defineProps<{
-  htmlData: string;
-  wardCode: string;
-}>();
+const props = withDefaults(
+  defineProps<{
+    htmlData: string;
+    query?: (business: string[]) => Promise<string>;
+    tableDisplay?: number;
+  }>(),
+  {
+    tableDisplay: 2,
+  }
+);
 
 const store = reactive({
   htmlData: "",
@@ -39,21 +38,9 @@ useResizeObserver(divRaf, () => {
 
 async function replace(query = true) {
   if (query) {
-    store.businessData = await magicApi({
-      url: "/public/dashboard/dataSource",
-      method: "post",
-      data: {
-        isSource: false,
-        business: Array.from(store.business.values()),
-        wardCode: props.wardCode,
-      },
-    })
-      .then(res => {
-        return res;
-      })
-      .catch(() => {
-        return {};
-      });
+    store.businessData = await props.query(
+      Array.from(store.business) as string[]
+    );
   }
 
   store.spans.forEach(item => {
@@ -87,9 +74,7 @@ async function replace(query = true) {
       td.innerHTML = "";
       td.appendChild(marqueeDiv);
 
-      const timePerCharacter = XEUtils.toNumber(
-        `${root.urlQuery.tableDisplay}`
-      );
+      const timePerCharacter = XEUtils.toNumber(`${props.tableDisplay}`);
       const totalCharacters = td.textContent.length;
       const totalDuration = totalCharacters * timePerCharacter;
 
@@ -152,6 +137,9 @@ defineExpose({
   reloadData() {
     renderTable();
   },
+  getBusiness() {
+    return store.business.values();
+  },
 });
 </script>
 

+ 7 - 1
src/views/settings/dashboard-editor/iframe-editor.vue

@@ -1,4 +1,6 @@
 <script setup lang="ts">
+import { isDev } from "@/utils/public";
+
 defineOptions({
   name: "iframeEditor",
 });
@@ -8,11 +10,15 @@ const emits = defineEmits(["save"]);
 const iframeRef = ref<HTMLIFrameElement>();
 
 function insertTable(rows: number, cols: number) {
-  iframeRef.value.contentWindow.addTable({ rows, cols });
+  iframeRef.value.contentWindow?.addTable({ rows, cols });
 }
 
 onMounted(() => {
   iframeRef.value.onload = async () => {
+    if (isDev) {
+      iframeRef.value.contentWindow.changeCopy(true);
+    }
+
     iframeRef.value.contentWindow.handleSave(htmlData => {
       emits("save", htmlData);
     });

+ 44 - 6
src/views/settings/dashboard-editor/index.vue

@@ -8,6 +8,8 @@ import * as api from "@/api/dashboardEditor/dashboardEditor";
 import { type TDashboardTemplate } from "@/api/dashboardEditor/dashboardEditor";
 import { BizException, ExceptionEnum } from "@/utils/BizException";
 import { stringIsBlank } from "@/utils/blank-utils";
+import SystemDeptSelect from "@/components/system/dept-select/SystemDeptSelect.vue";
+import { getDept } from "@/api/public-api";
 
 const dashboardEditorRef = useCompShallowRef(IframeEditor);
 
@@ -18,6 +20,8 @@ const store = reactive({
   wardList: [],
   currentTemplate: {} as null | TDashboardTemplate,
   collapseValue: "",
+  templateType: 0,
+  templateTypeList: [] as { code: number; name: string; url: string }[],
 });
 
 const tmpGroupDataSource = computed(() => {
@@ -32,8 +36,13 @@ const tmpGroupDataSource = computed(() => {
   return tmp;
 });
 
-async function handleWardChange(code) {
-  store.currentTemplate = await api.getDashboardTemplateByWardCode(code);
+async function handleWardChange() {
+  const { currentWard, templateType } = store;
+
+  store.currentTemplate = await api.getDashboardTemplateByWardCode(
+    currentWard,
+    templateType
+  );
   dashboardEditorRef.value.clearHtml();
   if (store.currentTemplate == null) {
     dashboardEditorRef.value.insertTable(17, 11);
@@ -44,9 +53,18 @@ async function handleWardChange(code) {
   }
 }
 
-onMounted(() => {
+function handleTemplateTypeChange() {
+  queryDataSource();
+  handleWardChange();
+}
+
+function queryDataSource() {
+  const tmp = store.templateTypeList.find(item => {
+    return item.code === store.templateType;
+  });
+
   magicApi({
-    url: "/public/dashboard/dataSource",
+    url: tmp.url,
     method: "post",
     data: { isSource: true },
   })
@@ -56,9 +74,20 @@ onMounted(() => {
     })
     .catch(() => {
       store.dataSource = [];
+      store.group = {};
     });
+}
 
-  getAllWards()
+onMounted(() => {
+  magicApi({
+    url: "/public/dashboard/getTemplateType",
+    method: "get",
+  }).then(res => {
+    store.templateTypeList = res;
+    queryDataSource();
+  });
+
+  getDept()
     .then(res => {
       store.wardList = res;
       store.wardList.unshift({
@@ -79,10 +108,12 @@ async function handleSave(htmlData) {
     store.currentTemplate = {
       wardCode: store.currentWard,
       htmlDataTemp: htmlData,
+      templateType: store.templateType,
     };
   } else {
     store.currentTemplate.htmlDataTemp = htmlData;
     store.currentTemplate.wardCode = store.currentWard;
+    store.currentTemplate.templateType = store.templateType;
   }
   store.currentTemplate = await api.saveTemplate(store.currentTemplate);
 }
@@ -133,9 +164,16 @@ defineOptions({
                 <xc-el-option :data="store.wardList" />
               </el-select>
             </el-form-item>
+            <el-form-item label="类型:">
+              <el-select
+                v-model="store.templateType"
+                @change="handleTemplateTypeChange"
+              >
+                <xc-el-option :data="store.templateTypeList" />
+              </el-select>
+            </el-form-item>
             <el-form-item>
               <el-button type="primary" @click="handleRelease">发布</el-button>
-              <el-button type="success" @click="handlePreview">预览</el-button>
             </el-form-item>
           </el-form>
         </header>

+ 22 - 2
src/views/single-page/InpatientBoardV2/BoardInfo.vue

@@ -3,8 +3,27 @@ import { SYSTEM_CONFIG } from "@/utils/public";
 import { InpatientBoardKey, type InpatientBoardType } from "./index";
 import BoardCard from "./BoardCard.vue";
 import RenderTable from "@/components/nursing-dashboard/RenderTable.vue";
+import { magicApi } from "@/utils/database/magic-api-request";
 
 const store = inject(InpatientBoardKey) as InpatientBoardType;
+
+async function handleQuery(business) {
+  return await magicApi({
+    url: "/public/dashboard/dataSource",
+    method: "post",
+    data: {
+      isSource: false,
+      business: business,
+      wardCode: store.urlQuery.ward,
+    },
+  })
+    .then(res => {
+      return res;
+    })
+    .catch(() => {
+      return {};
+    });
+}
 </script>
 
 <template>
@@ -45,12 +64,13 @@ const store = inject(InpatientBoardKey) as InpatientBoardType;
       <div class="右边宽度">
         <RenderTable
           :ref="
-            el => {
+            (el: any) => {
               store.renderTableRef.value = el;
             }
           "
+          :table-display="store.urlQuery.tableDisplay"
+          :query="handleQuery"
           :html-data="store.store.htmlData"
-          :ward-code="store.urlQuery.ward"
         />
       </div>
     </div>