Browse Source

课程修改

wangxy 1 month ago
parent
commit
87456f900b
2 changed files with 107 additions and 24 deletions
  1. 12 0
      api/kecheng.js
  2. 95 24
      pages/admin/Kecheng/list.vue

+ 12 - 0
api/kecheng.js

@@ -108,4 +108,16 @@ export function getClientKechengSave(data = {}) {
     data,
     timeout: 20000
   })
+}
+
+export function getAdminClassify(data = {}) {
+  return request({
+    url: '/app/kecheng/guanliyuan/classify',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
 }

+ 95 - 24
pages/admin/Kecheng/list.vue

@@ -3,41 +3,59 @@
 		<view class="icon-title-navBar-box">
 			<view @click="goUpPage" class="nav-bar-icon"></view>
 			<text class="nav-bar-title">课程管理</text>
+			<uni-icons class="nav-bar-right-icon" type="search" size="22" color="#666" @click="searchBtn"></uni-icons>
+		</view>
+		<!-- 查询职业 -->
+		<view class="phone-search-box">
+			<view @click.stop="clickAlltype" class="select-item-box">
+				<text>{{data.leixing}}</text>
+				<icon class="select-jt-default" />
+			</view>
+		<!-- 	<input class="search-input" placeholder="请输入课程名称" v-model="data.name" />
+			<view class="search-icon" @click="handleSearch">
+				<uni-icons type="search" size="24" color="#fff"></uni-icons>
+			</view> -->
 		</view>
 		<!-- 课程列表 -->
-			<scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
-				:refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
-				class="admin-phone-scroll-view">
-				<uni-list class="admin-list-box">
-					<uni-list-item v-for="item in data.list" class="admin-list-item-box">
-						<template v-slot:body>
-							<view class="kecheng-list-card">
-								<img :src="item.pic">
-								<view class="item-card-row">
-									<!-- 数量 -->
-									<view class="ks-item-top">
-										<view class="kc-name">{{item.name}}</view>
-									</view>
-									<view class="ks-totalTm kc-totalTm">
-										<icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
-									</view>
-									<button @click="checkKecheng(item)" type="primary" size="mini"  class="item-view-btn">查看内容</button>
+		<scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
+			:refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
+			class="admin-phone-scroll-view">
+			<uni-list class="admin-list-box">
+				<uni-list-item v-for="item in data.list" class="admin-list-item-box">
+					<template v-slot:body>
+						<view class="kecheng-list-card">
+							<img :src="item.pic">
+							<view class="item-card-row">
+								<!-- 数量 -->
+								<view class="ks-item-top">
+									<view class="kc-name">{{item.name}}</view>
+								</view>
+								<view class="ks-totalTm kc-totalTm">
+									<icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
 								</view>
+								<button @click="checkKecheng(item)" type="primary" size="mini"
+									class="item-view-btn">查看内容</button>
 							</view>
-						</template>
-					</uni-list-item>
-					<uni-load-more :status="data.state" @click="getMore(0)"
-						:contentText="data.contentText"></uni-load-more>
-				</uni-list>
-			</scroll-view>
+						</view>
+					</template>
+				</uni-list-item>
+				<uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
+			</uni-list>
+		</scroll-view>
 
 		<!-- 页面底端 -->
 		<customTabbarAdminVue :current-tab="2"></customTabbarAdminVue>
+		
+		<searchVue ref="searchRef" @search-btn="handleSearchFromBtn"></searchVue>
+		
+		<kechengLeixingVue ref="kclxRef" @select="handleSelectLeixing" @reset="handleResetLeixing"></kechengLeixingVue>
 	</view>
 </template>
 
 <script setup>
 	import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
+	import kechengLeixingVue from "@/pages/admin/Kecheng/components/kechengLeixing.vue";
+	import searchVue from "./components/search.vue";
 	import {
 		ref,
 		reactive
@@ -46,9 +64,19 @@
 		onLoad
 	} from "@dcloudio/uni-app";
 	import * as kechengApi from "@/api/kecheng.js"
-	import {formatDuration} from "@/utils/common.js"
+	import {
+		formatDuration
+	} from "@/utils/common.js"
+	
+	const kclxRef = ref(null)
+	
+	const selectClassify = ref(null)
+	const searchRef = ref(null)
 
 	const data = reactive({
+		leixing: '全部类型',
+		leixingList: [],
+		name: '',
 		list: [], // 考试列表
 		loading: false,
 		page: 0,
@@ -60,6 +88,33 @@
 			contentnomore: '没有更多'
 		}
 	})
+	
+	function searchBtn() {
+		searchRef.value.handleShow()
+	}
+	
+	function handleSearchFromBtn(textD) {
+		data.name = textD;
+		handleSearch()
+	}
+	
+	function handleSelectLeixing(item) {
+		data.leixing = item.lable;
+		selectClassify.value = item;
+		handleSearch();
+	}
+	
+	function handleResetLeixing() {
+		selectClassify.value = null;
+		data.leixing = '全部类型';
+		handleSearch();
+	}
+
+	function clickAlltype() {
+		kclxRef.value.showPopup({
+			data: data.leixingList 
+		})
+	}
 
 	function goUpPage() {
 		uni.redirectTo({
@@ -89,6 +144,8 @@
 		const opt = {
 			page: 1,
 			size: 10, // 固定查询10条
+			name: data.name,
+			kcClassifyId: selectClassify.value && selectClassify.value.id || null,
 		}
 		data.list = [];
 		// 数学
@@ -117,6 +174,8 @@
 		const opt = {
 			page: 1,
 			size: 10, // 固定查询10条
+			name: data.name,
+			kcClassifyId: selectClassify.value && selectClassify.value.id || null,
 		}
 		if (data.state == 'no-more') return;
 		data.state = 'loading';
@@ -139,8 +198,20 @@
 		})
 	}
 
+	function getKechengClassify() {
+		kechengApi.getAdminClassify().then(res => {
+			
+			res.data.children.forEach(item => {
+				item.checked = false;
+			})
+			
+			data.leixingList = res.data.children || [];
+		})
+	}
+
 	onLoad(() => {
 		getMore()
+		getKechengClassify();
 	})
 </script>