Procházet zdrojové kódy

feat: 排床备忘录

fan před 2 roky
rodič
revize
b018c23499

+ 98 - 0
src/api/biz/bed/scheduledMemoApi.ts

@@ -0,0 +1,98 @@
+import { defHttp } from '/@/utils/http/axios';
+import { setParams } from '/@/utils/index';
+
+enum Api {
+  bedScheduledMemoQueryPage = '/bed/scheduledMemo/query/page',
+  bedScheduledMemoDetail = '/bed/scheduledMemo/detail',
+  bedScheduledMemoAdd = '/bed/scheduledMemo/add',
+  bedScheduledMemoEdit = '/bed/scheduledMemo/edit',
+  bedScheduledMemoRemove = '/bed/scheduledMemo/removeByIds',
+}
+
+/**
+ *
+ * @author lf
+ * @date  2023/07/17 16:06
+ * @description: 根据条件查询排床备忘录列表,权限 - scheduled:scheduledMemo:query
+ * @method: POST
+ * @param:
+ * @return:
+ *       {String}  patientBasicId  基础病历id
+ *       {Date}  appointmentDate  预约日期
+ *       {String}  appointmentSailings  预约班次
+ *       {String}  remark  备注
+ *       {String}  creatorName  creator_name
+ *       {String}  updatorName  updator_name
+ */
+
+export const bedScheduledMemoQueryPage = (params?: object) => {
+  return defHttp.post({ url: Api.bedScheduledMemoQueryPage, params: setParams(params) });
+};
+/**
+ *
+ * @author lf
+ * @date  2023/07/17 16:06
+ * @description: 根据id查询排床备忘录详细信息,权限 - scheduled:scheduledMemo:query
+ * @method: GET
+ * @param:  id 排床备忘录主键id
+ * @return:
+ *       {String}  patientBasicId  基础病历id
+ *       {Date}  appointmentDate  预约日期
+ *       {String}  appointmentSailings  预约班次
+ *       {String}  remark  备注
+ *       {String}  creatorName  creator_name
+ *       {String}  updatorName  updator_name
+ */
+export const bedScheduledMemoDetail = (id: string) => {
+  return defHttp.get({ url: Api.bedScheduledMemoDetail + '/' + id });
+};
+
+/**
+ *
+ * @author lf
+ * @date  2023/07/17 16:06
+ * @description: 添加排床备忘录,权限 - scheduled:scheduledMemo:add
+ * @method: POST
+ * @param:
+ *       {String}  patientBasicId  基础病历id
+ *       {Date}  appointmentDate  预约日期
+ *       {String}  appointmentSailings  预约班次
+ *       {String}  remark  备注
+ *       {String}  creatorName  creator_name
+ *       {String}  updatorName  updator_name
+ * @return:
+ *       0 添加失败
+ *       1 添加成功
+ */
+export const bedScheduledMemoAdd = (params?: object) => {
+  return defHttp.post({ url: Api.bedScheduledMemoAdd, params: params });
+};
+
+/**
+ *
+ * @author lf
+ * @date  2023/07/17 16:06
+ * @description: 通过主键id编辑排床备忘录,权限 - scheduled:scheduledMemo:edit
+ * @method: POST
+ * @param:
+ *       {String}  patientBasicId  基础病历id
+ *       {Date}  appointmentDate  预约日期
+ *       {String}  appointmentSailings  预约班次
+ *       {String}  remark  备注
+ *       {String}  creatorName  creator_name
+ *       {String}  updatorName  updator_name
+ * @return:
+ *       0 编辑失败
+ *       1 编辑成功
+ */
+export const bedScheduledMemoEdit = (params?: object) => {
+  return defHttp.post({ url: Api.bedScheduledMemoEdit, params: params });
+};
+
+/**
+ * @description: 删除,权限 - scheduled:scheduledMemo:remove
+ * @method: POST
+ */
+export const bedScheduledMemoRemove = (params: Array<string | number>) => {
+  return defHttp.post({ url: Api.bedScheduledMemoRemove, params: params });
+};

+ 80 - 0
src/views/biz/bed/memo/FormModal.vue

