myTable.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="ba-table-box">
  3. <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
  4. <!-- 表格顶部菜单 -->
  5. <!-- 自定义按钮请使用插槽,甚至公共搜索也可以使用具名插槽渲染,参见文档 -->
  6. <TableHeader
  7. from="hrMyTable"
  8. :buttons="['comSearch']"
  9. :quick-search-placeholder="t('Quick search placeholder', { fields: t('hospital.hrpatient.quick Search Fields') })"
  10. >
  11. <el-tooltip v-if="baTable.auth('getMyHrpatientDetails')" :content="t('View detailed information')" placement="top">
  12. <el-button v-blur @click="onDetail()" :color="'var(--ba-vars-color-main-primary)'" :disabled="baTable.table.selection!.length > 0 ? false : true" class="table-header-operate view-detail" type="primary">
  13. <span class="table-header-operate-text">{{ t('View detailed information') }}</span>
  14. </el-button>
  15. </el-tooltip>
  16. </TableHeader>
  17. <!-- 表格 -->
  18. <!-- 表格列有多种自定义渲染方式,比如自定义组件、具名插槽等,参见文档 -->
  19. <!-- 要使用 el-table 组件原有的属性,直接加在 Table 标签上即可 -->
  20. <Table ref="tableRef" highlight-current-row></Table>
  21. <!-- 表单 -->
  22. <!-- <PopupForm /> -->
  23. </div>
  24. </template>
  25. <script setup lang="ts">
  26. import { onMounted, provide, ref, watch, inject } from 'vue'
  27. import { useI18n } from 'vue-i18n'
  28. import { baTableApi } from '/@/api/common'
  29. import TableHeader from '/@/components/table/header/index.vue'
  30. import Table from '/@/components/table/index.vue'
  31. import baTableClass from '/@/utils/baTable'
  32. import { FormatUtil } from '/@/utils/format'
  33. import {useLocalSelect} from '/@/stores/localSelect'
  34. import { routePush } from '/@/utils/router'
  35. import { useRoute } from 'vue-router'
  36. import { useAdminInfo } from '/@/stores/adminInfo'
  37. const { t } = useI18n()
  38. const tableRef = ref()
  39. const localSelect = useLocalSelect()
  40. const route = useRoute()
  41. const adminInfo = useAdminInfo()
  42. /**
  43. * baTable 内包含了表格的所有数据且数据具备响应性,然后通过 provide 注入给了后代组件
  44. */
  45. const baTable = new baTableClass(
  46. new baTableApi('/admin/hospital.Hrpatient/'),
  47. {
  48. comSearchSort: true,
  49. filter: {
  50. 'hospital_type': 'my'
  51. },
  52. showComSearch: false,
  53. column: [
  54. { fixed: true, label: t('hospital.hrpatient.index'), type: 'index', width: 52, align: 'center', operator: false },
  55. { fixed: true, comSearchWeight: 60, showOverflowTooltip: true, label: t('hospital.hrpatient.MPI'), prop: 'MPI', align: 'center', operatorPlaceholder: t('Accurate query'), operator: 'eq', sortable: 'custom', width: 120 },
  56. // { label: t('Serial number'), type: 'index', width: 70, align: 'center', operator: false },
  57. // { showOverflowTooltip: true, label: t('hospital.hrpatient.MPI'), prop: 'MPI', align: 'center', operator: 'LIKE', sortable: 'custom', },
  58. { fixed: true, operator: false, showOverflowTooltip: true, label: t('hospital.hrpatient.ENCOUNTER_DATE'), prop: 'ENCOUNTER_DATE', align: 'center', render: 'datetime', sortable: 'custom', width: 130, timeFormat: 'yyyy-mm-dd hh:MM' },
  59. { fixed: true, comSearchWeight: 100, comSearchLabel: t('hospital.hrpatient.Search_NAME'), showOverflowTooltip: true, label: t('hospital.hrpatient.NAME'), prop: 'NAME', align: 'center', operatorPlaceholder: t('Accurate query'), operator: 'eq', sortable: 'custom'},
  60. // {
  61. // show: false,
  62. // comSearchWeight: 90,
  63. // label: t('hospital.hrpatient.status'),
  64. // prop: 'status',
  65. // render: 'tag',
  66. // align: 'center',
  67. // replaceValue: { '0': ' ', '1': '互认', '2': '不互认'},
  68. // },
  69. {
  70. fixed: true,
  71. show: false,
  72. comSearchWeight: 90,
  73. label: t('hospital.hrpatient.status'),
  74. prop: 'status',
  75. // render: 'tag',
  76. align: 'center',
  77. comSearchRender: 'localSelect',
  78. local: localSelect.HR_STATUS_LIST,
  79. // replaceValue: { '0': ' ', '1': '互认', '2': '不互认'},
  80. },
  81. { fixed: true, showOverflowTooltip: true, label: t('hospital.hrpatient.GENDER'), prop: 'GENDER', align: 'center',
  82. operator: false, sortable: 'custom',
  83. // comSearchRender: 'localSelect',
  84. // local: localSelect.GENDER_LIST,
  85. // comSearchRender: 'remoteSelect', remote: {
  86. // // TODO 后期看看需不需要传ID服务端做对应调整
  87. // pk: "name",
  88. // field: "name",
  89. // params: {},
  90. // multiple: true,
  91. // remoteUrl: '/admin/option/getGENDERList',
  92. // }
  93. },
  94. {show: false, comSearchWeight: 80, showOverflowTooltip: true, label: t('hospital.hrpatient.AGE'), prop: 'AGE_DAY', align: 'center', operator: 'RANGE', sortable: 'custom',
  95. formatter: function(row, column, cellValue) {
  96. return FormatUtil.AGE.display(cellValue)
  97. }
  98. },
  99. { fixed: true, comSearchWeight: 80, showOverflowTooltip: true, label: t('hospital.hrpatient.AGE'), prop: 'AGE', align: 'center', operator: false, sortable: 'custom',
  100. formatter: function(row, column, cellValue) {
  101. return FormatUtil.AGE.display(cellValue)
  102. }
  103. },
  104. { fixed: true, comSearchWeight: 70, showOverflowTooltip: true, label: t('hospital.hrpatient.ID_CARDNUM'), prop: 'ID_CARDNUM', align: 'center', operatorPlaceholder: t('Accurate query'), operator: 'eq', sortable: false, width: 90 },
  105. // { showOverflowTooltip: true, label: t('hospital.hrpatient.CHIEFCOMPLAINT'), prop: 'CHIEFCOMPLAINT', align: 'center', operator: 'LIKE', sortable: 'custom', },
  106. { fixed: true, comSearchWeight: 50, showOverflowTooltip: true, label: t('hospital.hrpatient.DIAGNOSENAME'), prop: 'DIAGNOSENAME', align: 'center', operator: 'LIKE', sortable: false, width: 150 },
  107. { comSearchWeight: 20, comSearchLabel: t('hospital.hrpatient.Search_LAB_ITEMNAME'), showOverflowTooltip: true, label: t('hospital.hrpatient.LAB_ITEMNAME'), prop: 'LAB_ITEMNAME', width: 130, align: 'center', operator: 'LIKE', sortable: false, },
  108. { comSearchWeight: 10, comSearchLabel: t('hospital.hrpatient.Search_EXAM_ITEMNAME'), showOverflowTooltip: true, label: t('hospital.hrpatient.EXAM_ITEMNAME'), prop: 'EXAM_ITEMNAME', width: 130, align: 'center', operator: 'LIKE', sortable: false, },
  109. { comSearchWeight: 30, comSearchLabel: t('hospital.hrpatient.Search_create_time'), showOverflowTooltip: true, label: t('hospital.hrpatient.create_time'), prop: 'create_time', align: 'center', render: 'datetime', operator: 'RANGE', sortable: 'custom', width: 130, timeFormat: 'yyyy-mm-dd hh:MM' },
  110. { comSearchWeight: 110, comSearchLabel: t('hospital.hrpatient.Search_MY_ORGNAME'), show: false, showOverflowTooltip: true, label: t('hospital.hrpatient.MY_ORGNAME'), prop: 'ORGCODE', align: 'center', operator: 'IN',
  111. filterable: true,
  112. comSearchRender: 'localSelect',
  113. local: localSelect.INS_NAME_LIST,
  114. localExt: {
  115. clearable: false,
  116. },
  117. width: 125,
  118. formatter(row, column, cellValue, index) {
  119. return row.ORGNAME
  120. },
  121. // comSearchRender: 'remoteSelect', remote: {
  122. // // TODO 后期看看需不需要传ID服务端做对应调整
  123. // pk: "name",
  124. // field: "name",
  125. // params: {},
  126. // multiple: true,
  127. // remoteUrl: '/admin/option/getInsList',
  128. // }
  129. },
  130. { comSearchWeight: 40, comSearchLabel: t('hospital.hrpatient.Search_MY_HRORGNAME'), showOverflowTooltip: true, label: t('hospital.hrpatient.MY_HRORGNAME'), prop: 'HRORGNAME', width: 100, align: 'center',
  131. operator: 'LIKE'
  132. // operator: 'IN',
  133. // comSearchRender: 'remoteSelect', remote: {
  134. // // TODO 后期看看需不需要传ID服务端做对应调整
  135. // pk: "name",
  136. // field: "name",
  137. // params: {},
  138. // multiple: true,
  139. // remoteUrl: '/admin/option/getInsList',
  140. // }
  141. },
  142. ],
  143. dblClickNotEditColumn: [undefined],
  144. defaultOrder: { prop: 'create_time', order: 'desc' },
  145. },
  146. {
  147. defaultItems: { ORGNAME: null, HRORGNAME: null, NAME: null, GENDER: null, AGE: null, ID_CARDNUM: null, MPI: null, ENCOUNTER_DATE: null, CHIEFCOMPLAINT: null, DIAGNOSENAME: null, LAB_ITEMNAME: null, EXAM_ITEMNAME: null },
  148. },
  149. {
  150. onTableHeaderAction: function({ data }) {
  151. if(!data || !(data.data instanceof Array)) {
  152. return true
  153. }
  154. for(const item of data?.data) {
  155. // console.log('item.field', item.field)
  156. // if(item.field == 'GENDER') {
  157. // item.field = 'GENDER_CODE'
  158. // }
  159. if(item?.field == 'AGE') {
  160. item.val = FormatUtil.AGE.search(item.val)
  161. }
  162. }
  163. return true;
  164. }
  165. }
  166. )
  167. provide('baTable', baTable)
  168. const onDetail = () => {
  169. const selecttion: any = baTable.table.selection
  170. const HR_CODE = selecttion[selecttion.length-1].HR_CODE
  171. routePush('/admin/hospital/hrpatient/myDetail?CODE=' + HR_CODE)
  172. }
  173. const showComSearchHandle = () => {
  174. baTable.table.showComSearch = !baTable.table.showComSearch
  175. }
  176. defineExpose({
  177. showComSearchHandle
  178. });
  179. const updateBaTable = inject('updateBaTable') as any
  180. onMounted(async() => {
  181. baTable.table.ref = tableRef.value
  182. baTable.mount()
  183. await localSelect.initLISTS([localSelect._KEY.INS_NAME_LIST])
  184. baTable.comSearch.form['ORGNAME'] = route.query.name ? route.query.name : adminInfo.institution
  185. if(baTable.onComSearch) {
  186. baTable.onComSearch()
  187. updateBaTable(baTable)
  188. }
  189. // baTable.form['ORGNAME']
  190. // baTable.getIndex()?.then(() => {
  191. // baTable.initSort()
  192. // baTable.dragSort()
  193. // })
  194. })
  195. watch(
  196. () => route.query.name,
  197. (newVal) => {
  198. setTimeout(() => {
  199. baTable.comSearch.form['ORGNAME'] = newVal ? newVal : adminInfo.institution
  200. }, 100);
  201. },
  202. {deep: true}
  203. )
  204. </script>
  205. <style scoped lang="scss">
  206. .view-detail {
  207. position: fixed;
  208. top: 58px;
  209. }
  210. </style>