Files
rd_mes_uniapp/pages/esop/esopProLine.vue

139 lines
3.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="pwoCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" v-model="formData.pwoCode" type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产线编码" :labelWidth='90' name="productLineCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar1" v-model="formData.productLineCode"
type="text" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="状态" :labelWidth='90' name="issuedState">
<u-switch v-model="check" @change="favClick" activeColor="#5AC725"
style="float: left;"></u-switch>
<view style="float: left;margin: 5px;">{{status}}</view>
<!-- <view class="uni-padding-wrap uni-common-mt">
<uni-fav :checked="check" circle='true' bg-color="#dd524d" bg-color-checked="#67C23A" fg-color="#ffffff" fg-color-checked="#ffffff" star="false" :content-text="contentText" @click="favClick" />
</view> -->
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
updatePwo,
listProLine,
listPwo
} from "@/api/esop/esop.js";
export default {
mounted() {
},
data() {
return {
formData: {
pwoCode: null,
productLineCode: null,
proLineId: null,
issuedState: 0
},
check: false,
contentText: {
contentDefault: '待发',
contentFav: '已下发'
},
status: '待发',
rules: {
pwoCode: {
rules: [{
required: true,
errorMessage: '请输入生产工单!'
}]
},
productLineCode: {
rules: [{
required: true,
errorMessage: '请输入产线编码!'
}]
},
}
}
},
methods: {
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoCode = res.result;
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.productLineCode = res.result;
}
});
},
//切换状态
favClick(e) {
// this.check = !this.check;
// console.log(this.check + " " + e);
this.$forceUpdate();
if (e == false) {
this.status = '待发'
this.formData.issuedState = 0
} else {
this.status = '下发'
this.formData.issuedState = 1
}
},
submit() {
this.$refs["form"].validate().then(valid => {
if (this.formData.productLineCode) {
let obj = {
productLineCode: this.formData.productLineCode
}
listProLine(obj).then(res => {
this.formData.proLineId = res.rows[0].id;
let pwoCode = {
pwoCode: this.formData.pwoCode
}
listPwo(pwoCode).then(res => {
this.formData.id = res.rows[0].id;
this.$modal.loading('提交中')
updatePwo(this.formData).then(response => {
this.$modal.closeLoading();
this.$modal.msgSuccess("下发成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
});
})
})
}
});
}
},
}
</script>
<style>
</style>