@@ -0,0 +1,80 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerModal"
+    :title="getTitle"
+    :width="width"
+    @ok="handleSubmit"
+    :showFooter="true"
+  >
+    <BasicForm @register="registerForm" layout="vertical" class="!px-6 !pt-4" />
+  </BasicModal>
+</template>
+<script lang="ts" setup>
+  import { ref, computed, unref } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, useForm } from '/@/components/Form';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { dataFormSchema } from './data';
+
+  import {
+    bedScheduledMemoAdd,
+    bedScheduledMemoEdit,
+    bedScheduledMemoDetail,
+  } from '/@/api/biz/bed/scheduledMemoApi';
+  import dayjs from 'dayjs';
+
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增排床备忘录' : '编辑排床备忘录'));
+  const width = '30%';
+  const isUpdate = ref(false);
+  const rowId = ref();
+
+  const { createMessage } = useMessage();
+  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
+    labelWidth: 100,
+    schemas: dataFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => {
+    await resetFields();
+    setModalProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+
+    if (unref(isUpdate)) {
+      const resData = await bedScheduledMemoDetail(data.record.id);
+      rowId.value = resData.id;
+      await setFieldsValue({
+        ...resData,
+      });
+    } else {
+      await setFieldsValue({
+        appointmentDate: dayjs().format('YYYY-MM-DD'),
+      });
+    }
+  });
+
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setModalProps({ confirmLoading: true });
+      !unref(isUpdate)
+        ? await bedScheduledMemoAdd({ ...values })
+        : await bedScheduledMemoEdit({ ...values, id: rowId.value });
+      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
+      closeModal();
+      emit('success', {
+        isUpdate: unref(isUpdate),
+        values: { ...values, id: rowId.value },
+      });
+    } finally {
+      setModalProps({ confirmLoading: false });
+    }
+  }
+</script>

+ 113 - 0
src/views/biz/bed/memo/data.ts

@@ -0,0 +1,113 @@
+import dayjs from 'dayjs';
+import { BasicColumn, FormSchema } from '/@/components/Table';
+import { archivesPatientBasicQueryPage } from '@/api/biz/archives/patientBasicApi';
+
+export const columns: BasicColumn[] = [
+  {
+    title: '填写日期',
+    dataIndex: 'createTime',
+  },
+  {
+    title: '患者信息',
+    dataIndex: 'patientInfo',
+  },
+  {
+    title: '预约日期',
+    dataIndex: 'appointmentDate',
+  },
+  {
+    title: '预约班次',
+    dataIndex: 'appointmentSailingsName',
+  },
+  {
+    title: '备注',
+    dataIndex: 'remark',
+  },
+  {
+    title: '记录人',
+    dataIndex: 'creatorName',
+  },
+  {
+    title: '待办处理人',
+    dataIndex: 'todoName',
+  },
+];
+
+// 表单新增编辑
+export const dataFormSchema: FormSchema[] = [
+  {
+    label: '患者名称搜索',
+    field: 'patientBasicName',
+    component: 'Input',
+    ifShow: false,
+  },
+  {
+    label: '患者姓名',
+    field: 'patientBasicId',
+    required: true,
+    component: 'ApiSelect',
+    componentProps: ({ formModel }) => {
+      return {
+        api: archivesPatientBasicQueryPage,
+        params: {
+          name: formModel.patientBasicName,
+        },
+        labelField: 'name',
+        valueField: 'id',
+        resultField: 'data',
+        placeholder: '请输入患者姓名',
+        getPopupContainer: () => document.body,
+        showSearch: true,
+        filterOption: false,
+        onSearch: e => {
+          console.log('🚀 ~ file: data.ts:66 ~ e:', e);
+          formModel.patientBasicName = e;
+        },
+      };
+    },
+  },
+  {
+    label: '预约日期',
+    field: 'appointmentDate',
+    required: true,
+    component: 'DatePicker',
+    componentProps: {
+      placeholder: '请输入预约日期',
+      getPopupContainer: () => document.body,
+      valueFormat: 'YYYY-MM-DD',
+      disabledDate: current => {
+        return current < dayjs().subtract(1, 'day').endOf('day');
+      },
+    },
+  },
+  {
+    label: '预约班次',
+    field: 'appointmentSailingsSort',
+    required: true,
+    component: 'CheckboxGroup',
+    componentProps: {
+      options: [
+        {
+          label: '第一班',
+          value: '1',
+        },
+        {
+          label: '第二班',
+          value: '2',
+        },
+        {
+          label: '第三班',
+          value: '3',
+        },
+      ],
+    },
+  },
+  {
+    label: '备注',
+    field: 'remark',
+    component: 'InputTextArea',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
+];

+ 148 - 3
src/views/biz/bed/memo/index.vue

@@ -1,7 +1,152 @@
 <template>
-  <div> 占位符 </div>
+  <div class="m-4">
+    <div class="mb-2">
+      <XTTitle title="排床备忘录" :right-data="titleData" @click="callTitleClick" />
+    </div>
+    <BasicTable @register="registerTable">
+      <template #bodyCell="{ column, record }">
+        <template v-if="column.key === 'createTime'">
+          {{ record.createTime ? dayjs(record.createTime).format('YYYY-MM-DD') : '' }}
+        </template>
+        <template v-if="column.key === 'appointmentDate'">
+          {{ record.appointmentDate ? dayjs(record.appointmentDate).format('YYYY-MM-DD') : '' }}
+        </template>
+        <template v-if="column.key === 'appointmentSailingsName'">
+          <span v-for="(item, index) in record.appointmentSailingsName" :key="item">
+            {{ item }}
+            {{ index == record.appointmentSailingsName.length - 1 ? '' : '、' }}
+          </span>
+        </template>
+        <template v-if="column.key === 'patientInfo'">
+          {{ record.patientName }}/
+          {{ formatDictValue(bizDictOptions.gender, record.patientGender) }}/
+          {{ record.age }}
+        </template>
+        <template v-if="column.key === 'action'">
+          <TableAction
+            :actions="[
+              {
+                auth: 'bed:scheduledMemo:remove',
+                icon: 'icon-xt-details_delete_default|iconfont',
+                tooltip: '删除',
+                popConfirm: {
+                  title: '是否确认删除',
+                  placement: 'left',
+                  confirm: handleDelete.bind(null, record),
+                },
+              },
+            ]"
+          />
+        </template>
+      </template>
+    </BasicTable>
+    <FormModal @register="registerModal" @success="callSuccess" />
+  </div>
 </template>
