浏览代码

优化页面编辑,优化医嘱录入的提示

xiaochan 1 年之前
父节点
当前提交
fcb4d9c93f

+ 12 - 12
src/components/cy/cy-monaco-editor/CyMonacoEditor.tsx

@@ -169,7 +169,7 @@ interface CodeProps {
     testClick: (value: any, code: string) => boolean
 }
 
-export function cyCodeEditorDialog(props: CodeProps, dialogProps?: IsCyDialog) {
+export function CyCodeEditorDialog(props: CodeProps, dialogProps?: Partial<IsCyDialog>): Promise<string> {
     const codeRef = ref()
 
     function confirmClick(next: (arg0: any) => void) {
@@ -178,7 +178,7 @@ export function cyCodeEditorDialog(props: CodeProps, dialogProps?: IsCyDialog) {
         }
     }
 
-    const dialog = (
+    const Dialog = (
         <CyDialog
             bodyWidth='90%'
             bodyHeight='calc(100vh - 300px)'
@@ -196,8 +196,8 @@ export function cyCodeEditorDialog(props: CodeProps, dialogProps?: IsCyDialog) {
         </CyDialog>
     )
 
-    return new Promise(resolve => {
-        setDialogToJs(dialog, {}).then(res => {
+    return new Promise<string>(resolve => {
+        setDialogToJs(Dialog, {}).then(res => {
             resolve(res)
         }).catch(() => {
 
@@ -221,24 +221,24 @@ export function CyJsonEditorDialog<T extends object>(json: T | string,
         next(data)
     }
 
-    const dialog = (
+    const Dialog = (
         <CyDialog title='json编辑'
                   bodyHeight='50vh'
                   {...defaultProps}
                   confirmClick={confirmClick}
         >
-                  {{
-                      default: () => <JsonEditor
-                          ref={cyJsonEditorRef}
-                          data={json}
-                      />
-                  }}
+            {{
+                default: () => <JsonEditor
+                    ref={cyJsonEditorRef}
+                    data={json}
+                />
+            }}
 
         </CyDialog>
     )
 
     return new Promise(resolve => {
-        setDialogToJs(dialog, {data: json}).then((res) => {
+        setDialogToJs(Dialog, {data: json}).then((res) => {
             resolve(res)
         }).catch(() => {
 

+ 6 - 6
src/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/yz-edit/YzEditor.vue

@@ -461,11 +461,11 @@ const drugDefaultValue = async (isSearch: boolean, data: SearchOrdersType | YzTy
     // 使用默认的频率,如果有的话
     if (drugData.frequCode) {
       setYzData('frequCode', drugData.frequCode)
-      yzInfoPrompt.value.push('请注意已使用默认频率,药剂科维护默认执行频率。')
+      yzInfoPrompt.value.push('请注意已使用默认频率,药剂科维护默认执行频率。')
     }
     if (drugData.supplyCode) {
       setYzData('supplyCode', drugData.supplyCode)
-      yzInfoPrompt.value.push('请注意已使用默认给药方式,药剂科维护默认给药方式。')
+      yzInfoPrompt.value.push('请注意已使用默认给药方式,药剂科维护默认给药方式。')
     }
   }
 
@@ -518,10 +518,10 @@ const itemDefaultValue = (isSearch: boolean, data: SearchOrdersType | YzType) =>
   if (stringIsBlank(yiZhuData.value.frequCode)) {
     // 如果在临时医嘱页面的话,就变成临时的其他都是长期的
     if (queryParam.value.frequCode === frequCodeEnum.temporary) {
-      yzInfoPrompt.value.push('使用频率 ONCE')
+      yzInfoPrompt.value.push('使用频率 ONCE')
       setYzData('frequCode', 'ONCE')
     } else {
-      yzInfoPrompt.value.push(`使用频率 ${frequencyConfig}`)
+      yzInfoPrompt.value.push(`使用频率 ${frequencyConfig}`)
       setYzData('frequCode', frequencyConfig)
     }
   }
@@ -562,7 +562,7 @@ const defaultAll = async (isSearch: boolean, data: SearchOrdersType | YzType) =>
     setYzData('selfBuy', '4');
     setYzData('frequCode', 'ONCE');
     setYzData('supplyCode', '007');
-    yzInfoPrompt.value.push('请注意,出院带药频率默认 ONCE 给药方式变为出院带药。')
+    yzInfoPrompt.value.push('请注意,出院带药频率默认 ONCE 给药方式变为出院带药。')
   }
 
   if (yiZhuData.value.statusFlag !== '1' && yiZhuData.value.parentNo) {
@@ -575,7 +575,7 @@ const defaultAll = async (isSearch: boolean, data: SearchOrdersType | YzType) =>
 
   if (queryParam.value.frequCode === frequCodeEnum.temporary) {
     setYzData('frequCode', 'ONCE')
-    yzInfoPrompt.value.push('请注意,频率强制设置 ONCE')
+    yzInfoPrompt.value.push('请注意,频率强制设置 ONCE')
 
   }
 

+ 1 - 0
src/views/data-base/page-editor-help-v2/components/page-editor-v2/PageAddComponent.vue

@@ -27,6 +27,7 @@ function addComponentClick(item) {
 
   if (typeof props.store?.pageData.value.params[comp.key] === 'undefined') {
     props.store!.pageData.value.params[comp.key] = item.data.defaultValue ?? ''
+    props.store!.pageData.value.paramsDefaultValue[comp.key] = item.data.defaultValue ?? ''
   }
 
   emits('addComponent', comp)

+ 0 - 1
src/views/data-base/page-editor-help-v2/components/page-editor-v2/PageEditorV2.vue

@@ -1,6 +1,5 @@
 <script setup lang="ts">
 import {ref, nextTick} from "vue";
-import CyAutoSize from "@/components/cy/auto-size/cy-auto-size.vue";
 import PageHelpV2 from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageHelpV2.vue";
 import {pageHelpV2Mitt} from "@/views/data-base/page-editor-help-v2/page-help-v2";
 import {ReportForms} from "@/api/reports/report-query-center";

+ 56 - 10
src/views/data-base/page-editor-help-v2/components/page-editor-v2/PageFormBind.vue

@@ -6,7 +6,7 @@ import {
   PageStore
 } from "@/views/data-base/page-editor-help-v2/page-help-v2";
 import * as vue from "vue";
-import {h, nextTick, onMounted, ref} from "vue";
+import {h, nextTick, onMounted, ref, computed, Ref} from "vue";
 import {ElButton, ElDivider, ElInput, ElInputNumber, ElOption, ElSelect, ElSwitch} from "element-plus";
 import {PageHeader} from "@/api/reports/report-query-center";
 import {xcMessage} from "@/utils/xiaochan-element-plus";
@@ -15,7 +15,7 @@ import {copyStrFunc} from "@/utils/public";
 import {reportQueryCenterApi} from "@/api/base-data/report-center";
 import PageHelpOtherConfigurations
   from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageHelpOtherConfigurations.vue";
-import {cyCodeEditorDialog, CyJsonEditorDialog} from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
+import {CyCodeEditorDialog, CyJsonEditorDialog} from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
 import {useUserStore} from "@/pinia/user-store";
 
 const showDiv = ref(false)
@@ -29,6 +29,41 @@ const props = defineProps<{
 const userStore = useUserStore()
 const emits = defineEmits(['refresh', 'requiredChange'])
 
+const tmpKey = ref('')
+
+function handelKeyBlur() {
+  const {pageData} = props.store
+
+  pageData.value.params[tmpKey.value] = pageData.value.params[currentItem.value.key]
+  pageData.value.paramsDefaultValue[tmpKey.value] = pageData.value.paramsDefaultValue[currentItem.value.key]
+  currentItem.value.key = tmpKey.value
+
+  const keys = XEUtils.eachAndReturnList(pageData.value.header, (item) => {
+    return item.key
+  })
+
+  clearOtherKeys(keys, pageData.value.params)
+  clearOtherKeys(keys, pageData.value.paramsDefaultValue)
+}
+
+function clearOtherKeys(keys: string[], params: {}) {
+
+  const tmp = Object.keys(params)
+
+  const clearKey: string[] = [];
+  tmp.forEach(item => {
+    if (!keys.includes(item)) {
+      clearKey.push(item)
+    }
+  })
+
+  clearKey.forEach(item => {
+    //@ts-ignore
+    delete params[item]
+  })
+
+}
+
 const currentItem = ref<PageHeader>({
   key: "",
   compKey: "",
@@ -77,6 +112,7 @@ async function changeCurrentBind(item) {
     formFunc.value = bindData.value[item.name].func
   }
   onFuncHelp()
+  tmpKey.value = currentItem.value.key
   await nextTick()
   showDiv.value = true
 }
@@ -124,14 +160,14 @@ function render(key: string, item: ComponentBind) {
 
   const vModel = {
     modelValue: currentItem.value.bind[key],
-    "onUpdate:modelValue": (value) => {
+    "onUpdate:modelValue": (value: any) => {
       currentItem.value.bind[key] = value
     },
     ...getFunc()
   }
 
   function selectRender() {
-    const child = []
+    const child: any[] = []
     item.selectData?.forEach(value => {
       //@ts-ignore
       child.push(h(ElOption, {label: value, value: value}, () => null))
@@ -144,13 +180,13 @@ function render(key: string, item: ComponentBind) {
       activeValue: true,
       inactiveValue: false,
       ...vModel
-    }, null)
+    })
   }
 
   function inputRender() {
     return h(ElInput, {
       ...vModel
-    }, null)
+    })
   }
 
   function numberRender() {
@@ -163,7 +199,7 @@ function render(key: string, item: ComponentBind) {
       text: true,
       icon: 'Edit',
       onClick: () => {
-        CyJsonEditorDialog(currentItem.value?.bind[key]).then(res => {
+        CyJsonEditorDialog(currentItem.value?.bind[key], null).then(res => {
           currentItem.value!.bind[key] = res.json
         })
       }
@@ -193,13 +229,17 @@ function handleClickEdit(key: string, value: any, name: 'on' | 'func') {
   currentItem.value = pageData.value.header[currentClickIndex.value]
 
   if (!currentItem.value[name]) {
+    // @ts-ignore
     currentItem.value[name] = {}
   }
+  // @ts-ignore
   if (!currentItem.value[name][key]) {
+    // @ts-ignore
     currentItem.value[name][key] = ''
   }
 
-  cyCodeEditorDialog({
+  CyCodeEditorDialog({
+        // @ts-ignore
         code: currentItem.value[name][key],
         testClick: (value, code) => {
           const data = {
@@ -224,12 +264,14 @@ function handleClickEdit(key: string, value: any, name: 'on' | 'func') {
       {
         title: value.name
       }
-  ).then(res => {
+  ).then((res: string) => {
+    // @ts-ignore
     currentItem.value[name][key] = res
   })
 }
 
 function editStyleClick() {
+  // @ts-ignore
   CyJsonEditorDialog(currentItem.value.bind.style).then(res => {
     currentItem.value.bind.style = res.json
   })
@@ -238,6 +280,7 @@ function editStyleClick() {
 function exportJSON() {
   const temp = XEUtils.clone(currentItem.value)
   const bind = temp.bind
+  // @ts-ignore
   delete temp.bind
   const tempData = {
     bind: bind,
@@ -272,7 +315,10 @@ onMounted(() => {
       <el-form label-width="120px">
         <el-divider>主要</el-divider>
         <el-form-item label="key:">
-          <el-input v-model="currentItem.key" style="width: 80px"/>
+          <el-input
+              v-model="tmpKey"
+              @blur="handelKeyBlur"
+              style="width: 80px"/>
         </el-form-item>
         <el-form-item label="必填:">
           <el-switch v-model="currentItem.required" @change="emits('requiredChange')"/>

+ 15 - 27
src/views/data-base/page-editor-help-v2/page-help-v2.ts

@@ -4,19 +4,9 @@ import {Ref, ref} from 'vue'
 import XEUtils from "xe-utils";
 import {reportQueryCenterApi, saveTheFile} from "@/api/base-data/report-center";
 import * as ElementPlus from "element-plus";
-// @ts-ignore
-import XcComboGridV2 from "../../../components/xiao-chan/combo-grid/XcComboGridV2.vue";
-// @ts-ignore
-import CyComboGrid from "@/components/cy/combo-grid/src/CyComboGrid.vue";
 import {copyStrFunc} from "@/utils/public";
-// @ts-ignore
-import SystemDeptSelect from "@/components/system/dept-select/SystemDeptSelect.vue";
-// @ts-ignore
-import SystemStaffSelect from '@/components/system/staff-select/SystemStaffSelect.vue'
 import {xcMessage} from "@/utils/xiaochan-element-plus";
 import {CyJsonEditorDialog} from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
-// @ts-ignore
-import SystemItemDrug from "@/components/system/item-drug/SystemItemDrug.vue";
 
 interface TableData {
     data: any[],
@@ -25,11 +15,12 @@ interface TableData {
 
 export const ElAndXc = {
     ...ElementPlus,
-    XcComboGridV2: XcComboGridV2,
-    CyComboGrid: CyComboGrid,
-    SystemDeptSelect: SystemDeptSelect,
-    SystemStaffSelect: SystemStaffSelect,
-    SystemItemDrug: SystemItemDrug
+    XcComboGridV2: defineAsyncComponent(() => import('../../../components/xiao-chan/combo-grid/XcComboGridV2.vue')),
+    CyComboGrid: defineAsyncComponent(() => import('@/components/cy/combo-grid/src/CyComboGrid.vue')),
+    SystemDeptSelect: defineAsyncComponent(() => import('@/components/system/dept-select/SystemDeptSelect.vue')),
+    SystemStaffSelect: defineAsyncComponent(() => import('@/components/system/staff-select/SystemStaffSelect.vue')),
+    SystemItemDrug: defineAsyncComponent(() => import('@/components/system/item-drug/SystemItemDrug.vue')),
+    CyDateRange: defineAsyncComponent(() => import('@/components/cy/date-range/CyDateRange.vue'))
 }
 
 export const createFile = () => {
@@ -61,7 +52,7 @@ export interface PageHelpV2Mitt {
 
 
 export interface ComponentBind {
-    renderName: 'select' | 'boolean' | 'input' | 'number',
+    renderName: 'select' | 'boolean' | 'input' | 'number' | 'json',
     label: string,
     selectData?: string[],
     defaultValue: string | number | boolean,
@@ -115,19 +106,16 @@ export function usePageStore(props: any) {
 
     function handleSavaData() {
         const clone: PageJsonObject = XEUtils.clone(pageData.value, true)
-        if (XEUtils.isEmpty(clone.paramsDefaultValue)) {
-            defaultValue()
-            xcMessage.error('没有设置默认值。')
-            return
-        }
 
-        console.log(clone.paramsDefaultValue, clone.params)
-        if (Object.keys(clone.paramsDefaultValue).length !== Object.keys(clone.params).length) {
-            defaultValue()
-            xcMessage.error('有新增的组件没有创建默认值。')
-            return
-        }
+        for (let i = 0; i < clone.header.length; i++) {
+            const item = clone.header[i]
+            if (!XEUtils.has(clone.paramsDefaultValue, item.key)) {
+                defaultValue()
+                xcMessage.error('请设置默认值。')
+                return
+            }
 
+        }
         clone.params = {}
         clone.header.forEach(item => {
             if (item.name === 'ElSelectV2') {

+ 1 - 0
src/views/hospitalization/zhu-yuan-yi-sheng/comp/sidebar/YzSidebar.vue

@@ -43,5 +43,6 @@ import {yzInfoPrompt} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/
   width: 100%;
   padding: 5px;
   background: #eebe77;
+  word-wrap: break-word;
 }
 </style>