方剂搜索

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