<template>
|
<div>
|
<basic-container>
|
<div class="task-div-title">
|
<div style="margin-left:15px;">
|
<span style="font-size: 17px;font-weight: bold;color: #2d2d2d;"
|
>数据录入</span
|
>
|
</div>
|
</div>
|
<div
|
style="margin-bottom: 10px;margin-left: 15px; display:inline-block;width: 80%;margin-top: 30px"
|
>
|
<el-form
|
:model="formData"
|
class="l-mes"
|
style="margin-left: 10px"
|
ref="form"
|
:rules="rules"
|
label-width="70px"
|
>
|
<el-form-item prop="barCode" label="19条码">
|
<el-input
|
placeholder="请输入19条码"
|
v-model="formData.barCode"
|
clearable
|
></el-input>
|
</el-form-item>
|
<el-form-item prop="codeBox" label="箱码">
|
<el-input
|
placeholder="请输入箱码"
|
v-model="formData.codeBox"
|
clearable
|
></el-input>
|
</el-form-item>
|
|
<el-form-item prop="codeCer" label="合格证">
|
<el-input
|
placeholder="请输入合格证"
|
v-model="formData.codeCer"
|
clearable
|
></el-input>
|
</el-form-item>
|
<el-form-item prop="grossWei" label="毛重" class="flexOne">
|
<el-input
|
placeholder="请输入毛重"
|
v-model="formData.grossWei"
|
clearable
|
>
|
</el-input>
|
<el-button @click.prevent="autoWeight" size="mini"
|
>自动称重</el-button
|
>
|
</el-form-item>
|
<el-form-item prop="weighingApiAddress" label="地磅选择">
|
<el-select
|
placeholder="请进行地磅选择"
|
v-model="formData.weighingApiAddress"
|
clearable
|
>
|
<el-option
|
v-for="item in weighbridgeSelect"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<el-row type="flex" justify="space-around" style="margin-top: 50px">
|
<el-button type="primary" @click="submitForm()">提交</el-button>
|
<el-button @click="resetForm">清除</el-button>
|
</el-row>
|
</div>
|
</basic-container>
|
</div>
|
</template>
|
|
<script>
|
import { addCode19gross, getWeight } from '@/api/huawei/code19gross'
|
import { remote } from '@/api/admin/dict'
|
export default {
|
name: 'genForm',
|
data() {
|
return {
|
weighbridgeSelect: [],
|
formData: {
|
barCode: '',
|
codeBox: '',
|
codeCer: '',
|
grossWei: '',
|
weighingApiAddress: ''
|
},
|
rules: {
|
barCode: [{ required: true, message: '请输入19条码', trigger: 'blur' }],
|
codeBox: [{ required: true, message: '请输入箱码', trigger: 'blur' }],
|
codeCer: [{ required: true, message: '请输入合格证', trigger: 'blur' }],
|
grossWei: [{ required: true, message: '请输入毛重', trigger: 'blur' }],
|
weighingApiAddress: [
|
{ required: true, message: '请进行地磅选择', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
created() {
|
this.initOptions()
|
},
|
methods: {
|
initOptions() {
|
remote('weighing_api_address').then((response) => {
|
if (response.data.code === 0) {
|
this.weighbridgeSelect = response.data.data
|
}
|
})
|
},
|
submitForm() {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
if (this.formData.grossWei > 200 || this.formData.grossWei < 0) {
|
this.$message.error('毛重需在(0,200]范围内')
|
return
|
}
|
addCode19gross(this.formData)
|
.then((data) => {
|
this.$message.success('提交成功')
|
// 刷新列表
|
this.$emit('updateList')
|
})
|
.catch(() => {
|
this.$message.error('提交失败')
|
})
|
}
|
})
|
},
|
resetForm() {
|
this.$refs.form.resetFields()
|
},
|
// 自动称重
|
autoWeight() {
|
if (this.formData.weighingApiAddress) {
|
const id = 1
|
getWeight(this.formData.weighingApiAddress)
|
.then((res) => {
|
this.formData.grossWei = res.data.data
|
})
|
.catch(() => {})
|
} else {
|
this.$message.error('地磅选择不能为空')
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.flexOne {
|
>>> .el-form-item__content {
|
display: flex;
|
.el-input {
|
flex: 1;
|
}
|
}
|
}
|
</style>
|