فهرست منبع

feat: 新增病区属性及病区信息

Tong 2 سال پیش
والد
کامیت
eb5b8479b8

+ 29 - 0
src/api/biz/management/wardInfo.ts

@@ -0,0 +1,29 @@
+import { defHttp } from '/@/utils/http/axios';
+import { setParams } from '/@/utils/index';
+enum Api {
+  getWardInfo = '/biz/sys/wardInfo/query/page',
+  add = '/biz/sys/wardInfo/add',
+  edit = '/biz/sys/wardInfo/edit',
+  changeStatus = '/biz/sys/wardInfo/modify/status/',
+  WardInfoById = '/biz/sys/wardInfo/detail',
+}
+
+export const getWardInfo = (params?: object) => {
+  return defHttp.post({ url: Api.getWardInfo, params: setParams(params) });
+};
+
+export const wardInfoAdd = (params?: object) => {
+  return defHttp.post({ url: Api.add, params: params });
+};
+
+export const wardInfoEdit = (params?: object) => {
+  return defHttp.post({ url: Api.edit, params: params });
+};
+
+export const changeStatus = (id: string) => {
+  return defHttp.post({ url: Api.changeStatus + id });
+};
+
+export const wardInfoById = (id?: string | number, params?: object) => {
+  return defHttp.get({ url: Api.WardInfoById + '/' + id, params: params });
+};

+ 18 - 0
src/api/biz/management/wardType.ts

@@ -0,0 +1,18 @@
+import { defHttp } from '/@/utils/http/axios';
+enum Api {
+  add = '/biz/sys/wardProperties/add',
+  get = '/biz/sys/wardProperties/query/list',
+  delete = '/biz/sys/wardProperties/removeByIds',
+}
+
+export const wardTypeAdd = (params?: object) => {
+  return defHttp.post({ url: Api.add, params: params });
+};
+
+export const getAttrList = (params?: object) => {
+  return defHttp.post({ url: Api.get, params: params });
+};
+
+export const deleteWardType = (params?: object) => {
+  return defHttp.post({ url: Api.delete, params: params });
+};

+ 97 - 0
src/views/biz/management/ward/data.ts

@@ -0,0 +1,97 @@
+import { BasicColumn, FormSchema } from '/@/components/Table';
+import { getAttrList } from '/@/api/biz/management/wardType';
+export const wardInfoColumns: BasicColumn[] = [
+  {
+    title: '病区名',
+    dataIndex: 'name',
+  },
+  {
+    title: '病区属性',
+    dataIndex: 'propertiesName',
+  },
+  {
+    title: '状态',
+    dataIndex: 'disable',
+  },
+  {
+    title: '排序',
+    dataIndex: 'sort',
+  },
+];
+
+// 表单属性新增编辑
+export const wardTypeDataFormSchema: FormSchema[] = [
+  {
+    label: '病区类型',
+    field: 'positive',
+    component: 'RadioGroup',
+    required: true,
+    componentProps: {
+      options: [
+        { label: '阴性区', value: 0 },
+        { label: '阳性区', value: 1 },
+      ],
+      disabled: false,
+    },
+    defaultValue: 0,
+  },
+  {
+    label: '属性名称',
+    field: 'name',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入属性名称',
+    },
+  },
+];
+
+// 表单信息新增编辑
+export const wardInfoDataFormSchema: FormSchema[] = [
+  {
+    label: '病区属性',
+    field: 'propertiesId',
+    component: 'ApiSelect',
+    required: true,
+    componentProps: {
+      api: getAttrList,
+      mode: 'single',
+      labelField: 'name',
+      valueField: 'id',
+      resultField: 'data',
+      placeholder: '请输入存储配置',
+    },
+  },
+  {
+    label: '病区名',
+    field: 'name',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入病区名',
+    },
+  },
+  {
+    label: '排序',
+    field: 'sort',
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入排序',
+    },
+  },
+  {
+    label: '状态',
+    field: 'disable',
+    component: 'Input',
+    defaultValue: '0',
+    show: false,
+  },
+  {
+    label: '备注',
+    field: 'remark',
+    component: 'InputTextArea',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
+];

