index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <div class="m-4">
  3. <div>
  4. <XTTitle title="透析设备" :right-data="titleData" @click="callTitleClick" />
  5. <div class="flex justify-between my-4">
  6. <XTTab
  7. type="illness"
  8. :width="136"
  9. :selected="activeKey"
  10. :data="tabData"
  11. @item-click="callTab"
  12. />
  13. <XTForm :form-data="formData" @change="callFormChange" @click="callFormClick" />
  14. </div>
  15. <div class="flex mb-2" v-if="siftData.length">
  16. <Sift :data="siftData" @close="callClose" />
  17. </div>
  18. <BasicTable @register="registerTable">
  19. <template #bodyCell="{ column, record }">
  20. <template v-if="column.key === 'name'">
  21. <span :class="['table-dot', 'table-dot--' + record.status]" />
  22. <span>{{ record.name }}</span>
  23. </template>
  24. <template v-if="column.key === 'birthday'">
  25. {{ record.birthday ? dayjs(record.birthday).format('YYYY-MM-DD') : '' }}
  26. </template>
  27. <template v-if="column.key === 'firstDialysisTime'">
  28. {{
  29. record.firstDialysisTime ? dayjs(record.firstDialysisTime).format('YYYY-MM-DD') : ''
  30. }}
  31. </template>
  32. <template v-if="column.key === 'gender'">
  33. <span
  34. :style="{
  35. backgroundColor: formatDictColor(bizDictOptions.gender, record.gender),
  36. color: formatDictFontColor(bizDictOptions.gender, record.gender),
  37. padding: '1px 6px',
  38. borderRadius: '2px',
  39. marginRight: '4px',
  40. }"
  41. >
  42. {{ formatDictValue(bizDictOptions.gender, record.gender) }}
  43. </span>
  44. </template>
  45. <template v-if="column.key === 'firstDialysisType'">
  46. {{ formatDictValue(bizDictOptions.firstDialysisType, record.firstDialysisType) }}
  47. </template>
  48. <template v-if="column.key === 'type'">
  49. {{ formatDictValue(bizDictOptions.type, record.type) }}
  50. </template>
  51. <template v-if="column.key === 'infectiousDiseases'">
  52. <div class="flex">
  53. <div
  54. v-for="item in record.infectiousDiseases"
  55. :key="item"
  56. :style="{
  57. backgroundColor: formatDictColor(bizDictOptions.infectiousDiseases, item),
  58. color: formatDictFontColor(bizDictOptions.infectiousDiseases, item),
  59. padding: '1px 6px',
  60. borderRadius: '2px',
  61. marginRight: '4px',
  62. }"
  63. >
  64. <!-- {{ record.infectiousDiseases }} -->
  65. {{ formatDictValue(bizDictOptions.infectiousDiseases, item) }}
  66. </div>
  67. </div>
  68. </template>
  69. <template v-if="column.key === 'vascularAccess'">
  70. {{ formatDictValue(bizDictOptions.vascularAccess, record.vascularAccess) }}
  71. </template>
  72. <template v-if="column.key === 'patientReturn'">
  73. {{ formatDictValue(bizDictOptions.patientReturn, record.patientReturn) }}
  74. </template>
  75. <template v-if="column.key === 'action'">
  76. <TableAction
  77. :actions="[
  78. {
  79. auth: 'archives:patientBasic:query',
  80. icon: 'icon-xt-medical_default|iconfont',
  81. tooltip: '详情',
  82. label: '详情',
  83. onClick: handleView.bind(null, record),
  84. },
  85. ]"
  86. />
  87. </template>
  88. </template>
  89. </BasicTable>
  90. </div>
  91. <FormModal @register="registerModal" @success="callSuccess" />
  92. <FormDrawerSift @register="registerDrawer" @success="callSift" />
  93. </div>
  94. </template>
  95. <script setup lang="ts">
  96. import { XTTitle } from '/@/components/XTTitle/index';
  97. import { XTTab } from '/@/components/XTTab/index';
  98. import { XTForm } from '/@/components/XTForm/index';
  99. import { Sift } from '/@/components/XTList/index';
  100. import { BasicTable, useTable, TableAction } from '/@/components/TableCard';
  101. import { BasicTab, BasicTabActive, columns, siftFormSchema } from './data';
  102. import { ref } from 'vue';
  103. import { useRouter } from 'vue-router';
  104. import { archivesPatientBasicStats } from '/@/api/biz/archives/patientBasicApi';
  105. import { engineerDialysisDeviceQueryPage } from '@/api/biz/engineer/dialysisDeviceApi';
  106. import { listDictModelBatch } from '@/api/common';
  107. import { formatDictColor, formatDictFontColor, formatDictValue } from '/@/utils';
  108. import { onMounted, reactive } from 'vue';
  109. import dayjs from 'dayjs';
  110. import { useModal } from '/@/components/Modal';
  111. import FormModal from './FormModal.vue';
  112. // 筛选条件
  113. import FormDrawerSift from './FormDrawerSift.vue';
  114. import { useDrawer } from '@/components/Drawer';
  115. const bizDictOptions = reactive<any>({});
  116. const bizDictData = ref([
  117. // 血管材料
  118. { key: 'gender', dictCode: 'pb_sex' },
  119. // 转归类型
  120. { key: 'patientReturn', dictCode: 'pb_return' },
  121. // 传染病
  122. { key: 'infectiousDiseases', dictCode: 'pb_epidemic' },
  123. // 患者类型
  124. { key: 'type', dictCode: 'pb_type' },
  125. // 通路类型
  126. { key: 'vascularAccess', dictCode: 'va_type' },
  127. // 转归原因
  128. { key: 'return', dictCode: 'va_return' },
  129. // 首次透析方式
  130. { key: 'firstDialysisType', dictCode: 'dt' },
  131. ]);
  132. // 路由跳转
  133. const router = useRouter();
  134. const activeKey = ref(BasicTabActive);
  135. const tabData = ref(BasicTab);
  136. const [registerModal, { openModal }] = useModal();
  137. const [registerDrawer, { openDrawer }] = useDrawer();
  138. onMounted(async () => {
  139. const res = await listDictModelBatch(bizDictData.value.map(ele => ele.dictCode));
  140. for (const i in res) {
  141. const filter = bizDictData.value.filter(ele => ele.dictCode == i)[0];
  142. bizDictOptions[filter.key] = res[i];
  143. }
  144. const stats = await archivesPatientBasicStats();
  145. console.log('🚀 ~ file: index.vue:104 ~ onMounted ~ stats:', stats);
  146. tabData.value = tabData.value.map(ele => {
  147. if (ele.key == '0') {
  148. ele.value = stats.all;
  149. }
  150. if (ele.key == '1') {
  151. ele.value = stats.newPatient;
  152. }
  153. if (ele.key == '2') {
  154. ele.value = stats.noneFormulate;
  155. }
  156. if (ele.key == '3') {
  157. ele.value = stats.positive;
  158. }
  159. return ele;
  160. });
  161. console.log('🚀 ~ file: index.vue:118 ~ onMounted ~ tabData.value:', tabData.value);
  162. });
  163. const [registerTable, { reload }] = useTable({
  164. api: engineerDialysisDeviceQueryPage,
  165. exportAuthList: ['sys:log:export'],
  166. rowKey: 'id',
  167. columns,
  168. showIndexColumn: false,
  169. bordered: true,
  170. actionColumn: {
  171. width: 100,
  172. title: '操作',
  173. dataIndex: 'action',
  174. },
  175. beforeFetch: handleBeforeFetch,
  176. afterFetch: handleAfterFetch,
  177. });
  178. // 筛选数据
  179. const siftData = ref([]);
  180. // 标题数据
  181. const titleData = [
  182. {
  183. type: 'import',
  184. icon: 'icon-xt-import_default',
  185. },
  186. {
  187. type: 'add',
  188. btnIcon: 'icon-xt-add_default',
  189. btnText: '新增设备',
  190. },
  191. ];
  192. const formData = ref([
  193. {
  194. name: 'name',
  195. componentType: 'Input',
  196. placeholder: '请输入设备编号',
  197. prefix: 'icon-xt-search',
  198. width: 240,
  199. },
  200. {
  201. name: 'filter',
  202. componentType: 'IconBtn',
  203. count: 0,
  204. },
  205. ]);
  206. const formValue = reactive({
  207. name: '',
  208. }) as any;
  209. // const tableSort = ref([
  210. // {
  211. // field: 'create_time',
  212. // direction: 'DESC',
  213. // },
  214. // ]) as any;
  215. // 表格请求之前,对参数进行处理, 添加默认 排序
  216. function handleBeforeFetch(params) {
  217. // return { ...params, orders: tableSort.value };
  218. const sift = {};
  219. siftData.value.forEach(ele => {
  220. sift[ele.field] = ele.isDict ? ele.dict : ele.value;
  221. });
  222. if (params?.order) {
  223. params.orders = [
  224. {
  225. field: params.field,
  226. direction: params.order.substring(0, params.order.length - 3).toUpperCase(),
  227. },
  228. ];
  229. delete params.order;
  230. delete params.field;
  231. }
  232. return {
  233. ...params,
  234. queryType: activeKey.value == '0' ? '0' : activeKey.value,
  235. name: formValue.name,
  236. ...sift,
  237. };
  238. }
  239. function handleAfterFetch(data) {
  240. return data;
  241. }
  242. // 详情按钮事件
  243. function handleView(record: Recordable) {
  244. //
  245. router.push({
  246. path: '/bizEngineer/dialysisDevices/details',
  247. query: {
  248. id: record.id,
  249. name: record.name,
  250. },
  251. });
  252. }
  253. // 弹窗回调事件
  254. async function callSuccess({ isUpdate, values }) {
  255. console.log(isUpdate);
  256. console.log(values);
  257. await reload();
  258. }
  259. // 回调
  260. async function callTab(data) {
  261. activeKey.value = data.value;
  262. await reload();
  263. }
  264. function callTitleClick(data) {
  265. if (data.type == 'add') {
  266. openModal(true, {
  267. isUpdate: false,
  268. record: data,
  269. });
  270. }
  271. }
  272. async function callFormChange(data) {
  273. formValue.name = data.name ? data.name : '';
  274. await reload();
  275. }
  276. async function callFormClick(data) {
  277. if (data.name == 'filter') {
  278. const record = [];
  279. siftData.value.forEach(ele => {
  280. const obj = {
  281. field: ele.field,
  282. value: ele.value,
  283. } as any;
  284. if (ele.isDict) {
  285. obj.value = ele.dict;
  286. }
  287. record.push(obj);
  288. });
  289. openDrawer(true, {
  290. record,
  291. });
  292. }
  293. }
  294. // 筛选条件回调
  295. async function callSift(data) {
  296. siftData.value = [];
  297. for (const i in data) {
  298. if (data[i]) {
  299. siftFormSchema.forEach(ele => {
  300. // console.log('🚀 ~ file: index.vue:280 ~ obj ~ ele:', ele);
  301. if (ele.field == i) {
  302. siftData.value.push({
  303. field: ele.field,
  304. label: ele.label,
  305. value: ele.component.includes('Api')
  306. ? formatDictValue(bizDictOptions.gender, data[i])
  307. : data[i],
  308. isDict: ele.component.includes('Api'),
  309. dict: ele.component.includes('Api') ? data[i] : '',
  310. });
  311. }
  312. formData.value[formData.value.length - 1]['count'] = siftData.value.length;
  313. });
  314. }
  315. }
  316. await reload();
  317. }
  318. async function callClose(data) {
  319. if (data.type == 'clear') {
  320. console.log('清空全部');
  321. siftData.value = [];
  322. }
  323. if (data.type == 'close') {
  324. console.log('删除部分条件');
  325. siftData.value = siftData.value.filter(ele => {
  326. return ele.field != data.item?.field;
  327. });
  328. }
  329. formData.value[formData.value.length - 1]['count'] = siftData.value.length;
  330. await reload();
  331. }
  332. </script>
  333. <style lang="less" scoped>
  334. .table-dot {
  335. display: inline-block;
  336. width: 10px;
  337. height: 10px;
  338. margin-right: 6px;
  339. border-radius: 50%;
  340. &--1 {
  341. background-color: #1bc1b3;
  342. }
  343. &--2 {
  344. background-color: #d3d8dd;
  345. }
  346. &--3 {
  347. background-color: #f7b500;
  348. }
  349. }
  350. ::v-deep(.ant-btn-link) {
  351. color: rgb(61 65 85 / 100%);
  352. }
  353. </style>