ソースを参照

feat: 将格式与枚举值全部移至types文件夹

kuanghua liu 1 年間 前
コミット
30293c0a3c

+ 2 - 53
src/api/comments/comments.ts

@@ -1,57 +1,6 @@
 import { http } from '@/utils/http/axios';
-
-export enum REPLYSTATUS {
-  replied = 1,
-  unReplied = 0,
-  all = 2,
-}
-
-export enum COMMENTSTATUS {
-  unAuthed = 0,
-  rejected = 1,
-  passed = 2,
-  all = 3,
-}
-
-export interface Records {
-  id: number; //评论id
-  userId: number; //用户id
-  userName: string; //用户名
-  avatar: string; //用户头像
-  comment: string; //评论内容
-  picUrl: string; //评论图片
-  staffNo: string; //员工编号
-  mobile: string; //手机号
-  // problemImage: Array<File>;
-  reply: string | null; //回复内容
-  isReplied: REPLYSTATUS; //是否已回复
-  replyAt: string | null; //回复时间
-  status: COMMENTSTATUS; //审核状态
-  createdAt: string; //创建时间
-  updatedAt: string; //更新时间
-  isUserDeleted: number;
-  tenantId: number; //租户id
-  locationName: string;
-}
-
-export interface ListType {
-  records: Records[];
-  maxPageSize?: number;
-  pageNumber: number;
-  pageSize: number;
-  totalPage: number;
-  totalRow: number;
-  optimizeCountQuery: boolean;
-}
-
-export interface CommentsQuery {
-  pageNumber: number; //评论id
-  pageSize: number; //用户id
-  queryParam?: {
-    isReplied?: number;
-    isApproved?: number;
-  };
-}
+import { COMMENTSTATUS } from '@/types/comments/constant';
+import { CommentsQuery, ListType } from '@/types/comments/type';
 
 //查询留言列表
 export const getCommentsList = (data: CommentsQuery) => {

+ 12 - 0
src/types/comments/constant.ts

@@ -0,0 +1,12 @@
+export enum REPLYSTATUS {
+  replied = 1,
+  unReplied = 0,
+  all = 2,
+}
+
+export enum COMMENTSTATUS {
+  unAuthed = 0,
+  rejected = 1,
+  passed = 2,
+  all = 3,
+}

+ 41 - 0
src/types/comments/type.ts

@@ -0,0 +1,41 @@
+import { REPLYSTATUS, COMMENTSTATUS } from '@/types/comments/constant';
+
+export interface Records {
+  id: number; //评论id
+  userId: number; //用户id
+  userName: string; //用户名
+  avatar: string; //用户头像
+  comment: string; //评论内容
+  picUrl: string; //评论图片
+  staffNo: string; //员工编号
+  mobile: string; //手机号
+  // problemImage: Array<File>;
+  reply: string | null; //回复内容
+  isReplied: REPLYSTATUS; //是否已回复
+  replyAt: string | null; //回复时间
+  status: COMMENTSTATUS; //审核状态
+  createdAt: string; //创建时间
+  updatedAt: string; //更新时间
+  isUserDeleted: number;
+  tenantId: number; //租户id
+  locationName: string;
+}
+
+export interface ListType {
+  records: Records[];
+  maxPageSize?: number;
+  pageNumber: number;
+  pageSize: number;
+  totalPage: number;
+  totalRow: number;
+  optimizeCountQuery: boolean;
+}
+
+export interface CommentsQuery {
+  pageNumber: number; //评论id
+  pageSize: number; //用户id
+  queryParam?: {
+    isReplied?: number;
+    isApproved?: number;
+  };
+}

+ 3 - 3
src/views/system/comments/PageCommentsManage.vue

@@ -25,7 +25,7 @@
         v-for="(item, index) in commentsList"
         :key="index"
         :problem-data="item"
-        :re-fresh-list="getList"
+        @reFreshList="getList"
         style="margin-top: 22px; margin-bottom: 2px"
     /></div>
 
@@ -46,7 +46,7 @@
 <script setup lang="ts">
   import SingleComment from './component/SingleComment.vue';
   import useComments from './use-comments.ts';
-  import { REPLYSTATUS, COMMENTSTATUS } from '@/api/comments/comments';
+  import { REPLYSTATUS, COMMENTSTATUS } from '@/types/comments/constant.ts';
 
   const useCommentsList = useComments();
   const { commentsList, pageNumber, pageSize, totalRow, getList, listFilter } = useCommentsList;
@@ -98,4 +98,4 @@
     --el-select-width: 220px;
   }
 </style>
-./use-comments.ts
+./use-comments.ts @/types/comments/constant.ts

+ 9 - 5
src/views/system/comments/component/SingleComment.vue

@@ -92,12 +92,15 @@
 
 <script setup lang="ts">
   import { ref, computed } from 'vue';
-  import { Records, REPLYSTATUS, COMMENTSTATUS, undateCommentStatus, replyComment } from '@/api/comments/comments';
+  import { undateCommentStatus, replyComment } from '@/api/comments/comments';
+  import { REPLYSTATUS, COMMENTSTATUS } from '@/types/comments/constant';
+  import { Records } from '@/types/comments/type';
   const props = defineProps<{
     problemData: Records;
-    reFreshList: () => unknown;
   }>();
 
+  const emit = defineEmits(['reFreshList']);
+
   const problemImageUrls = computed(() => {
     const imageUrlString = props.problemData.picUrl;
     return imageUrlString ? imageUrlString.split(',') : [];
@@ -105,18 +108,18 @@
 
   const hideComment = () => {
     undateCommentStatus({ id: props.problemData.id, status: COMMENTSTATUS.rejected }).then(() => {
-      props.reFreshList();
+      emit('reFreshList');
     });
   };
   const displayComment = () => {
     undateCommentStatus({ id: props.problemData.id, status: COMMENTSTATUS.passed }).then(() => {
-      props.reFreshList();
+      emit('reFreshList');
     });
   };
   const submitReply = () => {
     replyComment({ id: props.problemData.id, reply: replyContent.value }).then(() => {
       openReply.value = false;
-      props.reFreshList();
+      emit('reFreshList');
     });
   };
 
@@ -205,3 +208,4 @@
     border-top: none;
   }
 </style>
+@/types/comments/constant

+ 3 - 1
src/views/system/comments/use-comments.ts

@@ -1,4 +1,6 @@
-import { REPLYSTATUS, COMMENTSTATUS, Records, CommentsQuery, getCommentsList } from '@/api/comments/comments';
+import { getCommentsList } from '@/api/comments/comments';
+import { REPLYSTATUS, COMMENTSTATUS } from '@/types/comments/constant';
+import { Records, CommentsQuery } from '@/types/comments/type';
 import { onMounted, ref } from 'vue';
 
 export function useCommentsList() {