Jelajahi Sumber

修改我的收藏

zs 1 tahun lalu
induk
melakukan
f925bf71cc

+ 14 - 0
src/store/api/platform/tool.js

@@ -4,6 +4,14 @@ const url = '/tool'
 const axios = new AxiosWrapper()
 
 export const ToolStore = defineStore('tool', () => {
+  const query = async ({ skip = 0, limit = undefined, ...info } = {}) => {
+    let cond = {}
+    if (skip) cond.skip = skip
+    if (limit) cond.limit = limit
+    cond = { ...cond, ...info }
+    const res = await axios.$get(`${url}/query`, cond)
+    return res
+  }
   const getCollection = async ({ skip = 0, limit = undefined, ...info } = {}) => {
     let cond = {}
     if (skip) cond.skip = skip
@@ -12,11 +20,17 @@ export const ToolStore = defineStore('tool', () => {
     const res = await axios.$get(`${url}/MyCollection`, cond)
     return res
   }
+  const total = async (info) => {
+    const res = await axios.$get(`${url}/getTotal`, info)
+    return res
+  }
   const getTotal = async () => {
     const res = await axios.$get(`${url}/CollectionTotal`)
     return res
   }
   return {
+    query,
+    total,
     getCollection,
     getTotal
   }

+ 9 - 7
src/views/index/index.vue

@@ -61,7 +61,7 @@
               <el-col
                 class="list"
                 :span="6"
-                v-for="(item, index) in menuList"
+                v-for="(item, index) in menu"
                 :key="index"
                 @click="switchMenu(item.href)"
               >
@@ -93,6 +93,7 @@ const loading = ref(false)
 const router = useRouter()
 // 搜索
 const searchValue = ref('')
+const menu = ref(menuList)
 // 请求
 onMounted(async () => {
   loading.value = true
@@ -100,15 +101,16 @@ onMounted(async () => {
   loading.value = false
 })
 const search = async () => {
-  //   let res: IQueryResult = await toolsAxios.dataCount();
-  //   if (res.errcode == '0') {
-  //     info.value = res.data;
-  //   }
+  const menuList = menu.value.filter((item) => {
+    if (item.href != 'home') return item
+  })
+  menu.value = menuList
 }
 // 搜索
 const onSearch = (data) => {
-  console.log('use value', data)
-  console.log('or use this.value', searchValue.value)
+  const query = { type: 'search' }
+  if (data) query.searchValue = data
+  router.push({ path: '/search', query })
 }
 const toCommon = (type) => {
   if (type === 0) router.push({ path: '/help' })

+ 54 - 14
src/views/search/index.vue

@@ -7,7 +7,10 @@
           <div class="input">
             <a-input v-model:value="searchValue" placeholder="请输入想要搜索的内容">
               <template #suffix>
-                <SearchOutlined :style="{ fontSize: '30px', color: '#ffffff' }" />
+                <SearchOutlined
+                  @click="toChange(activeKey)"
+                  :style="{ fontSize: '30px', color: '#ffffff' }"
+                />
               </template>
             </a-input>
           </div>
@@ -15,7 +18,8 @@
         <el-col :span="24" class="one">
           <a-tabs v-model:activeKey="activeKey" centered @change="toChange">
             <a-tab-pane v-for="item in actList" :key="item.value" :tab="item.label">
-              <List></List>
+              <News v-if="item.value == 'news'"></News>
+              <List v-else></List>
             </a-tab-pane>
           </a-tabs>
         </el-col>
@@ -29,14 +33,11 @@
 import { get } from 'lodash-es'
 const $checkRes = inject('$checkRes')
 import List from './parts/list.vue'
+import News from './parts/news.vue'
 import { SearchOutlined } from '@ant-design/icons-vue'
 // 接口
-import { AchievementStore } from '@/store/api/platform/achievement'
 import { ToolStore } from '@/store/api/platform/tool'
-import { DemandStore } from '@/store/api/platform/demand'
 import { DictDataStore } from '@/store/api/system/dictData'
-const achieveStore = AchievementStore()
-const demandStore = DemandStore()
 const toolStore = ToolStore()
 const dictDataStore = DictDataStore()
 // 图片引入
@@ -57,9 +58,10 @@ const actList = ref([
   { label: '企业', value: 'company' },
   { label: '专家', value: 'expert' }
 ])
-const searchForm = ref({})
+const searchValue = ref('')
 // 字典表
 const fieldList = ref([])
+const statusList = ref([])
 const typeList = ref([
   { value: '0', label: '供给' },
   { value: '1', label: '需求' }
@@ -74,10 +76,11 @@ const currentPage = ref(1)
 // 请求
 onMounted(async () => {
   loading.value = true
+  searchValue.value = route.query.searchValue || ''
   await searchField()
   await searchOther()
   if (route.query && route.query.type == 'collection') await searchActive()
-  else await search({ skip, limit })
+  else await searchTotal()
   loading.value = false
 })
 const searchField = async () => {
@@ -114,7 +117,7 @@ const searchField = async () => {
       { label: '企业名称', model: 'name', type: 'name' },
       { label: '法定代表人:', model: 'representative' },
       { label: '企业地区:', model: 'area', type: 'area' },
-      { label: '成立时间:', model: 'time' }
+      { label: '成立时间:', model: 'create_time' }
     ]
   } else if (activeKey.value == 'expert') {
     fields.value = [
@@ -123,19 +126,41 @@ const searchField = async () => {
       { label: '所在地区:', model: 'area', type: 'area' },
       { label: '研究方向:', model: 'direction' }
     ]
+  } else if (activeKey.value == 'news') {
+    fields.value = [
+      { label: '资讯标题', model: 'title', type: 'name' },
+      { label: '发布人:', model: 'person' },
+      { label: '发布时间:', model: 'time' },
+      { label: '浏览量:', model: 'number' }
+    ]
+  } else if (activeKey.value == 'unit') {
+    fields.value = [
+      { label: '单位名称', model: 'name', type: 'name' },
+      { label: '技术领域:', model: 'field', type: 'dict' },
+      { label: '所在地区:', model: 'area', type: 'area' },
+      { label: '研究方向:', model: 'direction' }
+    ]
   }
 }
+const searchTotal = async () => {
+  const menu = await toolStore.total({
+    ...{ searchValue: searchValue.value },
+    is_use: '0',
+    status: '1'
+  })
+  if (menu.errcode == '0') actList.value = menu.data
+  await search({ skip, limit })
+}
 const search = async (query = { skip: 0, limit }) => {
   const info = {
     skip: query.skip,
     limit: query.limit,
-    ...searchForm.value,
+    type: activeKey.value,
+    ...{ searchValue: searchValue.value },
     is_use: '0',
     status: '1'
   }
-  let res
-  if (activeKey.value == 'achievement') res = await achieveStore.query(info)
-  else if (activeKey.value == 'demand') res = await demandStore.query(info)
+  const res = await toolStore.query(info)
   if (res.errcode == '0') {
     list.value = res.data
     total.value = res.total
@@ -163,12 +188,16 @@ const searchOther = async () => {
   // 技术领域
   result = await dictDataStore.query({ code: 'field', is_use: '0' })
   if ($checkRes(result)) fieldList.value = result.data
+  // 赛事状态
+  result = await dictDataStore.query({ code: 'matchStatus', is_use: '0' })
+  if ($checkRes(result)) statusList.value = result.data
 }
 // 字典数据转换
 const getDict = (data, model) => {
   let res
   if (model == 'field') res = fieldList.value.find((f) => f.value == data)
   if (model == 'type') res = typeList.value.find((f) => f.value == data)
+  if (model == 'match_status') res = statusList.value.find((f) => f.value == data)
   return get(res, 'label')
 }
 // 地区显示
@@ -176,6 +205,10 @@ const getArea = (data) => {
   if (data) return data.join(',')
   else return '暂无地区'
 }
+// 时间
+const getTime = (data) => {
+  if (data) return `${data[0]} 至 ${data[1]}`
+}
 // 查看
 const toView = (item) => {
   let path
@@ -191,7 +224,7 @@ const toView = (item) => {
 const toChange = (key) => {
   activeKey.value = key
   if (route.query && route.query.type == 'collection') searchCollection({ skip, limit })
-  else search({ skip, limit })
+  else searchTotal()
   searchField()
 }
 // 分页
@@ -206,12 +239,19 @@ const sizeChange = (limits) => {
   if (route.query && route.query.type == 'collection') searchCollection({ skip, limit })
   else search({ skip, limit })
 }
+watch(route, (newVal) => {
+  if (newVal && newVal.query && newVal.query.type) {
+    if (newVal.query && newVal.query.type == 'collection') searchActive()
+    else searchTotal()
+  }
+})
 // provide
 provide('fields', fields)
 provide('list', list)
 provide('toView', toView)
 provide('getArea', getArea)
 provide('getDict', getDict)
+provide('getTime', getTime)
 provide('limit', limit)
 provide('total', total)
 provide('currentPage', currentPage)

+ 6 - 1
src/views/search/parts/list.vue

@@ -15,12 +15,16 @@
                     </el-col>
                     <el-col :span="24" class="other_1" v-else-if="i.type == 'dict'">
                       <span>{{ i.label }}</span>
-                      {{ getDict(item[i.model], 'field') }}
+                      {{ getDict(item[i.model], i.model) }}
                     </el-col>
                     <el-col :span="24" class="other_1" v-else-if="i.type == 'area'">
                       <span>{{ i.label }}</span>
                       {{ getArea(item[i.model]) }}
                     </el-col>
+                    <el-col :span="24" class="other_1" v-else-if="i.type == 'time'">
+                      <span>{{ i.label }}</span>
+                      {{ getTime(item[i.model]) }}
+                    </el-col>
                     <el-col :span="24" v-else class="other_1 textOver">
                       <span>{{ i.label }}</span>
                       {{ item[i.model] || '暂无' }}
@@ -61,6 +65,7 @@ const total = inject('total')
 const limit = inject('limit')
 const getDict = inject('getDict')
 const getArea = inject('getArea')
+const getTime = inject('getTime')
 const toView = inject('toView')
 const currentPage = inject('currentPage')
 const changePage = inject('changePage')

+ 136 - 0
src/views/search/parts/news.vue

@@ -0,0 +1,136 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <div class="w_1200">
+          <el-col :span="24" class="one">
+            <el-col
+              :span="12"
+              class="list"
+              v-for="(item, index) in list"
+              :key="index"
+              @click="toView(item, '3')"
+            >
+              <el-col :span="4" class="left">
+                <div class="year" v-if="item.time">{{ moment(item.time).format('YYYY') }}</div>
+                <div class="date" v-if="item.time">{{ moment(item.time).format('MM-DD') }}</div>
+              </el-col>
+              <el-col :span="20" class="right">
+                <el-col :span="24" class="name textOver">
+                  <el-tooltip effect="dark" :content="item.title" placement="top">
+                    {{ item.title || '暂无标题' }}
+                  </el-tooltip>
+                </el-col>
+                <el-col :span="24" class="content">
+                  <div v-html="removeHtmlStyle(item.content)"></div>
+                </el-col>
+              </el-col>
+            </el-col>
+          </el-col>
+          <el-col :span="24" class="two">
+            <el-pagination
+              background
+              layout="total, prev, pager, next"
+              :page-sizes="[10, 20, 50, 100, 200]"
+              :total="total"
+              :page-size="limit"
+              v-model:current-page="currentPage"
+              @current-change="changePage"
+              @size-change="sizeChange"
+            >
+            </el-pagination>
+          </el-col>
+        </div>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script setup>
+import moment from 'moment'
+const list = inject('list')
+const total = inject('total')
+const limit = inject('limit')
+const toView = inject('toView')
+const currentPage = inject('currentPage')
+const changePage = inject('changePage')
+const sizeChange = inject('sizeChange')
+const removeHtmlStyle = (html) => {
+  let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g //去除样式
+  let relTag = /<.+?>/g //去除标签
+  let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g // 清除类名
+  let newHtml = ''
+  if (html) {
+    newHtml = html.replace(relStyle, '')
+    newHtml = newHtml.replace(relTag, '')
+    newHtml = newHtml.replace(relClass, '')
+  }
+  return newHtml
+}
+</script>
+<style scoped lang="scss">
+.main {
+  .one {
+    display: flex;
+    flex-wrap: wrap;
+    .list {
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 20px;
+      transition: all 0.3s;
+
+      .left {
+        font-family: PingFangSC-Regular;
+        font-size: 12px;
+        color: #2374ff;
+        line-height: 12px;
+
+        .year {
+          margin-bottom: 2px;
+        }
+
+        .date {
+          font-size: 22px;
+          line-height: 22px;
+          margin-bottom: 10px;
+        }
+      }
+
+      .right {
+        .name {
+          font-family: PingFangSC-Medium;
+          font-size: 16px;
+          color: #121834;
+          line-height: 16px;
+          font-weight: 700;
+          margin-bottom: 8px;
+        }
+
+        .content {
+          font-size: 12px;
+          color: #525a68;
+          line-height: 19px;
+          font-weight: 400;
+          display: -webkit-box;
+          -webkit-line-clamp: 2;
+          -webkit-box-orient: vertical;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          margin-top: 8px;
+        }
+      }
+    }
+
+    .list:hover {
+      background: #f0f7ff;
+      box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
+    }
+  }
+  .two {
+    display: flex;
+    flex-direction: row-reverse;
+    padding: 20px;
+  }
+}
+</style>