+<script lang="ts" setup>
+  import { onMounted, reactive, ref } from 'vue';
 
-<script setup lang="ts"></script>
+  import { BasicTable, useTable, TableAction } from '/@/components/TableCard';
+  import { XTTitle } from '/@/components/XTTitle/index';
+  // import { useModal } from '/@/components/Modal';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import FormModal from './FormModal.vue';
+  import { columns } from './data';
 
-<style lang="less" scoped></style>
+  import {
+    bedScheduledMemoQueryPage,
+    bedScheduledMemoRemove,
+  } from '/@/api/biz/bed/scheduledMemoApi';
+  import { listDictModelBatch } from '/@/api/common';
+  import { formatDictValue } from '/@/utils';
+  import { useModal } from '@/components/Modal';
+  import dayjs from 'dayjs';
+
+  const { createConfirm, createMessage } = useMessage();
+  const [registerModal, { openModal }] = useModal();
+
+  const tableSort = ref([
+    {
+      field: 'create_time',
+      direction: 'DESC',
+    },
+  ]) as any;
+  const bizDictOptions = reactive<any>({});
+  const bizDictData = ref([{ key: 'gender', dictCode: 'pb_sex' }]);
+  onMounted(async () => {
+    const res = await listDictModelBatch(bizDictData.value.map(ele => ele.dictCode));
+    for (const i in res) {
+      const filter = bizDictData.value.filter(ele => ele.dictCode == i)[0];
+      bizDictOptions[filter.key] = res[i];
+    }
+  });
+  const [registerTable, { reload, getSelectRowKeys }] = useTable({
+    api: bedScheduledMemoQueryPage,
+    rowKey: 'id',
+    columns,
+    useSearchForm: false,
+    showIndexColumn: false,
+    actionColumn: {
+      width: 80,
+      title: '操作',
+      dataIndex: 'action',
+    },
+    beforeFetch: handleBeforeFetch,
+  });
+
+  // 标题数据
+  const titleData = [
+    {
+      type: 'add',
+      btnIcon: 'icon-xt-add_default',
+      btnText: '新增备忘录',
+    },
+  ];
+
+  // 新增按钮事件
+  function callTitleClick(data) {
+    if (data.type == 'add') {
+      openModal(true, {
+        isUpdate: false,
+        record: data,
+      });
+    }
+  }
+
+  // 删除按钮事件
+  async function handleDelete(record: Recordable) {
+    if (record) {
+      await bedScheduledMemoRemove([record.id]);
+      createMessage.success('删除成功!');
+      await reload();
+    } else {
+      createConfirm({
+        content: '你确定要删除?',
+        iconType: 'warning',
+        onOk: async () => {
+          const keys = getSelectRowKeys();
+          await bedScheduledMemoRemove(keys);
+          createMessage.success('删除成功!');
+          await reload();
+        },
+      });
+    }
+  }
+
+  // 表格请求之前,对参数进行处理, 添加默认 排序
+  function handleBeforeFetch(params) {
+    return { ...params, orders: tableSort.value };
+  }
+
+  // 弹窗回调事件
+  async function callSuccess({ isUpdate, values }) {
+    console.log(isUpdate);
+    console.log(values);
+    await reload();
+  }
+</script>
+<style lang="less" scoped>
+  ::v-deep(.ant-btn-link) {
+    color: rgb(61 65 85 / 100%);
+  }
+</style>