Browse Source

优化项目

DESKTOP-MINPJAU\Administrator 3 years ago
parent
commit
719ed94e6a

+ 4 - 0
src/api/public-api.js

@@ -116,6 +116,10 @@ export function getBldCat(name) {
     });
 }
 
+/**
+ * 获取 获取转科列表
+ * @returns {*}
+ */
 export function getTheTransferList() {
     return request({
         url: '/publicApi/getTheTransferList',

+ 1 - 0
src/components/index.ts

@@ -2,3 +2,4 @@ export {default as XcSelect} from '../components/xc/select/XcSelect.vue'
 export {default as XcOption} from '../components/xc/select/XcOption.vue'
 export {default as XcCode} from '../components/xc/code/XcCode.vue'
 export {default as InputAndTable} from '../components/input-table-query/InputAndTable.vue'
+export {default as XcSelectV2} from '../components/xc/select-v2/XcSelectV2.vue'

+ 0 - 80
src/components/xc/select-v2/TestElSelectV2.vue

@@ -1,80 +0,0 @@
-<template>
-  <el-select v-model="props.modelValue" placeholder="Select" ref="select" @visible-change="visible"
-             :teleported="false">
-    <el-option
-        v-for="item in listData"
-        :key="item.value"
-        :label="item.label"
-        :value="item.value"
-    >
-      <span>{{ item.label }}</span>
-      <span>{{ item.value }}</span>
-    </el-option>
-  </el-select>
-</template>
-
-<script setup name='TestElSelectV2'>
-const props = defineProps({
-  modelValue: {
-    type: String,
-    default: ''
-  },
-  data: {
-    type: Array,
-  }
-})
-
-let select = $ref(null)
-
-const itemHeight = 34
-let start = $ref(0)
-const containerHeight = 274
-const itemCount = Math.ceil(containerHeight / itemHeight)
-let translateY = $ref(0)
-
-const listData = computed(() => {
-  return props.data.slice(start, start + itemCount + 1)
-})
-
-watch(
-    () => props.data,
-    () => {
-
-    },
-    {immediate: true, deep: true}
-)
-
-onMounted(() => {
-  nextTick(() => {
-    let dropdownList = select.$el.querySelectorAll('.el-select-dropdown .el-select-dropdown__wrap')[0]
-    let ul = dropdownList.querySelectorAll('ul')[0]
-    ul.style.height = props.data.length * 37 + 'px'
-
-    // ul
-    // dropdownList.addEventListener('scroll', e => {
-    //   const {scrollTop} = e.target
-    //   start = Math.floor(scrollTop / itemHeight)
-    //   console.log(start)
-    // })
-
-  })
-})
-
-
-const visible = (val) => {
-  // console.log(option)
-  let dropdownList = select.$el.querySelectorAll('.el-select-dropdown .el-select-dropdown__wrap')[0]
-  let ul = dropdownList.querySelectorAll('ul')[0]
-  dropdownList.addEventListener('scroll', e => {
-    const {scrollTop} = e.target
-    ul.style.transform = `translateY(${scrollTop}px)`
-    start = Math.floor(scrollTop / itemHeight)
-  })
-}
-
-
-</script>
-
-<style scoped>
-
-</style>

+ 178 - 0
src/components/xc/select-v2/VirtualizationSelect.vue

@@ -0,0 +1,178 @@
+<template>
+  <div v-if="props.dataLength === 0" class="nullData">
+    暂无数据
+  </div>
+  <div v-else class="container" ref="container"
+       :style="{ height: containerHeight + 'px' }">
+    <div class="empty" :style="{ height: emptyHeight + 'px' }"></div>
+    <ul class="list" :style="{ transform: `translateY(${translateY})` }">
+      <li v-for="(item,index) in listData"
+          @click="clickLi(item,index)" :key="item" class="item"
+          :style="styleToLi(item,index)">
+        <slot :item="item"></slot>
+      </li>
+    </ul>
+  </div>
+</template>
+
+<script setup name="VirtualizationSelect">
+import {functionDebounce} from "@/utils/debounce";
+
+const props = defineProps({
+  modelValue: {
+    type: Number
+  },
+  data: {
+    type: Array,
+    default: []
+  },
+  value: {
+    type: String,
+    default: '',
+  },
+  dataLength: {
+    type: Number,
+    default: 0
+  },
+  localSearch: {
+    type: Boolean,
+    default: false
+  }
+})
+
+const emit = defineEmits(['change', 'update:modelValue'])
+
+const itemHeight = 34
+
+let emptyHeight = $ref(itemHeight * props.dataLength)
+
+// const emptyHeight = computed(() => {
+//   return itemHeight * props.dataLength
+// })
+
+let containerHeight = $ref(~~(props.dataLength * 34))
+
+
+const itemCount = computed(() => {
+  return Math.ceil(containerHeight / itemHeight)
+})
+
+const container = ref(null)
+const start = ref(0)
+const translateY = ref(0)
+
+const listData = computed(() => {
+  return props.data.slice(start.value, start.value + itemCount.value + 1)
+})
+
+const clickLi = async (item, index) => {
+  await emit('update:modelValue', start.value + index);
+  await emit('change', item)
+}
+
+const selectedDataSubscript = (idx) => {
+  try {
+    container.value.scrollTop = idx * itemHeight;
+  } catch (e) {
+    // console.error(e)
+  }
+}
+
+const styleToLi = (item, index) => {
+  if (props.value === item.value) {
+    return {
+      height: itemHeight + 'px',
+      backgroundColor: '#409EFF',
+      color: '#ffffff'
+    };
+  } else if (start.value + index === props.modelValue) {
+    return {
+      height: itemHeight + 'px',
+      backgroundColor: '#909399',
+      color: '#ffffff'
+    }
+  } else {
+    return {
+      height: itemHeight + 'px',
+    };
+  }
+}
+
+const enableScrollBar = functionDebounce(() => {
+  try {
+    container.value.addEventListener('scroll', e => {
+      const {scrollTop} = e.target
+      start.value = Math.floor(scrollTop / itemHeight)
+      translateY.value = scrollTop + 'px'
+    })
+  } catch (e) {
+  }
+}, 200)
+
+
+const resetData = () => {
+  emptyHeight = itemHeight * props.dataLength
+  containerHeight = emptyHeight > 300 ? 300 : emptyHeight
+  start.value = 0
+  translateY.value = 0 + 'px'
+  emit('update:modelValue', 0)
+  container.value.scrollTop = 0
+}
+
+defineExpose({selectedDataSubscript, $el: container, enableScrollBar, resetData})
+
+
+</script>
+<style scoped lang="scss">
+
+.nullData {
+  padding: 10px 0;
+  margin: 0;
+  text-align: center;
+  color: var(--el-text-color-secondary);
+  font-size: var(--el-select-font-size);
+}
+
+.container {
+  overflow: auto;
+  display: flex;
+  width: 100%;
+  direction: rtl;
+
+
+  ul {
+    list-style: none;
+    margin: 0;
+    width: 100%;
+    padding: 0;
+    direction: ltr;
+
+    .item {
+      font-size: var(--el-font-size-base);
+      padding: 0 32px 0 20px;
+      position: relative;
+      white-space: nowrap;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      color: var(--el-text-color-regular);
+      height: 34px;
+      line-height: 34px;
+      box-sizing: border-box;
+      cursor: pointer;
+      width: 100%;
+    }
+
+    .checked {
+      background-color: #4e91f8;
+      color: white;
+    }
+
+    .item:hover {
+      background-color: #fac44d;
+      color: white;
+    }
+  }
+}
+
+
+</style>

+ 346 - 0
src/components/xc/select-v2/XcSelectV2.vue

@@ -0,0 +1,346 @@
+<template>
+  <div class="xc-select-v2_main" @mousedown="stopLosingFocus($event)" ref="xcSelectV2Main">
+    <el-input ref="xcInput" @input="inputChange" v-model="label"
+              @blur="loseFocus"
+              :placeholder="placeholder"
+              @keydown.up.stop.prevent="onKeyboardNavigate('up')"
+              @keydown.down.stop.prevent="onKeyboardNavigate('down')"
+              @keydown.enter.stop.prevent="onKeyboardSelect"
+              @keydown.esc.stop.prevent="handleEsc"
+              @click="isShow = !isShow" @focus="getFocus">
+      <template #suffix>
+        <el-icon class="finger"
+                 @mouseenter="isClearable = true"
+                 @mouseleave="isClearable = false">
+            <span v-if="isClearable && props.clearable && props.modelValue[props.value]">
+              <CircleClose @click="clear"/>
+            </span>
+          <span v-else>
+              <ArrowUp v-show="isShow" @mousedown="clickIcon($event,false)"/>
+              <ArrowDown v-show="!isShow" @mousedown="clickIcon($event,true)"/>
+            </span>
+        </el-icon>
+      </template>
+    </el-input>
+    <transition name="el-zoom-in-top">
+      <div v-show="isShow" class="xc-select-v2" :style="inputStyle">
+        <VirtualizationSelect :data="props.data" @change="change"
+                              :value="props.modelValue[props.value]"
+                              v-model="selectedSubscript"
+                              :local-search="whetherToSearchLocally"
+                              ref="selectItem" :data-length="dataLenght">
+          <template #default="{item}">
+            {{ item.value }}
+            {{ item.label }}
+          </template>
+        </VirtualizationSelect>
+      </div>
+    </transition>
+  </div>
+</template>
+
+<script setup name='XcSelectV2'>
+import {debounce} from "@/utils/debounce";
+import VirtualizationSelect from './VirtualizationSelect.vue'
+import sleep from "@/utils/sleep";
+import {nextTick} from "vue";
+
+const props = defineProps({
+  modelValue: {
+    type: Object,
+  },
+  value: {
+    type: String,
+    default: 'code'
+  },
+  label: {
+    type: String,
+    default: 'name'
+  },
+  data: {
+    type: Array,
+    default: []
+  },
+  clearable: {
+    type: Boolean,
+    default: false
+  },
+  remoteMethod: {
+    type: Function,
+    default: null
+  },
+  maxCache: {
+    type: Number,
+    default: 100,
+  },
+  id: {
+    type: String,
+    default: 'id'
+  }
+})
+
+const emit = defineEmits(['change'])
+
+let label = $ref('')
+let isGetFocus = $ref(false)
+let tempMap = new Map()
+let selectItem = $ref(null)
+let xcInput = $ref(null)
+let top = $ref(22)
+let selectedSubscript = $ref(0)
+let dataLenght = $ref(0)
+let isClearable = $ref(false)
+let inputStyle = $ref({
+  top: 22,
+  width: 120
+})
+let xcSelectV2Main = $ref()
+let whetherToSearchLocally = $ref(!props.remoteMethod)
+
+let isShow = $ref(false)
+
+let placeholder = computed(() => {
+  if (!label) {
+    return props.modelValue[props.label] ? props.modelValue[props.label] : '请选择'
+  }
+})
+
+const clickIcon = async (e, val) => {
+  e.preventDefault()
+  isShow = val
+  await sleep(100)
+}
+
+const inputChange = debounce(value => {
+  if (value) {
+    method(value);
+  }
+}, 1000)
+
+
+const onKeyboardNavigate = (val) => {
+  if (val === 'up') {
+    selectedSubscript - 1 < 0 ? selectedSubscript = dataLenght - 1 : selectedSubscript -= 1
+  } else if (val === 'down') {
+    selectedSubscript + 1 > dataLenght - 1 ? selectedSubscript = 0 : selectedSubscript += 1
+  }
+  selectItem.selectedDataSubscript(selectedSubscript)
+}
+
+const onKeyboardSelect = () => {
+  if (isShow) {
+    change(props.data[selectedSubscript]);
+  } else {
+    isShow = true
+  }
+
+}
+
+const handleEsc = () => {
+  isShow = false
+}
+
+const method = (val) => {
+  if (props.remoteMethod) {
+    props.remoteMethod(val)
+  }
+}
+
+const change = async (data) => {
+  if (data) {
+    tempMap[data.value] = data
+    props.modelValue[props.value] = data.value
+    props.modelValue[props.label] = data.label
+    label = data.label
+    emit('change', data)
+    await sleep(200)
+    isShow = false
+  }
+}
+
+const clear = () => {
+  props.modelValue[props.value] = ''
+  props.modelValue[props.label] = ''
+}
+
+const stopLosingFocus = (e) => {
+  // 阻止失去焦点
+  e.preventDefault()
+  xcInput.focus()
+}
+
+const getFocus = async () => {
+  await sleep(100)
+  if (!isShow) {
+    isShow = true
+  }
+  label = ''
+  isGetFocus = true
+}
+
+const loseFocus = async () => {
+  label = props.modelValue[props.label]
+  await sleep(100)
+  isShow = false
+  isGetFocus = false
+}
+
+const focus = () => {
+  xcInput.focus()
+}
+
+const blur = () => {
+  xcInput.focus()
+}
+
+defineExpose({focus, blur})
+
+const selectItemResetData = async () => {
+  try {
+    await selectItem.resetData()
+  } catch (e) {
+    console.log(e)
+  }
+}
+
+const selectItemEnableScrollBar = async () => {
+  try {
+    await selectItem.enableScrollBar()
+  } catch (e) {
+    // console.log(e)
+  }
+}
+
+
+const valueChange = async () => {
+  dataLenght = props.data.length
+  await nextTick()
+  await selectItemResetData()
+  await selectItemEnableScrollBar()
+  if (isGetFocus) {
+    return;
+  }
+  let val = props.modelValue[props.value]
+  if (val) {
+    // 在 数据中寻找 找到里就没有必要在找了
+    for (let i = 0; i < dataLenght; i++) {
+      let data = props.data[i];
+      if (data.value === val) {
+        props.modelValue[props.value] = data.value
+        props.modelValue[props.label] = data.label
+        label = data.label
+        selectedSubscript = i
+        return;
+      }
+    }
+
+    if (props.modelValue[props.value] && props.modelValue[props.label]) {
+      label = props.modelValue[props.label]
+      props.data.push({
+        value: props.modelValue[props.value],
+        label: props.modelValue[props.label]
+      })
+      return;
+    }
+
+    if (!props.modelValue[props.label]) {
+      label = props.modelValue[props.value]
+    }
+    await method(props.modelValue[props.value])
+  } else {
+    label = props.modelValue[props.value]
+  }
+}
+
+watch(
+    () => props.modelValue[props.value],
+    (newValue, oldValue) => {
+      valueChange()
+    },
+    {immediate: true, deep: true}
+)
+
+watch(
+    () => props.data,
+    async () => {
+      valueChange()
+    },
+    {immediate: true, deep: true}
+)
+
+
+watch(
+    () => isShow,
+    () => {
+      if (isShow && dataLenght > 0) {
+        nextTick(() => {
+          if (!props.data[selectedSubscript].value === props.modelValue[props.value]) {
+            for (let i = 0; i < dataLenght; i++) {
+              let data = props.data[i];
+              if (data.value === props.data[selectedSubscript].value) {
+                selectedSubscript = i
+                try {
+                  selectItem.selectedDataSubscript(i)
+                } catch (e) {
+                }
+                return;
+              }
+            }
+          } else {
+            selectItem.selectedDataSubscript(selectedSubscript)
+          }
+          let docInput = xcInput.input
+          let inputTop = docInput.getBoundingClientRect().top
+          let inputLeft = docInput.getBoundingClientRect().left
+          let selectBox = selectItem.$el
+          const {innerWidth: windowWidth, innerHeight: windowHeight} = window;
+          selectBox.style.direction = 'rtl'
+          if (inputLeft + selectBox.clientWidth > innerWidth) {
+            inputStyle['right'] = xcSelectV2Main.clientWidth + 'px'
+            inputStyle['top'] = 0 - (selectBox.clientHeight / 2) + 'px'
+            selectBox.style.direction = 'ltr'
+          }
+          if (inputTop + 320 >= innerHeight) {
+            inputStyle['top'] = 0 - (selectBox.clientHeight) + 'px'
+          }
+        });
+      }
+    }
+)
+
+onMounted(() => {
+  nextTick(() => {
+    let docInput = xcInput.input
+    inputStyle = {
+      top: docInput.scrollHeight + 5 + 'px',
+      minWidth: docInput.scrollWidth + 15 + 'px',
+      minHeight: '40px'
+    }
+  })
+})
+
+</script>
+
+<style lang="scss">
+.xc-select-v2_main {
+  position: relative;
+  display: inline-block;
+
+  .xc-select-v2 {
+    box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
+    border-radius: 5px;
+    display: flex;
+    position: absolute;
+    flex-direction: column;
+    z-index: 1000;
+    top: 28px;
+    background-color: white;
+  }
+
+  .finger:hover {
+    cursor: pointer; //悬浮时变手指
+  }
+}
+
+
+</style>

+ 2 - 1
src/components/xc/select/XcSelect.vue

@@ -2,7 +2,8 @@
   <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" @focus="getFocus">
+             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}">

+ 9 - 34
src/components/zhu-yuan-yi-sheng/shou-shu-shen-qing/BianJiShouShu.vue

@@ -50,15 +50,15 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item label="术前诊断" prop="diagBeforeOpObj">
+          <el-form-item label="术前诊断" prop="diagBeforeCode">
             <!--    TODO  v2 选择器中我绑定了 value 是对象记得搞      -->
-            <el-select-v2 v-model="data.diagBeforeOpObj"
-                          :options="shouShuZhenDuan"
-                          filterable
-                          remote
-                          value-key="value"
-                          :remote-method="souSuoZhenDuan"
-                          size="small"/>
+            <XcSelectV2
+                v-model="data"
+                :data="shouShuZhenDuan"
+                value="diagBeforeCode"
+                label="diagBeforeOp"
+                :remote-method="souSuoZhenDuan"
+            />
             <el-switch
                 v-model="zhenDuanLaiYuan"
                 :active-value="true"
@@ -68,24 +68,6 @@
                 inactive-color="#ff4949"
                 inactive-text="本院">
             </el-switch>
-
-            <!--            <el-select v-model="data.diagBeforeOpObj" :remote-method="souSuoZhenDuan" clearable filterable remote-->
-            <!--                       style="width: 220px" @change="huoQuXialaKuangMing">-->
-            <!--              <el-pagination-->
-            <!--                  :current-page="zhenDuanDangQianYe"-->
-            <!--                  :page-size="20"-->
-            <!--                  :pager-count="7"-->
-            <!--                  :total="shouShuZhenDuan.length"-->
-            <!--                  layout="total,  prev, pager, next"-->
-            <!--                  @current-change="zhenDuanFanYe">-->
-            <!--              </el-pagination>-->
-            <!--              <el-option v-for="item in shouShuZhenDuan.slice((zhenDuanDangQianYe - 1) * 20,zhenDuanDangQianYe * 20)"-->
-            <!--                         :key="item.code" :label="item.name" :value="{label:item.name,value:item.code,laiYuan:'术前诊断'}">-->
-            <!--                <span style="color: #8492a6; font-size: 12px">{{ item.code }}</span>-->
-            <!--                <el-divider direction="vertical"></el-divider>-->
-            <!--                <span>{{ item.name }}</span>-->
-            <!--              </el-option>-->
-            <!--            </el-select>-->
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -330,12 +312,7 @@ export default {
     const souSuoZhenDuan = (val) => {
       if (val.length > 1) {
         huoQuLinChuangZhenDuan(val, zhenDuanLaiYuan.value).then(res => {
-          res.forEach(item => {
-            let temp = {value: item.value, label: item.label}
-            item.value = temp
-          })
           shouShuZhenDuan.value = res
-          console.log(shouShuZhenDuan.value)
         })
       }
     }
@@ -418,7 +395,7 @@ export default {
       applyDate: [{required: true, message: '申请时间不能为空', trigger: 'blur'}],
       opDatetime: [{required: true, message: '手术时间不能为空', trigger: 'blur'},
         {validator: shenQingShiJian, trigger: 'blur'}],
-      diagBeforeOpObj: [{required: true, message: '术前诊断不能为空', trigger: 'blur'}],
+      diagBeforeCode: [{required: true, message: '术前诊断不能为空', trigger: 'blur'}],
       partCodeObj: [{required: true, message: '手术部位不能为空', trigger: 'blur'}],
       doctorZdObj: [{required: true, message: '主刀医生不能为空', trigger: 'blur'}],
       opScale: [{required: true, message: '手术等级不能为空', trigger: 'blur'}],
@@ -426,8 +403,6 @@ export default {
 
 
     const jiaoYanShuJu = async () => {
-      data.value.diagBeforeCode = data.value.diagBeforeOpObj.value
-      data.value.diagBeforeOp = data.value.diagBeforeOpObj.label
       const form = unref(shouShuBiaoGe);
       if (!form) return
       try {

+ 11 - 1
src/utils/debounce.js

@@ -16,4 +16,14 @@ export function debounce(cb, delay) {
     }
 }
 
-0
+export function functionDebounce(cb, delay) {
+    let timer
+    return function () {
+        if (timer) {
+            clearTimeout(timer)
+        }
+        timer = setTimeout(() => {
+            cb.call(this)
+        }, delay)
+    };
+}

+ 10 - 33
src/views/hospitalization/zhu-yuan-yi-sheng/jian-cha-jian-yan-shen-qing/BianJiJianChaJianYanShenQing.vue

@@ -64,14 +64,13 @@
         </el-col>
         <el-col v-if="jianCha" :span="12">
           <el-form-item class="bi_tian" label="临床诊断:" prop="diagCode">
-            <!--    TODO  v2 选择器中我绑定了 value 是对象记得搞      -->
-            <el-select-v2 v-model="bianJiJianChaShuJu.diagCodeObj"
-                          :options="linChuangZhenDuanShuJu"
-                          filterable
-                          remote
-                          :remote-method="linChuangZhenDuanSuoSou"
-                          @change="huoQuXiangXiZhenDuan"
-                          size="small"/>
+            <XcSelectV2
+                v-model="bianJiJianChaShuJu"
+                :data="linChuangZhenDuanShuJu"
+                :remote-method="linChuangZhenDuanSuoSou"
+                value="diagCode"
+                label="diagText"
+            />
           </el-form-item>
         </el-col>
         <el-col v-if="jianCha" :span="12">
@@ -129,7 +128,6 @@ import {ElMessage} from 'element-plus'
 import {stringIsBlank, stringNotBlank} from '@/utils/blank-utils'
 import {biaoBenApi, huoQuLinChuangZhenDuan} from '@/api/zhu-yuan-yi-sheng/jian-yan-jian-cha-shen-qing'
 import {logoutShortcut, xcHotKey} from '@/utils/xckeydown'
-import {clone} from "@/utils/clone";
 
 const props = defineProps({
   jianCha: {
@@ -191,17 +189,6 @@ const daKaiBenDuiHua = async (val, xiaBiao, zhongShu) => {
   count.value = zhongShu
   bianJiJianChaShuJu.value = val
 
-  if (stringNotBlank(val.diagCode)) {
-    let index = linChuangZhenDuanShuJu.value.findIndex(item => {
-      return item.key === val.diagCode
-    })
-    if (index === -1) {
-      linChuangZhenDuanShuJu.value.push({
-        value: JSON.stringify({value: val.diagCode, label: val.diagText}),
-        label: val.diagText
-      });
-    }
-  }
   if (!props.jianCha) {
     if (stringNotBlank(val.inspectStuff)) {
       let index = biaoBenShuJu.value.findIndex(item => {
@@ -237,19 +224,9 @@ let options = $ref([])
  * @param val
  */
 const linChuangZhenDuanSuoSou = (val) => {
-  if (stringNotBlank(val) && val.length > 1) {
-    huoQuLinChuangZhenDuan(val, zhenDuanLaiYuan.value).then((res) => {
-      linChuangZhenDuanShuJu.value = res
-    })
-  }
-}
-
-const huoQuXiangXiZhenDuan = (val) => {
-  if (val) {
-    let data = JSON.parse(val)
-    bianJiJianChaShuJu.value.diagText = data.label
-    bianJiJianChaShuJu.value.diagCode = data.value
-  }
+  huoQuLinChuangZhenDuan(val, zhenDuanLaiYuan.value).then((res) => {
+    linChuangZhenDuanShuJu.value = res
+  })
 }
 
 const bianJiFenYe = async (val) => {

+ 43 - 16
src/views/hospitalization/zhu-yuan-yi-sheng/yi-zhu-lu-ru/TianJiaYiZhu.vue

@@ -38,8 +38,15 @@
       </el-col>
       <el-col :span="span">
         <el-form-item class="bi_tian" label="频率:" prop="frequCode">
-          <XcSelect v-model="yiZhuData" :data="yaoPinPingLvData" :name="['frequCode', 'frequCodeName']" clearable remote
-                    @method="pinLvRemoteMethod" ref="pingLv"></XcSelect>
+          <XcSelectV2
+              style="width: 120px"
+              v-model="yiZhuData"
+              :data="yaoPinPingLvData"
+              value="frequCode"
+              label="frequCodeName"
+              :remote-method="pinLvRemoteMethod"
+              ref="pingLv"
+          />
         </el-form-item>
       </el-col>
       <el-col :span="span">
@@ -58,8 +65,15 @@
       </el-col>
       <el-col :span="span">
         <el-form-item class="bi_tian" label="给药方式:" prop="supplyCode">
-          <XcSelect v-model="yiZhuData" :data="geiYaoFangShiData" :name="['supplyCode', 'supplyCodeName']" clearable
-                    remote @method="geiYaoFangShiRemoteMethod"></XcSelect>
+          <XcSelectV2
+              style="width: 120px"
+              v-model="yiZhuData"
+              :data="geiYaoFangShiData"
+              value="supplyCode"
+              label="supplyCodeName"
+              :remote-method="geiYaoFangShiRemoteMethod"
+              clearable
+          />
         </el-form-item>
       </el-col>
       <el-col :span="span">
@@ -97,8 +111,14 @@
       </el-col>
       <el-col :span="span">
         <el-form-item class="bi_tian" label="执行科室:" prop="execUnit">
-          <XcSelect v-model="yiZhuData" :data="zhiXingKeShiData" :name="['execUnit', 'execUnitName']" remote
-                    @method="metZhiXingKeShi"></XcSelect>
+          <XcSelectV2
+              style="width: 120px"
+              v-model="yiZhuData"
+              :data="zhiXingKeShiData"
+              value="execUnit"
+              label="execUnitName"
+              :remote-method="metZhiXingKeShi"
+          />
         </el-form-item>
       </el-col>
       <el-col :span="span">
@@ -156,7 +176,7 @@
       </el-col>
       <el-col v-if="yiZhuData.orderCode === zkCode" :span="span">
         <el-form-item label="转科:" class="bi_tian">
-          <el-select v-model="yiZhuData.zkObj">
+          <el-select v-model="yiZhuData.zkObj" filterable>
             <el-option v-for="(item, index) in zkList" :key="item.value" :label="item.wardName + '|' + item.smallName"
                        :value="item.value">
               <span>{{ item.wardName }}</span>
@@ -268,7 +288,7 @@
     </el-table-column>
     <el-table-column fixed="right" label="操作" width="120">
       <template #default="scope">
-        <el-button circle icon="Edit" type="warning" @click="xiuGaiYiZhu(scope.row)"></el-button>
+        <el-button circle icon="Edit" type="warning" @click="xiuGaiYiZhu(scope.row,scope.$index)"></el-button>
         <el-button circle icon="Delete" type="danger" @click="shanChuBiaoGeYiZhu(scope.$index)"></el-button>
         <el-button circle class="iconfont icon-fuzhi" type="info" @click="dianJiFuZhiYiZhu(scope.row)"></el-button>
       </template>
@@ -316,6 +336,8 @@ import Sleep from '@/utils/sleep'
 import {logoutShortcut, xcHotKey} from '@/utils/xckeydown'
 import {BizException, ExceptionEnum} from '@/utils/BizException'
 import {setScrollTop} from "@/utils/el-table-scroll";
+import XcSelectV2 from "@/components/xc/select-v2/XcSelectV2.vue";
+import {nextTick} from "vue";
 
 const windowSize = computed(() => {
   return store.state.app.windowSize
@@ -407,7 +429,7 @@ const xuanZhongFeiYong = async (row) => {
   if (row.serial !== '00') {
     huoQuFeiYongXinXi(row.orderCode, row.serial)
         .then((res) => {
-          yiZhuData.value.drugFlag = row.orderType
+          yiZhuData.value.drugFlag = row.drugFlag ? row.drugFlag : row.orderType
           // 判断是否 是皮试的药 如果是就只能有这些 给药方式
           if (res.data.psFlag === 1) {
             geiYaoFangShiData.value = res.piShi
@@ -462,7 +484,7 @@ const xuanZhongFeiYong = async (row) => {
     yiZhuData.value.kjywFlag = 0
     huoQuFeiYongXinXi(row.orderCode, '00')
         .then((res) => {
-          yiZhuData.value.drugFlag = row.orderType
+          yiZhuData.value.drugFlag = row.drugFlag ? row.drugFlag : row.orderType
           yiZhuData.value.frequCode = 'ONCE'
           if (stringNotBlank(res.paiChiYiZhu)) {
             tiShiBiaoTi.value.push({title: res.paiChiYiZhu, type: 'error'})
@@ -494,8 +516,12 @@ const xuanZhongFeiYong = async (row) => {
   if (stringIsBlank(row.id)) {
     yiZhuData.value.id = uuid(8, 10)
   }
+  if (!yiZhuData.value.frequCode) {
+    yiZhuData.value.frequCode = 'ONCE'
+  }
   try {
     pingLv.focus()
+
   } catch (e) {
     console.log(e)
   }
@@ -509,6 +535,7 @@ const closeTheDoctorSOrderSearchBox = () => {
 /* 频率 */
 let pingLv = $ref(null)
 const yaoPinPingLvData = ref([])
+
 const pinLvRemoteMethod = (val) => {
   huoQuZhuYuanPinLv(val).then((res) => {
     yaoPinPingLvData.value = res
@@ -586,7 +613,7 @@ const tianJiaYiZhu = () => {
   }
   shangChuanYiZhu(data)
       .then((res) => {
-        let index = tianJiaYiZhuWeiYiBiaoShi.value.indexOf(yiZhuData.value.id)
+        let index = tianJiaYiZhuWeiYiBiaoShi.value.findIndex(item => item.id === yiZhuData.value.id)
         if (index > -1) {
           yiZhuList.value.splice(index, 1)
           tianJiaYiZhuWeiYiBiaoShi.value.splice(index, 1)
@@ -611,11 +638,11 @@ const whetherToResetTheDataSubscript = () => {
 }
 
 /* 这个是点击单个修改的 */
-const xiuGaiYiZhu = (val) => {
+const xiuGaiYiZhu = (val, index) => {
   xuanZhongFeiYong(val)
   ElMessage.success('你点击了修改')
-  yiZhuList.value.splice(val, 1)
-  tianJiaYiZhuWeiYiBiaoShi.value.splice(val, 1)
+  yiZhuList.value.splice(index, 1)
+  tianJiaYiZhuWeiYiBiaoShi.value.splice(index, 1)
   whetherToResetTheDataSubscript()
 }
 
@@ -979,7 +1006,7 @@ const copyData = () => {
 
 const editData = () => {
   dataJudgmentIsEmpty(true)
-  xiuGaiYiZhu(yiZhuList.value[dataIndex])
+  xiuGaiYiZhu(yiZhuList.value[dataIndex], dataIndex)
 }
 
 const deleteSelectedOrders = () => {
@@ -1010,7 +1037,7 @@ onMounted(() => {
   if (stringIsBlank(huanZheXinXi.value.inpatientNo)) {
     ElMessage.warning('您现在进入的是医嘱模板编辑')
   } else {
-    ElMessage.warning('您现在进入的是医嘱编辑模块,' + '您的编辑时间有 10 分钟,你准备好了吗?Are ya ready kids?')
+    ElMessage.warning('您现在进入的是医嘱编辑模块,' + '您的编辑时间有 10 分钟,你准备好了吗?')
     kaiQiDaoJiShi()
     whetherThePatientHasAllergens(huanZheXinXi.value.inpatientNo).then((res) => {
       allergenDialog = res

+ 2 - 1
src/views/hospitalization/zhu-yuan-yi-sheng/yi-zhu-lu-ru/YiZhuLuRu.vue

@@ -180,7 +180,8 @@ 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 '@/utils/sleep'
+import XcSelectV2 from "@/components/xc/select-v2/XcSelectV2.vue";
+import sleep from "@/utils/sleep";
 
 const windowSize = computed(() => {
   return store.state.app.windowSize

+ 0 - 2
src/views/settings/Test.vue

@@ -1,5 +1,4 @@
 <template>
-  <TestElSelectV2 v-model="obj.tcode" :data="data"></TestElSelectV2>
   <xc-select-v2 style="width: 120px; " v-model="obj"
                 value="tcode" label="tname"
                 :data="data" :remote-method="testmethod"/>
@@ -20,7 +19,6 @@
 
 <script setup name='Test'>
 import sleep from "@/utils/sleep";
-import TestElSelectV2 from "@/components/xc/select-v2/TestElSelectV2.vue";
 
 const obj = $ref({
   tcode: '',