+ 291 - 0
src/views/biz/management/ward/index.vue

@@ -0,0 +1,291 @@
+<template>
+  <PageWrapper>
+    <Card
+      :bordered="false"
+      :active-tab-key="activeKey"
+      :tab-list="tabList"
+      style="height: 800px"
+      @tabChange="
+        key => {
+          activeKey = key;
+        }
+      "
+    >
+      <p :key="0" v-if="activeKey == 0">
+        <Row>
+          <Col :span="6">
+            <Card title="病区属性" style="height: 680px">
+              <template #extra
+                ><Button size="small" v-auth="['sys:wardProperties:add']" @click="handleAddAttr"
+                  >+</Button
+                ></template
+              >
+              <Row>
+                <div class="type-title">阴性</div>
+              </Row>
+              <Row v-for="item in attributeFeminineList" :key="item.key" style="margin: 4px 0">
+                <Tag
+                  class="attrs"
+                  closable
+                  @close="handleDeleteAttr(item.key)"
+                  @click="handleSelectWard(item)"
+                  :value="item.key"
+                  >{{ item.label }}
+                </Tag>
+              </Row>
+              <Row>
+                <div class="type-title">阳性</div>
+              </Row>
+              <Row v-for="item in attributePositiveList" :key="item.key" style="margin: 4px 0">
+                <Tag
+                  class="attrs"
+                  closable
+                  @close="handleDeleteAttr(item.key)"
+                  @click="handleSelectWard(item)"
+                  :value="item.key"
+                  >{{ item.label }}</Tag
+                >
+              </Row>
+            </Card>
+          </Col>
+          <Col :span="1" />
+          <Col :span="17">
+            <Card title="病区信息" style="height: 680px">
+              <template #extra
+                ><Button size="small" v-auth="['sys:wardInfo:add']" @click="handleAddInfo"
+                  >+</Button
+                ></template
+              >
+              <BasicTable @register="registerTable">
+                <template #bodyCell="{ column, record }">
+                  <template v-if="column.key === 'disable'">
+                    <Tag :color="formatDictColor(disableOptions, record.disable)">
+                      {{ formatDictValue(disableOptions, record.disable) }}
+                    </Tag>
+                  </template>
+                  <template v-if="column.key === 'action'">
+                    <TableAction
+                      :actions="[
+                        {
+                          auth: 'sys:wardInfo:status',
+                          icon: 'icon-minus-square|iconfont',
+                          tooltip: '停用',
+                          label: '',
+                          color: 'error',
+                          ifShow: record.disable == 0,
+                          popConfirm: {
+                            title: '是否确认停用',
+                            placement: 'left',
+                            confirm: handleChangeState.bind(null, record),
+                          },
+                        },
+                        {
+                          auth: 'sys:wardInfo:status',
+                          icon: 'icon-plus|iconfont',
+                          tooltip: '启用',
+                          label: '',
+                          ifShow: record.disable == 1,
+                          color: 'error',
+                          popConfirm: {
+                            title: '是否确认启用',
+                            placement: 'left',
+                            confirm: handleChangeState.bind(null, record),
+                          },
+                        },
+                        {
+                          auth: 'sys:wardInfo:edit',
+                          icon: 'icon-edit|iconfont',
+                          tooltip: '编辑',
+                          label: '',
+                          onClick: handleEdit.bind(null, record),
+                        },
+                      ]"
+                    />
+                  </template>
+                </template>
+              </BasicTable>
+            </Card>
+          </Col>
+        </Row>
+      </p>
+      <p :key="1" v-else> 班次设置 </p>
+    </Card>
+  </PageWrapper>
+  <WardTypeFormModal @register="registerWardTypeModal" @success="handleWardTypeSuccess" />
+  <WardInfoFormModal @register="registerWardInfoModal" @success="handleWardInfoSuccess" />
+</template>
+
+<script lang="ts" setup>
+  import { onBeforeMount, ref } from 'vue';
+  import { PageWrapper } from '/@/components/Page';
+  import { Button, Card, Row, Col, Tag } from 'ant-design-vue';
+  import { BasicTable, useTable, TableAction } from '/@/components/Table';
+  import { wardInfoColumns } from './data';
+  import WardTypeFormModal from './wardTypeFormModal.vue';
+  import WardInfoFormModal from './wardInfoFormModal.vue';
+  import { getWardInfo, changeStatus } from '/@/api/biz/management/wardInfo';
+  import { getAttrList, deleteWardType } from '/@/api/biz/management/wardType';
+  import { useModal } from '/@/components/Modal';
+  import { listDictModel } from '/@/api/common';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { formatDictColor, formatDictValue } from '/@/utils';
+  const { createConfirm, createMessage } = useMessage();
+  const tabList = ref([
+    { key: 0, tab: '病区管理', type: 'WARD' },
+    { key: 1, tab: '工作日班次', type: 'WORK' },
+  ]);
+  const activeKey = ref(0);
+  const attributePositiveList = ref([]); // 阳性列表
+  const attributeFeminineList = ref([]); // 阴性列表
+  const disableOptions = ref();
+  onBeforeMount(async () => {
+    disableOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
+    await getWardType();
+  });
+  const [registerTable, { reload }] = useTable({
+    api: getWardInfo,
+    rowKey: 'id',
+    columns: wardInfoColumns,
+    showIndexColumn: false,
+    formConfig: {
+      labelWidth: 120,
+      autoSubmitOnEnter: true,
+      baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
+      resetButtonOptions: {
+        preIcon: 'icon-delete|iconfont',
+      },
+      submitButtonOptions: {
+        preIcon: 'icon-search|iconfont',
+      },
+    },
+    useSearchForm: false,
+    bordered: true,
+    actionColumn: {
+      width: 320,
+      title: '操作',
+      dataIndex: 'action',
+    },
+    beforeFetch: handleBeforeFetch,
+    sortFn: handleSortFn,
+  });
+
+  const [registerWardTypeModal, { openModal: openWardTypeModal }] = useModal();
+  const [registerWardInfoModal, { openModal: openWardInfoModal }] = useModal();
+  const tableSort = ref([
+    {
+      field: 'sort',
+      direction: 'ASC',
+    },
+  ]);
+  const selectType = ref();
+
+  // 方法区
+  // 获取病区信息前事件
+  function handleBeforeFetch(params) {
+    return { ...params, propertiesId: selectType.value, orders: tableSort.value };
+  }
+
+  function handleSortFn() {}
+  // 打开新增属性方法
+  function handleAddAttr() {
+    openWardTypeModal(true, {
+      isUpdate: false,
+    });
+  }
+  // 打开删除属性方法
+  async function handleDeleteAttr(id) {
+    createConfirm({
+      content: '你确定要删除?',
+      iconType: 'warning',
+      onOk: async () => {
+        await deleteWardType([id]);
+        createMessage.success('属性删除成功!');
+        await getWardType();
+      },
+      onCancel: async () => {
+        attributePositiveList.value = [];
+        attributeFeminineList.value = [];
+        await getWardType();
+      },
+    });
+  }
+  //打开新增病区信息方法
+  function handleAddInfo() {
+    openWardInfoModal(true, {
+      isUpdate: false,
+    });
+  }
+
+  // 打开编辑病区信息方法
+  function handleEdit(record: Recordable) {
+    openWardInfoModal(true, {
+      record,
+      isUpdate: true,
+    });
+  }
+  // 停用启用病区方法
+  async function handleChangeState(record) {
+    const notes = record.disable == 0 ? '停用' : '启用';
+    createConfirm({
+      content: '是否确定要' + notes + '此病区',
+      iconType: 'warning',
+      onOk: async () => {
+        await changeStatus(record.id);
+        createMessage.success('病区' + notes + '成功!');
+        reload();
+      },
+    });
+  }
+
+  // 保存成功回调事件
+  async function handleWardTypeSuccess() {
+    await getWardType();
+  }
+
+  function handleWardInfoSuccess() {
+    reload();
+  }
+
+  async function getWardType() {
+    const attrList = await getAttrList();
+    attributePositiveList.value = []; // 阳性列表
+    attributeFeminineList.value = [];
+    attrList.forEach(item => {
+      if (item.positive) {
+        attributePositiveList.value.push({ label: item.name, key: item.id });
+      } else {
+        attributeFeminineList.value.push({ label: item.name, key: item.id });
+      }
+    });
+  }
+  // 通过病区属性搜索病区信息
+  function handleSelectWard(e) {
+    selectType.value = e.key;
+    reload();
+  }
+</script>
+
+<style lang="less" scoped>
+  ::v-deep(.ant-card-head) {
+    background-color: #f6f8fa !important;
+  }
+
+  .type-title {
+    font-size: 14px;
+    font-weight: bold;
+    color: #000a18;
+  }
+
+  .attrs {
+    background: #fff !important;
+    height: 32px !important;
+    line-height: 32px !important;
+    font-weight: 400 !important;
+    color: #17233d !important;
+    font-size: 14px !important;
+    border-radius: 4px !important;
+    border: 1px solid #c2ccd4 !important;
+  }
+</style>
+
+function $forceUpdate() { throw new Error('Function not implemented.'); }

