Files
2025-11-17 10:01:33 +08:00

137 lines
3.2 KiB
Vue

<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-forms-item label="刀柄编码" :labelWidth='90' name="shankCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" v-model="formData.shankCode" type="text" />
</uni-forms-item>
<uni-forms-item label="刀刃编码" :labelWidth='90' name="bladeCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarbladeCode" v-model="formData.bladeCode"
type="text" />
</uni-forms-item>
<uni-forms-item label="安装员" :labelWidth='90' name="installCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarinstallBy" @change="selectinstallBy"
v-model="installCode" type="text" />
</uni-forms-item>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
</view>
</template>
<script>
import {
listUseRecord,
getUseRecord,
delUseRecord,
addStartUse,
updateEndUse,
listEntity,
listMaterial,
listEquipment,
getEntity,
bindRecord
} from "@/api/basic/cutter.js";
import {
listEmployee
} from "@/api/mes/jobIn.js";
export default {
data() {
return {
formData: {
shankCode: null,
bladeCode: null,
installBy: null,
},
installCode: null,
rules: {
bladeCode: {
rules: [{
required: true,
errorMessage: '请输入刀刃编码!'
}]
},
shankCode: {
rules: [{
required: true,
errorMessage: '请输入刀柄编码!'
}]
},
installCode: {
rules: [{
required: true,
errorMessage: '请输入安装员!'
}]
},
}
}
},
mounted() {},
methods: {
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.shankCode = res.result;
}
});
},
scanBarbladeCode() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.bladeCode = res.result;
}
});
},
selectinstallBy(code) {
listEmployee({
empCode: code
}).then(async res => {
if (res.rows.length > 0) {
this.formData.installBy = res.rows[0].name;
} else {
this.$modal.msg("未查询到该人员,请重新输入!")
}
})
},
scanBarinstallBy() {
const _this = this;
uni.scanCode({
scanType: ['qrCode', 'barCode'],
success: function(res) {
_this.formData.installCode = res.result;
_this.selectinstallBy(res.result);
}
});
},
submit() {
this.$refs.form.validate().then(async res => {
if (this.formData.bladeCode && this.formData.shankCode) {
//判断安装员是否填入
setTimeout(() => {
if (this.formData.installBy) {
this.$modal.loading('提交中')
bindRecord(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("刀具安装成功!")
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
this.$modal.msg("请输入安装员!")
}
}, 500);
}
})
}
}
}
</script>
<style>
</style>