diff --git a/src/api/daikin/base.ts b/src/api/daikin/base.ts index 46595e4..cf09083 100755 --- a/src/api/daikin/base.ts +++ b/src/api/daikin/base.ts @@ -117,12 +117,17 @@ export interface ArticlePageReq { type?: string // 分类 1-外部环境 2-竞争对手 3-供方动向 4-大金集团 5-中国据点 6-调达本部 7-news 8-重要通知 cate?: String - position: String + position?: String + keyword?: String } export async function getArticlePage(params: ArticlePageReq) { // return openApiRequest({ url: '/article/getPage', params }) return http.get('/article/getPage', { params }) } +export async function getSearchGlobal(params: ArticlePageReq) { + // return openApiRequest({ url: '/article/getPage', params }) + return http.get('/app/search', { params }) +} export async function getArticleList(params: ArticlePageReq) { // return openApiRequest({ url: '/article/getList', params }) diff --git a/src/components/search.vue b/src/components/search.vue index 09364d5..e3961d6 100755 --- a/src/components/search.vue +++ b/src/components/search.vue @@ -1,27 +1,32 @@ \ No newline at end of file + diff --git a/src/stores/modules/search.ts b/src/stores/modules/search.ts index 841437a..c2ada0f 100755 --- a/src/stores/modules/search.ts +++ b/src/stores/modules/search.ts @@ -1,17 +1,15 @@ import { defineStore } from 'pinia' - - - export const searchStore = defineStore('search', () => { - const search = ref({ - content:'' - }) - - function setArticle(data: { content: string }){ - search.value = data - } - - return { search,setArticle } + const search = ref({ + content: '', + time: 0 + }) -}) \ No newline at end of file + function setArticle(data: string) { + search.value.content = data + search.value.time = new Date().getTime() + } + + return { search, setArticle } +}) diff --git a/src/views/extermal/Article/Detail.vue b/src/views/extermal/Article/Detail.vue index 28e9692..192232f 100755 --- a/src/views/extermal/Article/Detail.vue +++ b/src/views/extermal/Article/Detail.vue @@ -17,44 +17,44 @@ const newId = ref() const scale = ref(1) const imgW = ref('auto') const pageInfo = reactive({ - currentPage: 1, - pageSize: 10, - type: '1', - total: 10 + currentPage: 1, + pageSize: 10, + type: '1', + total: 10 }) const listData = ref([]) async function setModule(codes: any) { - const moduleCode = codes - await report({ moduleCode }) + const moduleCode = codes + await report({ moduleCode }) } const toDetail = (n: any, item: any) => { - // push(`${route.path}/${item.id}`) - // if(n.isSelect===1){ - setModule(item) - push(`/external/info/${n.id}`) - // } - // else{ - // message.info("您没有权限查看!") - // } + // push(`${route.path}/${item.id}`) + // if(n.isSelect===1){ + setModule(item) + push(`/external/info/${n.id}`) + // } + // else{ + // message.info("您没有权限查看!") + // } } const toList = (nb) => { - if (nb === 7) { - pages.page.cate = '7' - pages.page.title = 'News' - } else { - pages.page.cate = '8' - pages.page.title = '重要通知' - } - replace(`/external/info/${nb === 7 ? 'news' : 'info'}`) - // push({ name: 'DetailInfoList' }) + if (nb === 7) { + pages.page.cate = '7' + pages.page.title = 'News' + } else { + pages.page.cate = '8' + pages.page.title = '重要通知' + } + replace(`/external/info/${nb === 7 ? 'news' : 'info'}`) + // push({ name: 'DetailInfoList' }) } const SideNews = [ - { key: 'IntelligenceWithin', name: 'News', cate: 7, type: 0 }, - { key: 'IntelligenceOutside', name: '重要通知', cate: 8, type: 1 } + { key: 'IntelligenceWithin', name: 'News', cate: 7, type: 0 }, + { key: 'IntelligenceOutside', name: '重要通知', cate: 8, type: 1 } ] // 获取News数据 getArticlePage @@ -63,16 +63,15 @@ const newsSoll = ref(null) let newLength: number let newPum = 1 async function getArticle(page: any) { - const pasr = { - pageNum: page, - pageSize: '10', - type: '1', - cate: '7' - } - const { rows, total } = await externalList(pasr) - console.log('🚀 ~ file: Detail.vue:46 ~ rows:', rows) - newsList.value = rows || [] - newLength = total / 10 + const pasr = { + pageNum: page, + pageSize: '10', + type: '1', + cate: '7' + } + const { rows, total } = await externalList(pasr) + newsList.value = rows || [] + newLength = total / 10 } // 获取重要通知数据 getArticlePage const portantList = ref([]) @@ -80,395 +79,379 @@ const portant = ref(null) let pLenght: number let prpum = 1 async function getArticleP(page: any) { - const pasr = { - pageNum: page, - pageSize: '10', - type: '1', - cate: '8' - } - const { rows, total } = await externalList(pasr) - portantList.value = rows || [] - pLenght = total / 10 + const pasr = { + pageNum: page, + pageSize: '10', + type: '1', + cate: '8' + } + const { rows, total } = await externalList(pasr) + portantList.value = rows || [] + pLenght = total / 10 } const state = ref({}) const type = ref('') watchEffect(() => { - const { id } = route.params as any - if (!id) return - newId.value = id as string - scale.value = id === '701' ? 2 : ['778', '840', '887'].includes(id) ? 1.5 : 1 - imgW.value = id !== '1241' ? '100%' : 'auto' - getArticleP(1) - getArticle(1) - getData() + const { id } = route.params as any + if (!id) return + newId.value = id as string + scale.value = id === '701' ? 2 : ['778', '840', '887'].includes(id) ? 1.5 : 1 + imgW.value = id !== '1241' ? '100%' : 'auto' + getArticleP(1) + getArticle(1) + getData() }) async function getData() { - const { id } = route.params - if (!id) return - if (id == 'news' || id == 'info') { - const { rows, total } = await externalList({ - pageNum: pageInfo.currentPage, - pageSize: pageInfo.pageSize, - type: pageInfo.type, - cate: id === 'news' ? '7' : '8' - }) - type.value = id == 'news' ? 'News' : '重要通知' - pageInfo.total = total - listData.value = rows - return - } - listData.value = [] - type.value = '' - const { data } = await externalInfo(id as string) - data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' + const { id } = route.params + if (!id) return + if (id == 'news' || id == 'info') { + const { rows, total } = await externalList({ + pageNum: pageInfo.currentPage, + pageSize: pageInfo.pageSize, + type: pageInfo.type, + cate: id === 'news' ? '7' : '8' + }) + type.value = id == 'news' ? 'News' : '重要通知' + pageInfo.total = total + listData.value = rows + return + } + listData.value = [] + type.value = '' + const { data } = await externalInfo(id as string) + data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' - data.content = unescapeHTML(data.content) - state.value = data - console.log(state) + data.content = unescapeHTML(data.content) + state.value = data + console.log(state) } function unescapeHTML(html: string) { - const doc = new DOMParser().parseFromString(html, 'text/html') - return doc.documentElement.textContent + const doc = new DOMParser().parseFromString(html, 'text/html') + return doc.documentElement.textContent } const handleSizeChange = (e) => { - pageInfo.pageSize = e - pageInfo.currentPage = 1 - getData() + pageInfo.pageSize = e + pageInfo.currentPage = 1 + getData() } const handleCurrentChange = (e) => { - pageInfo.currentPage = e - getData() + pageInfo.currentPage = e + getData() } diff --git a/src/views/home/intelligence/Detail.vue b/src/views/home/intelligence/Detail.vue index 5d27046..18bf60b 100755 --- a/src/views/home/intelligence/Detail.vue +++ b/src/views/home/intelligence/Detail.vue @@ -4,60 +4,56 @@ import AppBlock from '@/components/AppBlock.vue' import AppNewsBox from '@/components/AppNewsBox.vue' import Layout from './components/Layout.vue' import DetailNews from './DetailNews.vue' -import { - getArticleDetail, - getArticlePage, - getManagerDetail -} from '@/api/daikin/base' +import { getArticleDetail, getArticlePage, getManagerDetail } from '@/api/daikin/base' import { message } from '@/utils/message' const { push } = useRouter() const route = useRoute() const SideNews = [ - { key: 'IntelligenceOutside', name: '社外情报' }, - { key: 'IntelligenceWithin', name: '社内情报' } + { key: 'IntelligenceOutside', name: '社外情报' }, + { key: 'IntelligenceWithin', name: '社内情报' } ] const state = ref({}) async function getData() { - const { id, flag } = route.params - console.log(typeof flag) - if (!id) return - if (flag === 'true') { - // 驳回&撤回 - const { data } = await getManagerDetail(id as string) - data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' - data.content = unescapeHTML(data.content) - state.value = data - } else { - const { data } = await getArticleDetail(id as string) - data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' + const { id, flag } = route.params + console.log(typeof flag) + if (!id) return + if (flag === 'true') { + // 驳回&撤回 + const { data } = await getManagerDetail(id as string) + data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' + data.content = unescapeHTML(data.content) + state.value = data + } else { + const { data } = await getArticleDetail(id as string) + data.tagColor = data.tag === '紧急' ? '#e60e0e' : '#2cba06' - data.content = unescapeHTML(data.content) - state.value = data - } + data.content = unescapeHTML(data.content) + state.value = data + } } function unescapeHTML(html: string) { - const doc = new DOMParser().parseFromString(html, 'text/html') - return doc.documentElement.textContent + const doc = new DOMParser().parseFromString(html, 'text/html') + return doc.documentElement.textContent } async function getDatas(id: string) { - if (!id) return - const { data } = await getArticleDetail(id as string) - data.content = unescapeHTML(data.content) - state.value = data + if (!id) return + const { data } = await getArticleDetail(id as string) + data.content = unescapeHTML(data.content) + state.value = data } async function toDetail2(n: { id: any }) { - console.log(route, route.path, n.id) - if (n.id === 0) return - if (n.isSelect === 1) { - getDatas(n.id) - } else { - message.info('您没有权限查看!') - } + console.log(route, route.path, n.id) + if (n.id === 0) return + if (n.isSelect === 1) { + getDatas(n.id) + } else { + message.info('您没有权限查看!') + } } getData() @@ -67,101 +63,96 @@ getPageLists(1) const neiScoll = ref(null) const waiScoll = ref(null) onMounted(() => { - neiScoll.value?.addEventListener('scroll', handleNeiScoll) - waiScoll.value?.addEventListener('scroll', handlewaiScoll) + neiScoll.value?.addEventListener('scroll', handleNeiScoll) + waiScoll.value?.addEventListener('scroll', handlewaiScoll) }) const listData = ref([]) let neiLength: number let neiPum = 1 async function getPageList(page) { - const pasr = { - pageNum: page, - pageSize: 5, - type: 2, - position: 'recommend' - } - const { rows, total } = await getArticlePage(pasr) - neiLength = total / 6 - listData.value.push(...rows) - console.log(listData.value) + const pasr = { + pageNum: page, + pageSize: 5, + type: 2, + position: 'recommend' + } + const { rows, total } = await getArticlePage(pasr) + neiLength = total / 6 + listData.value.push(...rows) + console.log(listData.value) } const listDatas = ref([]) let waiLength: number let waiPum = 1 async function getPageLists(page) { - const pasr = { - pageNum: page, - pageSize: 5, - type: 1, - position: 'recommend' - } - const { rows, total } = await getArticlePage(pasr) - waiLength = total / 6 - listDatas.value.push(...rows) + const pasr = { + pageNum: page, + pageSize: 5, + type: 1, + position: 'recommend' + } + const { rows, total } = await getArticlePage(pasr) + waiLength = total / 6 + listDatas.value.push(...rows) } const handleNeiScoll = () => { - const container = neiScoll.value - if (container) { - const isAtBottom = - container.scrollHeight - container.scrollTop === container.clientHeight - if (isAtBottom) { - if (neiPum < neiLength) { - ++neiPum - getPageList(neiPum) - } - } - } + const container = neiScoll.value + if (container) { + const isAtBottom = container.scrollHeight - container.scrollTop === container.clientHeight + if (isAtBottom) { + if (neiPum < neiLength) { + ++neiPum + getPageList(neiPum) + } + } + } } const handlewaiScoll = () => { - const container = waiScoll.value - if (container) { - const isAtBottom = - container.scrollHeight - container.scrollTop === container.clientHeight - if (isAtBottom) { - if (waiPum < waiLength) { - ++waiPum - getPageList(waiPum) - } - } - } + const container = waiScoll.value + if (container) { + const isAtBottom = container.scrollHeight - container.scrollTop === container.clientHeight + if (isAtBottom) { + if (waiPum < waiLength) { + ++waiPum + getPageList(waiPum) + } + } + } } diff --git a/src/views/home/search/index.vue b/src/views/home/search/index.vue index f65ba79..67bcf58 100755 --- a/src/views/home/search/index.vue +++ b/src/views/home/search/index.vue @@ -3,10 +3,12 @@ import { useUserStore } from '@/stores/modules/user' import HomeHead from '@/views/home/components/HomeHead.vue' // import HomeHeadSearch from '@/views/home/components/HomeHeadSearch.vue' import { useDate } from '@/views/home/hooks/useDate' -import { getArticlePage } from '@/api/daikin/base' +import { getArticlePage, getSearchGlobal } from '@/api/daikin/base' import { noticeld } from '@/stores/modules/noticeId' import { searchStore } from '@/stores/modules/search' import { message } from '@/utils/message' +import { NPopover } from 'naive-ui' + const store = noticeld() const store2 = useUserStore() const searchS = searchStore() @@ -15,81 +17,282 @@ const { push } = useRouter() const route = useRoute() const listData = ref() -const flg =ref() -let keywords =ref() +const flg = ref() +let keywords = ref() +const pageInfo = reactive({ + currentPage: 1, + pageSize: 10, + total: 0 +}) +// App_Article 外部情报模块,App_Market 市况汇率,App_data_platform 数据平台, App_BCP BCP模块, App_CSR 碳中和模块,App_Quality 品质模块,App_Lab Lab模块,App_Database DatabBase模块 +const codeType = { + App_Article: '外部情报', //分内部情报 和 外部情报 + App_Market: '市况汇率', //返回下文件大小 fileCommon.fileSize + App_data_platform: '数据平台', //返回文件大小 fileCommon.fileSize + App_BCP: 'BCP模块', //返回文件大小 fileCommon.fileSize + App_CSR: '碳中和模块', //返回文件大小 fileCommon.fileSize + App_Quality: '品质模块', //返回文件大小 fileCommon.fileSize + App_Lab: 'Lab模块', //返回文件大小 fileCommon.fileSize + App_Database: 'DatabBase模块', //返回文件大小 fileCommon.fileSize + App_News: '新闻模块' +} +const loading = ref(true) async function getSearchList() { - const keyword = keywords.value - const { rows } = await getArticlePage({ pageNum: 1, pageSize: 100, type: 2, position: 'search', keyword } as any); - listData.value = rows + loading.value = true + const keyword = searchS.search.content + // const { rows } = await getArticlePage({ pageNum: 1, pageSize: 100, type: 2, position: 'search', keyword } as any); + const { rows, total } = await getSearchGlobal({ + pageNum: pageInfo.currentPage, + pageSize: pageInfo.pageSize, + keyword + } as any).catch((e) => { + loading.value = false + listData.value = [] + }) + listData.value = rows + setTimeout(() => { + loading.value = false + }, 300) + pageInfo.total = total } -watchSyncEffect(()=>{ - keywords.value = searchS.search.content - // console.log(keywords.value) - getSearchList() +watchEffect(() => { + searchS.search.time + getSearchList(searchS.search.content) }) -onMounted(() => { - getSearchList() - flg.value = store2.user.isReview > 0 - console.log(flg.value,store2.user.isReview) -}) -const clickTo=(obj)=>{ - // console.log(obj) - if(obj.isSelect===1){ - push(`${route.path}/${obj.id}`) - } - else{ - message.info("您没有权限查看!") - } + +const codePath = { + App_Article: { + path: '/intelligence/outside/', + modulePath: '/Home/intelligence' + }, + App_Market: { + path: '/Home/market', + modulePath: '/Home/market' + }, + App_data_platform: { + path: '/Home/cd', + modulePath: '/Home/cd' + }, + App_BCP: { + path: '/Home/bcp', + modulePath: '/Home/bcp' + }, + // '碳中和模块', + App_CSR: { + path: '/Home/csr', + modulePath: '/Home/csr' + }, + // '品质模块', + App_Quality: { + path: '/Home/quality', + modulePath: '/Home/quality' + }, + // 'Lab模块', + App_Lab: { + path: '/Home/diffspace', + modulePath: '/Home/diffspace' + }, + // 'DatabBase模块' + App_Database: { + path: '/DataBase', + modulePath: '/DataBase' + } } + +const clickItem = (item) => { + const { id, filePath, isSelect, moduleCode, fileCommon = {} } = item + console.log('🚀 ~ file: index.vue:104 ~ item:', item) + + if (isSelect === 1) { + downloads({ fileCommon, filePath }) + } else { + message.info('您没有权限查看!') + } +} + +const downloads = (data: any = {}) => { + const { fileCommon, filePath } = data + if ((fileCommon?.fileSize || 0) > 25 * 1024 * 1024) { + message.info('正在下载中,请稍等~') + downloadFile(filePath) + return + } + if (filePath) { + window.open(filePath, '_blank') + } else { + message.info('没有可预览文件!') + } +} +function downloadFile(url: any) { + fetch(url) + .then((response) => response.blob()) + .then((blob) => { + const downloadUrl = URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = downloadUrl + link.download = getFileNameFromUrl(url) + link.click() + }) +} +function getFileNameFromUrl(url: string) { + console.log( + '🚀 ~ file: index.vue:107 ~ getFileNameFromUrl ~ getFileNameFromUrl:', + getFileNameFromUrl + ) + const lastSlashIndex = url.lastIndexOf('/') + if (lastSlashIndex !== -1) { + return url.substring(lastSlashIndex + 1) + } else { + return 'Invalid URL' + } +} + +const goModule = (item, type) => { + const { moduleCode, id } = item + const { modulePath, path } = codePath[moduleCode] + if (modulePath) { + if (type === 'module') { + push(modulePath) + } else { + push(path + id) + } + } +} + +const handleSizeChange = (e) => { + pageInfo.pageSize = e + pageInfo.currentPage = 1 + getSearchList() +} + +// const handleCurrentChange = (e) => { +// pageInfo.currentPage = e +// getSearchList() +// } +const fileSize = 24 * 1024 * 1024 +} +