DESKTOP-0GD05B0\Administrator 2 سال پیش
والد
کامیت
1ef67282b3

+ 0 - 16
src/components/xiao-chan/xc-table-v2/XcTableColumnV2.vue

@@ -1,16 +0,0 @@
-<template>
-
-</template>
-
-<script setup name='XcTableColumnV2'>
-const props = defineProps({
-  label: String,
-  prop: String,
-  width: String
-})
-
-</script>
-
-<style scoped lang="scss">
-
-</style>

+ 81 - 54
src/components/xiao-chan/xc-table-v2/XcTableV2.vue

@@ -2,30 +2,33 @@
   <div class="xc-table">
     <div class="header">
       <div
-          v-if="!!useSlots().default"
-          v-for="item in useSlots().default()"
+          v-for="item in props.columns"
           class="th"
-          :style="{width :item.props.width +   'px' }">
-        {{ item.props.label }}
+          @click="headerClick(item)"
+          :style="{width :item.width +   'px' }">
+        {{ item.name }}
       </div>
     </div>
 
-    <div v-bind="containerProps" style="height: 300px">
+    <div v-bind="containerProps"
+         class="xc-body"
+         :style="{height : props.height + 'px'}">
       <div v-bind="wrapperProps">
         <div v-for="item in list"
              :key="item.index"
+             :style="rowStyle(item.data, item.index)"
+             @dblclick.stop="dbRowClick(item.data, $event, item.index)"
+             @click="rowClick(item.data, $event, item.index)"
              class="row">
-          <div v-if="!!useSlots().default"
-               v-for="(he) in useSlots().default()"
-               :title="item.data[he.props.code]"
+          <div v-for="(he) in props.columns"
+               :title="item.data[he.code]"
                class="cell"
-               :style="{width :he.props.width + 'px' }">
-
-            <template v-if="he.children">
-              <component :is="he.children.default({data: item.data,index:item.index,cellData: item.data[he.code]})"/>
+               :style="{width :he.width + 'px' }">
+            <template v-if="he.cellRenderer">
+              <component :is="he.cellRenderer({data: item.data,index:item.index,cellData: item.data[he.code]})"/>
             </template>
             <template v-else>
-              {{ item.data[he.props.code] }}
+              {{ item.data[he.code] }}
             </template>
           </div>
         </div>
@@ -36,50 +39,86 @@
 
 <script setup name='XcTableV2' lang="tsx">
 import {useVirtualList} from "@vueuse/core";
-import {onMounted, useSlots, ref} from 'vue'
 
 const props = defineProps({
-  data: Array
+  data: Array,
+  columns: Array,
+  height: {
+    type: Number,
+    default: 300
+  },
+
 })
 
+const emits = defineEmits(['rowClick', 'dbRowClick', 'rowStyle'])
+
 const {list, containerProps, wrapperProps} = useVirtualList(
     props.data,
     {
-      itemHeight: 22,
+      itemHeight: 24,
     },
 )
 
