| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <template>
- <div>
- <div class="flex justify-between mb-4">
- <div>
- <a-button type="primary" size="large" class="btn-add" @click="handleCreate">查房</a-button>
- </div>
- <div>
- <XTForm :form-data="formData" @change="callForm" />
- </div>
- </div>
- <BasicTable @register="registerTable">
- <template #bodyCell="{ column, record }">
- <template v-if="column.key === 'updatorName'">
- <img :src="record.updateAvatar" class="table-avatar" />
- {{ record.updatorName }}
- </template>
- <template v-if="column.key === 'action'">
- <TableAction
- :actions="[
- {
- auth: 'archives:patrolWard:edit',
- icon: 'icon-xt-details_edit_default|iconfont',
- tooltip: '编辑',
- onClick: handleEdit.bind(null, record),
- },
- {
- auth: 'archives:patrolWard:remove',
- icon: 'icon-xt-details_delete_default|iconfont',
- tooltip: '删除',
- popConfirm: {
- title: '是否取消删除',
- placement: 'left',
- confirm: handleDelete.bind(null, record, column),
- },
- },
- ]"
- />
- </template>
- </template>
- </BasicTable>
- <FormModal @register="registerModal" @success="callSuccess" />
- </div>
- </template>
- <script lang="ts" setup>
- import { reactive, ref } from 'vue';
- import { XTForm } from '/@/components/XTForm/index';
- import { BasicTable, useTable, TableAction } from '/@/components/Table';
- // import { useModal } from '/@/components/Modal';
- import { useMessage } from '/@/hooks/web/useMessage';
- import FormModal from './FormModal.vue';
- // import ViewDrawer from './viewDrawer.vue';
- import { columns } from './data';
- import {
- archivesPatrolWardQueryPage,
- archivesPatrolWardRemove,
- } from '/@/api/biz/archives/patrolWardApi';
- import { useModal } from '/@/components/Modal';
- import dayjs from 'dayjs';
- const props = defineProps({
- info: {
- type: Object,
- default: () => {},
- },
- });
- const { createConfirm, createMessage } = useMessage();
- const [registerModal, { openModal }] = useModal();
- const tableSort = ref([
- {
- field: 'create_time',
- direction: 'DESC',
- },
- ]) as any;
- // formdata
- const formData = [
- {
- name: 'patrolTime',
- label: '查房时间',
- componentType: 'RangePicker',
- placeholder: '请输入',
- format: 'YYYY-MM-DD',
- valueFormat: 'YYYY-MM-DD',
- defaultValue: [
- dayjs().subtract(3, 'month').format('YYYY-MM-DD'),
- dayjs().format('YYYY-MM-DD'),
- ],
- },
- {
- name: 'content',
- componentType: 'Input',
- placeholder: '请输入',
- prefix: 'icon-xt-search',
- width: 280,
- },
- ];
- const formValue = reactive({
- patrolTime: [
- dayjs().subtract(3, 'month').format('YYYY-MM-DD'),
- dayjs().add(1, 'day').format('YYYY-MM-DD'),
- ],
- content: '',
- });
- const [registerTable, { reload, getSelectRowKeys }] = useTable({
- api: archivesPatrolWardQueryPage,
- rowKey: 'id',
- columns,
- showIndexColumn: false,
- bordered: true,
- striped: false,
- actionColumn: {
- width: 200,
- title: '操作',
- dataIndex: 'action',
- },
- beforeFetch: handleBeforeFetch,
- sortFn: handleSortFn,
- });
- // 新增按钮事件
- function handleCreate() {
- openModal(true, {
- isUpdate: false,
- record: { patientBasicId: props.info.id },
- });
- }
- // 编辑按钮事件
- function handleEdit(record: Recordable) {
- openModal(true, {
- record: { patientBasicId: props.info.id, ...record },
- isUpdate: true,
- });
- }
- // 删除按钮事件
- async function handleDelete(record: Recordable) {
- if (record) {
- await archivesPatrolWardRemove([record.id]);
- createMessage.success('删除成功!');
- await reload();
- } else {
- createConfirm({
- content: '你确定要删除?',
- iconType: 'warning',
- onOk: async () => {
- const keys = getSelectRowKeys();
- await archivesPatrolWardRemove(keys);
- createMessage.success('删除成功!');
- await reload();
- },
- });
- }
- }
- // 表格点击字段排序
- function handleSortFn(sortInfo) {
- if (sortInfo?.order && sortInfo?.columnKey) {
- // 默认单列排序
- tableSort.value = [
- {
- field: sortInfo.columnKey,
- direction: sortInfo.order.replace(/(\w+)(end)/g, '$1').toUpperCase(),
- },
- ];
- }
- }
- // 表格请求之前,对参数进行处理, 添加默认 排序
- function handleBeforeFetch(params) {
- console.log({ ...params, orders: tableSort.value, patientBasicId: props.info?.id });
- return {
- ...params,
- orders: tableSort.value,
- patientBasicId: props.info?.id,
- patrolTime: [
- formValue.patrolTime[0],
- dayjs(formValue.patrolTime[1]).add(1, 'day').format('YYYY-MM-DD'),
- ],
- content: formValue.content,
- };
- }
- // 弹窗回调事件
- async function callSuccess() {
- await reload();
- }
- // 查询回调
- async function callForm(data) {
- formValue.content = data.content || '';
- formValue.patrolTime = data.patrolTime || '';
- await reload();
- }
- </script>
- <style lang="less" scoped>
- ::v-deep(.ant-btn-link) {
- color: rgb(61 65 85 / 100%);
- }
- ::v-deep(.ant-input) {
- border-color: #c2ccd4;
- border-radius: 4px;
- }
- ::v-deep(.ant-input-affix-wrapper) {
- border-color: #c2ccd4;
- border-radius: 4px;
- }
- ::v-deep(.ant-picker) {
- border-color: #c2ccd4;
- border-radius: 4px;
- }
- ::v-deep(.ant-table-tbody > tr > td) {
- border-right: 0 !important;
- border-left: 0 !important;
- border-bottom: 1px solid #f0f0f0;
- }
- ::v-deep(.ant-table-wrapper table) {
- border: 0;
- }
- ::v-deep(.ant-table-cell-fix-right-first::after, .ant-table-cell-fix-right-last::after) {
- content: '';
- top: auto;
- width: 0;
- }
- .btn-add {
- width: 120px;
- border-radius: 4px;
- }
- </style>
|