优化用户、动物搜索功能,实现模糊搜索
This commit is contained in:
parent
4d493f1f2e
commit
53af23e703
70
README.md
70
README.md
@ -28,6 +28,8 @@
|
||||
|
||||
# 需要后端提供的数据
|
||||
|
||||
一切以最终实现的接口为准,你需要前端提供什么数据就什么数据
|
||||
|
||||
## 登录功能
|
||||
|
||||
前端提供参数
|
||||
@ -50,76 +52,40 @@
|
||||
|
||||
### 用户查询
|
||||
|
||||
打开界面直接显示数据、需要管理员权限
|
||||
前端提供一个用户对象数据,后端通过一整个对象进行查询,比如用户id、用户身份是什么(用可变sql这种办法实现就行)
|
||||
|
||||
前端提供的数据,用户名
|
||||
```json
|
||||
{
|
||||
"username": "user1"
|
||||
}
|
||||
```
|
||||
后端根据用户名查询用户是否有权限访问再返回数据
|
||||
后端返回数据
|
||||
|
||||
若成功,返回所有用户的结果集(节省时间不搞分页了)
|
||||
|
||||
### 用户添加
|
||||
|
||||
需要管理员权限
|
||||
|
||||
前端提供的数据
|
||||
|
||||
```json
|
||||
{
|
||||
"user":{
|
||||
"username": "user2",
|
||||
"password": "123456",
|
||||
"auth": "1",
|
||||
"other": "更多需要提供的数据请写在接口文档里"
|
||||
}
|
||||
}
|
||||
```
|
||||
前端提供的数据一个用户对象
|
||||
|
||||
后端返回状态码,哪个码表示什么意思记得写一下
|
||||
|
||||
### 用户删除
|
||||
|
||||
前端提供的数据,用户名
|
||||
```json
|
||||
{
|
||||
"username": "user1"
|
||||
}
|
||||
```
|
||||
前端提供的数据要删除的用户唯一标识(看后端需要什么,前端就传什么)
|
||||
|
||||
后端删除对应的用户返回结果
|
||||
|
||||
### 用户编辑
|
||||
前端提供的数据,用户名
|
||||
```json
|
||||
{
|
||||
"user":{
|
||||
"username": "user2",
|
||||
"password": "123456",
|
||||
"auth": "1",
|
||||
"other": "更多需要提供的数据请写在接口文档里"
|
||||
}
|
||||
}
|
||||
```
|
||||
前端提供的数据:一个用户对象
|
||||
|
||||
后端修改对应的用户返回结果
|
||||
|
||||
## 动物信息管理功能
|
||||
|
||||
### 动物查询
|
||||
|
||||
打开界面直接显示数据
|
||||
|
||||
前端提供的数据,一个动物对象(先不搞那种体重身高范围的查询),都为空就是查询全部
|
||||
|
||||
若成功,返回所有动物的结果集(节省时间不搞分页了)
|
||||
|
||||
### 动物添加
|
||||
|
||||
需要管理员权限
|
||||
|
||||
前端提供用户名(只有管理员才能添加删除修改,其他人只能查询)、一个动物对象
|
||||
前端提供数据:一个动物对象
|
||||
|
||||
后端返回操作结果
|
||||
|
||||
@ -131,12 +97,22 @@
|
||||
|
||||
### 动物编辑
|
||||
|
||||
需要管理员权限
|
||||
|
||||
前端提供用户名、一个动物对象
|
||||
前端提供数据:一个动物对象
|
||||
|
||||
后端修改对应的动物返回结果
|
||||
|
||||
## 饲养管理
|
||||
|
||||
|
||||
|
||||
|
||||
## 档案管理
|
||||
|
||||
## 健康检测
|
||||
|
||||
## 统计分析
|
||||
|
||||
|
||||
# 开发进度
|
||||
|
||||
## 登录界面
|
||||
|
@ -88,7 +88,6 @@ export default {
|
||||
</el-form-item>
|
||||
<el-form-item label="动物颜色">
|
||||
<el-color-picker v-model="form.color" />
|
||||
<!-- <el-input v-model="form.color" placeholder="动物颜色"/>-->
|
||||
</el-form-item>
|
||||
<el-form-item label="动物特征">
|
||||
<el-input v-model="form.features" placeholder="动物特征"/>
|
||||
|
@ -145,17 +145,16 @@ export default {
|
||||
|
||||
},
|
||||
searchAnimal() {
|
||||
console.log('动物搜索',this.searchInput)
|
||||
console.log('动物搜索', this.searchInput)
|
||||
let searchResult = []//搜索结果数组
|
||||
//第一步匹配搜索选项,如果选择了特定用户身份
|
||||
if (typeof this.searchInput.state ==='number') {
|
||||
this.animals.forEach(e=>{
|
||||
if (typeof this.searchInput.state === 'number') {
|
||||
this.animals.forEach(e => {
|
||||
if (e.state === this.searchInput.state) {
|
||||
searchResult.push(copy(e))//如果符合特定权限,则添加到搜索结果
|
||||
}
|
||||
})
|
||||
}
|
||||
else { //如果没有选择特定用户身份,代表所有数据都需要参加到下一轮的模糊搜索
|
||||
} else { //如果没有选择特定用户身份,代表所有数据都需要参加到下一轮的模糊搜索
|
||||
searchResult = copy(this.animals)
|
||||
}
|
||||
|
||||
@ -163,10 +162,10 @@ export default {
|
||||
let keyset = splitKeyWords(this.searchInput.keyword)//切割关键字
|
||||
|
||||
//第二步进行模糊搜索
|
||||
searchResult.forEach(e=>{
|
||||
searchResult.forEach(e => {
|
||||
//如果该对象能匹配上所有关键字,则添加到结果
|
||||
// console.log('开始进行模糊匹配,对象、关键字集合分别为',e,keyset)
|
||||
let is = fuzzyMatching(e,keyset);
|
||||
let is = fuzzyMatching(e, keyset);
|
||||
if (is) {
|
||||
searchResult2.push(e)
|
||||
}
|
||||
@ -243,7 +242,12 @@ export default {
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="roleId" label="饲养员ID" width="120"/>
|
||||
<el-table-column prop="color" label="动物颜色" width="90"/>
|
||||
<el-table-column prop="color" label="动物颜色" width="150">
|
||||
<template #default="scope">
|
||||
{{ scope.row.color }}
|
||||
<el-color-picker v-model="scope.row.color" disabled/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="features" label="动物特征" width="100"/>
|
||||
<el-table-column prop="habit" label="生活习性" width="100"/>
|
||||
<el-table-column fixed="right" label="操作" width="130">
|
||||
|
@ -55,6 +55,11 @@ export default {
|
||||
|
||||
<template>
|
||||
<div id="login-root">
|
||||
<el-carousel height="400px" motion-blur>
|
||||
<el-carousel-item v-for="item in 4" :key="item">
|
||||
<h3 class="small justify-center" text="2xl">{{ item }}</h3>
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
<div class="center">
|
||||
<el-card style="width: 480px" shadow="always" header="登录">
|
||||
<el-form :model="user" label-width="auto" style="max-width: 600px">
|
||||
|
@ -25,23 +25,6 @@ export default {
|
||||
|
||||
// endregion
|
||||
|
||||
// passwordInvisible() {
|
||||
// return '••••••••'
|
||||
// },
|
||||
// dataFilters() {
|
||||
// // 计算格式化后的数组
|
||||
// let data = copy(this.tableData)
|
||||
// data.forEach(e => {
|
||||
// if (e.auth === 0) {
|
||||
// e.auth = '管理员'
|
||||
// } else if (e.auth === 1) {
|
||||
// e.auth = '饲养员'
|
||||
// } else if (e.auth === 2) {
|
||||
// e.auth = '兽医'
|
||||
// }
|
||||
// })
|
||||
// return data
|
||||
// }
|
||||
},
|
||||
watch: {
|
||||
searchInput: {
|
||||
|
Loading…
Reference in New Issue
Block a user