Commit 21f48430 by zhuxiaomei

app扫码功能改为输完查询

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