瀏覽代碼

优化数据

DESKTOP-0GD05B0\Administrator 2 年之前
父節點
當前提交
7204795e51

+ 61 - 29
src/components/xiao-chan/combo-grid/XcComboGrid.vue

@@ -13,6 +13,7 @@
             @focus="inputFocus"
             @click="clickInput"
             @blur="inputBlur"
+            @keydown.esc="tableConfig.isShow = false"
             @keydown.enter.prevent="keyEnter"
             @mousedown.stop
             @keydown.up.prevent="keyUp"
@@ -35,13 +36,12 @@
         </el-table>
         <el-pagination
             small
-            background
             :pager-count="5"
             :total="tableData.total"
             :current-page="tableData.currentPage"
             :page-size="tableData.pageSize"
             @size-change="handleSizeChange"
-            layout="total,prev, pager, next, jumper"
+            layout="total,prev, pager, next"
             @current-change="handleCurrentChange"/>
       </div>
     </el-popover>
@@ -57,10 +57,12 @@ const props = defineProps({
     type: [String, Object],
   },
   code: {
-    type: String
+    type: String,
+    default: 'code'
   },
   name: {
-    type: String
+    type: String,
+    default: 'name'
   },
   rowKey: {
     type: String,
@@ -81,8 +83,8 @@ const props = defineProps({
   tableHeader: {
     type: Array,
     default: [
-      {label: '编码', prop: 'code'},
-      {label: '名称', prop: 'name'},
+      {label: '编码', prop: 'code', width: 120},
+      {label: '名称', prop: 'name', width: 220},
     ]
   },
   placeholder: {
@@ -134,7 +136,8 @@ const keyUp = () => {
   if (tableConfig.value.isShow) {
     currentIndex--;
     if (currentIndex < 0) {
-      currentIndex = tableData.value.pageSize - 1
+      currentIndex = tempTableList.value.length - 1
+      keyLeft()
     }
     rowAddClass()
   }
@@ -143,8 +146,9 @@ const keyUp = () => {
 const keyDown = () => {
   if (tableConfig.value.isShow) {
     currentIndex++;
-    if (currentIndex > tableData.value.pageSize - 1) {
+    if (currentIndex > tempTableList.value.length - 1) {
       currentIndex = 0
+      keyRight()
     }
     rowAddClass()
   }
@@ -166,6 +170,9 @@ const keyLeft = () => {
   } else {
     tableData.value.currentPage--
   }
+  if (currentIndex > tempTableList.value.length) {
+    currentIndex = 0
+  }
 }
 
 const keyRight = () => {
@@ -193,31 +200,54 @@ const rowAddClass = async () => {
 }
 
 const inputFocus = () => {
-  placeholder.value = props.modelValue
+  if (isObj) {
+    placeholder.value = props.modelValue[props.name]
+  } else {
+    placeholder.value = props.modelValue;
+  }
   inputData.value = ''
 }
 
 const clickInput = () => {
-  placeholder.value = props.modelValue
+  if (isObj) {
+    placeholder.value = props.modelValue[props.name]
+  } else {
+    placeholder.value = props.modelValue;
+  }
   inputData.value = ''
   tableConfig.value.isShow = !tableConfig.value.isShow
 }
 
 const highlightRow = async () => {
   await nextTick()
-  if (props.currentKey === null) return
+  if (!isObj && props.currentKey === null) {
+    return;
+  }
   let row = tableRef.value.$el.querySelectorAll('.el-table__row')
   for (let i = 0; i < tempTableList.value.length; i++) {
     let item = tempTableList.value[i]
     row[i].classList.remove('current_key')
-    if (item[props.rowKey] === props.currentKey) {
-      row[i].classList.add('current_key')
+    if (isObj) {
+      if (item[props.rowKey] === props.modelValue[props.code]) {
+        row[i].classList.add('current_key');
+      }
+    } else {
+      if (item[props.rowKey] === props.currentKey) {
+        row[i].classList.add('current_key');
+      }
     }
   }
 }
 
 const inputBlur = () => {
-  inputData.value = props.modelValue
+  if (isObj) {
+    inputData.value = props.modelValue[props.name]
+  } else {
+    inputData.value = props.modelValue;
+  }
+  if (!inputData.value) {
+    placeholder.value = props.placeholder
+  }
   tableConfig.value.isShow = false
 }
 
@@ -235,32 +265,34 @@ const handleCurrentChange = async (val) => {
 }
 
 const clickRow = async (row) => {
-  selectedRowStyle()
+  if (isObj) {
+    props.modelValue[props.code] = row['code']
+    props.modelValue[props.name] = row['name']
+  }
+  await highlightRow()
   emit('rowClick', row)
   tableConfig.value.isShow = false
 }
 
-const selectedRowStyle = () => {
-  let row = tableRef.value.$el.querySelectorAll('.el-table__row')
-  for (let i = 0; i < tempTableList.value.length; i++) {
-    row[i].classList.remove('current_key')
-    if (i === currentIndex) {
-      row[i].classList.add('current_key')
-    }
-  }
-}
-
-watch(() => props.modelValue, () => {
-  inputData.value = props.modelValue
-}, {immediate: true, deep: true})
-
 const inputRef = ref()
 const focus = () => {
   inputRef.value.focus()
 }
 
+const isObj = typeof props.modelValue === 'object'
 onMounted(() => {
   rowAddClass()
+  if (isObj) {
+    watch(() => props.modelValue[props.code], () => {
+      inputData.value = props.modelValue[props.name]
+      highlightRow()
+    }, {immediate: true, deep: true})
+  } else {
+    watch(() => props.modelValue, () => {
+      inputData.value = props.modelValue
+      highlightRow()
+    }, {immediate: true, deep: true})
+  }
 })
 
 defineExpose({

+ 6 - 5
src/components/xiao-chan/select-v3/XcSelectV3.vue

@@ -62,7 +62,6 @@
             </tbody>
           </table>
         </div>
-
       </div>
     </transition>
   </div>
@@ -72,6 +71,7 @@
 import {onClickOutside} from '@vueuse/core'
 import {functionDebounce} from "@/utils/debounce";
 import sleep from "@/utils/sleep";
+import {stringIsBlank} from "@/utils/blank-utils";
 
 const props = defineProps({
   modelValue: {
@@ -113,7 +113,7 @@ const emit = defineEmits(['change'])
 
 const judgingCodeIsEmpty = () => {
   if (props.modelValue[props.code] === null) {
-    return null
+    return true
   }
   let codeType = typeof props.modelValue[props.code]
 
@@ -121,7 +121,7 @@ const judgingCodeIsEmpty = () => {
     case "number":
       return props.modelValue[props.code] === null;
     case "string":
-      return !props.modelValue[props.code]
+      return stringIsBlank(props.modelValue[props.code])
   }
 
 }
@@ -138,7 +138,7 @@ const findSpecifiedData = () => {
       reject()
     }
     for (let i = 0; i < dataLength; i++) {
-      if (props.data[i][props.code] === props.modelValue[props.code]) {
+      if (props.data[i]['code'] === props.modelValue[props.code]) {
         resolve({item: props.data[i], index: i})
         return
       }
@@ -361,13 +361,14 @@ watch(() => props.data, async () => {
   await nextTick()
   enableScrollBar()
   containerRef.value.scrollTop = 0
-  if (judgingCodeIsEmpty()) {
+  if (!judgingCodeIsEmpty()) {
     dataFilling()
   }
 }, {deep: true, immediate: true})
 
 watch(() => props.modelValue[props.code], async () => {
   await nextTick()
+  // 寻找数据
   dataFilling()
   if (judgingCodeIsEmpty()) {
     placeholder = '请选择'

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

@@ -1,5 +1,5 @@
 <template>
-  <div ref="editorMainRef" style="border: 1px solid">
+  <div ref="editorMainRef">
     <div v-if="tiShiBiaoTi?.length > 0" class="editor__title">
         <span v-for="item in tiShiBiaoTi">
             {{ item }}
@@ -318,7 +318,6 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
     qingKong()
     return BizException(ExceptionEnum.LOGICAL_ERROR, '出院带药不能开项目')
   }
-
   if (yiZhuData.value.actOrderNo === 'tempOrderNo') {
     yiZhuData.value.actOrderNo = await getOrderNo()
   }
@@ -330,8 +329,10 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
   }
   await fuYiZhuClick()
   qingKong()
-  await Sleep(300)
-  yiZhuData.value = row
+  await Sleep(200)
+  // 克隆一下数据防止有问题
+  yiZhuData.value = clone(row) // clone(row)
+  console.log(row)
   if (tempOrderNo !== null) {
     yiZhuData.value.actOrderNo = tempOrderNo;
     yiZhuData.value.statusFlag = '1'
@@ -340,7 +341,6 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
   if (row.serial === '01' || row.serial === '99') {
     try {
       let res = await huoQuFeiYongXinXi(row.orderCode, row.serial, props.patientInfo.zkWard)
-
       // 加载药品计量
       yaoPinJiLiangData.value = res.yaoPingJiLiang
       if (newData) {
@@ -356,7 +356,6 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
         yiZhuData.value.miniUnitName = res.data.miniUnitName
         yiZhuData.value.drugVolume = res.data.volum
         yiZhuData.value.drugVolUnit = res.data.volUnit
-
         // 加载 剂量单位
         if (stringNotBlank(yiZhuData.value.doseUnit)) {
           yaoPinJiLiangData.value.forEach((item) => {
@@ -397,7 +396,6 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
         qingKong()
       }
     }
-
   } else {
     yiZhuData.value.kjywFlag = 0
     try {
@@ -411,6 +409,9 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
         if (!res.dose) {
           yiZhuData.value.dose = 1
         }
+        // 如果是项目就不需要给药方式
+        yiZhuData.value.supplyCode = null
+        yiZhuData.value.supplyCodeName = ''
       }
     } catch (e) {
       if (yiZhuData.value.statusFlag === '1') {
@@ -422,9 +423,7 @@ const xuanZhongFeiYong = async (row, laiyuan = 1) => {
   if (newData) {
     // 判断这个是不是 新添加的数据 如果是空的就是 新数据
     let serverDate = await getServerDateApi()
-    // 如果是项目就不需要给药方式
-    yiZhuData.value.supplyCode = null
-    yiZhuData.value.supplyCodeName = ''
+
 
     if (!yiZhuData.value.orderTime) {
       yiZhuData.value.orderTime = serverDate

+ 1 - 2
src/views/hospitalization/zhu-yuan-yi-sheng/jian-cha-jian-yan-shen-qing/InspectionRequisition.vue

@@ -44,8 +44,7 @@
                 active-color="#13ce66"
                 active-text="急诊"
                 inactive-color="#ff4949"
-                inactive-text="普通"            >
-            </el-switch>
+                inactive-text="普通"/>
           </el-form-item>
         </el-col>
         <el-col :span="12">