YzTable.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <table border="1" cellspacing="0" cellpadding="0" class="table" ref="tableRef">
  3. <thead>
  4. <tr>
  5. <th>
  6. 序号
  7. </th>
  8. <th v-for="item in header"
  9. :style="setWidth(item)">
  10. {{ item.name }}
  11. </th>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. <template v-for="(item,index) in tempYzData">
  16. <tr @click="rowClick(item,index)" :style="setBackgroundColor(item)">
  17. <td>
  18. {{ index }}
  19. <input type="checkbox"
  20. v-model="item['tempCheckbox']"
  21. @click.stop="selectedRow(item,index)">
  22. </td>
  23. <td v-for="he in header">
  24. <div v-if="he.func" v-html="he.func(item)"/>
  25. <div v-else>
  26. {{ item[he.code] }}
  27. </div>
  28. </td>
  29. </tr>
  30. </template>
  31. </tbody>
  32. </table>
  33. </template>
  34. <script setup name='YzTable'>
  35. import {stringIsBlank} from "@/utils/blank-utils";
  36. import {
  37. selectedData,
  38. yiZhuData,
  39. tempYzData
  40. } from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
  41. const props = defineProps({
  42. data: {
  43. type: Array
  44. },
  45. })
  46. const emit = defineEmits(['rowClick'])
  47. const index = 0
  48. const header = [
  49. {code: 'orderGroup', name: '组'},
  50. {
  51. code: 'statusFlag', name: '状态', func: (val) => {
  52. return getYiZhuFlag(val.statusFlag)
  53. },
  54. width: 20
  55. },
  56. {
  57. code: 'actOrderNo', name: '医嘱号', func: (val) => {
  58. if (val.error) {
  59. return `<span style="color: red">${nu(val.actOrderNo)}</span>`
  60. } else {
  61. return nu(val.actOrderNo)
  62. }
  63. }
  64. },
  65. {code: 'orderName', name: '医嘱名称'},
  66. {
  67. code: 'dose', name: '剂量', func: (val) => {
  68. return nu(val.dose) + ' ' + nu(val.doseUnitName)
  69. }
  70. },
  71. {code: 'frequCode', name: '频率'},
  72. {code: 'supplyCodeName', name: '给药方式'},
  73. {code: 'startTime', name: '开始时间'},
  74. {code: 'endTime', name: '结束时间'},
  75. {code: 'orderTime', name: '医嘱时间'},
  76. {code: 'emergencyFlag', name: '紧急'},
  77. {code: 'ybSelfFlag', name: '医保自费'},
  78. {code: 'physicianName', name: '医生'},
  79. {code: 'selfBuyName', name: '费用标志'},
  80. {code: 'execUnitName', name: '执行科室'},
  81. {
  82. code: 'drugQuan', name: '领量', func: (val) => {
  83. return nu(val.drugQuan) + nu(val.drugQuanName)
  84. }
  85. },
  86. {code: 'groupNoName', name: '药房'},
  87. {code: 'serialName', name: '序号'},
  88. {code: 'instruction', name: '嘱托'},
  89. {code: 'parentNo', name: '父医嘱'},
  90. ]
  91. const tableRef = ref()
  92. const setBackgroundColor = (item) => {
  93. if (yiZhuData.value.actOrderNo == item.actOrderNo) {
  94. return {
  95. 'backgroundColor': 'rgba(0,58,241,0.68)',
  96. 'color': '#fff'
  97. }
  98. }
  99. }
  100. const setWidth = (val) => {
  101. if (val.width) {
  102. return {
  103. 'width': val.width + 'px'
  104. }
  105. }
  106. }
  107. const rowClick = (val, index) => {
  108. emit('rowClick', val)
  109. }
  110. const nu = (val) => {
  111. if (val === null) {
  112. return ''
  113. } else if (typeof val === 'undefined') {
  114. return ''
  115. } else {
  116. return val
  117. }
  118. }
  119. const selectedRow = (row, index) => {
  120. row.tempCheckbox = !row.tempCheckbox
  121. if (row['tempCheckbox']) {
  122. selectedData.value.push(row)
  123. } else {
  124. let tempIndex = selectedData.value.indexOf(row)
  125. if (tempIndex > -1) {
  126. selectedData.value.splice(tempIndex, 1)
  127. }
  128. }
  129. }
  130. function getYiZhuFlag(val) {
  131. if (stringIsBlank(val)) {
  132. return val
  133. }
  134. switch (val) {
  135. case '1':
  136. return '<span style="color: #05ff00">R</span>'
  137. case '2':
  138. return '<span style="color: #0000fb">Q</span>'
  139. case '3':
  140. return '<span style="color: #ff07f3">Z</span>'
  141. case '4':
  142. return '<span style="color: #ff07f3">Z</span>'
  143. case '5':
  144. return '<span style="color: red">T</span>'
  145. default:
  146. return 'warning'
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .table {
  152. width: 100%;
  153. }
  154. table {
  155. border-collapse: collapse;
  156. border-spacing: 0;
  157. }
  158. table, tbody {
  159. width: 100%;
  160. cursor: default;
  161. }
  162. tbody {
  163. td {
  164. white-space: nowrap;
  165. text-overflow: ellipsis;
  166. overflow: hidden;
  167. line-height: 40px;
  168. }
  169. }
  170. </style>