方剂搜索

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

View File

@@ -6,12 +6,19 @@
<!-- <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="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"> <view class="search_box" v-if="oneCateList.length > 0">
<!-- <u-search :disabled="userMes.pointPower == 0 && oneCateList[curOneCateIndex].id == 3 || userMes <!-- <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" .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> --> v-model="searchValue" @input="input" @blur="blur" @search="search"></u-search> -->
<u-search @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear" <u-search @click="checkDisable" placeholder="请输入方剂名" @focus="focus" @clear="clear"
v-model="searchValue" @input="input" @blur="blur" @search="search"></u-search> v-model="searchValue" @input="input" @blur="blur" @search="search" @custom="search"></u-search>
</view> </view>
<view class="searchList" v-show="showSearchList"> <view class="searchList" v-show="showSearchList">
<view class="itemBox" v-if="searchList.length > 0"> <view class="itemBox" v-if="searchList.length > 0">
@@ -23,13 +30,8 @@
<u-divider text="未找到相关方剂哦~"></u-divider> <u-divider text="未找到相关方剂哦~"></u-divider>
</view> </view>
</view> </view>
<view v-show="!showSearchList" 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>
<!-- </scroll-view> --> <!-- </scroll-view> -->
<view v-show="!showSearchList">
<view class="grid twoCateList" v-if="twoCateList.length > 0"> <view class="grid twoCateList" v-if="twoCateList.length > 0">
<u-grid :col="3" border class="u-grid-list"> <u-grid :col="3" border class="u-grid-list">
<u-grid-item v-for="(item, index) in twoCateList" :key="item.prescriptCategoryId" <u-grid-item v-for="(item, index) in twoCateList" :key="item.prescriptCategoryId"
@@ -58,6 +60,7 @@
<u-divider v-else text="暂无方剂数据哦~"></u-divider> <u-divider v-else text="暂无方剂数据哦~"></u-divider>
</view> </view>
</view> </view>
</view>
<!-- <view class="search_box flexbox" @click=""> <!-- <view class="search_box flexbox" @click="">
@@ -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;