Commit 20ac819a authored by 罗超's avatar 罗超

提交部分搜索功能

parent a805b73d
......@@ -176,5 +176,10 @@ class ConfigService{
static async UpdateShareAsync(params:{ShareId:number,ShareTargetIds:string,EditType:string}):Promise<HttpResponse>{
return Api.Post("triptemplate_EditTripShare",params)
}
static async SearchFileAsync(params:{FileType:number,FileName:string,pageSize:number, [key: string]: any}):Promise<HttpResponse>{
params.pageIndex=1
return Api.Post("triptemplate_HomeQuery",params)
}
}
export default ConfigService;
\ No newline at end of file
......@@ -60,3 +60,43 @@ export const getDaysBetween = (date1:any, date2:any) => {
const difference = Math.abs(date1Time - date2Time); // 获取时间差
return Math.round(difference / ONE_DAY); // 两个日期之间的天数
}
export const formatDateTimeToRead = (dateStr:string,prefix:string='') =>{
console.log(dateStr)
let minute = 1000 * 60;
let hour = minute * 60;
let day = hour * 24;
let halfamonth = day * 15;
let month = day * 30;
let dateTimeStamp = Date.parse(dateStr.replaceAll('-',"/"))
let result = ''
let now = new Date().getTime();
let diffValue = now - dateTimeStamp;
if(diffValue < 0){
//若日期不符则弹出窗口告之
//alert("结束日期不能小于开始日期!");
return ''
}
let monthC =diffValue/month;
let weekC =diffValue/(7*day);
let dayC =diffValue/day;
let hourC =diffValue/hour;
let minC =diffValue/minute;
if(monthC>=1){
result=parseInt(monthC.toString()) + "月前";
}
else if(weekC>=1){
result=parseInt(weekC.toString()) + "周前";
}
else if(dayC>=1){
result=parseInt(dayC.toString()) +"天前";
}
else if(hourC>=1){
result=parseInt(hourC.toString()) +"小时前";
}
else if(minC>=1){
result=parseInt(minC.toString()) +"分钟前";
}else
result= "刚刚";
return prefix+result;
}
\ No newline at end of file
......@@ -98,13 +98,6 @@ import { useSellTemplateStore, useScreenStore, useSlidesStore } from '@/store'
const {userInfo} = storeToRefs(userStore())
const currentMenu = ref<number>(0)
// const datas = reactive({
// journeyAds:{
// RefreshLoading: false
// }
// })
// provide('journeyAds',datas.journeyAds)
const searchData = ref({} as any)
searchData.value = inject(injectKeyTemplate)
if(searchData.value.SellTemplateType){
......@@ -123,6 +116,10 @@ const sellAdd = (type:number) =>{
marketStore.setMarket(true)
}
const openFilePosition = (playload:{FileId:number,FileType:1|2,Position:{FileId:number,FileName:string}[]})=>{
}
const setCurrentMenuHandler=(i:number)=>{
currentMenu.value=i
searchData.value.currentMenu=i
......
......@@ -150,7 +150,7 @@
</div>
<el-divider
class="no-bg q-mt-lg"
v-if="queryObj.pageCount == queryObj.pageIndex && !loading"
v-if="queryObj.pageCount == queryObj.pageIndex && !loading && queryObj.pageCount != 1"
>
<span
class="text-small bg-white"
......
<template>
<div class="q-pa-md rounded search-area" style="display: inline-block;" :class="{'search-range-box':isSearchFocus}" v-click-outside="()=>isSearchFocus=false"><!-- v-click-outside="()=>isSearchFocus=false" -->
<div class="q-pa-md rounded search-area" style="display: inline-block;" :class="{'search-range-box':isSearchFocus}" @keypress.enter="searchHandler" v-click-outside="()=>isSearchFocus=false"><!-- v-click-outside="()=>isSearchFocus=false" -->
<el-input size="large" @focus="()=>isSearchFocus=true" v-model="searchKey" placeholder="搜索行程,广告,分享文件" style="width: 38vw;">
<template #prefix>
<el-icon><Search style="color:var(--el-color-primary);"/></el-icon>
</template>
</el-input>
<div v-if="isSearchFocus">
<el-tabs v-model="searchType" class="q-mt-md q-mx-md" @tab-click="handleClick">
<el-tab-pane label="全部" name="all"></el-tab-pane>
<el-tab-pane label="行程" name="trip"></el-tab-pane>
<el-tab-pane label="广告" name="ad"></el-tab-pane>
<el-tabs v-model="searchType" class="q-mt-md q-mx-md" @tab-change="()=>changeSearchType()">
<el-tab-pane label="全部" name="0"></el-tab-pane>
<el-tab-pane label="行程" name="1"></el-tab-pane>
<el-tab-pane label="广告" name="2"></el-tab-pane>
</el-tabs>
<div class="search-result-block">
<div class="text-h6 text-left text-bolder q-mx-md q-mb-sm">行程文档</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708337830000_43.png" />
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 摩洛哥、突尼斯北非系列2024-03-12 摩洛哥、突尼斯<span class="text-waring">北非系</span>列2024-03-12 摩洛哥、突尼斯北非系列</div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
</div>
</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708337830000_43.png" />
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 摩洛哥、<span class="text-waring">突尼斯</span>北非系列</div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
</div>
</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708337830000_43.png" />
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 <span class="text-waring">摩洛哥</span>、突尼斯北非系列2024-03-12 摩洛哥、突尼斯北非系列</div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
</div>
</div>
</div>
<el-skeleton :rows="5" v-if="loading" animated />
<div class="search-result-block q-mt-lg">
<div class="text-h6 text-left text-bolder q-mx-md q-mb-sm">广告图</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708250377000_777.png" />
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 摩洛哥、突尼斯北非系列2024-03-12 摩洛哥、突尼斯<span class="text-waring">北非系</span>列2024-03-12 摩洛哥、突尼斯北非系列</div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
</div>
</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708250377000_777.png" />
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 摩洛哥、<span class="text-waring">突尼斯</span>北非系列</div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
</div>
</div>
<div class="items row items-center q-pa-md">
<img class="biao" src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708250377000_777.png" />
<el-empty :image-size="150" v-if="searchResult && searchResult.length==0" :description="`没有查询到与 ‘${lastKeyword}’ 相关内容`" />
<el-scrollbar max-height="300px">
<div class="search-result-block" :class="{'q-mt-lg':i>0}" v-for="(x,i) in searchResult">
<div class="text-h6 text-left text-bolder q-mx-md q-mb-sm">{{x.type==1?'行程文档':'广告图'}}</div>
<div class="items row items-center q-pa-md" v-for="(item) in x.pageData" @click="editorFileHandler(item)" v-click-outside="()=>showRightContent=0" @contextmenu="()=>showRightContent=item.FileId">
<img class="biao" :src="(x.type==1 ?'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708337830000_43.png':'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1708250377000_777.png')" />
<el-popover :width="200" trigger="contextmenu" :visible="showRightContent==item.FileId">
<template #reference>
<div class="right col text-left q-pb-md">
<div class="file-name" truncated>2024-03-12 <span class="text-waring">摩洛哥</span>、突尼斯北非系列2024-03-12 摩洛哥、突尼斯北非系列</div>
<div class="file-name" truncated v-html="item.FileName.replaceAll(lastKeyword,`<span class='text-waring'>${lastKeyword}</span>`)"></div>
<div class="text-small q-mt-sm row items-center text-info">
<span>我的行程文档</span>
<span class="q-mx-md col">6 天前编辑过</span>
<span>我 创建的</span>
</div>
<el-tooltip effect="dark" :content="`${x.type==1?'行程文档':'广告图'}${item.FolderName=='/'?'':'/'+item.FolderName}`">
<span class="folder-path">{{x.type==1?'行程文档':'广告图'}}{{item.FolderName=='/'?'':'/'+item.FolderName}}</span>
</el-tooltip>
<span class="q-mx-md col"> {{formatDateTimeToRead((item.UpdateTime && item.UpdateTime!=''?item.UpdateTime:item.CreateTime))}} {{ item.UpdateTime&&item.UpdateTime!=''?'修改过':'创建' }}</span>
<span>{{userInfo.EmployeeId==item.CreateBy?'我 创建的':`${item.CreateName} 分享的`}}</span>
</div>
</div>
</template>
<el-menu mode="vertical">
<el-menu-item index="1" @click="editorFileHandler(item)">打开文件</el-menu-item>
<el-menu-item index="2-4-1">打开文件所在位置</el-menu-item>
</el-menu>
</el-popover>
<div class="text-info cusor-pointer q-mt-md text-small text-left q-mx-md">更多</div>
</div>
<div class="text-info cusor-pointer q-mt-md text-small text-left q-mx-md" v-if="searchType=='0' && x.count>3" @click="()=>changeSearchType(x.type.toString())">更多</div>
</div>
</el-scrollbar>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { inject, ref } from 'vue';
import { Search } from '@element-plus/icons-vue';
import ConfigService from '@/services/ConfigService';
import { userStore } from '@/store/user';
import { storeToRefs } from 'pinia';
import {formatDateTimeToRead} from '@/utils/common'
import { useScreenStore, useSellTemplateStore, useSlidesStore } from '@/store';
import { injectKeyTemplate } from '@/types/injectKey';
const {userInfo} = storeToRefs(userStore())
const searchKey = ref<string>('')
const isSearchFocus = ref(false)
const searchType = ref<string>('all')
const searchType = ref<string>('0')
const loading = ref(false)
const searchResult = ref<any[]|null>(null)
const lastKeyword = ref('')
const searchData = ref({} as any);
searchData.value = inject(injectKeyTemplate);
const showRightContent = ref(0)
const searchHandler = ()=>{
if(loading.value) return
loading.value = true
searchResult.value=null
if(searchKey.value!=''){
lastKeyword.value = searchKey.value
let task:any[] = []
console.log(searchType)
if(searchType.value=='0'||searchType.value=='1') task.push(searchByType(1,searchType.value=='0'?3:1000))
if(searchType.value=='0'||searchType.value=='2') task.push(searchByType(2,searchType.value=='0'?3:1000))
Promise.all(task).then(r=>{
if(r && r.length>0){
searchResult.value=[]
r.forEach((x,i)=>{
if(x.data.data && x.data.data.count>0){
x.data.data.type = i==0 && searchType.value!='2'?1:2
searchResult.value!.push(x.data.data)
}
})
}
loading.value = false
}).catch(()=>{
console.log('异常')
loading.value = false
})
}else{
loading.value = false
}
}
const editorFileHandler = (item:any)=>{
let list:any = [{
id: "test-slide-1",
pageType: 0,
elements: [],
background: {
type: "solid",
color: "#ffffff",
},
}];
const SalesEditorStore = useSellTemplateStore();
useSlidesStore().setSlides(list);
const marketStore = useScreenStore();
searchData.value.sellId = item.FileId;
searchData.value.sellTempId = item.TempId;
searchData.value.TemplateType = item.FileType;
SalesEditorStore.setSalesEditor(2);
marketStore.setMarket(false);
}
const searchByType = (t:1|2,count:number)=>{
return ConfigService.SearchFileAsync({
FileType:t,
FileName:searchKey.value,
pageSize:count
})
}
const changeSearchType = (val:string='')=>{
if(val!='') searchType.value=val
searchHandler()
}
</script>
<style>
.search-area{
......@@ -142,4 +175,17 @@ const searchType = ref<string>('all')
.search-result-block .items:hover .right{
border-bottom-color: transparent;
}
.search-result-block .items .right .folder-path{
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
max-width: 30%;
}
.el-menu,
.el-popper.is-light{
border:none !important;
}
.el-menu-item{
height: 35px !important;
}
</style>
\ No newline at end of file
......@@ -138,7 +138,7 @@
v-if="item.editTitle"
@blur="handleUpdateTitle(item)"
/></td>
<td class="text-center" @click.stop="item.FileType?OffEdit():editDelete(item,2)"><span>{{item.Day?item.Day+'天前':item.UpdateTime}}</span></td>
<td class="text-center" @click.stop="item.FileType?OffEdit():editDelete(item,2)"><span>{{formatDateTimeToRead(item.UpdateTime&&item.UpdateTime!=''?item.UpdateTime:item.CreateTime)}}</span></td>
<td class="text-center" @click.stop="item.FileType?OffEdit():editDelete(item,2)"><span>{{item.CreateName}}</span></td>
<td class="text-center">
<div class="hoverShow row items-center just-center q-pt-sm">
......@@ -224,13 +224,13 @@
refreshHandler()}"></TreeFile>
</template>
<script setup lang="ts">
import { ref, reactive, provide, watch, inject, onMounted } from "vue";
import { ref, reactive, provide, watch, inject, onMounted, PropType } from "vue";
import { ElLoading, ElMessage, ElMessageBox } from "element-plus";
import { MoreFilled, Edit, ArrowLeft,CopyDocument,DCaret,CaretTop,CaretBottom } from "@element-plus/icons-vue";
import ConfigService from "@/services/ConfigService";
import FolderService from "@/services/FolderService";
import { injectKeyTemplate } from "@/types/injectKey";
import { getDaysBetween } from "@/utils/common";
import { getDaysBetween,formatDateTimeToRead } from "@/utils/common";
import { useSellTemplateStore, useScreenStore, useSlidesStore } from "@/store";
import ShareForm from "./ShareForm.vue";
import Folder from "./Folder.vue";
......@@ -246,6 +246,10 @@ const props = defineProps({
type: Number,
default: 3,
},
Position:{
type:Object as PropType<{FileId:number,FileType:1|2,Position:{FileId:number,FileName:string}[]}|null>,
default:null
}
});
const PopoverVisibleControls = ref(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment