Pārlūkot izejas kodu

feat:新增小程序知识库

lsw 9 mēneši atpakaļ
vecāks
revīzija
6b2ac3b6c0

+ 1 - 1
admin-ui/src/views/work/knowledge/edit.vue

@@ -37,7 +37,7 @@ export default {
   dicts: ['knowledge_type'],
   data() {
     return {
-      form: {},
+      form: { state: 0 },
       rules: {
         title: [{ required: true, message: '不能为空', trigger: 'blur' }],
         type: [{ required: true, message: '不能为空', trigger: 'blur' }],

+ 2 - 2
admin-ui/src/views/work/knowledge/index.vue

@@ -25,8 +25,8 @@
 
     <el-table :data="response.rows" border @selection-change="selects" height="calc(100vh - 270px)">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="标题" align="left" prop="title" />
-      <el-table-column label="分类" align="center" prop="type" width="140" />
+      <el-table-column label="标题名称" align="left" prop="title" />
+      <el-table-column label="知识分类" align="center" prop="type" width="140" />
       <el-table-column label="状态" align="center" prop="state" width="140">
         <template slot-scope="scope">
           <el-tag type="success" v-if="scope.row.state == 0">启用</el-tag>

+ 20 - 0
app/common/common.scss

@@ -59,6 +59,9 @@
 	padding: 5px;
 	margin-top: 15px;
 }
+.search {
+	padding: 5px 15px 5px 15px;
+}
 .msilde {
 	.top {
 		padding: 10px;
@@ -94,6 +97,23 @@
 		background-color: white;
 		.list {
 			padding: 10px 10px 85px 10px;
+			.item {
+				padding: 15px 5px 15px 0px;
+				overflow: hidden;
+				border-bottom: 1px solid $line;
+				&:first-child {
+					padding-top: 0px;
+				}
+				.con {
+					.labels {
+						float: left;
+						font-size: 14px;
+						color: $font-c;
+						padding-top: 5px;
+						padding-right: 15px;
+					}
+				}
+			}
 		}
 	}
 }

+ 2 - 2
app/common/http.js

@@ -1,6 +1,6 @@
-const ip = 'http://127.0.0.1:9191';
+//const ip = 'http://127.0.0.1:9191';
 //const ip = 'https://chenglantimes.com/prod-api';
-//const ip = 'http://192.168.1.21:9191';
+const ip = 'http://192.168.1.19:9191';
 /**
  * 封装的http请求
  */

+ 14 - 10
app/pages.json

@@ -18,24 +18,28 @@
 			}
 		},
 		{
-			"path" : "pages/knowledge/index",
-			"style" : 
-			{
-				"navigationBarTitleText" : "健康知识库"
+			"path": "pages/knowledge/index",
+			"style": {
+				"navigationBarTitleText": "健康知识库"
 			}
 		},
 		{
-			"path" : "pages/knowledge/detail",
-			"style" : 
-			{
-				"navigationBarTitleText" : "知识详情"
+			"path": "pages/knowledge/detail",
+			"style": {
+				"navigationBarTitleText": "知识详情"
+			}
+		},
+		{
+			"path": "pages/introduction/index",
+			"style": {
+				"navigationBarTitleText": "医院介绍"
 			}
 		},
 		{
-			"path" : "pages/introduction/index",
+			"path" : "pages/doctor/index",
 			"style" : 
 			{
-				"navigationBarTitleText" : "医介绍"
+				"navigationBarTitleText" : "医介绍"
 			}
 		}
 	],

+ 19 - 0
app/pages/doctor/index.vue

@@ -0,0 +1,19 @@
+<template>
+	<view>
+		
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			};
+		}
+	}
+</script>
+
+<style lang="scss">
+
+</style>

+ 4 - 4
app/pages/knowledge/detail.vue

@@ -11,7 +11,7 @@
 			</view>
 			<view class="con">
 				<u-divider :dot="true"></u-divider>
-				<u-parse :content="item.contents"></u-parse>
+				<u-parse :content="item.content"></u-parse>
 			</view>
 		</view>
 	</view>
@@ -26,10 +26,10 @@ export default {
 	},
 	onLoad(e) {
 		this.http.request({
-			url: '/app/news/detail/' + e.id,
+			url: '/app/knowledge/detail/' + e.id,
 			success: (res) => {
 				this.item = res.data.data;
-				this.item.contents = res.data.data.contents.replace(new RegExp('/profile/upload/', 'g'), this.http.ip + '/profile/upload/');
+				this.item.content = res.data.data.content.replace(new RegExp('/profile/upload/', 'g'), this.http.ip + '/profile/upload/');
 			}
 		});
 	},
@@ -38,7 +38,7 @@ export default {
 	onShareAppMessage: function (res) {
 		return {
 			title: this.item.title,
-			path: '/pages/news/detail?id=' + this.item.id,
+			path: '/pages/knowledge/detail?id=' + this.item.id,
 			success: (res) => {},
 			fail: (res) => {}
 		};

+ 54 - 20
app/pages/knowledge/index.vue

@@ -1,19 +1,20 @@
 <template>
-	<view class="msilde">
-		<view class="top">
-			<u-search placeholder="搜索标题" bgColor="white" :showAction="false"></u-search>
+	<view>
+		<view class="search">
+			<u-search placeholder="搜索标题" v-model="param.title" bgColor="white" :showAction="false" @search="(current = 0), (param.type = ''), refresh()" @clear="(current = 0), (param.type = ''), (param.title = ''), refresh()"></u-search>
 		</view>
-		<view class="left">
-			<view class="item" :class="{ active: index == current }" v-for="(item, index) in type_list" :key="index" @click="selected(item, index)">{{ item.dictLabel }}</view>
+		<view class="tab">
+			<u-tabs :list="tab" :current="current" keyName="dictLabel" @click="click"></u-tabs>
 		</view>
-		<view class="right">
-			<view class="list">
-				<view class="u_item" v-for="(item, index) in list" :key="index" @click="go('/pages/knowledge/detail?id=' + item.id)">
-					<view class="con">
-						<view class="name">{{ item.name }}</view>
-						<view class="labels omit">{{ item.labels }}</view>
-						<view class="labels">{{ item.columnName }}</view>
-					</view>
+		<view class="list">
+			<view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/knowledge/detail?id=' + item.id)">
+				<view class="title omit">
+					<text class="icon" v-if="item.top === 1">&#xe61f;</text>
+					<text>{{ item.title }}</text>
+				</view>
+				<view class="desc">
+					<text>{{ item.type }}</text>
+					<text>发布于 {{ item.createTime }}</text>
 				</view>
 			</view>
 			<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
@@ -26,7 +27,7 @@
 export default {
 	data() {
 		return {
-			type_list: [],
+			tab: [],
 			current: 0,
 			list: [],
 			param: { pageNum: 1, pageSize: 10 },
@@ -38,6 +39,11 @@ export default {
 		this.getData();
 	},
 	methods: {
+		click(e) {
+			this.current = e.index;
+			this.param.type = e.dictValue;
+			this.refresh();
+		},
 		getData() {
 			this.http.request({
 				url: '/app/knowledge/list',
@@ -55,21 +61,22 @@ export default {
 		getType() {
 			this.http.request({
 				url: '/app/common/type/knowledge_type',
+				loading: 'false',
 				success: (res) => {
-					this.type_list = res.data.data;
-					this.type_list.unshift({ dictLabel: '全部类型', dictValue: '' });
+					this.tab = res.data.data;
+					this.tab.unshift({ dictLabel: '全部类型', dictValue: '' });
 				}
 			});
 		},
+		go(url) {
+			uni.navigateTo({ url: url });
+		},
 		//刷新数据
 		refresh() {
 			this.loadMore = true;
 			this.param.pageNum = 1;
 			this.list = [];
 			this.getData();
-		},
-		go(url) {
-			uni.navigateTo({ url: url });
 		}
 	},
 	//下拉刷新
@@ -89,4 +96,31 @@ export default {
 };
 </script>
 
-<style lang="scss"></style>
+<style lang="scss">
+.list {
+	padding: 10px 12px;
+	.item {
+		border-radius: 5px;
+		padding: 13px 12px 13px 12px;
+		margin-bottom: 10px;
+		overflow: hidden;
+		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+		background-color: white;
+		.title {
+			font-size: 15px;
+			font-weight: bold;
+			.icon {
+				color: orangered;
+				padding-right: 3px;
+			}
+		}
+		.desc {
+			font-size: 14px;
+			padding-top: 10px;
+			text {
+				padding-right: 30px;
+			}
+		}
+	}
+}
+</style>

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_KnowledgeController.java

@@ -34,7 +34,7 @@ public class Api_KnowledgeController extends BaseController {
 
     @GetMapping(value = "/detail/{id}")
     public AjaxResult detail(@PathVariable("id") Long id) {
-        return AjaxResult.success(knowledgeService.getById(id));
+        return knowledgeService.detail(id);
     }
 
 }

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/config/InterceptorConfig.java

@@ -22,6 +22,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
         registration.addPathPatterns("/app/**");
         registration.excludePathPatterns("/app/user/login"); //排除
         registration.excludePathPatterns("/app/home/**"); //排除
+        registration.excludePathPatterns("/app/knowledge/**"); //排除
         registration.excludePathPatterns("/app/common/type/*"); //排除
         registration.excludePathPatterns("/app/common/introduction/*"); //排除
     }

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/base/BaseData.java

@@ -32,6 +32,7 @@ public class BaseData {
     private String dateEnd;
 
     @TableField(exist = false)
+    @JsonIgnore
     private Map<String, Object> params;
 
     public Map<String, Object> getParams() {

+ 13 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IKnowledgeService.java

@@ -1,13 +1,23 @@
 package com.ruoyi.web.work.service;
 
-import java.util.List;
-import com.ruoyi.web.work.domain.Knowledge;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.web.work.domain.Knowledge;
+
+import java.util.List;
 
 /**
  * @author lsw
  * @date 2024-07-10
  */
-public interface IKnowledgeService extends IService<Knowledge>{
+public interface IKnowledgeService extends IService<Knowledge> {
     List<Knowledge> selectList(Knowledge knowledge);
+
+    /**
+     * 知识详情
+     *
+     * @param id
+     * @return
+     */
+    AjaxResult detail(Long id);
 }

+ 17 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/KnowledgeServiceImpl.java

@@ -1,12 +1,14 @@
 package com.ruoyi.web.work.service.impl;
 
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.ruoyi.web.work.mapper.KnowledgeMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.web.work.domain.Knowledge;
+import com.ruoyi.web.work.mapper.KnowledgeMapper;
 import com.ruoyi.web.work.service.IKnowledgeService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * @author lsw
@@ -19,6 +21,16 @@ public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper, Knowledge
 
     @Override
     public List<Knowledge> selectList(Knowledge knowledge) {
+        knowledge.setState(0);
         return knowledgeMapper.selectList(knowledge);
     }
+
+    @Override
+    public AjaxResult detail(Long id) {
+        Knowledge knowledge = getById(id);
+        if (knowledge == null || knowledge.getState() != 0) {
+            return AjaxResult.error("知识不存在或被下架");
+        }
+        return AjaxResult.success(knowledge);
+    }
 }