Commit c546d62e by zhuxiaomei

抽样条码

parent c680e4f8
NODE_ENV=development
VUE_APP_BASE_URL=http://192.168.0.13:7000
VUE_APP_BASE_URL=http://192.168.0.50:7000
......@@ -30,3 +30,4 @@ export {default as message} from './message/message'
*/
export {default as sample} from './taihe/sample'
export {default as scanRelSamplingNum} from './taihe/scan-rel-sampling-num'
/**
*
*/
import http from '../http'
export default {
page: data => http.post('/taihe/v1/scan_rel_sampling_num/page', data).then(res => res),
add: data => http.post('/taihe/v1/scan_rel_sampling_num/', data).then(res => res),
edit: data => http.put('/taihe/v1/scan_rel_sampling_num/' + data.id, data.obj).then(res => res),
getById: data => http.get('/taihe/v1/scan_rel_sampling_num/' + data).then(res => res),
deleteByIds: data => http.delete('/taihe/v1/scan_rel_sampling_num/?ids=' + data).then(res => res),
}
......@@ -10,7 +10,7 @@
></van-nav-bar>
</template>
<template #content>
<search-bar label="抽样单号" ref="searchBar"></search-bar>
<search-bar label="抽样单号" ref="searchBar" @search="_search"></search-bar>
<div class="layout-cont-s">
<!--下拉刷新 https://vant-contrib.gitee.io/vant/#/zh-CN/pull-refresh-->
<van-pull-refresh v-model="refreshing" @refresh="_refresh">
......@@ -22,7 +22,8 @@
@load="_load">
<van-swipe-cell v-for="item in resultList" :key="item.id">
<div class="result-item" @click="_tapItem(item)">
<div>抽样单号:{{item.humidity}}</div>
<div style="width: 100%">抽样单号:{{item.samplingNum}}</div>
<div style="width: 100%">条码号:{{item.scanNum}}</div>
</div>
<template #right>
<van-button square type="info" text="编辑" class="swipe-cell-btn"
......@@ -39,7 +40,7 @@
</template>
<script>
import {envMonitor} from '../../api'
import {scanRelSamplingNum} from '../../api'
export default {
name: "SamplingCode",
......@@ -69,12 +70,12 @@
rows: this.rows,
};
if (this.key) {
data.location = this.key
data.samplingNum = this.key
}
return this.$serializeForm(data)
},
_getData: async function () {
let result = await envMonitor.page(this._searchParams())
let result = await scanRelSamplingNum.page(this._searchParams())
this.resultList = [...(this.page === 1 ? [] : this.resultList), ...result.records]
this.refreshing = false
this.loading = false
......@@ -107,7 +108,7 @@
}
},
_delOk: async function (ids) {
let result = await envMonitor.deleteByIds(ids)
let result = await scanRelSamplingNum.deleteByIds(ids)
if (result) {
this.$toast('操作成功!')
this._refresh()
......
<template>
<div>
<div class="layout-cont-btn">
<van-field
v-model="code"
label="条码"
right-icon="scan"
placeholder="请输入或扫码条码"
@click-right-icon="_scan"
></van-field>
<van-field
v-model="code"
label="抽样单编号"
placeholder="请输入抽样单号"
></van-field>
<van-form ref="form">
<van-field
v-model="formObj.scanNum"
label="条码"
right-icon="scan"
:rules="[{ required: true, message: '请填写条码'}]"
placeholder="请输入或扫码条码"
@click-right-icon="_scan"
></van-field>
<van-field
v-model="formObj.samplingNum"
label="抽样单编号"
:rules="[{ required: true, message: '请填写抽样单编号'}]"
placeholder="请输入抽样单号"
></van-field>
</van-form>
</div>
<div class="bottom-btn">
<van-button square block type="default" @click="_back">取消</van-button>
<van-button square block type="info" @click="_save" v-if="id">保存</van-button>
<van-button square block type="info" @click="_saveNext" v-else>保存并下一个</van-button>
<van-button square block type="primary" @click="_save">保存</van-button>
<van-button square block type="info" @click="_saveNext" v-if="id===''">保存并下一个
</van-button>
</div>
</div>
</template>
<script>
import {mapMutations} from "vuex";
// import {envMonitor} from '../../api'
import {scanRelSamplingNum} from '../../api'
export default {
name: "SamplingCodeAdd",
data() {
return {
code: '',
formObj: {
scanNum: '',
samplingNum: '',
},
id: ''
}
},
mounted() {
this.code = this.$store.state.barcode
this.formObj.scanNum = this.$store.state.barcode
this.setBarcode()
this._open()
},
......@@ -50,18 +58,18 @@
}
},
_getData: async function () {
// let result = await envMonitor.getById(this.id)
// if (result) {
// for (let key in this.formObj) {
// if (result[key]) {
// if (key === 'monitorDate') {
// this.formObj[key] = this.$dateformat(result[key], 'yyyy-mm-dd')
// } else {
// this.formObj[key] = result[key]
// }
// }
// }
// }
let result = await scanRelSamplingNum.getById(this.id)
if (result) {
for (let key in this.formObj) {
if (result[key]) {
if (key === 'monitorDate') {
this.formObj[key] = this.$dateformat(result[key], 'yyyy-mm-dd')
} else {
this.formObj[key] = result[key]
}
}
}
}
},
_scan() {
this.$router.push('/scan_bar')
......@@ -69,9 +77,34 @@
_back() {
this.$router.go(-1);
},
_saveNext() {
}
_save() {
if (this.id) {
this._editSave(this.formObj)
} else {
this._addSave(this.formObj)
}
},
_saveNext: async function () {
let result = await scanRelSamplingNum.add(this.formObj)
if (result) {
this.$toast('添加成功!')
this.formObj = this.$resetFields(this.formObj)
}
},
_addSave: async function (res) {
let result = await scanRelSamplingNum.add(res)
if (result) {
this.$toast('添加成功!')
this.$router.go(-1)
}
},
_editSave: async function (res) {
let result = await scanRelSamplingNum.edit({id: this.id, obj: res})
if (result) {
this.$toast('编辑成功!')
this.$router.go(-1)
}
},
}
}
</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