+ 67 - 0
src/views/biz/management/ward/wardInfoFormModal.vue

@@ -0,0 +1,67 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerModal"
+    :title="getTitle"
+    @ok="handleSubmit"
+  >
+    <BasicForm @register="registerForm" />
+  </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 { wardInfoDataFormSchema } from './data';
+
+  import { wardInfoAdd, wardInfoEdit, wardInfoById } from '/@/api/biz/management/wardInfo';
+
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增病区信息' : '编辑病区信息'));
+  const isUpdate = ref(false);
+  const rowId = ref();
+
+  const { createMessage } = useMessage();
+  const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({
+    layout: 'vertical',
+    showResetButton: true,
+    labelWidth: 100,
+    schemas: wardInfoDataFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => {
+    await resetFields();
+    setModalProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+
+    if (unref(isUpdate)) {
+      rowId.value = data.record.configId;
+      const resData = await wardInfoById(data.record.id);
+      await setFieldsValue({
+        ...resData,
+      });
+    }
+  });
+
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setModalProps({ confirmLoading: true });
+      !unref(isUpdate)
+        ? await wardInfoAdd({ ...values })
+        : await wardInfoEdit({ ...values, configId: rowId.value });
+      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
+      closeModal();
+      emit('success', { isUpdate: unref(isUpdate), values: { ...values, configId: rowId.value } });
+    } finally {
+      setModalProps({ confirmLoading: false });
+    }
+  }
+</script>

+ 57 - 0
src/views/biz/management/ward/wardTypeFormModal.vue

@@ -0,0 +1,57 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerModal"
+    :title="getTitle"
+    @ok="handleSubmit"
+  >
+    <BasicForm @register="registerForm" />
+  </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 { wardTypeDataFormSchema } from './data';
+
+  import { wardTypeAdd } from '/@/api/biz/management/wardType';
+
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增病区属性' : '编辑病区属性'));
+  const isUpdate = ref(false);
+  const rowId = ref();
+
+  const { createMessage } = useMessage();
+  const [registerForm, { resetFields, validate }] = useForm({
+    layout: 'vertical',
+    showResetButton: true,
+    labelWidth: 100,
+    schemas: wardTypeDataFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerModal, { setModalProps, closeModal }] = useModalInner(async data => {
+    await resetFields();
+    setModalProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+  });
+
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setModalProps({ confirmLoading: true });
+      await wardTypeAdd({ ...values });
+      createMessage.success('新增成功!');
+      closeModal();
+      emit('success', { isUpdate: unref(isUpdate), values: { ...values, configId: rowId.value } });
+    } finally {
+      setModalProps({ confirmLoading: false });
+    }
+  }
+</script>