feat(src/views/reagent/weighing/index.vue): 称重模块接口接入

duizhaopin_ui
duan 2 years ago
parent 49aca32d0e
commit 81349b956f

@ -8,6 +8,22 @@ export function weigh() {
})
}
export function tare() {
return request({
url: '/api/tare/',
method: 'get',
baseURL: process.env.VUE_APP_FACE_API
})
}
export function zero() {
return request({
url: '/api/zero/',
method: 'get',
baseURL: process.env.VUE_APP_FACE_API
})
}
export function update_drug_remain(data) {
return request({
url: '/api/drug/update_drug_remain',
@ -23,3 +39,4 @@ export function get_drug_info(data) {
data
})
}

@ -15,15 +15,15 @@
<div class="tip">精度0.01g±0.03g</div>
<div class="show-data">
<div class="top">
<span class="num">{{ weight }}</span>
<span class="num">{{ checkInputWeigh() ? parseFloat(inputWeigh) : weight }}</span>
<span class="unit">(g)</span>
</div>
<div class="bottom">
<el-radio v-model="radio" label="1"></el-radio>
<el-radio v-model="radio" label="2"></el-radio>
<el-button type="primary" @click="doWeigh"></el-button>
<el-button type="primary" plain>去皮初始化天平</el-button>
<el-input placeholder="手动输入" />
<el-button type="primary" plain @click="doTare"></el-button>
<el-input v-model="inputWeigh" placeholder="手动输入" />
<el-button type="warning">设置为空</el-button>
</div>
</div>
@ -61,7 +61,7 @@
<script>
import stringify from '@/utils/stringify'
import Scannner from '@/components/Scannner/index'
import { update_drug_remain, weigh, get_drug_info } from '@/api/reagent/weight'
import { update_drug_remain, weigh, get_drug_info, tare, zero } from '@/api/reagent/weight'
import { set_drug_empty_bottle } from '@/api/reagent/management'
export default {
@ -76,7 +76,9 @@ export default {
infoData: '',
statusMap: ['在库', '出库', '空瓶'],
statusColorMap: ['success', '', 'warning'],
weight: '0.00'
weight: '0.00',
timer: undefined,
inputWeigh: ''
}
},
watch: {
@ -89,10 +91,56 @@ export default {
})
}
},
mounted() {
// (1000*60*60=>**60)
this.timer = setInterval(() => {
this.doWeigh()
}, 200)
this.doZero()
},
destroyed() {
clearInterval(this.timer)
},
methods: {
checkInputWeigh() {
const w = parseFloat(this.inputWeigh)
return !!w
},
getCode(code) {
this.barCode = code
},
doWeigh() {
weigh().then(
res => {
let weigh = null
if (res.data) {
weigh = parseFloat(res.data)
//
if (this.radio === '1') {
this.weight = weigh
} else {
//
this.weight = parseFloat(this.infoData.remain) - weigh
}
}
}
)
},
doTare() {
tare().then(
res => {
this.$message.success('去皮操作成功')
}
)
},
doZero() {
zero().then(
res => {
this.$message.success('清零成功')
}
)
},
handleSetEmpty() {
if (this.infoData.medicament_id) {
const data = {
@ -105,16 +153,12 @@ export default {
this.$message.warning('请选择试剂!')
}
},
doWeigh() {
weigh().then(
res => (this.weight = res.data)
)
},
updateDrugRemain() {
if (this.infoData.medicament_id) {
const w = this.checkInputWeigh()
const data = {
'medicament_id': this.infoData.medicament_id,
'reain': this.weight
'reain': w ? parseFloat(this.inputWeigh) : this.weight
}
update_drug_remain(stringify(data)).then(
res => {

Loading…
Cancel
Save