diff --git a/src/api/api.ts b/src/api/api.ts index 2c00801..465ed55 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -214,7 +214,6 @@ export const getNewsInfo = (params: any, headers?: any) => { method: 'get', params, headers, - }); }; @@ -283,7 +282,6 @@ export const getIndustryHierarchy = (params?: any) => { }); }; - export const getTagConcept = (params?: any) => { return request({ url: '/tag/concept', @@ -312,7 +310,8 @@ export const doRecover = (data?: any) => { export const doNewSubmit = (data?: any) => { return request({ url: '/news/submit', - method: 'post', data + method: 'post', + data, }); }; @@ -329,7 +328,7 @@ export const doNewLog = (params?: any) => { return request({ url: '/news/log', method: 'get', - params + params, }); }; @@ -338,7 +337,7 @@ export const doNewCheck = (params?: any) => { return request({ url: '/news/check', method: 'post', - params + params, }); }; @@ -347,7 +346,7 @@ export const doNewReturn = (params?: any) => { return request({ url: '/news/return', method: 'post', - params + params, }); }; @@ -356,6 +355,14 @@ export const getSignalRules = (params?: any) => { return request({ url: '/news/getSignalRulesList', method: 'get', - params + params, + }); +}; + +export const searchCompany = (params?: any) => { + return request({ + url: '/news/getCompanyNames', + method: 'get', + params, }); }; diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 59c84df..3fb7768 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -1,8 +1,18 @@ // 工具函数:判断是否为移动设备(基于屏幕宽度) export const isMobileByWidth = (): boolean => { - if (typeof window === 'undefined') { - return false; // 非浏览器环境 - } - // 通常以 768px 作为移动设备的宽度阈值 - return window.innerWidth < 768; -}; \ No newline at end of file + if (typeof window === 'undefined') { + return false; // 非浏览器环境 + } + // 通常以 768px 作为移动设备的宽度阈值 + return window.innerWidth < 768; +}; +/* 防抖 */ +export function debounce(fn, delay) { + let timer = null; + return function () { + clearTimeout(timer); + timer = setTimeout(() => { + fn.apply(this, arguments); + }, delay); + }; +} diff --git a/src/views/pages/richedit/all.vue b/src/views/pages/richedit/all.vue index 2f4ce95..a6aa528 100644 --- a/src/views/pages/richedit/all.vue +++ b/src/views/pages/richedit/all.vue @@ -129,17 +129,23 @@ /> 企业检索: - - + 独家资源: @@ -438,6 +444,7 @@ import { getTagSource, getSignalRules, doRecover, + searchCompany, } from '/@/api/api'; import { highlightTitle } from '/@/utils/highlight'; import clipboard from 'clipboard'; @@ -892,6 +899,28 @@ function signalChange(event, type) { getData(); } +import { debounce } from '/@/utils/utils'; + +const companyList = ref([]); +const getCompany = debounce(async (val: string) => { + if (!val) { + return; + } + let { code, data } = await searchCompany({ + companyName: val, + }); + + if (code == 200) { + companyList.value = data; + // data.forEach((item) => { + // companyList.value.push({ + // label: item.companyName, + // value: item.companyName, + // }); + // }); + } +}, 500); + // 页面加载时 onMounted(async () => { if (isMobileByWidth() && Session.get('userInfoLocal').userType == '01') { diff --git a/src/views/pages/richedit/index.vue b/src/views/pages/richedit/index.vue index 6b1b0e7..8257b35 100644 --- a/src/views/pages/richedit/index.vue +++ b/src/views/pages/richedit/index.vue @@ -240,7 +240,7 @@ @change="handleSearch" /> 企业检索: - + --> + + + 独家资源: @@ -623,6 +643,7 @@ import DetailDrawer from './DetailDrawer/index.vue'; import { doNewRevoke, doNewSubmit, + searchCompany, getNews, doNewsPublish, doDeleteNews, @@ -1122,6 +1143,28 @@ function signalChange(event, type) { getData(); } +import { debounce } from '/@/utils/utils'; + +const companyList = ref([]); +const getCompany = debounce(async (val: string) => { + if (!val) { + return; + } + let { code, data } = await searchCompany({ + companyName: val, + }); + + if (code == 200) { + companyList.value = data; + // data.forEach((item) => { + // companyList.value.push({ + // label: item.companyName, + // value: item.companyName, + // }); + // }); + } +}, 500); + // 页面加载时 onMounted(async () => { if (isMobileByWidth() && (Session.get('userInfoLocal').userType == '01' || Session.get('userInfoLocal').userType == '02')) {