Commit 21f48430 by zhuxiaomei

app扫码功能改为输完查询

parent 2c1f235c
...@@ -291,9 +291,17 @@ ...@@ -291,9 +291,17 @@
label-align="center" label-align="center"
v-model="sample.qrcode" v-model="sample.qrcode"
label="条形码" label="条形码"
right-icon="scan" @blur="_getSample"
@click-right-icon="_scan"
></van-field> ></van-field>
<!--<van-field-->
<!--label-class="cus-field-class"-->
<!--label-width="25%"-->
<!--label-align="center"-->
<!--v-model="sample.qrcode"-->
<!--label="条形码"-->
<!--right-icon="scan"-->
<!--@click-right-icon="_scan"-->
<!--&gt;</van-field>-->
</table-col> </table-col>
</table-row> </table-row>
<table-row> <table-row>
...@@ -848,7 +856,7 @@ ...@@ -848,7 +856,7 @@
import SamplingListAddTable from './components/SamplingListAddTable' import SamplingListAddTable from './components/SamplingListAddTable'
import TableRow from './components/TableRow' import TableRow from './components/TableRow'
import TableCol from './components/TableCol' import TableCol from './components/TableCol'
import {samplingSummary} from '../../api' import {samplingSummary, samplingSample} from '../../api'
import {default as areaList} from '../../lib/area' import {default as areaList} from '../../lib/area'
import SelectClass from './components/SelectClass' import SelectClass from './components/SelectClass'
import SelectTester from './components/SelectTester' import SelectTester from './components/SelectTester'
...@@ -1072,46 +1080,42 @@ ...@@ -1072,46 +1080,42 @@
} }
}, },
mounted() { mounted() {
mui.init({ // mui.init({
beforeback: function () { // beforeback: function () {
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
return true // return true
} // }
}) // })
this._open() this._open()
}, },
beforeDestroy(){ // beforeDestroy(){
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
}, // },
methods: { methods: {
_open() { _open() {
if (this.$route.query.id) {//编辑 if (this.$route.query.id) {//编辑
this.id = this.$route.query.id this.id = this.$route.query.id
//localStorage.getItem('summary')有值 是扫码进来的 // if (localStorage.getItem('summary')) {
console.log(localStorage.getItem('summary'), 'localStorage.getItem(\'summary\')') // this._initData(JSON.parse(localStorage.getItem('summary')))
if (localStorage.getItem('summary')) { // if (localStorage.getItem('sample')) {
this._initData(JSON.parse(localStorage.getItem('summary'))) // this._scanResult(JSON.parse(localStorage.getItem('sample')))
if (localStorage.getItem('sample')) { // }
this._scanResult(JSON.parse(localStorage.getItem('sample'))) // } else {
} this._getData()
} else { // }
this._getData()
}
} else {//添加 } else {//添加
this.id = '' this.id = ''
//localStorage.getItem('summary')有值 是扫码进来的 // if (localStorage.getItem('summary')) {
console.log(localStorage.getItem('summary'), 'localStorage.getItem(\'summary\')') // this._initData(JSON.parse(localStorage.getItem('summary')))
if (localStorage.getItem('summary')) { // if (localStorage.getItem('sample')) {
this._initData(JSON.parse(localStorage.getItem('summary'))) // this._scanResult(JSON.parse(localStorage.getItem('sample')))
if (localStorage.getItem('sample')) { // }
this._scanResult(JSON.parse(localStorage.getItem('sample'))) // } else {
} this.formObj.testMembers = this.$global.getUserInfo().realname
} else { this._getLastTester()
this.formObj.testMembers = this.$global.getUserInfo().realname // }
this._getLastTester()
}
} }
}, },
_companySelect(type) { _companySelect(type) {
...@@ -1348,8 +1352,8 @@ ...@@ -1348,8 +1352,8 @@
let result = await samplingSummary.add(data) let result = await samplingSummary.add(data)
if (result) { if (result) {
this.$toast('添加成功!') this.$toast('添加成功!')
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
this.$router.go(-1) this.$router.go(-1)
} }
}, },
...@@ -1358,8 +1362,8 @@ ...@@ -1358,8 +1362,8 @@
let result = await samplingSummary.edit(data) let result = await samplingSummary.edit(data)
if (result) { if (result) {
this.$toast('编辑成功!') this.$toast('编辑成功!')
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
this.$router.go(-1) this.$router.go(-1)
} }
}, },
...@@ -1384,6 +1388,15 @@ ...@@ -1384,6 +1388,15 @@
this.nonNetTested.testedCountry = value[2].name this.nonNetTested.testedCountry = value[2].name
this.showCityPicker = false this.showCityPicker = false
}, },
_getSample: async function () {
if (this.sample.qrcode) {
let res = await samplingSample.scanSample({qrcode: this.sample.qrcode})
if (res) {
this._scanResult(res)
}
}
},
} }
} }
</script> </script>
......
...@@ -522,14 +522,22 @@ ...@@ -522,14 +522,22 @@
</van-field> </van-field>
</table-col> </table-col>
<table-col> <table-col>
<!--<van-field-->
<!--label-class="cus-field-class"-->
<!--label-width="25%"-->
<!--label-align="center"-->
<!--v-model="sample.qrcode"-->
<!--label="条形码"-->
<!--right-icon="scan"-->
<!--@click-right-icon="_scan"-->
<!--&gt;</van-field>-->
<van-field <van-field
label-class="cus-field-class" label-class="cus-field-class"
label-width="25%" label-width="25%"
label-align="center" label-align="center"
v-model="sample.qrcode" v-model="sample.qrcode"
label="条形码" label="条形码"
right-icon="scan" @blur="_getSample"
@click-right-icon="_scan"
></van-field> ></van-field>
</table-col> </table-col>
<table-col> <table-col>
...@@ -845,7 +853,7 @@ ...@@ -845,7 +853,7 @@
import SamplingListAddTable from './components/SamplingListAddTable' import SamplingListAddTable from './components/SamplingListAddTable'
import TableRow from './components/TableRow' import TableRow from './components/TableRow'
import TableCol from './components/TableCol' import TableCol from './components/TableCol'
import {samplingSummary} from '../../api' import {samplingSummary, samplingSample} from '../../api'
import {default as areaList} from '../../lib/area' import {default as areaList} from '../../lib/area'
import SelectClass from './components/SelectClass' import SelectClass from './components/SelectClass'
import SelectTester from './components/SelectTester' import SelectTester from './components/SelectTester'
...@@ -1010,36 +1018,36 @@ ...@@ -1010,36 +1018,36 @@
}, },
mounted() { mounted() {
this._open() this._open()
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
},
beforeDestroy(){
localStorage.removeItem('summary')
localStorage.removeItem('sample')
}, },
// beforeDestroy(){
// localStorage.removeItem('summary')
// localStorage.removeItem('sample')
// },
methods: { methods: {
_open() { _open() {
if (this.$route.query.id) {//编辑 if (this.$route.query.id) {//编辑
this.id = this.$route.query.id this.id = this.$route.query.id
if (localStorage.getItem('summary')) { // if (localStorage.getItem('summary')) {
this._initData(JSON.parse(localStorage.getItem('summary'))) // this._initData(JSON.parse(localStorage.getItem('summary')))
if (localStorage.getItem('sample')) { // if (localStorage.getItem('sample')) {
this._scanResult(JSON.parse(localStorage.getItem('sample'))) // this._scanResult(JSON.parse(localStorage.getItem('sample')))
} // }
} else { // } else {
this._getData() this._getData()
} // }
} else {//添加 } else {//添加
this.id = '' this.id = ''
if (localStorage.getItem('summary')) { // if (localStorage.getItem('summary')) {
this._initData(JSON.parse(localStorage.getItem('summary'))) // this._initData(JSON.parse(localStorage.getItem('summary')))
if (localStorage.getItem('sample')) { // if (localStorage.getItem('sample')) {
this._scanResult(JSON.parse(localStorage.getItem('sample'))) // this._scanResult(JSON.parse(localStorage.getItem('sample')))
} // }
} else { // } else {
this.formObj.testMembers = this.$global.getUserInfo().realname this.formObj.testMembers = this.$global.getUserInfo().realname
this._getLastTester() this._getLastTester()
} // }
} }
}, },
_companySelect(type) { _companySelect(type) {
...@@ -1255,17 +1263,18 @@ ...@@ -1255,17 +1263,18 @@
let result = await samplingSummary.add(data) let result = await samplingSummary.add(data)
if (result) { if (result) {
this.$toast('添加成功!') this.$toast('添加成功!')
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') } // localStorage.removeItem('sample')
this.$router.go(-1) this.$router.go(-1)
}
}, },
_editSave: async function (data) { _editSave: async function (data) {
data.id = this.id data.id = this.id
let result = await samplingSummary.edit(data) let result = await samplingSummary.edit(data)
if (result) { if (result) {
this.$toast('编辑成功!') this.$toast('编辑成功!')
localStorage.removeItem('summary') // localStorage.removeItem('summary')
localStorage.removeItem('sample') // localStorage.removeItem('sample')
this.$router.go(-1) this.$router.go(-1)
} }
}, },
...@@ -1291,6 +1300,14 @@ ...@@ -1291,6 +1300,14 @@
this.netTested.testedCountry = value[2].name this.netTested.testedCountry = value[2].name
this.showCityPicker = false this.showCityPicker = false
}, },
_getSample: async function () {
if (this.sample.qrcode) {
let res = await samplingSample.scanSample({qrcode: this.sample.qrcode})
if (res) {
this._scanResult(res)
}
}
},
} }
} }
</script> </script>
......
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