Commit 2113b1d7 by zhuxiaomei

字段搜索查询优化

parent cdefca66
......@@ -46,7 +46,8 @@
},
"globals": {
"BMap": true,
"plus": true
"plus": true,
"mui": true
},
"rules": {}
},
......
......@@ -8,6 +8,7 @@ document.addEventListener('touchstart',function(){
document.addEventListener('plusready', function() {
var webview = plus.webview.currentWebview().setStyle({scrollIndicator:'none'});
plus.key.addEventListener('backbutton', function() {
console.log(webview.canBack,'webview.canBack')
webview.canBack(function(e) {
if(e.canBack) {
webview.back();
......
/**
* 双随机抽样货架表相关
*/
import http from '../../api/http'
export default {
getTested: data => http.post('/drs/v1/net_tested/get_tested_by_name',data).then(res => res),
}
/**
* 双随机抽样货架表相关
*/
import http from '../../api/http'
export default {
getTested: data => http.post('/drs/v1/non_net_tested/get_tested_by_name',data).then(res => res),
}
/**
* 双随机抽样货架表相关
*/
import http from '../../api/http'
export default {
scanSample: data => http.post('/drs/v1/sampling_sample/scan_sample', data).then(res => res),
}
......@@ -11,4 +11,6 @@ export default {
deleteByIds: ids => http.delete('/drs/v1/sampling_summary/?ids=' + ids).then(res => res),
getById: id => http.get('/drs/v1/sampling_summary/' + id).then(res => res),
lastTester: () => http.post('/drs/v1/sampling_summary/last_tester').then(res => res),
getTester: data => http.post('/drs/v1/sampling_summary/get_tester_by_name',data).then(res => res),
getProducter: data => http.post('/drs/v1/sampling_summary/get_producter_by_name',data).then(res => res),
}
/**
* 相关食品类别
*/
import http from '../../api/http'
export default {
// 默认大类-pid为0 根据类别pid获取下拉数据
categoryList:data=>http.post('/food/v1/classify_info/list_by_name', data).then(res=>res),
}
......@@ -24,6 +24,10 @@ export {default as advise} from './base/advise'
*/
export {default as message} from './message/message'
/**
* food
*/
export {default as foodClassifyInfo} from './food/food-classify-info'
/**
* drs
*/
export {default as samplingPlan} from './drs/sampling-plan'
......@@ -32,3 +36,6 @@ export {default as samplingShelf} from './drs/sampling-shelf'
export {default as samplingSummary} from './drs/sampling-summary'
export {default as samplingSummaryAttachment} from './drs/sampling-summary-attachment'
export {default as attendanceRecord} from './drs/attendance_record'
export {default as samplingSample} from './drs/sampling-sample'
export {default as netTested} from './drs/net-tested'
export {default as nonNetTested} from './drs/non-net-tested'
<template>
<!--https://youzan.github.io/vant/#/zh-CN/search-->
<div class="search-bar-box">
<div class="search-bar-box-fixed-top" :class="{'search-bar-box':fixed===false}">
<van-search
v-model="searchValue"
show-action
......@@ -31,7 +31,8 @@
props: {
label: String,
//是否展示高级查询按钮
highSearch: {type: Boolean, default: false}
highSearch: {type: Boolean, default: false},
fixed: {type: Boolean, default: true}
},
data() {
return {
......@@ -40,6 +41,21 @@
labelText: this.label ? this.label : '关键字'
}
},
watch: {
showHighSearch: function (val) {
let that = this
mui.init({
beforeback: function () {
if (val) {
that._hideHighSearch()
return false;
} else {
return true
}
}
});
}
},
methods: {
onSearch() {
this.$emit('search', this.searchValue)
......@@ -48,7 +64,7 @@
this.searchValue = ''
this.$emit('high-search')
},
_hideHighSearch(){
_hideHighSearch() {
this.showHighSearch = false
},
onReset() {
......
<template>
<van-popup v-model="showScan"
:safe-area-inset-bottom="true"
:close-on-popstate="true" :style="{ height: '100%',width:'100%' }">
<van-nav-bar title="扫码"
left-arrow
@click-left="_cancelScan"></van-nav-bar>
<div id="bcid">
<div style="height:40%"></div>
</div>
<div class="bottom-btn">
<van-button block type="default" @click="_cancelScan">取消</van-button>
</div>
</van-popup>
</template>
<style scoped>
#bcid {
width: 100%;
height: calc(100% - 44px - 46px);
text-align: center;
}
</style>
<script>
import {samplingSample} from '../../../api'
var barcode = null;//扫码对象
export default {
data() {
return {
num: '',
showScan: false
}
},
watch: {
showScan: function (val) {
let that = this
//返回键操作
mui.init({
beforeback: function () {
if (val) {
barcode.close();
that.showScan = false
return false;
} else {
return that
}
}
});
}
},
methods: {
_open() {
this.showScan = true
this.$nextTick(function () {
barcode = null;
let that = this;
if (!barcode) {
barcode = new plus.barcode.Barcode('bcid', [plus.barcode.CODE128], {
frameColor: '#00FF00',
scanbarColor: '#00FF00'
});
barcode.onmarked = function (type, result) {
if (type === plus.barcode.CODE128) {
that._getSample(result)
}
};
plus.webview.currentWebview().append(barcode);
}
barcode.start();
})
},
_getSample: async function (data) {
console.log(data, 'data')
let res = await samplingSample.scanSample({num: data})
if (res) {
this.$emit('on-result-change', res)
barcode.close();
this.showScan = false
} else {
this.$toast('扫描失败!')
barcode.close()
this._open()
}
},
_cancelScan() {
barcode.close();
this.showScan = false
},
// _scanPicture() {
// let that = this;
// plus.gallery.pick(function (path) {
// plus.barcode.scan(path, function (type, result) {
// var text = '未知: ';
// switch (type) {
// case plus.barcode.CODE128:
// text = 'CODE128: ';
// break;
// }
// that.$store.dispatch('EnvSample/scanReceive', {num: result}).then(() => {
// if (that.$store.state.EnvSample.success) {
// barcode.close();
// that.$router.go(-1);
// }
// });
// }, function (error) {
// plus.nativeUI.alert('无法识别此图片');
// }, [plus.barcode.CODE128]);
// }, function (err) {
// console.log('Failed: ' + err.message);
// });
// },
}
}
</script>
<template>
<van-popup v-model="showPicker" position="bottom"
:safe-area-inset-bottom="true"
:close-on-popstate="true">
<div style="height: 70vh;overflow: hidden;background: #f7f8fa">
<search-bar ref="searchBar" :label="level===0?'大类':level===1?'亚类':level===2?'次亚类':'细类'" :fixed="false"
@search="_search"></search-bar>
<div style="height:calc(100% - 55px);overflow:auto">
<div class="result-item" v-for="item in resultList" :key="item"
@click="_tapResult(item)">
<div> {{item}}</div>
</div>
</div>
</div>
</van-popup>
</template>
<script>
import {foodClassifyInfo} from '../../../api'
export default {
name: "SelectClass",
data() {
return {
key: '',
resultList: [],
level: '',
pname: '',
showPicker: false
}
},
methods: {
_open(level, pname) {
this.showPicker = true
this.level = level
this.pname = pname
this.key = ''
this.$nextTick(function () {
this.$refs.searchBar.searchValue = ''
})
this._getData()
},
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this._getData()
},
_searchParams() {
let obj = {level: this.level}
if (this.key) {
obj.name = this.key
}
if (this.pname) {
obj.pName = this.pname
}
return obj
},
_getData: async function () {
let result = await foodClassifyInfo.categoryList(this._searchParams())
this.resultList = result
},
_tapResult(item) {
this.$emit('on-result-change', item, this.level)
this.showPicker = false
},
}
}
</script>
<style scoped>
</style>
<template>
<van-popup v-model="showPicker" position="bottom"
:safe-area-inset-bottom="true"
:close-on-popstate="true">
<div style="height: 70vh;overflow: hidden;background: #f7f8fa">
<search-bar ref="searchBar" label="生产者名称" :fixed="false"
@search="_search"></search-bar>
<div style="height:calc(100% - 55px);overflow:auto">
<div class="result-item" v-for="item in resultList" :key="item.id"
@click="_tapResult(item)">
<div> {{item.proName}}</div>
</div>
</div>
</div>
</van-popup>
</template>
<script>
import {samplingSummary} from '../../../api'
export default {
data() {
return {
key: '',
resultList: [],
showPicker: false
}
},
methods: {
_open() {
this.showPicker = true
this.key = ''
this.$nextTick(function () {
this.$refs.searchBar.searchValue = ''
})
this._getData()
},
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this._getData()
},
_searchParams() {
let obj = {}
if (this.key) {
obj.name = this.key
}
return obj
},
_getData: async function () {
let result = await samplingSummary.getProducter(this._searchParams())
this.resultList = result
},
_tapResult(item) {
this.$emit('on-result-change', item)
this.showPicker = false
},
}
}
</script>
<style scoped>
</style>
<template>
<van-popup v-model="showPicker" position="bottom"
:safe-area-inset-bottom="true"
:close-on-popstate="true">
<div style="height: 70vh;overflow: hidden;background: #f7f8fa">
<search-bar ref="searchBar" label="被抽样单位名称" :fixed="false"
@search="_search"></search-bar>
<div style="height:calc(100% - 55px);overflow:auto">
<div class="result-item" v-for="item in resultList" :key="item.id"
@click="_tapResult(item)">
<div> {{item.name}}</div>
</div>
</div>
</div>
</van-popup>
</template>
<script>
import {netTested,nonNetTested} from '../../../api'
export default {
data() {
return {
key: '',
resultList: [],
type: '',
showPicker: false
}
},
methods: {
_open(type) {
this.showPicker = true
this.type = type
this.key = ''
this.$nextTick(function () {
this.$refs.searchBar.searchValue = ''
})
this._getData()
},
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this._getData()
},
_searchParams() {
let obj = {}
if (this.key) {
obj.name = this.key
}
return obj
},
_getData: async function () {
if(this.type==='netTested'){
let result = await netTested.getTested(this._searchParams())
this.resultList = result
}else{
let result = await nonNetTested.getTested(this._searchParams())
this.resultList = result
}
},
_tapResult(item) {
this.$emit('on-result-change', item, this.type)
this.showPicker = false
},
}
}
</script>
<style scoped>
</style>
<template>
<van-popup v-model="showPicker" position="bottom"
:safe-area-inset-bottom="true"
:close-on-popstate="true">
<div style="height: 70vh;overflow: hidden;background: #f7f8fa">
<search-bar ref="searchBar" label="抽样单位名称" :fixed="false"
@search="_search"></search-bar>
<div style="height:calc(100% - 55px);overflow:auto">
<div class="result-item" v-for="item in resultList" :key="item.id"
@click="_tapResult(item)">
<div>{{item.testName}}</div>
</div>
</div>
</div>
</van-popup>
</template>
<script>
import {samplingSummary} from '../../../api'
export default {
data() {
return {
key: '',
resultList: [],
showPicker: false
}
},
methods: {
_open() {
this.showPicker = true
this.key = ''
this.$nextTick(function () {
this.$refs.searchBar.searchValue = ''
})
this._getData()
},
//简单查询 清空高级查询条件 赋值简单查询数据
_search(value) {
this.key = value
this._getData()
},
_searchParams() {
let obj = {}
if (this.key) {
obj.name = this.key
}
return obj
},
_getData: async function () {
let result = await samplingSummary.getTester(this._searchParams())
this.resultList = result
},
_tapResult(item) {
this.$emit('on-result-change', item)
this.showPicker = false
},
}
}
</script>
<style scoped>
</style>
......@@ -237,6 +237,11 @@ html, body, #app, .main-content-con {
/*search-bar begin */
.search-bar-box {
position: relative !important;
top: 0px !important;
}
.search-bar-box-fixed-top {
position: fixed;
width: 100%;
top: 45px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment