方剂搜索

This commit is contained in:
yanwenlong
2023-12-19 22:26:17 +08:00
parent 6e08e1db2d
commit dd655db39d

View File

@@ -6,56 +6,59 @@
<!-- <uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input" <!-- <uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @focus="focus" @input="input"
@cancel="cancel" @clear="clear"> @cancel="cancel" @clear="clear">
</uni-search-bar> --> </uni-search-bar> -->
<view class="search_box" v-if="oneCateList.length > 0">
<!-- <u-search :disabled="userMes.pointPower == 0 && oneCateList[curOneCateIndex].id == 3 || userMes <view class="contentBox">
.pointPower == 0 && oneCateList[curOneCateIndex].id == 6 ? true : false" @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear"
v-model="searchValue" @input="input" @blur="blur" @search="search"></u-search> -->
<u-search @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear"
v-model="searchValue" @input="input" @blur="blur" @search="search"></u-search>
</view>
<view class="searchList" v-show="showSearchList">
<view class="itemBox" v-if="searchList.length > 0">
<view class="item" v-for="(item, index) in searchList" :key="index" @click="gotoDetail(item)">
{{item.title}}
</view>
</view>
<view v-else class="">
<u-divider text="未找到相关方剂哦~"></u-divider>
</view>
</view>
<view v-show="!showSearchList" class="contentBox">
<!-- <scroll-view class="scroll-view_H oneCateList" scroll-x="true" scroll-left="0"> --> <!-- <scroll-view class="scroll-view_H oneCateList" scroll-x="true" scroll-left="0"> -->
<view class="oneCateList flexbox"> <view class="oneCateList flexbox">
<text :class="[curOneCateIndex == index ? 'cur' : '']" @click="setOneCateIndex(item,index)" <text :class="[curOneCateIndex == index ? 'cur' : '']" @click="setOneCateIndex(item,index)"
v-for="(item, index) in oneCateList" :key="item.prescriptCategoryId">{{item.title}}</text> v-for="(item, index) in oneCateList" :key="item.prescriptCategoryId">{{item.title}}</text>
</view> </view>
<view class="search_box" v-if="oneCateList.length > 0">
<!-- <u-search :disabled="userMes.pointPower == 0 && oneCateList[curOneCateIndex].id == 3 || userMes
.pointPower == 0 && oneCateList[curOneCateIndex].id == 6 ? true : false" @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear"
v-model="searchValue" @input="input" @blur="blur" @search="search"></u-search> -->
<u-search @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear"
v-model="searchValue" @input="input" @blur="blur" @search="search" @custom="search"></u-search>
</view>
<view class="searchList" v-show="showSearchList">
<view class="itemBox" v-if="searchList.length > 0">
<view class="item" v-for="(item, index) in searchList" :key="index" @click="gotoDetail(item)">
{{item.title}}
</view>
</view>
<view v-else class="">
<u-divider text="未找到相关方剂哦~"></u-divider>
</view>
</view>
<!-- </scroll-view> --> <!-- </scroll-view> -->
<view class="grid twoCateList" v-if="twoCateList.length > 0"> <view v-show="!showSearchList">
<u-grid :col="3" border class="u-grid-list"> <view class="grid twoCateList" v-if="twoCateList.length > 0">
<u-grid-item v-for="(item, index) in twoCateList" :key="item.prescriptCategoryId" <u-grid :col="3" border class="u-grid-list">
@click="setTwoCateIndex(item, index)"> <u-grid-item v-for="(item, index) in twoCateList" :key="item.prescriptCategoryId"
<view :class="['grid-text',curTwoCateIndex == index ? 'cur' : '']">{{item.title}}</view> @click="setTwoCateIndex(item, index)">
</u-grid-item> <view :class="['grid-text',curTwoCateIndex == index ? 'cur' : '']">{{item.title}}</view>
</u-grid>
</view>
<view class="titleList" v-if="oneCateList[curOneCateIndex].prescriptCategoryId != 3">
<u-grid :col="3" v-if="titleList.length > 0">
<u-grid-item v-for="(item, index) in titleList" :key="item.prescriptId" @click="gotoDetail(item)">
<view :class="['titleItem']">{{item.title}}</view>
</u-grid-item>
</u-grid>
<u-divider v-else text="暂无方剂数据哦~"></u-divider>
</view>
<view class="titleList" v-else>
<u-grid :col="1" v-if="titleList">
<u-grid-item v-for="(item, index) in titleList" :key="index">
<view :class="['titleItem']">{{index}}</view>
<u-grid-item v-for="(item1, index1) in item" :key="item1.prescriptId" >
<view :class="['JFtitleItem']" @click="gotoDetail(item1)">{{item1.title}}</view>
</u-grid-item> </u-grid-item>
</u-grid-item> </u-grid>
</u-grid> </view>
<u-divider v-else text="暂无方剂数据哦~"></u-divider> <view class="titleList" v-if="oneCateList[curOneCateIndex].prescriptCategoryId != 3">
<u-grid :col="3" v-if="titleList.length > 0">
<u-grid-item v-for="(item, index) in titleList" :key="item.prescriptId" @click="gotoDetail(item)">
<view :class="['titleItem']">{{item.title}}</view>
</u-grid-item>
</u-grid>
<u-divider v-else text="暂无方剂数据哦~"></u-divider>
</view>
<view class="titleList" v-else>
<u-grid :col="1" v-if="titleList">
<u-grid-item v-for="(item, index) in titleList" :key="index">
<view :class="['titleItem']">{{index}}</view>
<u-grid-item v-for="(item1, index1) in item" :key="item1.prescriptId" >
<view :class="['JFtitleItem']" @click="gotoDetail(item1)">{{item1.title}}</view>
</u-grid-item>
</u-grid-item>
</u-grid>
<u-divider v-else text="暂无方剂数据哦~"></u-divider>
</view>
</view> </view>
</view> </view>
@@ -212,6 +215,9 @@
let id = item.prescriptCategoryId let id = item.prescriptCategoryId
this.curOneCateIndex = index this.curOneCateIndex = index
this.curTwoCateIndex = 0 this.curTwoCateIndex = 0
this.searchValue = ''
this.searchList = []
this.showSearchList = false
if(index!=2){ if(index!=2){
this.getTowCateList(id) this.getTowCateList(id)
} else { } else {
@@ -313,19 +319,23 @@
}, },
getSearch() { getSearch() {
$http.request({ $http.request({
url: "book/point/searchPointList", url: "book/prescript/searchPrescript",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档 method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: { data: {
loadAnimate: 'none', // 请求加载动画 loadAnimate: 'none', // 请求加载动画
'keywords': this.searchValue 'keywords': this.searchValue,
type: this.curOneCateIndex + 1
}, },
header: { //默认 无 说明:请求头 header: { //默认 无 说明:请求头
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
}).then(res => { }).then(res => {
console.log(res, '搜索结果') console.log(res, '搜索结果')
if (res.code == 0 && res.points.length > 0) { if (res.code == 0 && res.list.length >= 0) {
this.searchList = res.points this.showSearchList = true
this.searchList = res.list
}else{
this.searchList = []
} }
}).catch(e => { }).catch(e => {
// this.titleList = [] // this.titleList = []
@@ -339,6 +349,12 @@
// title: '搜索:' + res, // title: '搜索:' + res,
// icon: 'none' // icon: 'none'
// }) // })
if (res == '') {
this.showSearchList = false
this.searchList = []
} else {
this.getSearch()
}
}, },
input(res) { input(res) {
@@ -350,6 +366,7 @@
} }
}, },
clear(res) { clear(res) {
console.log('----clear:', res)
// uni.showToast({ // uni.showToast({
// title: 'clear事件清除值为', // title: 'clear事件清除值为',
// icon: 'none' // icon: 'none'
@@ -358,20 +375,22 @@
this.showSearchList = false this.showSearchList = false
}, },
blur(res) { blur(res) {
if (res == '') { // console.log('----blur:', res)
this.showSearchList = false // if (res == '') {
this.searchList = [] // this.showSearchList = false
} else { // this.searchList = []
this.getSearch() // } else {
} // this.getSearch()
// }
}, },
focus(e) { focus(e) {
console.log('----focus:')
// uni.showToast({ // uni.showToast({
// title: 'focus事件输出值为' + e.value, // title: 'focus事件输出值为' + e.value,
// icon: 'none' // icon: 'none'
// }) // })
// 等于1 就是有权限 // 等于1 就是有权限
this.showSearchList = true // this.showSearchList = true
}, },
// cancel(res) { // cancel(res) {
@@ -471,11 +490,10 @@
.search_box { .search_box {
margin: 0 auto; margin: 0 auto;
overflow: hidden; overflow: hidden;
margin-top: 20rpx;
align-items: center; align-items: center;
width: calc(100% - 10px); width: calc(100% - 10px);
margin-top: 0; margin-top: 20rpx;
margin-bottom: 40rpx; margin-bottom: 20rpx;
.search { .search {
height: 56upx; height: 56upx;