SearchPlatform.vue 7.3 KB

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