index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="m-4 modals">
  3. <div>
  4. <XTTitle title="耗材预估" :right-data="titleData" @click="callTitleClick" />
  5. <div class="flex items-center justify-between my-4">
  6. <XTTab
  7. type="illness"
  8. :width="180"
  9. :selected="tabSelected"
  10. :data="typeOptions"
  11. @item-click="callTab"
  12. />
  13. <XTForm :form-data="formData" @change="callForm" />
  14. </div>
  15. </div>
  16. <BasicTable @register="registerTable">
  17. <template #bodyCell="{ column, record }">
  18. <template v-if="column.key === 'dialyzer'">
  19. <div v-for="(item, index) in record.consumable.dialyzer" :key="index">
  20. {{ item.name + ':' + item.count + item.unit }}</div
  21. >
  22. </template>
  23. <template v-if="column.key === 'punctureNeedle'">
  24. <div v-for="(item, index) in record.consumable.punctureNeedle" :key="index">
  25. {{ item.name + ':' + item.count + item.unit }}</div
  26. >
  27. </template>
  28. <template v-if="column.key === 'conduit'">
  29. <div v-for="(item, index) in record.consumable.conduit" :key="index">
  30. {{ item.name + ':' + item.count + item.unit }}</div
  31. >
  32. </template>
  33. <template v-if="column.key === 'drug'">
  34. <div v-for="(item, index) in record.drug" :key="index">
  35. {{ item.name + ':' + item.count + item.unit }}</div
  36. >
  37. </template>
  38. <template v-if="column.key === 'vascularAccess'">
  39. <div v-for="(item, index) in record.vascularAccess" :key="index">{{
  40. item.name + ':' + item.count + item.unit
  41. }}</div>
  42. </template>
  43. </template>
  44. <template #expandedRowRender>
  45. <BasicTable @register="registerTableInner">
  46. <template #bodyCell="{ column, record }">
  47. <template v-if="column.key === 'dialyzer'">
  48. <div v-for="(item, index) in record.suppliesByType.dialyzer" :key="index">
  49. {{ item.name + ':' + item.count + item.unit }}</div
  50. >
  51. </template>
  52. <template v-if="column.key === 'punctureNeedle'">
  53. <div v-for="(item, index) in record.suppliesByType.punctureNeedle" :key="index">
  54. {{ item.name + ':' + item.count + item.unit }}</div
  55. >
  56. </template>
  57. <template v-if="column.key === 'conduit'">
  58. <div v-for="(item, index) in record.suppliesByType.conduit" :key="index">
  59. {{ item.name + ':' + item.count + item.unit }}</div
  60. >
  61. </template>
  62. <template v-if="column.key === 'supplies'">
  63. <div v-for="(item, index) in record.supplies" :key="index">
  64. {{ item.name + ':' + item.count + item.unit }}</div
  65. >
  66. </template>
  67. </template>
  68. </BasicTable>
  69. </template>
  70. <template #expandIcon>
  71. <Icon icon="icon-right|iconfont" :size="14" />
  72. </template>
  73. </BasicTable>
  74. <PrintModal @register="registerModal" />
  75. </div>
  76. </template>
  77. <script lang="ts" setup>
  78. import { onBeforeMount, ref } from 'vue';
  79. import { BasicTable, useTable } from '/@/components/TableCard';
  80. import { columns, innerColumns } from './data';
  81. import {
  82. getestimateWardList,
  83. getWardAndNumber,
  84. getestimateInWardList,
  85. } from '/@/api/biz/inventory/estimateApi';
  86. import Icon from '/@/components/Icon';
  87. import { XTTitle } from '/@/components/XTTitle/index';
  88. import { XTTab } from '/@/components/XTTab/index';
  89. import { useModal } from '/@/components/Modal';
  90. import PrintModal from './printModal.vue';
  91. import { XTForm } from '/@/components/XTForm/index';
  92. import dayjs from 'dayjs';
  93. // 标题数据
  94. const titleData = [
  95. {
  96. type: 'print',
  97. icon: 'icon-xt-print_default',
  98. },
  99. ];
  100. // formdata
  101. const formData = [
  102. {
  103. name: 'shiftDate',
  104. componentType: 'DatePicker',
  105. format: 'YYYY-MM-DD',
  106. valueFormat: 'YYYY-MM-DD',
  107. placeholder: '请选择日期',
  108. width: 240,
  109. defaultValue: dayjs().format('YYYY-MM-DD'),
  110. },
  111. {
  112. name: 'searchNames',
  113. componentType: 'Input',
  114. prefix: 'icon-xt-search',
  115. placeholder: '请输入耗材名称',
  116. width: 240,
  117. },
  118. ];
  119. // tab 切换选中
  120. const tabSelected = ref();
  121. // 操作名称
  122. const searchNames = ref('');
  123. const shiftDate = ref([]);
  124. const typeOptions = ref();
  125. const innerTableList = ref([] as any);
  126. const innerTableOpen = ref(false);
  127. const [registerModal, { openModal }] = useModal();
  128. onBeforeMount(async () => {
  129. getTab();
  130. });
  131. const tableSort = ref([
  132. {
  133. field: 'create_time',
  134. direction: 'DESC',
  135. },
  136. ]) as any;
  137. const [registerTable, { reload, collapseAll }] = useTable({
  138. api: getestimateWardList,
  139. rowKey: 'inpatientWardId',
  140. isTreeTable: true,
  141. expandRowByClick: true,
  142. columns,
  143. showIndexColumn: false,
  144. bordered: true,
  145. onExpand: handleExpand,
  146. beforeFetch: handleBeforeFetch,
  147. });
  148. const [registerTableInner, { setTableData }] = useTable({
  149. // , { reload: reloadInner }
  150. dataSource: innerTableList,
  151. rowKey: 'inpatientWardId',
  152. columns: innerColumns,
  153. showIndexColumn: true,
  154. bordered: true,
  155. pagination: false,
  156. });
  157. // 新增按钮事件
  158. function callTitleClick(data) {
  159. if (data.type == 'print') {
  160. console.log('打印中...');
  161. openModal(true, {
  162. suppliesName: searchNames.value == '' ? undefined : searchNames.value,
  163. partWardId: tabSelected.value == '' ? undefined : tabSelected.value,
  164. time: shiftDate.value.length <= 0 ? dayjs().format('YYYY-MM-DD') : shiftDate.value,
  165. });
  166. }
  167. }
  168. // 表格请求之前,对参数进行处理, 添加默认 排序
  169. async function handleBeforeFetch(params) {
  170. return {
  171. ...params,
  172. orders: tableSort.value,
  173. suppliesName: searchNames.value == '' ? undefined : searchNames.value,
  174. partWardId: tabSelected.value == '' ? undefined : tabSelected.value,
  175. time: shiftDate.value.length <= 0 ? dayjs().format('YYYY-MM-DD') : shiftDate.value,
  176. };
  177. }
  178. // 点击一级展示二级数据
  179. async function handleExpand(expandedRows, record) {
  180. if (expandedRows) {
  181. const params = {
  182. pageNum: 1,
  183. pageSize: 999,
  184. suppliesName: searchNames.value == '' ? undefined : searchNames.value,
  185. partWardId: record.inpatientWardId,
  186. time: shiftDate.value.length <= 0 ? dayjs().format('YYYY-MM-DD') : shiftDate.value,
  187. };
  188. const resList = await getestimateInWardList(params);
  189. if (resList) {
  190. innerTableList.value = resList;
  191. setTableData(resList);
  192. }
  193. innerTableOpen.value = true;
  194. }
  195. }
  196. // 切换病区事件
  197. async function getTab() {
  198. const typeNums = await getWardAndNumber(); // 获取各类型数量
  199. const typeList = [];
  200. typeNums.forEach(item => {
  201. typeList.push({
  202. key: item.inpatientWardId ? item.inpatientWardId : '',
  203. label: item.inpatientWardName ? item.inpatientWardName : '全部',
  204. value: item.arrangedNumber,
  205. hasValue: true,
  206. hasBracket: true,
  207. toolTipTitle: '已排床:' + item.arrangedNumber + ' 空床位:' + item.emptyNumber,
  208. });
  209. });
  210. typeOptions.value = typeList;
  211. tabSelected.value = typeOptions.value[0].key;
  212. }
  213. // 选项卡组件回调
  214. async function callTab(data) {
  215. tabSelected.value = data.value;
  216. await reload();
  217. if (innerTableOpen.value) {
  218. await collapseAll();
  219. }
  220. }
  221. // 查询组件回调
  222. async function callForm(data) {
  223. shiftDate.value = data.shiftDate ? data.shiftDate : '';
  224. searchNames.value = data.searchNames ? data.searchNames : '';
  225. console.log('callForm:::', searchNames.value);
  226. await reload();
  227. if (innerTableOpen.value) {
  228. await collapseAll();
  229. }
  230. }
  231. </script>
  232. <style lang="less" scoped>
  233. .table-dot {
  234. display: inline-block;
  235. width: 10px;
  236. height: 10px;
  237. margin-right: 6px;
  238. border-radius: 50%;
  239. }
  240. ::v-deep(.ant-btn-link) {
  241. color: #3d4155;
  242. }
  243. ::v-deep(.ant-input-prefix) {
  244. color: #8a99ac;
  245. }
  246. .colUpdateAvatar {
  247. display: flex;
  248. justify-content: center;
  249. text-align: center;
  250. line-height: 28px;
  251. }
  252. .colImg {
  253. width: 28px;
  254. height: 28px;
  255. margin-right: 5px;
  256. }
  257. </style>