xiebaomin 1 year ago
parent
commit
5003cbea32

+ 3 - 3
src/App.vue

@@ -1,17 +1,17 @@
-<script setup lang="ts">
+<!--<script setup lang="ts">
 import { watch } from 'vue';
 import { useRoute } from 'vue-router';
 
 const route = useRoute()
 watch(() => route.query, () => {
-  if (!sessionStorage.getItem('isDetailRefresh') && route.fullPath !== '/login') {
+  if (!sessionStorage.getItem('isDetailRefresh') && route.fullPath !== '/login' && route.fullPath !== '/database/add') {
 		sessionStorage.setItem('isDetailRefresh', '1')
     window.location.reload()
 	}
 }, {
   immediate: true,
 })
-</script>
+</script>-->
 
 <template>
   <Suspense>

+ 11 - 15
src/Hooks/useCopyText.ts

@@ -1,23 +1,19 @@
 import { showNotify } from 'vant';
 import { statisticAddContext } from '@/api/context/context';
+import Clipboard from 'clipboard'
 
 const useCopyText = async (text: string, authorId: string) => {
     await statisticAddContext({ type: 1, authorId })
-    if (navigator.clipboard && navigator.clipboard.writeText) {
-        navigator.clipboard.writeText(text)
-            .then(() => {
-                showNotify('已成功复制!'); // 提示复制成功信息
-            })
-            .catch(() => {
-                const oInput = document.createElement('input');
-                oInput.value = text;
-                document.body.appendChild(oInput);
-                oInput.select(); // 选择对象
-                document.execCommand("Copy"); // 执行浏览器复制命令
-                document.body.removeChild(oInput);
-                showNotify('已成功复制!'); // 提示复制成功信息
-            }); 
-    }
+    const clipboard = new Clipboard('.copy', {
+          text: function () {
+            return text
+          }
+        })
+        clipboard.on('success', () => {
+          showNotify('已成功复制!'); // 提示复制成功信息
+          // 释放内存
+          clipboard.destroy()
+        })
 }
 
 export default useCopyText

+ 3 - 4
src/Hooks/useWeChatShare.ts

@@ -63,10 +63,9 @@ export const shareOptions: shareOptions[] = [
 const useWeChatShare = async (params: shareParams) => {
 	const isWeChat = () => /MicroMessenger/i.test(navigator.userAgent)
 	const linkParams =
-		import.meta.env.VITE_HTTP_URL +
-		(Number(params.type) === 7 ? '/encyclopedia/detail-' : '/info/detail-') +
-		params.id +
-		'.html'
+		Number(params.type) === 7
+			? import.meta.env.VITE_HTTP_URL + '/encyclopedia/detail-' + params.id + '.html'
+			: import.meta.env.VITE_HTTP_URL + '/info/detail-' + params.id + '-1.html'
 	if (sessionStorage.getItem('isDetailRefresh')) {
 		sessionStorage.removeItem('isDetailRefresh')
 	}

+ 2 - 2
src/store/tab/tab.ts

@@ -7,7 +7,7 @@ export const useTabStore = defineStore('myTabStore', {
 		stageStatus: '',
 		productId: 0,
 		labelIds: '',
-		searchValue: '',
+		title: '',
 		allStatus: '1'
 	}),
 	actions: {
@@ -16,7 +16,7 @@ export const useTabStore = defineStore('myTabStore', {
 			this.type = step?.type!
 			this.productId = step?.productId
 			this.labelIds = step?.labelIds
-			this.searchValue = step?.searchValue!
+			this.title = step?.title!
 			this.allStatus = step?.allStatus!
 		}
 	},

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

@@ -6,6 +6,6 @@ export type DTabStore = {
 	labelIds: DFindParams<IArchiveRequest, 'labelIds'>
 	stageStatus: DFindParams<IArchiveRequest, 'stageStatus'>
 	productId: DFindParams<IArchiveRequest, 'productId'>
-	searchValue: string
-	allStatus: DFindParams<IAllStatus, 'allStatus'>
+	title: string
+	allStatus?: DFindParams<IAllStatus, 'allStatus'>
 }

+ 2 - 0
src/views/Database/add.vue

@@ -44,6 +44,7 @@ import type { FormInstance, FormRules } from "element-plus";
 import { useRouter } from "vue-router";
 import { useUserInfoState } from "@/store/user/user";
 import { addAllStatusForm } from "@/api/context/context";
+import { showToast } from 'vant';
 const router = useRouter();
 const { serviceProviderId } = useUserInfoState()
 const formRef = ref<FormInstance>();
@@ -76,6 +77,7 @@ const onSubmit = (formEl: FormInstance | undefined) => {
       const data = await addAllStatusForm(formLabelAlign)
       if (data.code === 0) {
         router.back()
+        showToast('新增话术成功')
       }
     } else {
       console.log("error submit!", fields);

+ 4 - 3
src/views/Database/components/context-contain.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="box" :style="{paddingBottom: route.query.t === '5' ? '100px' : ''}">
+  <div class="box" :style="{paddingBottom: DType === '5' ? '100px' : ''}">
     <slot name="head" :data="props" />
     <div v-for="(d, i) in dataList" :key="i">
       <div class="shareFile">
@@ -36,9 +36,10 @@
 import { DDataBaseListAll, DEmit } from "@/types/views/database.type";
 import FileContent from "./file-content.vue";
 import { ref, computed } from 'vue';
-import { useRouter, useRoute } from 'vue-router'
+import { useRouter } from 'vue-router'
+import { useTabStore } from '@/store/tab/tab';
+const { type: DType } = useTabStore()
 const router = useRouter()
-const route = useRoute()
 const pageNum = ref<number>(1);
 const emit = defineEmits<DEmit>();
 

+ 8 - 13
src/views/Database/components/context-head.vue

@@ -23,35 +23,30 @@ import {
   tabList,
   allStatusList,
 } from "@/types/views/database.type";
-import { ref, computed, watch } from 'vue';
+import { ref, computed, watch, toRefs } from 'vue';
 import { DTabStore } from "@/store/tab/tab.type";
-//import { useRoute } from "vue-router";
-//const route = useRoute();
+import { useTabStore } from '@/store/tab/tab';
+
 const props = defineProps<{
   type: ChangeTabEmit | string
   index: number
 }>();
+const { type: Dtype } = toRefs(useTabStore())
 const form = ref<Pick<DTabStore, 'type'> & Pick<DTabStore, 'allStatus'>>({
   type: props.type,
   allStatus: "1",
 });
 const emit = defineEmits<DEmit>();
-watch(
-  () => props.type,
-  () => {
-    form.value.allStatus = '1'
-  },
-  {
-    deep: true,
-  }
-);
 watch(
   () => form.value.allStatus,
   () => {
     emit("handle-all-status", { type: props.type, allStatus: form.value.allStatus, index: props.index });
   }
 );
-
+watch(() => Dtype.value, (val) => {
+  console.log('tab变化', val)
+  form.value.allStatus = '1'
+})
 const controlText = computed<DFindParams<DScrollTab, "text">>(
   () => tabList.filter((e) => e.type === props.type)[0].text
 );

+ 2 - 20
src/views/Database/components/context-share.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="share" v-if="type === '5'">
-    <!--<div class="show" @click.stop="useCopyText(props.content!, props.id!)">复制话术内容</div>-->
-    <el-button class="show copy" type="text" @click="handleCopy(props.content!, props.id!)">复制话术内容</el-button>
+    <el-button class="show copy" type="text" @click="useCopyText(props.content!, props.id!)">复制话术内容</el-button>
     <div class="showNum" v-if="allStatus === 1">已使用:{{ props.pv || 0 }}次</div>
   </div>
   <div class="share" v-else>
@@ -22,7 +21,6 @@
 </template>
 
 <script setup lang="ts">
-import Clipboard from 'clipboard'
 import { DArchiveResultData } from "@/types/api/context.type";
 import { DFindParams, DScrollTab, tabList } from "@/types/views/database.type";
 import { computed } from "vue";
@@ -31,8 +29,7 @@ import { useRouter } from "vue-router";
 import useWeChatShare from "@/Hooks/useWeChatShare";
 import { useUserInfoState } from "@/store/user/user";
 import getFileImg from "@/Hooks/useFileImage";
-import { statisticAddContext } from "@/api/context/context";
-import { showNotify } from 'vant';
+import useCopyText from '@/Hooks/useCopyText';
 
 const props = defineProps<DArchiveResultData>();
 const { serviceProviderId, userId } = useUserInfoState();
@@ -42,7 +39,6 @@ const imageLink = computed<string>(() => {
   if (props.type !== "3") return props.image as string;
   else return getFileImg(props.waters![0] && props.waters![0].split('?')[0]).img as string;
 });
-console.log(imageLink.value)
 const controlText = computed<DFindParams<DScrollTab, "text">>(
   () => tabList.filter((e) => e.type === props.type)[0].text
 );
@@ -57,20 +53,6 @@ const handleDetail = ($event: DArchiveResultData) => {
   router.push("/database/detail?id=" + $event.id + "&t=" + $event.type);
   console.log($event.type);
 };
-
-const handleCopy = async (content: string, authorId: string) => {
-  await statisticAddContext({ type: 1, authorId })
-  const clipboard = new Clipboard('.copy', {
-        text: function () {
-          return content
-        }
-      })
-      clipboard.on('success', () => {
-        showNotify('已成功复制!'); // 提示复制成功信息
-        // 释放内存
-        clipboard.destroy()
-      })
-}
 </script>
 
 <style scoped lang="scss">

+ 2 - 1
src/views/Database/components/high-light-text.vue

@@ -10,11 +10,12 @@
 </template>
 
 <script setup lang="ts">
-defineProps<{
+const props = defineProps<{
   keywords: string;
   text: string;
   isTitle: boolean;
 }>();
+console.log(props)
 </script>
 
 <style scoped lang="scss">

+ 2 - 2
src/views/Database/components/search-head.vue

@@ -92,7 +92,7 @@ import { getLabelKeyList, getStoreList } from "@/api/context/context";
 import { CheckboxInstance, showToast, DropdownMenuInstance } from "vant";
 import { ILabelKeyRequest, IStoreRequest } from "@/types/api/context.type";
 import { useTabStore } from "@/store/tab/tab";
-const { searchValue, labelIds } = useTabStore();
+const { title, labelIds } = useTabStore();
 const activePadding = ref<string>("20vw 1vw 1vw 1vw"); // vue 样式
 const handleOpen = (val: number) => {
   activePadding.value = val < 2 ? "20vw 1vw 1vw 1vw" : "5vw 1vw 1vw 1vw";
@@ -107,7 +107,7 @@ const labelKeyParams = ref<ILabelKeyRequest>({
   pageSize: 10,
   v: "",
 }); // 搜索条件
-const value = ref<string>(searchValue || ""); // 标题搜索
+const value = ref<string>(title || ""); // 标题搜索
 const checked = ref<Array<number | null>>(
   labelIds?.split(",").map((e) => Number(e)) || []
 ); // 默认选中 多选

+ 3 - 3
src/views/Database/components/text-file-content.vue

@@ -5,9 +5,9 @@
       <van-image fit="contain" :src="getFileImg(props?.waters![0].split('?')[0] as string).img" v-else />
     </div>
     <div class="title">
-      <div class="t1"><high-light-text v-if="title" :keywords="searchValue" :text="title!" :is-title="true"/></div>
+      <div class="t1"><high-light-text v-if="title" :keywords="DTitle || ''" :text="title!" :is-title="true"/></div>
       <div class="t2" v-if="!showFileContent()">
-        <high-light-text v-if="content" :keywords="searchValue" :text="content!" :is-title="false"/>
+        <high-light-text v-if="content" :keywords="DTitle || ''" :text="content!" :is-title="false"/>
       </div>
     </div>
   </div>
@@ -20,7 +20,7 @@ import { useTabStore } from "@/store/tab/tab";
 import { toRefs, computed } from 'vue';
 import getFileImg from "@/Hooks/useFileImage";
 
-const { searchValue } = toRefs(useTabStore());
+const { title: DTitle } = toRefs(useTabStore());
 const props = defineProps<DArchiveResultData>();
 
 const showFileContent = (): boolean => ["3", "6"].indexOf(props.type as string) !== -1;

+ 2 - 2
src/views/Database/components/video-img-content.vue

@@ -3,7 +3,7 @@
     <div class="text-title">
       <high-light-text
         v-if="props.title"
-        :keywords="searchValue"
+        :keywords="DTitle || ''"
         :text="props.title!"
         :is-title="true"
       />
@@ -27,7 +27,7 @@ import highLightText from "./high-light-text.vue";
 import { DArchiveResultData } from "@/types/api/context.type";
 import { toRefs, computed } from "vue";
 import ImageContent from "./image-content.vue";
-const { searchValue } = toRefs(useTabStore());
+const { title: DTitle } = toRefs(useTabStore());
 
 const props = defineProps<DArchiveResultData>();
 

+ 16 - 76
src/views/Database/data-all/index.vue

@@ -26,7 +26,7 @@
   </div>
   <div class="bottom-btn" v-if="reqParams!.type! === '5' && isAddStatus">
     <data-button
-      @handle-emit="router.push('/database/add')"
+      @handle-emit="bindRouter"
       backgroundColor="#FF5B00"
       color="#FFFFFF"
       label="添加话术"
@@ -35,60 +35,33 @@
 </template>
 
 <script setup lang="ts">
-//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 { ref, watch } 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 } from "vue-router";
 import { getArchiveList } from "@/api/context/context";
 import { useUserInfoState } from "@/store/user/user";
 import { myDecrypt } from "@/util/authStorage";
-import useWeChatShare from "@/Hooks/useWeChatShare";
+//import useWeChatShare from "@/Hooks/useWeChatShare";
 import { DTabStore } from "@/store/tab/tab.type";
+import { useTabStore } from '@/store/tab/tab';
 const { userId } = useUserInfoState();
-const router = useRouter();
-//const route = useRoute();
+const { allStatus } = useTabStore()
+const bindRouter = () => window.location.href = '/database/add'
 const dataList = ref<DDataBaseListAll[] | null>(null);
 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 isEmpty = ref<boolean>(false);
 const isShowType = (data: DDataBaseListAll): boolean => {
-  //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 {
     return true;
   }
 };
-const formParams = ref({ allStatus: "1", userId: userId as string });
+const formParams = ref({ allStatus, userId: userId as string });
 const reqArchiveList = async (res?: DetailParams) => {
   if (!res) {
     const { data } = await getArchiveList({ ...reqParams.value, ...formParams.value });
@@ -103,7 +76,7 @@ const reqArchiveList = async (res?: DetailParams) => {
     }));
     isEmpty.value = data?.length === 0;
   } else {
-    const { data } = await getArchiveList({ ...reqParams.value, ...res! });
+    const { data } = await getArchiveList({ ...reqParams.value, ...formParams.value, ...res! });
     const DcreptoList = data?.map((e) => ({
       ...e,
       waters: myDecrypt(e.waters! as string[]),
@@ -120,35 +93,7 @@ const reqArchiveList = async (res?: DetailParams) => {
     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;
-//  }
-//  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) {
@@ -159,7 +104,12 @@ const valueChange = (form: Record<string, any>): Record<string, any> => {
 }
 watch(() => props, (val) => {
   reqParams.value = valueChange(val)
-  reqArchiveList()
+  formParams.value.allStatus = '1'
+  if (Object.values(reqParams.value).some(e => !!e && e !== '')) {
+    reqArchiveList()
+  } else {
+    dataList.value = []
+  }
 }, {
   immediate: true,
   deep: true,
@@ -172,18 +122,8 @@ const handleAllStatus = ($event: DetailParams) => {
   console.log("改变成企业", $event);
   formParams.value.allStatus = $event.allStatus!;
   reqArchiveList($event);
-  isAddStatus.value = $event.allStatus === "2";
+  isAddStatus.value = formParams.value.allStatus === "2";
 };
-onMounted(() => {
-  useWeChatShare({
-    type: '3',
-    id: '1',
-    imageUrl: '',
-    spId: 0,
-    isShowToast: false,
-    suid: 0,
-  });
-})
 </script>
 
 <style lang="scss" scoped>

+ 6 - 19
src/views/Database/detail.vue

@@ -23,8 +23,7 @@
     <p class="foot-mark">{{ form?.keywords?.split(',').join('、') }}</p>
     <div class="data-btn">
       <data-button @handle-emit="handleClick" backgroundColor="#FFF" color="#FF5B00" label="查看文件" v-if="type === '3'" />
-      <data-button @handle-emit="handleCopy(form!.content!, form!.id!)" backgroundColor="#FFF" color="#FF5B00"
-        label="复制文本" v-if="type === '5'" />
+      <van-button @click="useCopyText(form!.content!, form!.id!)" class="copy" v-if="type === '5'" plain>复制文本</van-button>
       <data-button @handle-emit="
         useWeChatShare({
           type: form?.type!,
@@ -40,7 +39,6 @@
 </template>
 
 <script setup lang="ts">
-//import useCopyText from '@/Hooks/useCopyText'
 import useWeChatShare from '@/Hooks/useWeChatShare'
 import ImageContent from './components/image-content.vue'
 import { getArchiveFormDetails } from '@/api/context/context'
@@ -51,9 +49,7 @@ import { useRoute, useRouter } from 'vue-router'
 import getFileImg from '@/Hooks/useFileImage'
 import { useUserInfoState } from '@/store/user/user'
 import { myDecrypt } from '@/util/authStorage'
-import Clipboard from 'clipboard'
-import { statisticAddContext } from "@/api/context/context";
-import { showNotify } from 'vant';
+import useCopyText from '@/Hooks/useCopyText';
 
 const route = useRoute()
 const router = useRouter()
@@ -84,19 +80,6 @@ const getArchiveForm = async () => {
 const move = () => {
   document.body.style.position = 'static'
 }
-const handleCopy = async (content: string, authorId: string) => {
-  await statisticAddContext({ type: 1, authorId })
-  const clipboard = new Clipboard('.copy', {
-        text: function () {
-          return content
-        }
-      })
-      clipboard.on('success', () => {
-        showNotify('已成功复制!'); // 提示复制成功信息
-        // 释放内存
-        clipboard.destroy()
-      })
-}
 onActivated(() => {
   getArchiveForm()
   move()
@@ -183,4 +166,8 @@ onActivated(() => {
     margin-bottom: 12px;
   }
 }
+.copy {
+  width: 100%;
+  color: $basicColor;
+}
 </style>

+ 8 - 23
src/views/Database/index.vue

@@ -4,13 +4,12 @@
     <scroll-tap-btn @handle-tab-emit="handleTabEmit" />
   </div>
   <div class="container">
-    <!--<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"
+      :title="form.title"
       :all-status="form.allStatus"
     />
   </div>
@@ -24,47 +23,33 @@ import type {
   SearchEmitParams,
   ChangeEmitParams,
   DScrollTab,
-ChangeTabEmit,
+  ChangeTabEmit,
 } from "@/types/views/database.type";
 import { ref, toRefs } from "vue";
-//import { useRouter } from "vue-router";
 import { DTabStore } from "@/store/tab/tab.type";
 import DataAll from "./data-all/index.vue";
-const { type } = toRefs(useTabStore());
+const { type, labelIds, productId, title, stageStatus } = toRefs(useTabStore());
 const { updatedTabStore } = useTabStore();
-//const router = useRouter();
 
 const form = ref<DTabStore>({
-  labelIds: "",
-  productId: "",
-  stageStatus: "",
+  labelIds: labelIds.value,
+  productId: productId.value,
+  stageStatus: stageStatus.value,
   type: type.value,
-  searchValue: "",
-  allStatus: "1",
+  title: title.value,
 });
-
-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 || ""}`
-  //);
-};
 const handleSearch = (event: SearchEmitParams) => {
-  form.value = { ...form.value, ...{ searchValue: event } };
+  form.value = { ...form.value, ...{ title: event } };
   updatedTabStore(form.value);
-  routerLink();
 };
 const handleChange = (event: ChangeEmitParams) => {
   form.value = { ...form.value, ...event };
   updatedTabStore(form.value);
-  routerLink();
 };
 const handleTabEmit = (event: DScrollTab): void => {
   console.log("tab", event);
   form.value = { ...form.value, ...event };
   updatedTabStore(form.value);
-  routerLink();
 };
 </script>