SearchPlatform.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div class="search-platform container-height">
  3. <div v-if="!isChildRoute">
  4. <Breadcrumb />
  5. <div class="search-platform-top bg_color_fff border_radius_16 box_shadow_card">
  6. <!-- 搜索与创建区域 -->
  7. <div class="search-create-bar">
  8. <div class="search-input-container flex_1">
  9. <input
  10. type="text"
  11. :placeholder="$t('common.qingshuruyaosousuodegongzuoliu')"
  12. class="search-input"
  13. v-model="searchFom.workflowTitle"
  14. />
  15. <button class="search-btn bg_color_primary gradient" @click.stop.prevent="getList('init')">
  16. <img :src="searchIcon" alt="" class="icon-search">
  17. {{$t('common.shousuo')}}
  18. </button>
  19. </div>
  20. <button class="create-btn bg_color_primary gradient" @click.stop.prevent="goWorkflowAdd">
  21. <img :src="addIcon" alt="" class="icon-add">
  22. {{$t('common.chuangjiangongzuoliu')}}
  23. </button>
  24. <div class="flex-center-between border_radius_10 pad20 cursor-pointer"
  25. @click="openNewTab(platformUrl)"
  26. style="background: #EAF0FF;height: 56px;">
  27. <!-- <img :src="n8Icon" alt="" style="width: 30px; height: 30px;" class="mr10"> -->
  28. <img :src="n8Icon" alt="" style="width: 30px; height: 30px;" class="mr10" v-if="activePlatform === 'n8n'">
  29. <img :src="cozeIcon" alt="" style="width: 30px; height: 30px;" class="mr10" v-if="activePlatform === 'coze'">
  30. <img :src="difyIcon" alt="" style="width: 30px; height: 30px;" class="mr10" v-if="activePlatform === 'dify'">
  31. <img :src="fastgptIcon" alt="" style="width: 30px; height: 30px;" class="mr10" v-if="activePlatform === 'fastGpt'">
  32. <div class="font_size18 color_theme">{{$t('common.go')}}{{activePlatform}}</div>
  33. <el-icon :size="24" color="#2D71FF"><CaretRight /></el-icon>
  34. </div>
  35. </div>
  36. <div class="typeList flex-between typeborder">
  37. <div class="gray font_size14 typeName">{{$t('common.dictType')}}:</div>
  38. <div class="flex_1 gap10">
  39. <div class="font_size14 typeItem" :class="{'active':searchFom.categoryId2 === ''}"
  40. @click="searchFom.categoryId2 = ''; searchFom.categoryId3 = '';getList('init');categoryListTree2=[]"
  41. :key="-1">
  42. {{$t('common.all')}}
  43. </div>
  44. <div class="font_size14 typeItem"
  45. v-for="item in categoryListTree" :key="item.categoryId"
  46. :class="{'active':searchFom.categoryId2 === item.categoryId}"
  47. @click="searchFom.categoryId2 = item.categoryId;searchFom.categoryId3 = '';categoryListTree2=[]; getList('init');getCategoryListTreeFn2();">
  48. {{item.categoryName}}
  49. </div>
  50. </div>
  51. </div>
  52. <div class="typeList flex-between">
  53. <div class="gray font_size14 typeName">{{$t('common.dictTypeSecond')}}:</div>
  54. <div class="flex_1 gap10">
  55. <div class="font_size14 typeItem" :class="{'active':searchFom.categoryId3 === ''}"
  56. @click="searchFom.categoryId3 = ''; getList('init');"
  57. :key="-1">
  58. {{$t('common.all')}}
  59. </div>
  60. <div class="font_size14 typeItem"
  61. v-for="item in categoryListTree2" :key="item.categoryId"
  62. :class="{'active':searchFom.categoryId3 === item.categoryId}"
  63. @click="searchFom.categoryId3 = item.categoryId; getList('init');">
  64. {{item.categoryName}}
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <!-- 列表 -->
  70. <div class="course-list mt20">
  71. <div class="course-grid">
  72. <CourseCard v-for="item in list" :key="item.publishId" :info="item"/>
  73. </div>
  74. </div>
  75. <!-- 分页 -->
  76. <!-- 替换原有的分页代码 -->
  77. <Pagination
  78. :total="listTotal"
  79. :page-size="searchFom.pageSize"
  80. :current-page="searchFom.pageNum"
  81. @page-change="handlePageChange"
  82. />
  83. </div>
  84. <router-view />
  85. </div>
  86. </template>
  87. <script setup>
  88. import searchIcon from '@/assets/imgs/search.png'
  89. import addIcon from '@/assets/imgs/add.png'
  90. import n8Icon from '@/assets/imgs/8n8.png'
  91. import cozeIcon from '@/assets/imgs/coze.png'
  92. import difyIcon from '@/assets/imgs/dify.png'
  93. import fastgptIcon from '@/assets/imgs/FastGPT.png'
  94. import CourseCard from '@/components/course-card.vue'
  95. import Pagination from '@/components/Pagination.vue'
  96. import { getCategoryListTree } from '@/api/category.js'
  97. import { getPublishList } from '@/api/publish.js'
  98. import { isLogin,openFullScreenLoading, openNewTab } from '@/utils/util.js'
  99. import { useI18n } from 'vue-i18n'
  100. const { t } = useI18n()
  101. import { useRouter, useRoute } from 'vue-router'
  102. const router = useRouter();
  103. const route = useRoute();
  104. import { ref, computed, reactive, onMounted, inject } from 'vue'
  105. //获取参数
  106. const query = route.query
  107. const categoryId = ref(query.categoryId || '');
  108. const activePlatform = ref(query.activePlatform || '');
  109. const platformUrl = ref(query.platformUrl || '')
  110. //获取当前路由路径
  111. // const currentPath = ref(router.currentRoute.value.path)
  112. const isChildRoute = computed(() => {
  113. return route.matched.length > 1
  114. });
  115. // 一级分类列表
  116. const categoryListTree = ref([]);
  117. // 二级分类列表
  118. const categoryListTree2 = ref([]);
  119. // 活动平台
  120. // 添加分页相关数据
  121. const list = ref([]);
  122. const listTotal = ref(0);
  123. const searchFom = reactive({
  124. categoryId1: categoryId.value,
  125. categoryId2: '',
  126. categoryId3: '',
  127. workflowTitle: '',
  128. pageNum: 1,
  129. pageSize: 20,
  130. orderByColumn: 'publishId',
  131. isAsc: 'desc'
  132. })
  133. onMounted(() => {
  134. searchFom.workflowTitle = query.workflowTitle || '';
  135. getList();
  136. getCategoryListTreeFn();
  137. })
  138. // 查询寻找工作流列表
  139. const getList = async (type) => {
  140. if(type === 'init'){
  141. searchFom.pageNum = 1
  142. }
  143. // 打开loading
  144. const loading = openFullScreenLoading();
  145. const res = await getPublishList(searchFom)
  146. // 关闭loading
  147. loading.close();
  148. if(res.code === 200){
  149. list.value = res.rows || [];
  150. listTotal.value = res.total || 0;
  151. }
  152. }
  153. const handlePageChange = (page, pageSize) => {
  154. searchFom.pageNum = page;
  155. if(pageSize)searchFom.pageSize = pageSize;
  156. // 这里可以添加获取数据的逻辑
  157. console.log('当前页:', page)
  158. getList();
  159. }
  160. const openLoginDialog = inject('openLoginDialog')
  161. const goWorkflowAdd = () => {
  162. //判断是否登录
  163. if(!isLogin({callback: openLoginDialog,t})){
  164. return;
  165. }
  166. //增加参数名称
  167. router.push({
  168. path: `/search-platform/workflow-add`,
  169. query: {
  170. activePlatform: activePlatform.value,
  171. }
  172. })
  173. };
  174. const getCategoryListTreeFn = () => {
  175. getCategoryListTree({categoryId: categoryId.value}).then(res => {
  176. console.log(res)
  177. categoryListTree.value = res.rows || [];
  178. })
  179. };
  180. const getCategoryListTreeFn2 = () => {
  181. getCategoryListTree({categoryId: searchFom.categoryId2}).then(res => {
  182. console.log(res)
  183. categoryListTree2.value = res.rows || [];
  184. })
  185. };
  186. </script>
  187. <style scoped lang="scss">
  188. // 2. 混合器:按钮通用样式
  189. @mixin btn-style() {
  190. padding: 0 16px;
  191. color: #ffffff;
  192. border: none;
  193. border-radius: 10px;
  194. cursor: pointer;
  195. display: flex;
  196. align-items: center;
  197. gap:8px;
  198. font-size: 18px;
  199. &:hover {
  200. opacity: 0.9;
  201. }
  202. }
  203. .search-platform {
  204. .search-platform-top{
  205. padding: 12px 12px 0 12px;
  206. }
  207. // 搜索创建栏嵌套
  208. .search-create-bar {
  209. display: flex;
  210. align-items: center;
  211. gap: 8px;
  212. background-color: rgba(255, 255, 255, 0.5);
  213. border-radius: 10px;
  214. .search-input {
  215. flex: 1;
  216. height: 60px;
  217. padding: 0 12px;
  218. outline: none;
  219. font-size: 18px;
  220. border-radius:7px;
  221. border: none;
  222. width: 100%;
  223. //占位符的颜色
  224. ::placeholder {
  225. color: #999;
  226. }
  227. }
  228. .search-btn {
  229. height: 50px;
  230. @include btn-style();
  231. }
  232. .create-btn {
  233. height: 56px;
  234. @include btn-style();
  235. }
  236. .search-input-container{
  237. position: relative;
  238. border-radius: 8px;
  239. border:2px solid $primary-color;
  240. .search-btn{
  241. position: absolute;
  242. top: 6px;
  243. right: 6px;
  244. }
  245. }
  246. }
  247. .typeList{
  248. padding: 10px 0;
  249. &.typeborder{
  250. border-bottom: 1px dashed #DCDFE6;
  251. }
  252. .typeName{
  253. margin-top: 6px;
  254. min-width: 80px;
  255. white-space: nowrap;
  256. }
  257. .typeItem{
  258. margin: 0 8px;
  259. cursor: pointer;
  260. padding: 4px 8px;
  261. &.active{
  262. background: rgba(45,113,255,0.1);
  263. border-radius: 4px 4px 4px 4px;
  264. color: $primary-color;
  265. font-weight: 600;
  266. }
  267. }
  268. }
  269. }
  270. </style>