xiebaomin пре 1 година
родитељ
комит
ea8694c739

+ 1 - 1
src/router/index.ts

@@ -25,7 +25,7 @@ router.beforeEach((to, _, next) => {
 	}
 	}
 	if (token) {
 	if (token) {
 		if (to.path === '/login') {
 		if (to.path === '/login') {
-			next('/database/index?t=0')
+			next('/database/index')
 			return
 			return
 		}
 		}
 		next()
 		next()

+ 1 - 1
src/store/tab/tab.type.ts

@@ -2,7 +2,7 @@ import { IArchiveRequest } from "@/types/api/context.type"
 import { DFindParams, DScrollTab, IAllStatus } from "@/types/views/database.type"
 import { DFindParams, DScrollTab, IAllStatus } from "@/types/views/database.type"
 
 
 export type DTabStore = {
 export type DTabStore = {
-	type: DFindParams<DScrollTab, 'type'>
+	type: DFindParams<DScrollTab, 'type'> | string
 	labelIds: DFindParams<IArchiveRequest, 'labelIds'>
 	labelIds: DFindParams<IArchiveRequest, 'labelIds'>
 	stageStatus: DFindParams<IArchiveRequest, 'stageStatus'>
 	stageStatus: DFindParams<IArchiveRequest, 'stageStatus'>
 	productId: DFindParams<IArchiveRequest, 'productId'>
 	productId: DFindParams<IArchiveRequest, 'productId'>

+ 1 - 1
src/types/views/database.type.ts

@@ -30,7 +30,7 @@ export type ChangeTabEmit = DFindParams<DScrollTab, 'type'>
 
 
 export type DetailParams = {
 export type DetailParams = {
   id?: string,
   id?: string,
-  type: ChangeTabEmit
+  type: ChangeTabEmit | string
   pageNum?: number
   pageNum?: number
   content?: string
   content?: string
   index?: number
   index?: number

+ 7 - 6
src/views/Database/components/context-head.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
   <div>
   <div>
-    <div class="title" v-if="route.query.t === '0'">{{ controlText }}</div>
+    <div class="title" v-if="type !== '0'">{{ controlText }}</div>
     <div v-if="type === '5'" class="enterprise">
     <div v-if="type === '5'" class="enterprise">
       <van-tabs v-model:active="form.allStatus" shrink>
       <van-tabs v-model:active="form.allStatus" shrink>
         <van-tab
         <van-tab
@@ -25,19 +25,19 @@ import {
 } from "@/types/views/database.type";
 } from "@/types/views/database.type";
 import { ref, computed, watch } from 'vue';
 import { ref, computed, watch } from 'vue';
 import { DTabStore } from "@/store/tab/tab.type";
 import { DTabStore } from "@/store/tab/tab.type";
-import { useRoute } from "vue-router";
-const route = useRoute();
+//import { useRoute } from "vue-router";
+//const route = useRoute();
 const props = defineProps<{
 const props = defineProps<{
-  type: ChangeTabEmit
+  type: ChangeTabEmit | string
   index: number
   index: number
 }>();
 }>();
 const form = ref<Pick<DTabStore, 'type'> & Pick<DTabStore, 'allStatus'>>({
 const form = ref<Pick<DTabStore, 'type'> & Pick<DTabStore, 'allStatus'>>({
-  type: route.query.t as ChangeTabEmit,
+  type: props.type,
   allStatus: "1",
   allStatus: "1",
 });
 });
 const emit = defineEmits<DEmit>();
 const emit = defineEmits<DEmit>();
 watch(
 watch(
-  () => route.query,
+  () => props.type,
   () => {
   () => {
     form.value.allStatus = '1'
     form.value.allStatus = '1'
   },
   },
@@ -55,6 +55,7 @@ watch(
 const controlText = computed<DFindParams<DScrollTab, "text">>(
 const controlText = computed<DFindParams<DScrollTab, "text">>(
   () => tabList.filter((e) => e.type === props.type)[0].text
   () => tabList.filter((e) => e.type === props.type)[0].text
 );
 );
+console.log(props.type, controlText.value)
 </script>
 </script>
 
 
 <style scoped lang="scss">
 <style scoped lang="scss">

+ 6 - 4
src/views/Database/components/scroll-tap-btn.vue

@@ -6,7 +6,7 @@
         :key="i.type"
         :key="i.type"
         :label="i.text"
         :label="i.text"
         @handle-emit="handleChangeTab(i)"
         @handle-emit="handleChangeTab(i)"
-        :class="route.query.t === i.type ? 'active' : ''"
+        :class="type === i.type ? 'active' : ''"
         backgroundColor="#fff"
         backgroundColor="#fff"
         color="#666666"
         color="#666666"
       />
       />
@@ -16,9 +16,11 @@
 
 
 <script setup lang="ts">
 <script setup lang="ts">
 import { DScrollTab, DEmit, tabList } from '@/types/views/database.type';
 import { DScrollTab, DEmit, tabList } from '@/types/views/database.type';
-import { useRoute } from 'vue-router';
-
-const route = useRoute()
+//import { useRoute } from 'vue-router';
+import { useTabStore } from "@/store/tab/tab";
+import { toRefs } from 'vue';
+//const route = useRoute()
+const { type } = toRefs(useTabStore());
 
 
 const emit = defineEmits<DEmit>()
 const emit = defineEmits<DEmit>()
 const handleChangeTab = (event: DScrollTab): void => {
 const handleChangeTab = (event: DScrollTab): void => {

+ 82 - 53
src/views/Database/data-all/index.vue

@@ -4,7 +4,7 @@
       :type="data.type"
       :type="data.type"
       :data-list="data.dataList"
       :data-list="data.dataList"
       :show-more="data.showMore"
       :show-more="data.showMore"
-      v-if="data.type !== '0' && isShowType(data)"
+      v-if="isShowType(data) && data.type !== '0'"
       :index="i"
       :index="i"
       @handle-see-more="handleSeeMore"
       @handle-see-more="handleSeeMore"
     >
     >
@@ -24,7 +24,7 @@
       </template>
       </template>
     </context-contain>
     </context-contain>
   </div>
   </div>
-  <div class="bottom-btn" v-if="reqParams.type === '5' && isAddStatus">
+  <div class="bottom-btn" v-if="reqParams!.type! === '5' && isAddStatus">
     <data-button
     <data-button
       @handle-emit="router.push('/database/add')"
       @handle-emit="router.push('/database/add')"
       backgroundColor="#FF5B00"
       backgroundColor="#FF5B00"
@@ -35,46 +35,60 @@
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
-import { computed, ref, watch, onMounted } from "vue";
+//import { computed, ref, watch, onMounted } from "vue";
+//import contextContain from "../components/context-contain.vue";
+//import { DDataBaseListAll, DetailParams, tabList } from "@/types/views/database.type";
+//import contextHead from "../components/context-head.vue";
+//import contextShare from "../components/context-share.vue";
+//import { useRouter, useRoute, LocationQueryValue } from "vue-router";
+//import { getArchiveList } from "@/api/context/context";
+//import { IArchiveRequest } from "@/types/api/context.type";
+import { ref, watch, onMounted } from "vue";
 import contextContain from "../components/context-contain.vue";
 import contextContain from "../components/context-contain.vue";
 import { DDataBaseListAll, DetailParams, tabList } from "@/types/views/database.type";
 import { DDataBaseListAll, DetailParams, tabList } from "@/types/views/database.type";
 import contextHead from "../components/context-head.vue";
 import contextHead from "../components/context-head.vue";
 import contextShare from "../components/context-share.vue";
 import contextShare from "../components/context-share.vue";
-import { useRouter, useRoute, LocationQueryValue } from "vue-router";
+import { useRouter } from "vue-router";
 import { getArchiveList } from "@/api/context/context";
 import { getArchiveList } from "@/api/context/context";
-import { IArchiveRequest } from "@/types/api/context.type";
 import { useUserInfoState } from "@/store/user/user";
 import { useUserInfoState } from "@/store/user/user";
 import { myDecrypt } from "@/util/authStorage";
 import { myDecrypt } from "@/util/authStorage";
 import useWeChatShare from "@/Hooks/useWeChatShare";
 import useWeChatShare from "@/Hooks/useWeChatShare";
-
+import { DTabStore } from "@/store/tab/tab.type";
 const { userId } = useUserInfoState();
 const { userId } = useUserInfoState();
 const router = useRouter();
 const router = useRouter();
-const route = useRoute();
+//const route = useRoute();
 const dataList = ref<DDataBaseListAll[] | null>(null);
 const dataList = ref<DDataBaseListAll[] | null>(null);
-const routeQuery = (str: LocationQueryValue | LocationQueryValue[]) =>
-  str === "0" ? "" : str;
-const reqParams = computed<IArchiveRequest>(
-  () =>
-    ({
-      type: routeQuery(route.query.t),
-      title: route.query.sv,
-      productId: routeQuery(route.query.pId),
-      labelIds: routeQuery(route.query.lId),
-      stageStatus: routeQuery(route.query.ss),
-      spId: "",
-      userId: userId,
-    } as IArchiveRequest)
-);
+const props = defineProps<DTabStore>()
+//const routeQuery = (str: LocationQueryValue | LocationQueryValue[]) =>
+//  str === "0" ? "" : str;
+//const reqParams = computed<IArchiveRequest>(
+//  () =>
+//    ({
+//      type: routeQuery(route.query.t),
+//      title: route.query.sv,
+//      productId: routeQuery(route.query.pId),
+//      labelIds: routeQuery(route.query.lId),
+//      stageStatus: routeQuery(route.query.ss),
+//      spId: "",
+//      userId: userId,
+//    } as IArchiveRequest)
+//);
+const reqParams = ref<Record<string, any>>()
 const isAddStatus = ref<boolean>(false);
 const isAddStatus = ref<boolean>(false);
 const isEmpty = ref<boolean>(false);
 const isEmpty = ref<boolean>(false);
 const isShowType = (data: DDataBaseListAll): boolean => {
 const isShowType = (data: DDataBaseListAll): boolean => {
-  if (routeQuery(route.query.t) !== "") {
-    return routeQuery(route.query.t) === data.type;
+  //if (routeQuery(route.query.t) !== "") {
+  //  return routeQuery(route.query.t) === data.type;
+  //} else {
+  //  return true;
+  //}
+  if (reqParams.value!.type !== "") {
+    return reqParams.value!.type === data.type;
   } else {
   } else {
     return true;
     return true;
   }
   }
 };
 };
-const formParams = ref({ allStatus: "1" });
+const formParams = ref({ allStatus: "1", userId: userId as string });
 const reqArchiveList = async (res?: DetailParams) => {
 const reqArchiveList = async (res?: DetailParams) => {
   if (!res) {
   if (!res) {
     const { data } = await getArchiveList({ ...reqParams.value, ...formParams.value });
     const { data } = await getArchiveList({ ...reqParams.value, ...formParams.value });
@@ -102,39 +116,54 @@ const reqArchiveList = async (res?: DetailParams) => {
       ...DcreptoList!,
       ...DcreptoList!,
     ];
     ];
     isEmpty.value =
     isEmpty.value =
-      dataList.value![res.index!]!.dataList.length === 0 && reqParams.value.type !== "";
+      dataList.value![res.index!]!.dataList.length === 0;
     dataList.value![res.index!]!.showMore = res.pageNum! > 1 && data?.length! < 5;
     dataList.value![res.index!]!.showMore = res.pageNum! > 1 && data?.length! < 5;
   }
   }
 };
 };
-const isSearch = () => {
-  if (route.query.t !== '0') {
-    return true
-  }
-  if (
-    (route.query.lId !== "0" && route.query.lId !== "") ||
-    route.query.sv !== "" ||
-    (route.query.pId !== "0" && route.query.pId !== "") ||
-    (route.query.ss !== "0" && route.query.ss !== "")
-  ) {
-    return true;
+//const isSearch = () => {
+//  if (route.query.t !== '0') {
+//    return true
+//  }
+//  if (
+//    (route.query.lId !== "0" && route.query.lId !== "") ||
+//    route.query.sv !== "" ||
+//    (route.query.pId !== "0" && route.query.pId !== "") ||
+//    (route.query.ss !== "0" && route.query.ss !== "")
+//  ) {
+//    return true;
+//  }
+//  else return false;
+//};
+//watch(
+//  () => route.query,
+//  () => {
+//    console.log("路由变化", route);
+//    if (route.path === "/database/index" && isSearch()) {
+//      formParams.value.allStatus = "1";
+//      reqArchiveList();
+//    } else {
+//      dataList.value = []
+//    }
+//  },
+//  {
+//    immediate: true,
+//  }
+//);
+const valueChange = (form: Record<string, any>): Record<string, any> => {
+  const f: Record<string, any> = {}
+  for (const key in form) {
+    f[key] = (form[key] === '0' || form[key] === 0) ? '' : form[key]; 
   }
   }
-};
-watch(
-  () => route.query,
-  () => {
-    console.log("路由变化", route);
-    if (route.path === "/database/index" && isSearch()) {
-      formParams.value.allStatus = "1";
-      reqArchiveList();
-    } else {
-      dataList.value = []
-    }
-  },
-  {
-    immediate: true,
-  }
-);
-
+  console.log(f);
+  return f
+}
+watch(() => props, (val) => {
+  reqParams.value = valueChange(val)
+  reqArchiveList()
+}, {
+  immediate: true,
+  deep: true,
+})
 const handleSeeMore = ($event: DetailParams) => {
 const handleSeeMore = ($event: DetailParams) => {
   console.log("查看更多", $event.index);
   console.log("查看更多", $event.index);
   reqArchiveList($event);
   reqArchiveList($event);

+ 27 - 17
src/views/Database/index.vue

@@ -4,7 +4,15 @@
     <scroll-tap-btn @handle-tab-emit="handleTabEmit" />
     <scroll-tap-btn @handle-tab-emit="handleTabEmit" />
   </div>
   </div>
   <div class="container">
   <div class="container">
-    <router-view />
+    <!--<router-view />-->
+    <data-all
+      :type="(form.type! as ChangeTabEmit)"
+      :label-ids="form.labelIds"
+      :product-id="form.productId"
+      :stage-status="form.stageStatus"
+      :search-value="form.searchValue"
+      :all-status="form.allStatus"
+    />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -16,43 +24,45 @@ import type {
   SearchEmitParams,
   SearchEmitParams,
   ChangeEmitParams,
   ChangeEmitParams,
   DScrollTab,
   DScrollTab,
+ChangeTabEmit,
 } from "@/types/views/database.type";
 } from "@/types/views/database.type";
-import { ref, toRefs } from 'vue';
-import { useRouter } from "vue-router";
+import { ref, toRefs } from "vue";
+//import { useRouter } from "vue-router";
 import { DTabStore } from "@/store/tab/tab.type";
 import { DTabStore } from "@/store/tab/tab.type";
+import DataAll from "./data-all/index.vue";
 const { type } = toRefs(useTabStore());
 const { type } = toRefs(useTabStore());
 const { updatedTabStore } = useTabStore();
 const { updatedTabStore } = useTabStore();
-const router = useRouter();
+//const router = useRouter();
 
 
 const form = ref<DTabStore>({
 const form = ref<DTabStore>({
-  labelIds: '',
-  productId: '',
-  stageStatus: '',
+  labelIds: "",
+  productId: "",
+  stageStatus: "",
   type: type.value,
   type: type.value,
-  searchValue: '',
+  searchValue: "",
   allStatus: "1",
   allStatus: "1",
 });
 });
 
 
 const routerLink = () => {
 const routerLink = () => {
-  router.push(
-    `/database/index?t=${form.value.type || "0"}&lId=${form.value.labelIds || ""}&sv=${
-      form.value.searchValue || ""
-    }&pId=${form.value.productId || ""}&ss=${form.value.stageStatus || ""}`
-  );
+  //router.push(
+  //  `/database/index?t=${form.value.type || "0"}&lId=${form.value.labelIds || ""}&sv=${
+  //    form.value.searchValue || ""
+  //  }&pId=${form.value.productId || ""}&ss=${form.value.stageStatus || ""}`
+  //);
 };
 };
 const handleSearch = (event: SearchEmitParams) => {
 const handleSearch = (event: SearchEmitParams) => {
-  form.value = { ...form.value, ...{ searchValue: event } }
+  form.value = { ...form.value, ...{ searchValue: event } };
   updatedTabStore(form.value);
   updatedTabStore(form.value);
   routerLink();
   routerLink();
 };
 };
 const handleChange = (event: ChangeEmitParams) => {
 const handleChange = (event: ChangeEmitParams) => {
-  form.value = { ...form.value, ...event }
+  form.value = { ...form.value, ...event };
   updatedTabStore(form.value);
   updatedTabStore(form.value);
   routerLink();
   routerLink();
 };
 };
 const handleTabEmit = (event: DScrollTab): void => {
 const handleTabEmit = (event: DScrollTab): void => {
-  console.log('tab', event)
-  form.value = { ...form.value, ...event }
+  console.log("tab", event);
+  form.value = { ...form.value, ...event };
   updatedTabStore(form.value);
   updatedTabStore(form.value);
   routerLink();
   routerLink();
 };
 };

+ 1 - 1
src/views/Login/index.vue

@@ -60,7 +60,7 @@ const onSubmit = async () => {
     console.log(data);
     console.log(data);
     if (code === 0) {
     if (code === 0) {
       showLoadingToast(msg!);
       showLoadingToast(msg!);
-      window.location.href = '/database/index?t=0&lId=&sv=&pId=&ss='
+      window.location.href = '/database/index'
     } else {
     } else {
       showLoadingToast(msg!);
       showLoadingToast(msg!);
     }
     }