Commit c546d62e by zhuxiaomei

抽样条码

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