Sfoglia il codice sorgente

feat: (dashbroad) 对接api

gemercheung 2 anni fa
parent
commit
7211e2ac64

+ 3 - 0
readme.md

@@ -0,0 +1,3 @@
+# 2022-9-14 对接事项
+
+时间 统一为: YYYY-MM-DD HH:mm:ss, 不使用 UTF ease 标准时间。部分使用 timestamp

+ 2 - 2
src/api/corporation/model.ts

@@ -36,8 +36,8 @@ export interface auditParam {
 }
 
 export interface addPointParam {
-  id: number | null;
-  idpoint: number | null;
+  id: number | string;
+  point: number | string;
 }
 export interface selectUserListParam {
   id: number | null;

+ 37 - 0
src/api/dashboard/analysis.ts

@@ -0,0 +1,37 @@
+import { defHttp } from '/@/utils/http/axios';
+// PageParams
+import { BasicStaticsParams } from './model';
+import { Result } from '/#/axios';
+
+enum Api {
+  bulletChat = '/zfb-api/zfb/platform/bulletChat/list',
+  userStatics = '/zfb-api/zfb/platform/dashboard/liveRoom/userStatics',
+  bulletChatStatics = '/zfb-api/zfb/platform/dashboard/liveRoom/bulletChatStatics',
+  liveRoomStatics = '/zfb-api/zfb/platform/dashboard/company/liveRoomStatics',
+  bulletChatExport = '/zfb-api/zfb/platform/bulletChat/export',
+  companyChatExport = '/zfb-api/zfb//platform/dashboard/company/export',
+}
+
+/**
+ * @description: Get sample list value
+ */
+
+export const bulletChatApi = (params: BasicStaticsParams) =>
+  defHttp.post<Result>({
+    url: Api.bulletChat,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const userStaticsApi = (params: BasicStaticsParams) =>
+  defHttp.post<Result>({
+    url: Api.userStatics,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 10 - 0
src/api/dashboard/model.ts

@@ -0,0 +1,10 @@
+import { BasicPageParams } from '/@/api/model/baseModel';
+/**
+ * @description: Request list interface parameters
+ */
+export type PageParams = BasicPageParams;
+
+export interface BasicStaticsParams extends PageParams {
+  liveRoomId: string;
+  time: string[];
+}

+ 29 - 28
src/api/model/baseModel.ts

@@ -1,28 +1,29 @@
-export interface BasicPageParams {
-  page: number;
-  pageSize: number;
-}
-
-export interface BasicFetchResult<T> {
-  items: T[];
-  total: number;
-  endRow: number;
-  firstPage: number;
-  hasNextPage: boolean;
-  hasPreviousPage: boolean;
-  isFirstPage: boolean;
-  isLastPage: boolean;
-  lastPage: number;
-  list: T[];
-  navigateFirstPage: number;
-  navigateLastPage: number;
-  navigatePages: number;
-  navigatepageNums: number[];
-  nextPage: number;
-  pageNum: number;
-  pageSize: number;
-  pages: number;
-  prePage: number;
-  size: number;
-  startRow: number;
-}
+export interface BasicPageParams {
+  page: number;
+  pageSize?: number;
+  limit?: number;
+}
+
+export interface BasicFetchResult<T> {
+  items: T[];
+  total: number;
+  endRow: number;
+  firstPage: number;
+  hasNextPage: boolean;
+  hasPreviousPage: boolean;
+  isFirstPage: boolean;
+  isLastPage: boolean;
+  lastPage: number;
+  list: T[];
+  navigateFirstPage: number;
+  navigateLastPage: number;
+  navigatePages: number;
+  navigatepageNums: number[];
+  nextPage: number;
+  pageNum: number;
+  pageSize: number;
+  pages: number;
+  prePage: number;
+  size: number;
+  startRow: number;
+}

+ 20 - 1
src/api/notification/list.ts

@@ -1,5 +1,5 @@
 import { defHttp } from '/@/utils/http/axios';
-import { PageParams, ListGetResultModel, NoticeParams } from './model';
+import { PageParams, ListGetResultModel, NoticeParams, UnreadModel } from './model';
 import { Result } from '/#/axios';
 
 enum Api {
@@ -42,3 +42,22 @@ export const editNoticeApi = (params: NoticeParams) =>
       ignoreCancelToken: true,
     },
   });
+
+export const DeleteNoticeApi = (params: NoticeParams) =>
+  defHttp.post<Result>({
+    url: Api.delNotice,
+    params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const unreadNoticeApi = () =>
+  defHttp.post<UnreadModel>({
+    url: Api.unreadNoticesList,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 4 - 0
src/api/notification/model.ts

@@ -20,6 +20,10 @@ export interface NoticeParams {
   effectiveTime: string[];
 }
 
+export interface UnreadModel {
+  list: any[];
+  totalCount: number;
+}
 /**
  * @description: Request list return value
  */

+ 19 - 15
src/layouts/default/header/components/notify/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div :class="prefixCls">
     <Popover title="" trigger="click" :overlayClassName="`${prefixCls}__overlay`">
-      <Badge size="small" dot :count="100" :numberStyle="numberStyle">
+      <Badge size="small" dot :count="count" :numberStyle="numberStyle" @click="onNoticeClick">
         <BellOutlined />
       </Badge>
       <!-- <template #content>
@@ -22,34 +22,38 @@
   </div>
 </template>
 <script lang="ts">
-  import { computed, defineComponent, ref } from 'vue';
+  import { onMounted, defineComponent, ref } from 'vue';
   // Tabs, Badge
   import { Popover, Badge } from 'ant-design-vue';
   import { BellOutlined } from '@ant-design/icons-vue';
-  import { tabListData, ListItem } from './data';
+  import { tabListData } from './data';
   // import NoticeList from './NoticeList.vue';
   import { useDesign } from '/@/hooks/web/useDesign';
-  import { useMessage } from '/@/hooks/web/useMessage';
+  // import { useMessage } from '/@/hooks/web/useMessage';
+  import { unreadNoticeApi } from '/@/api/notification/list';
+  import { useGo } from '/@/hooks/web/usePage';
   // Tabs, TabPane: Tabs.TabPane, Badge, NoticeList
   export default defineComponent({
     components: { Popover, BellOutlined, Badge },
     setup() {
       const { prefixCls } = useDesign('header-notify');
-      const { createMessage } = useMessage();
+      // const { createMessage } = useMessage();
       const listData = ref(tabListData);
+      const go = useGo();
 
-      const count = computed(() => {
-        let count = 0;
-        for (let i = 0; i < tabListData.length; i++) {
-          count += tabListData[i].list.length;
-        }
-        return count;
+      const count = ref(0);
+
+      onMounted(async () => {
+        const unread = await unreadNoticeApi();
+        console.log('unread', unread.totalCount);
+        count.value = unread.totalCount;
       });
 
-      function onNoticeClick(record: ListItem) {
-        createMessage.success('你点击了通知,ID=' + record.id);
-        // 可以直接将其标记为已读(为标题添加删除线),此处演示的代码会切换删除线状态
-        record.titleDelete = !record.titleDelete;
+      function onNoticeClick() {
+        if (count.value > 0) {
+          go('/notification/list');
+        }
+        // createMessage.success('你点击了通知,ID=' + record.id);
       }
 
       return {

+ 23 - 23
src/utils/dateUtil.ts

@@ -1,23 +1,23 @@
-/**
- * Independent time operation tool to facilitate subsequent switch to dayjs
- */
-import dayjs from 'dayjs';
-
-const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
-const DATE_FORMAT = 'YYYY-MM-DD';
-
-export function formatToDateTime(
-  date: dayjs.Dayjs | undefined = undefined,
-  format = DATE_TIME_FORMAT,
-): string {
-  return dayjs(date).format(format);
-}
-
-export function formatToDate(
-  date: dayjs.Dayjs | undefined = undefined,
-  format = DATE_FORMAT,
-): string {
-  return dayjs(date).format(format);
-}
-
-export const dateUtil = dayjs;
+/**
+ * Independent time operation tool to facilitate subsequent switch to dayjs
+ */
+import dayjs from 'dayjs';
+
+const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
+const DATE_FORMAT = 'YYYY-MM-DD';
+
+export function formatToDateTime(
+  date: dayjs.Dayjs | undefined = undefined,
+  format = DATE_TIME_FORMAT,
+): string {
+  return dayjs(date).format(format);
+}
+
+export function formatToDate(
+  date: dayjs.Dayjs | undefined = undefined,
+  format = DATE_FORMAT,
+): string {
+  return dayjs(date).format(format);
+}
+
+export const dateUtil = dayjs;

+ 1 - 1
src/views/corporation/chargeModal.vue

@@ -73,7 +73,7 @@
       const modelRef = ref({
         id: 0,
       });
-      const [registerForm, { setFieldsValue, resetFields, getFieldsValue }] = useForm({
+      const [registerForm, { setFieldsValue, resetFields, getFieldsValue, reload }] = useForm({
         labelWidth: 120,
         schemas,
         showActionButtonGroup: false,

+ 25 - 4
src/views/dashboard/analysis/index.vue

@@ -17,9 +17,7 @@
         </div>
       </template>
       <template #toolbar>
-        <!-- <a-button type="primary" @click="openAddModal">{{
-          t('routes.devices.addCamera')
-        }}</a-button> -->
+        <a-button type="primary">导出数据</a-button>
       </template>
     </BasicTable>
     <!-- <div class="md:flex enter-y">
@@ -40,13 +38,16 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { ref } from 'vue';
+  import { onMounted, reactive, ref } from 'vue';
   import { BasicTable, useTable, BasicColumn, FormProps } from '/@/components/Table';
   // import { useI18n } from '/@/hooks/web/useI18n';
   // import GrowCard from './components/GrowCard.vue';
   import { Card } from 'ant-design-vue';
   import VisitAnalysis from './components/VisitAnalysis.vue';
   import VisitAnalysisBar from './components/VisitAnalysisBar.vue';
+  import { bulletChatApi, userStaticsApi } from '../../../api/dashboard/analysis';
+  import { formatToDate } from '/@/utils/dateUtil';
+  import dayjs from 'dayjs';
 
   const loading = ref(true);
   // const { t } = useI18n();
@@ -113,11 +114,31 @@
     ],
   };
 
+  const today = formatToDate(dayjs(new Date()));
+  const priorDate = formatToDate(dayjs(new Date().setDate(new Date().getDate() - 30)));
+
+  const searchInfo = reactive({
+    limit: 20,
+    page: 1,
+    time: [priorDate, today],
+  });
+
   const [registerTable] = useTable({
     title: '房间留言状态',
     columns: columns,
     useSearchForm: true,
     formConfig: searchForm,
+    api: bulletChatApi,
+    afterFetch: function (data) {
+      console.log('data', data);
+
+      return data;
+    },
+    searchInfo: searchInfo,
+  });
+
+  onMounted(async () => {
+    await userStaticsApi(searchInfo);
   });
 
   setTimeout(() => {

+ 14 - 10
src/views/notification/addModal.vue

@@ -21,11 +21,12 @@
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   // import { ListAllCompanyApi } from '/@/api/corporation/list';
-  // import { useI18n } from '/@/hooks/web/useI18n';
-  // import { useMessage } from '/@/hooks/web/useMessage';
+  import { useI18n } from '/@/hooks/web/useI18n';
+  import { useMessage } from '/@/hooks/web/useMessage';
   // import { useUserStore } from '/@/store/modules/user';
   import { Tinymce } from '/@/components/Tinymce';
-  // const { t } = useI18n();
+  import { formatToDateTime } from '/@/utils/dateUtil';
+  const { t } = useI18n();
   export default defineComponent({
     components: { BasicModal, BasicForm },
     props: {
@@ -60,6 +61,9 @@
         {
           field: 'effectiveTime',
           component: 'RangePicker',
+          componentProps: {
+            format: 'YYYY-MM-DD HH:mm:ss',
+          },
           label: '时间段',
           required: true,
           colProps: {
@@ -99,7 +103,7 @@
         },
       ];
       const title = ref('新 增');
-      // const { createMessage } = useMessage();
+      const { createMessage } = useMessage();
       const [registerForm, { validate, resetFields }] = useForm({
         labelWidth: 120,
         schemas,
@@ -109,7 +113,7 @@
         },
       });
       // closeModal
-      const [register] = useModalInner((data) => {
+      const [register, { closeModal }] = useModalInner((data) => {
         data && onDataReceive(data);
       });
       function onDataReceive(data) {
@@ -168,15 +172,15 @@
         let res = await requestApi({
           title: data.title,
           content: data.content,
-          type: data.type,
-          effectiveTime: data.effectiveTime,
+          type: String(data.type),
+          effectiveTime: data.effectiveTime.map((i) => formatToDateTime(i)),
           id: data.id,
         });
         console.log('res', res);
         emit('ok', res);
-        // createMessage.success(t('common.optSuccess'));
-        // closeModal();
-        // resetFields();
+        createMessage.success(t('common.optSuccess'));
+        closeModal();
+        resetFields();
       }
 
       return {