-const header = [
-  {
-    width: 20, name: '#',
-  },
-  {width: 20, code: 'tempCheckbox'},
-  {
-    width: 30, name: '排序',
-  },
-  {width: 20, code: 'orderGroup', name: '组'},
-  {width: 70, code: 'actOrderNo', name: '医嘱号'},
-  {width: 225, code: 'orderName', name: '医嘱名称'},
-];
-
-const tableHeader = ref([])
-
-onMounted(() => {
-  if (!!useSlots().default) {
-    useSlots().default().forEach((item) => {
-      console.log(item)
-      console.log(item.children.default)
-    })
+const headerClick = (item) => {
+  if (item.headerFunc) {
+    item.headerFunc()
   }
-})
+}
 
-const clickSelected = (row, event) => {
-  row.tempCheckbox = !row.tempCheckbox
+const rowStyle = (data, index) => {
+  emits('rowStyle', data, index)
+}
+
+
+let timer = null
+const rowClick = (item, event, index) => {
+  if (timer) {
+    clearTimeout(timer)
+  }
+  timer = setTimeout(() => {
+    emits('rowClick', item, index, event)
+  }, 300)
+}
+
+const dbRowClick = (item, event, index) => {
+  if (timer) {
+    clearTimeout(timer)
+  }
+  emits('dbRowClick', item, index, event)
 }
 
 </script>
 
 <style scoped lang="scss">
+
+.xc-table {
+  overflow-x: auto;
+}
+
+.xc-body {
+
+  .row {
+    height: 22px;
+    display: flex;
+    align-items: center;
+  }
+
+  .cell {
+    overflow: hidden;
+    border: 1px solid #fff;
+    display: flex;
+    align-items: center;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    height: 100%;
+    flex-grow: 0;
+    flex-shrink: 0;
+  }
+
+
+}
+
+
 .header {
   height: max-content;
   display: flex;
@@ -91,22 +130,10 @@ const clickSelected = (row, event) => {
     border: 1px solid #fff;
     text-overflow: ellipsis;
     white-space: nowrap;
+    flex-grow: 0;
+    flex-shrink: 0
   }
 }
 
-.cell {
-  overflow: hidden;
-  border: 1px solid #fff;
-  display: flex;
-  align-items: center;
-  text-overflow: ellipsis;
-  white-space: nowrap;
-  height: 100%;
-}
 
-.row {
-  height: 20px;
-  display: flex;
-  align-items: center;
-}
 </style>

+ 4 - 3
src/components/zhu-yuan-yi-sheng/yi-zhu-lu-ru/table/YzTable.vue

@@ -42,7 +42,10 @@
                          v-model="item.tempCheckbox">
                 </div>
                 <div
-                    v-else-if="heindex === 10 && stringIsBlank(item.endTime) && stringIsBlank(item.parentNo) && item.frequCode != 'ONCE' ">
+                    v-else-if="heindex === 10
+                    && stringIsBlank(item.endTime)
+                    && stringIsBlank(item.parentNo)
+                    && item.frequCode !== 'ONCE' ">
                   <input type="datetime-local"
                          v-model="item.endTimeTemp"
                          :style="endDateStyle(item)"
@@ -150,7 +153,6 @@ const header = [
       return `${val.emergencyFlag === '1' ? '√' : ''}`
     },
     width: 20
-
   },
   {
     code: 'ybSelfFlag', name: '自费', width: 20, func: (val) => {
@@ -254,7 +256,6 @@ const cancelStopTime = (val) => {
   if (val.tempCheckbox) {
     clickSelected(val)
   }
-
 }
 
 // div 的最大高度

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

@@ -53,7 +53,6 @@
         <div>
           一次剂量:
           <el-input-number v-model="yiZhuData.dose"
-                           :min="jiLiangValue"
                            :step="jiLiangValue"
                            :controls="false"
                            ref="doseRef"

+ 168 - 23
src/views/settings/Test.vue

@@ -1,19 +1,17 @@
 <template>
-  <xc-table-v2 :data="allItems">
-    <el-table-column label="组" prop="orderGroup" width="20">
-      <template #default="{data}">
-        {{ data.orderGroup }}
-      </template>
-    </el-table-column>
-  </xc-table-v2>
+  <xc-table-v2 :data="allItems"
+               @rowClick="rowClick"
+               @dbRowClick="setDefaultStopTime"
+               :columns="header"/>
 </template>
 
 
 <script setup name='Test' lang="tsx">
-import {useVirtualList} from '@vueuse/core'
 import {ref} from 'vue'
 import XcTableV2 from "@/components/xiao-chan/xc-table-v2/XcTableV2.vue";
-import XcTableColumnV2 from "@/components/xiao-chan/xc-table-v2/XcTableColumnV2.vue";
+import {stringIsBlank} from "@/utils/blank-utils";
+import {getFormatDatetime} from "@/utils/date";
+import {getServerDateApi} from '@/api/public-api'
 
 const allItems = ref([
   {
@@ -55,7 +53,7 @@ const allItems = ref([
     "drugWeight": null,
     "drugWeightUnit": null,
     "drugWeightUnitName": null,
-    "statusFlag": "1",
+    "statusFlag": "2",
     "statusTime": null,
     "selfBuy": "0",
     "dose": 1,
@@ -77,8 +75,8 @@ const allItems = ref([
     "execUnit": "1040000",
     "execUnitName": "儿科",
     "regFlag": "0",
-    "ybSelfFlag": "0",
-    "emergencyFlag": "0",
+    "ybSelfFlag": "1",
+    "emergencyFlag": "1",
     "kfFlag": null,
     "kjywFlag": null,
     "stockAmount": null,
@@ -248,7 +246,7 @@ const allItems = ref([
     "drugWeight": null,
     "drugWeightUnit": null,
     "drugWeightUnitName": null,
-    "statusFlag": "1",
+    "statusFlag": "3",
     "statusTime": null,
     "selfBuy": "4",
     "dose": 0.19,
@@ -344,7 +342,7 @@ const allItems = ref([
     "drugWeight": null,
     "drugWeightUnit": null,
     "drugWeightUnitName": null,
-    "statusFlag": "1",
+    "statusFlag": "4",
     "statusTime": null,
     "selfBuy": "4",
     "dose": 0.125,
@@ -440,7 +438,7 @@ const allItems = ref([
     "drugWeight": null,
     "drugWeightUnit": null,
     "drugWeightUnitName": null,
-    "statusFlag": "1",
+    "statusFlag": "5",
     "statusTime": null,
     "selfBuy": "0",
     "dose": 1,
@@ -2322,8 +2320,6 @@ const allItems = ref([
     "selfBuyName": ""
   }
 ])
-
-
 for (let i = 0; i < 1000; i++) {
   allItems.value.push({
     "id": "17205159",
@@ -2429,11 +2425,13 @@ const header = [
     width: 20, name: '#',
     cellRenderer: ({data}) => (
         <input type="checkbox"
-               v-model={data.tempCheckbox}
-               onClick={(event) => clickSelected(data, event)}/>
-    )
+               checked={data.tempCheckbox}
+               onClick={(event) => clickSelected(data)}/>
+    ),
+    headerFunc: () => {
+      console.log(123)
+    }
   },
-  {width: 20, code: 'tempCheckbox'},
   {
     width: 30, name: '排序',
     cellRenderer: ({index}) => (
@@ -2441,14 +2439,161 @@ const header = [
     )
   },
   {width: 20, code: 'orderGroup', name: '组'},
-  {width: 70, code: 'actOrderNo', name: '医嘱号'},
+  {
+    width: 20, code: 'statusFlag', cellRenderer: ({cellData}) => {
+      return getYiZhuFlag(cellData)
+    }
+  },
+  {
+    width: 70, code: 'actOrderNo', name: '医嘱号', cellRenderer: ({data}) => {
+      if (data.error) {
+        return (<span style="color: red" class={data.newOrderFlag > 0 ? 'new_order' : ''}>{nu(data.actOrderNo)}</span>)
+      } else {
+        return (<span class={data.newOrderFlag > 0 ? 'new_order' : ''}>{nu(data.actOrderNo)}</span>)
+      }
+    }
+  },
   {width: 225, code: 'orderName', name: '医嘱名称'},
+  {
+    code: 'dose', name: '剂量', width: 75, cellRenderer: ({data}) => {
+      return <span>{nu(data.dose) + ' ' + nu(data.doseUnitName)}</span>
+    }
+  },
+  {code: 'frequCode', name: '频率', width: 75},
+  {code: 'supplyCodeName', name: '给药方式', width: 60},
+  {
+    code: 'startTime', name: '开始时间', width: 95, cellRenderer: ({data}) => {
+      return (<span>{timeFomat(data.startTime)}</span>)
+    }
+  },
+  {
+    // 出院时间的大小不能改
+    code: 'endTime', name: '结束时间', width: 160, cellRenderer: ({data}) => {
+      if (stringIsBlank(data.endTime) && stringIsBlank(data.parentNo) && data.frequCode !== 'ONCE') {
+        return <input type="datetime-local"
+                      style={endDateStyle(data)}
+                      value={data.endTimeTemp}
+                      oncontextmenu={(event) => {
+                        event.preventDefault();
+                        cancelStopTime(data)
+                      }}
+        />
+      }
+      return <span>{timeFomat(data.endTime)}</span>
+    }
+  },
+  {
+    code: 'emergencyFlag', name: '紧急', cellRenderer: ({cellData}) => {
+      return <span>{cellData === '1' ? '√' : ''}</span>
+    },
+    width: 30
+  },
+  {
+    code: 'ybSelfFlag', name: '自费', cellRenderer: ({cellData}) => {
+      return <span>{cellData === '1' ? '√' : ''}</span>
+    },
+    width: 30
+  },
+  {code: 'physicianName', name: '医生', width: 65},
+  {code: 'selfBuyName', name: '费用标志', width: 60},
+  {code: 'execUnitName', name: '执行科室', width: 80},
+  {
+    code: 'drugQuan', name: '领量', cellRenderer: ({data}) => {
+      return <span>{nu(data.drugQuan) + nu(data.drugQuanName)}</span>
+    },
+    width: 30
+  },
+  {code: 'groupNoName', name: '药房', width: 91},
+  {code: 'serial', name: '序号', width: 35},
+  {code: 'instruction', name: '嘱托', width: 150},
+  {
+    name: '操作', width: 53, cellRenderer: ({data}) => (
+        <button onclick={(e) => {
+          e.preventDefault();
+          e.stopImmediatePropagation();
+          console.log(data)
+        }}>作废</button>
+    )
+  }
 ];
 
-const clickSelected = (row, event) => {
+const clickSelected = (row) => {
   row.tempCheckbox = !row.tempCheckbox
 }
 
+const timeFomat = (val) => {
+  return getFormatDatetime(val, 'YY-MM-DD HH:mm')
+}
+
+function getYiZhuFlag(val) {
+  if (stringIsBlank(val)) {
+    return val
+  }
+  switch (val) {
+    case '1':
+      return (<span style="color: #05ff00">R</span>)
+    case '2':
+      return (<span style="color: #0000fb">Q</span>)
+    case '3':
+      return (<span style="color: #ff07f3">Z</span>)
+    case '4':
+      return (<span style="color:  #ff07f3">Z</span>)
+    case '5':
+      return (<span style="color: red">T</span>)
+    case '-1':
+      return (<span style="color: #00ffe0">D</span>)
+    default:
+      return 'warning'
+  }
+}
+
+const endDateStyle = (item) => {
+  if (item.endTimeTemp && item.tempCheckbox) {
+    return {
+      width: '140px',
+      color: 'white',
+      backgroundColor: 'red',
+      border: 0,
+    }
+  } else {
+    return {
+      width: '140px',
+      border: 0,
+    }
+  }
+}
+
+const rowClick = (data) => {
+  console.log('rowClick', data)
+}
+
+const setDefaultStopTime = async (item) => {
+  if (item.parentNo) return
+  item.endTimeTemp = getFormatDatetime(await getServerDateApi(), 'yyyy-MM-DD HH:mm')
+  if (!item.tempCheckbox) {
+    clickSelected(item)
+  }
+}
+
+const cancelStopTime = (val) => {
+  if (val.parentNo) return
+  val.endTimeTemp = ''
+  if (val.tempCheckbox) {
+    clickSelected(val)
+  }
+}
+
+
+const nu = (val) => {
+  if (val === null) {
+    return ''
+  } else if (typeof val === 'undefined') {
+    return ''
+  } else {
+    return val
+  }
+}
+
 </script>
 
 <style lang="scss" scoped>