Browse Source

优化操作以及代码

DESKTOP-MINPJAU\Administrator 3 years ago
parent
commit
2249c6fd56

+ 7 - 3
src/components/xc/select/XcSelect.vue

@@ -2,8 +2,7 @@
   <el-select v-model="modelObj" :clearable="props.clearable"
              :remote="props.remote" :remote-method="xcMethod"
              :style="{width: props.width + 'px'}"
-             ref="xcselect"
-             filterable @change="changeStaff" @clear="clear">
+             ref="xcselect" filterable @change="changeStaff" @clear="clear" @focus="getFocus">
     <el-option v-for="(item,index) in props.data" :key="item.index"
                :label="item.name"
                :value="{value:item.code,label:item.name}">
@@ -51,7 +50,7 @@ const props = defineProps({
   }
 })
 
-const emit = defineEmits(['method', 'change'])
+const emit = defineEmits(['method', 'change', 'focus'])
 
 let modelObj = $ref({
   value: '',
@@ -88,6 +87,10 @@ const xcMethod = debounce(value => {
   }
 }, 400)
 
+const getFocus = () => {
+  emit('focus')
+}
+
 /**
  * 监听父组件的值是否改变
  * 如果改变了那么就,要执行查询动作
@@ -136,6 +139,7 @@ const method = (value) => {
 const focus = () => {
   xcselect.focus()
 }
+
 defineExpose({focus})
 
 onMounted(() => {

+ 14 - 1
src/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/SouSuoYiZhu.vue

@@ -54,6 +54,7 @@ import {computed, ref} from "vue";
 import store from "@/store";
 import YaoPingXiangQing from "@/components/zhu-yuan-yi-sheng/he-li-yong-yao/YaoPingXiangQing.vue";
 import Sleep from "element-plus/packages/test-utils/sleep";
+import {xcHotKey} from "@/utils/xckeydown";
 
 const emit = defineEmits(['xuanZhongFeiYong', 'close'])
 
@@ -69,6 +70,7 @@ const orderData = ref({
   data: [],
 })
 
+
 const dianJiChaXunYiZhu = () => {
   huoQuXiangMu(orderName.value).then((res) => {
     orderData.value.data = res
@@ -85,8 +87,19 @@ let yaoPinXiangQing = $ref({
   code: '',
 })
 
-const hotKey = () => {
+const direction = (val) => {
+  console.log(val)
+}
+const enter = () => {
+  console.log(123)
+}
 
+let registerShortcuts = {
+  alt: {'direction': direction, 'enter': enter}
+}
+
+const hotKey = () => {
+  xcHotKey(registerShortcuts)
 }
 
 onMounted(async () => {

+ 23 - 0
src/utils/xckeydown.js

@@ -1,4 +1,6 @@
 let registerShortcuts = null
+const direction = ['ArrowRight', 'ArrowLeft', 'ArrowDown', 'ArrowUp']
+
 
 export const xcHotKey = (keyList) => {
     registerShortcuts = keyList
@@ -9,6 +11,7 @@ export const xcHotKey = (keyList) => {
 
 export const logoutShortcut = () => {
     document.onkeydown = null
+    registerShortcuts = null
 }
 
 /**
@@ -24,7 +27,27 @@ const shortcutTrigger = (event) => {
             if (event[pressSimultaneously] && event.key === key) {
                 event.returnValue = false
                 data[key]()
+                return
+            }
+            if (key === 'direction') {
+                if ((event[pressSimultaneously] && direction.includes(event.code))) {
+                    event.returnValue = false
+                    data['direction'](event.key)
+                    return
+                }
             }
+            if (key === 'number') {
+                if (event[pressSimultaneously] && event.code === ('Digit' + event.key)) {
+                    event.returnValue = false
+                    data['number'](event.key)
+                    return
+                }
+            }
+        }
+        if (listKey === event.key) {
+            event.returnValue = false
+            registerShortcuts[listKey]()
+            return
         }
     }
 }

+ 5 - 2
src/views/hospitalization/zhu-yuan-yi-sheng/yi-zhu-lu-ru/TianJiaYiZhu.vue

@@ -220,8 +220,7 @@
                        :value="item.code">
               <span style="color: #8492a6; font-size: 12px">{{ item.code }}</span>
               <el-divider direction="vertical"></el-divider>
-              <span>{{ item.name }}</span></el-option
-            >
+              <span>{{ item.name }}</span></el-option>
           </el-select>
         </el-form-item>
       </el-col>
@@ -229,6 +228,7 @@
   </el-form>
   <el-button icon="el-icon-plus" type="primary" @click="tianJiaYiZhu">添加</el-button>
   <xc-code code="Ctrl+S" description="键盘添加"></xc-code>
+  <xc-code code="Ctrl+f" description="打开搜索框"></xc-code>
   <el-button @click="dianJiXiuGaiZhiXingKeShi">修改执行科室</el-button>
   <el-table :data="yiZhuList" :height="windowSize.h / 2.4" @selection-change="dianJiXuanZhongShuJu">
     <el-table-column type="selection"></el-table-column>
@@ -463,6 +463,9 @@ const xuanZhongFeiYong = async (row) => {
           if (stringNotBlank(res.paiChiYiZhu)) {
             tiShiBiaoTi.value.push({title: res.paiChiYiZhu, type: 'error'})
           }
+          if (!res.dose) {
+            yiZhuData.value.dose = 1
+          }
         })
         .catch((e) => {
           setTimeout(() => {

+ 4 - 3
src/views/hospitalization/zhu-yuan-yi-sheng/yi-zhu-lu-ru/YiZhuLuRu.vue

@@ -184,6 +184,7 @@ import store from '@/store'
 import {stringIsBlank, stringNotBlank} from '@/utils/blank-utils'
 import {getServerDateApi, getTheTransferList} from '@/api/public-api'
 import router from '@/router'
+import Sleep from "element-plus/packages/test-utils/sleep";
 
 const windowSize = computed(() => {
   return store.state.app.windowSize
@@ -392,9 +393,9 @@ const dianJiFuZhuXuanZhongYiZhu = () => {
 }
 
 onMounted(async () => {
-  // setTimeout(() => {
-  //   addYiZhuClick()
-  // }, 300)
+  setTimeout(() => {
+    addYiZhuClick()
+  }, 300)
   zkList.value = await getTheTransferList()
 })