Files
rd_mes_uniapp/pages/esop/esopPwo.vue

109 lines
2.4 KiB
Vue
Raw Permalink Normal View History

2025-12-18 14:11:48 +08:00
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="工位编码" :labelWidth='90' name="stationCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" v-model="formData.stationCode"
type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='90' name="pwoJobCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.pwoJobCode"
type="text" />
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
listStation,
listPwoJob,
addCustomizeEsop
} from "@/api/esop/esop.js";
export default {
mounted() {
},
data() {
return {
formData: {
pwoJobCode: null,
stationCode: null,
},
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
stationCode: {
rules: [{
required: true,
errorMessage: '请输入工位编码!'
}]
},
}
}
},
methods: {
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.stationCode = res.result;
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
}
});
},
submit() {
this.$refs["form"].validate().then(valid => {
if (this.formData.stationCode) {
let obj = {
stationCode: this.formData.stationCode
}
listStation(obj).then(res => {
this.formData.stationId = res.rows[0].id;
let pwoJobCd = {
code: this.formData.pwoJobCode
}
listPwoJob(pwoJobCd).then(res => {
this.formData.pwoJobId = res.rows[0].id;
this.$modal.loading('提交中')
addCustomizeEsop(this.formData).then(response => {
this.$modal.closeLoading();
this.$modal.msgSuccess("提交成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
});
})
})
}
});
}
},
}
</script>
<style>
</style>