初始化仓库

This commit is contained in:
tao
2025-12-18 14:11:48 +08:00
parent e96f277a68
commit 54ec472bd4
1107 changed files with 158756 additions and 0 deletions

View File

@@ -0,0 +1,343 @@
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='80' name="pwoJobCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth='80' name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='80' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='80' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='80' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='80' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程编码" :labelWidth='80' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程名称" :labelWidth='80' name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="用时(s)" :labelWidth='80' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="报工类型" :labelWidth='80' name="type">
<uni-easyinput disabled type="text" v-model="formData.type" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报工数量" :labelWidth='80' name="reportNumber">
<uni-easyinput type="number" :placeholder="'可报工数量:'+reportableNum" v-model="formData.reportNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良原因" :labelWidth='80' name="reason">
<uni-data-select v-model="formData.reason" :localdata="reasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='80' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @confirm="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='80' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="是否录入件号" :labelWidth='120'>
<uni-data-checkbox v-model="radio" :localdata="pieceIn"></uni-data-checkbox>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<view v-show="radio==1">
<uni-forms-item label="件号" :labelWidth='80' name="pieceNo">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPieceNo" type="text" v-model="formData.pieceNo" />
</uni-forms-item>
</view>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='90'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='90' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit" v-if="!isPwoRoute">提交</u-button>
</view>
</template>
<script>
import {
listPwoJob,
addReport,
getEquipment,
addReportEnterPiece
} from "@/api/mes/jobReport.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
import {
getDicts
} from "@/api/system/dict/dictData.js";
export default {
onLoad: function(option) {
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.formData.type = '不良品';
if (option) {
this.formData = JSON.parse(decodeURIComponent(option.formData));
this.isPwoRoute = true;
}
getDicts("mes_job_report_defect").then(res => {
this.reasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
// this.formData.createByName = this.$store.state.user.name;
},
data() {
return {
isPwoRoute: false,
formData: {
pwoJobCode: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
pieceNo: null,
startTime: null,
endTime: null,
},
reportableNum: 0,
radio: 0,
pieceIn: [{
text: '是',
value: 1
},
{
text: '否',
value: 0
}
],
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
reportNumber: {
rules: [{
required: true,
errorMessage: '请输入报工数量!'
}]
},
reason: {
rules: [{
required: true,
errorMessage: '请输入不良原因!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
},
// machineId: {
// rules: [
// { required: true, errorMessage:'请输入设备编码!' }
// ]
// },
},
reasonOptions: [],
}
},
methods: {
submit() {
this.$refs.form.validate().then(res => {
//判断是否选择录入件号
if (this.radio == 1) {
//判断是否输入件号
if (this.formData.pieceNo && this.formData.pieceNo != "") {
this.$modal.loading('提交中')
addReportEnterPiece(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
this.$modal.msg("请输入件号!");
}
} else {
this.$modal.loading('提交中')
addReport(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
}
})
},
scanBarCode() {
if (this.formData.pwoJobCode) {
listPwoJob({
code: this.formData.pwoJobCode
}).then(async res => {
let jobs = res.rows;
if (jobs.length == 0) {
this.$modal.msg("未检索到该作业编码相关的信息!");
} else {
let job = jobs[0];
this.formData.pwoCode = job.pwoCode;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.reportableNum = job.targetNum - job.finishQty;
if (job.eqpId) {
await getEquipment(job.eqpId).then(res => {
this.formData.machineId = res.data.equipmentCode;
})
//调取最后一条转入记录的操作人
let code = {
powJobCode: this.formData.pwoJobCode
}
listConversion(code).then(async res => {
if (res.rows[0].operateBy && res.rows[0].operateBy != "") {
this.formData.createByName = res.rows[0].operateBy;
let arry = {
name: this.formData.createByName
}
listEmployee(arry).then(async res => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
});
}
})
}
this.formData.batchNo = job.batchNo;
}
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
scanBarPieceNo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pieceNo = res.result;
}
});
}
}
}
</script>

View File

@@ -0,0 +1,81 @@
<template>
<view class="uni-padding-wrap uni-common-mt" >
<view class="grid-body">
<uni-grid :column="3" :showBorder="false" @change="changeGrid1">
<uni-grid-item :index="1" style="line-height: 100px;margin-top:100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-tongguo" size="30"></uni-icons>
<text class="text">合格品报工</text>
</view>
</uni-grid-item>
<uni-grid-item :index="2" style="line-height: 100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-shenhebutongguo" size="30"></uni-icons>
<text class="text">不良品报工</text>
</view>
</uni-grid-item>
<uni-grid-item :index="3" style="line-height: 100px;margin-left:37.5%;width: 100%;">
<view class="grid-item-box">
<uni-icons custom-prefix="iconfont" type="icon-tubiaozhizuomoban-134" size="30"></uni-icons>
<text class="text">报废品报工</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
<!-- <u-button type="primary" @click="$tab.navigateTo('/pages/mes/jobReport/pass')">合格品报工</u-button>
<u-button style="margin-top:100px; background-color:#ffff00;" @click="$tab.navigateTo('/pages/mes/jobReport/defect')">不良品报工</u-button>
<u-button style="margin-top:100px;;" type="warn" @click="$tab.navigateTo('/pages/mes/jobReport/scrap')">报废品报工</u-button>
</view> -->
<!-- </view> -->
</template>
<script>
export default {
onLoad: function() {
},
methods: {
changeGrid1(e) {
console.log(e.detail.index);
if (e.detail.index == 1) {
this.$tab.navigateTo('/pages/mes/jobReport/pass');
} else if (e.detail.index == 2) {
this.$tab.navigateTo('/pages/mes/jobReport/defect');
} else if (e.detail.index == 3) {
this.$tab.navigateTo('/pages/mes/jobReport/scrap');
}
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

View File

@@ -0,0 +1,323 @@
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='80' name="pwoJobCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth='80' name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='80' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='80' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='80' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='80' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程编码" :labelWidth='80' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程名称" :labelWidth='80' name="opTitle">
<uni-easyinput disabled disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="用时(s)" :labelWidth='80' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="报工类型" :labelWidth='80' name="type">
<uni-easyinput disabled disabled type="text" v-model="formData.type" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报工数量" :labelWidth='80' name="reportNumber">
<uni-easyinput type="number" :placeholder="'可报工数量:'+reportableNum" v-model="formData.reportNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗原因" :labelWidth='80' name="reason">
<uni-data-select v-model="formData.reason" :localdata="reasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='80' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @confirm="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='80' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='90'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='90' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit" v-if="!isPwoRoute">提交</u-button>
</view>
</template>
<script>
import {
listPwoJob,
addReport,
getEquipment,
addReportEnterPiece
} from "@/api/mes/jobReport.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
import { getDicts } from "@/api/system/dict/dictData.js";
export default {
onLoad: function(option) {
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.formData.type = '损耗';
if (option) {
this.formData = JSON.parse(decodeURIComponent(option.formData));
this.isPwoRoute = true;
}
getDicts("mes_job_report_loss").then(res => {
this.reasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
// this.formData.createByName = this.$store.state.user.name;
},
data() {
return {
isPwoRoute: false,
reasonOptions: [],
formData: {
pwoJobCode: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
pieceNo: null,
},
radio: 0,
reportableNum: 0,
pieceIn: [{
text: '是',
value: 1
},
{
text: '否',
value: 0
}
],
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
reportNumber: {
rules: [{
required: true,
errorMessage: '请输入报工数量!'
}]
},
reason: {
rules: [{
required: true,
errorMessage: '请输入不良原因!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
},
}
}
},
methods: {
submit() {
this.$refs.form.validate().then(res => {
//判断是否选择录入件号
if (this.radio == 1) {
//判断是否输入件号
if (this.formData.pieceNo && this.formData.pieceNo != "") {
this.$modal.loading('提交中')
addReportEnterPiece(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
this.$modal.msg("请输入件号!");
}
} else {
this.$modal.loading('提交中')
addReport(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
}
})
},
scanBarCode() {
if (this.formData.pwoJobCode) {
let obj = {
code: this.formData.pwoJobCode
}
listPwoJob(obj).then(async res => {
let jobs = res.rows;
if (jobs.length == 0) {
this.$modal.msg("未检索到该作业编码相关的信息!");
} else {
let job = jobs[0];
this.formData.pwoCode = job.pwoCode;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.reportableNum = job.targetNum - job.finishQty;
if (job.eqpId) {
await getEquipment(job.eqpId).then(res => {
this.formData.machineId = res.data.equipmentCode;
})
//调取最后一条转入记录的操作人
let code = {
powJobCode: this.formData.pwoJobCode
}
listConversion(code).then(async res => {
if (res.rows[0].operateBy && res.rows[0].operateBy != "") {
this.formData.createByName = res.rows[0].operateBy;
let arry = {
name: this.formData.createByName
}
listEmployee(arry).then(async res => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
})
}
})
}
this.formData.batchNo = job.batchNo;
}
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
scanBarPieceNo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pieceNo = res.result;
}
});
}
}
}
</script>

View File

@@ -0,0 +1,527 @@
<template>
<view style="background-color: #fff">
<uni-forms ref="form" :modelValue="formData" :rules="rules" label-align="right">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth="90" name="pwoJobCode" required>
<!-- <utils-input prefixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" @input="handleInput" :key="input.boolean" :focus='true'
@focus="focus" @click="focus" /> -->
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" @input="handleInput" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth="90" name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth="90" name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth="90" name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="18">
<uni-forms-item label="设备编号" :labelWidth="90" name="machineId">
<uni-easyinput type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="6">
<u-button style="height: 37px;" @click="handleBindEqp" text="绑定设备"
:disabled="!formData.pwoJobCode || !formData.machineId" />
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth="90" name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程编码" :labelWidth="90" name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程名称" :labelWidth="90" name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="用时(s)" :labelWidth="90" name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth="90" name="createByCode" required>
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @confirm="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth="90" name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
<u-divider :text="'可报工数量:' + reportableNum"></u-divider>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="合格数量" :labelWidth="90" name="pass">
<u-number-box button-size="36" inputWidth="auto"
v-model="formData.mesJobReportOnceRequestDTO.pass.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良数量" :labelWidth="90" name="defect">
<u-number-box button-size="36" inputWidth="auto"
v-model="formData.mesJobReportOnceRequestDTO.defect.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良原因" :labelWidth="90" name="defectReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['defect'].reason"
:localdata="defectReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废数量" :labelWidth="90" name="scrap">
<u-number-box button-size="36" inputWidth="auto"
v-model="formData.mesJobReportOnceRequestDTO.scrap.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废原因" :labelWidth="90" name="scrapReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['scrap'].reason"
:localdata="scrapReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗数量" :labelWidth="90" name="loss">
<u-number-box button-size="36" inputWidth="auto"
v-model="formData.mesJobReportOnceRequestDTO.loss.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗原因" :labelWidth="90" name="lossReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['loss'].reason"
:localdata="lossReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth="90">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth="90" name="endTime" required>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="备注" :labelWidth="90" name="remark" :required="requireRemark">
<uni-easyinput autoHeight type="textarea" v-model="formData.remark"></uni-easyinput>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
<!-- <u-button type="primary" @click="end">关闭</u-button> -->
</view>
</template>
<script>
import {
listPwoJob,
addReport,
updatePwoJob,
getEquipment,
addReportOnce,
listEquipment
} from '@/api/mes/jobReport.js';
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from '@/api/mes/jobIn.js';
import { getDicts } from '@/api/system/dict/dictData.js';
// const serialPort = uni.requireNativePlugin('Fvv-UniSerialPort')
import utilsInput from '@/utils/uniapp/utilsInput.vue';
import { getConfigKey } from '@/api/system/config.js';
import { listAllBadCauseByOpCode } from '@/api/basic/badCause';
export default {
components: {
utilsInput
},
onLoad: async function(option) {
if (option.code) {
this.isSearchRoute = true;
this.formData.pwoJobCode = option.code;
this.scanBarCode();
}
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ('0' + (currentDate.getMonth() + 1)).slice(-2);
var day = ('0' + currentDate.getDate()).slice(-2);
var hours = ('0' + currentDate.getHours()).slice(-2);
var minutes = ('0' + currentDate.getMinutes()).slice(-2);
var seconds = ('0' + currentDate.getSeconds()).slice(-2);
var formattedDate = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
// this.formData.type = '报废品';
// this.formData.createByName = this.$store.state.user.name;
await getConfigKey('basic:operation:badCause').then((res) => {
if (!res.msg) return;
this.reasonFrom = +res.msg;
this.formData.reasonFrom = +res.msg || 0;
});
await getConfigKey('mes.job.report.requireRemark').then(res => {
if (res.msg == null) return;
this.requireRemark = Boolean(+res.msg);
});
this.getOptions();
},
data() {
return {
input: {
boolean: 0,
inputValue: ''
},
//判断是否从工单状态页面查询过来
isSearchRoute: false,
lossReasonOptions: [],
scrapReasonOptions: [],
defectReasonOptions: [],
formData: {
pwoJobCode: null,
pwoJobId: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
remark: null,
mesJobReportOnceRequestDTO: {
pass: {
reportNumber: 0,
reason: null
},
defect: {
reportNumber: 0,
reason: null
},
scrap: {
reportNumber: 0,
reason: null
},
loss: {
reportNumber: 0,
reason: null
}
},
startTime: null,
endTime: null
},
reasonFrom: null,
reportableNum: 0,
requireRemark: false,
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
}
}
};
},
created: function(option) {
// const self = this
// serialPort.getAllDeviceList(res => {
// console.log('//设备列表', res)
// })
// serialPort.getAllDevicePath(res => {
// console.log('//路径列表', res)
// }),
// setTimeout(() => {
// serialPort.setPath('/dev/ttyUSB0')
// serialPort.setBaudRate(9600)
// serialPort.open(res => {
// if (!res.status) {
// uni.showToast({
// title: res.msg,
// duration: 2000,
// icon: "none"
// });
// return
// }
// serialPort.onMessage(rec => {
// this.onMessage(rec);
// }, send => {
// console.log(send)
// })
// })
// }, 10000)
},
methods: {
test() {
serialPort.sendHex('A00102A3');
},
end() {
serialPort.sendHex('A00100A1');
},
getOptions() {
this.defectReasonOptions = [];
this.scrapReasonOptions = [];
this.lossReasonOptions = [];
if (this.formData.opCode && this.reasonFrom === 1) {
listAllBadCauseByOpCode(this.formData.opCode).then((res) => {
res.rows.forEach((item) => {
switch (item.causeType) {
case '0':
this.defectReasonOptions.push({
text: item.name,
value: item.id,
disable: false
});
break;
case '1':
this.scrapReasonOptions.push({
text: item.name,
value: item.id,
disable: false
});
break;
case '2':
this.lossReasonOptions.push({
text: item.name,
value: item.id,
disable: false
});
break;
}
});
});
} else {
getDicts('mes_job_report_defect').then((res) => {
this.defectReasonOptions = res.data.map((dict) => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
};
});
});
getDicts('mes_job_report_scrap').then((res) => {
this.scrapReasonOptions = res.data.map((dict) => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
};
});
});
getDicts('mes_job_report_loss').then((res) => {
this.lossReasonOptions = res.data.map((dict) => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
};
});
});
}
},
async handleRenderEmp() {
if(!this.formData.machineId) return;
const { rows, total } = await listEmpEqpHistory({ equipmentCode: this.formData.machineId });
const emp = rows.filter(item => !item.endTime)?.[0];
if(!emp || !total > 0) return this.$modal.msg('该设备下没有绑定人员');
this.formData.createByCode = rows[0].empCode || '';
this.formData.createByName = rows[0].empName || '';
this.formData.createById = rows[0].empId || '';
},
// 绑定设备
async handleBindEqp() {
let eqpId = '';
this.$modal.loading('绑定中');
try {
const { rows, total } = await listEquipment({ equipmentCode: this.formData.machineId });
if(total == 1) {
eqpId = rows[0].id;
} else {
this.$modal.msg('未检索到该设备编码相关的信息!');
return;
}
await updatePwoJob({
id: this.formData.pwoJobId,
eqpId
});
this.$modal.msgSuccess("绑定成功!");
this.handleRenderEmp();
} catch (err) {
console.log(err);
this.$modal.msgError('绑定失败!');
} finally {
this.$modal.closeLoading();
}
},
submit() {
this.$refs.form.validate().then((res) => {
if(this.requireRemark && !this.formData.remark) {
this.$modal.msg('请输入备注!');
return;
}
this.formData.mesJobReportOnceRequestDTO.pass.reportNumber = Number(this.formData.mesJobReportOnceRequestDTO
.pass.reportNumber);
this.formData.mesJobReportOnceRequestDTO.defect.reportNumber = Number(this.formData
.mesJobReportOnceRequestDTO.defect.reportNumber);
this.formData.mesJobReportOnceRequestDTO.scrap.reportNumber = Number(this.formData
.mesJobReportOnceRequestDTO.scrap.reportNumber);
this.$modal.loading('提交中');
addReportOnce(this.formData).then((res) => {
this.$modal.closeLoading();
this.$modal.msgSuccess('报工成功!');
if ((this.isSearchRoute = true)) {
setTimeout(() => {
this.$tab.navigateBack();
}, 500);
} else {
setTimeout(() => {
this.$tab.switchTab('/pages/work/index');
}, 500);
}
});
});
},
scanBarCode() {
if (!this.formData.pwoJobCode) return;
listPwoJob({
code: this.formData.pwoJobCode
}).then(async (res) => {
if (!res.total > 0) return this.$modal.msg('未检索到该作业编码相关的信息!');
const job = res.rows[0];
this.formData.pwoCode = job.pwoCode;
this.formData.pwoJobId = job.id;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.formData.batchNo = job.batchNo;
this.reportableNum = job.targetNum - job.finishQty;
this.getOptions();
if (job.eqpId) {
await getEquipment(job.eqpId).then((res) => {
this.formData.machineId = res.data.equipmentCode;
});
// 查找该设备下上机人员
await this.handleRenderEmp();
}
if(this.formData.createById) return;
// 若没有人员,则调取最后一条转入记录的操作人
listConversion({
powJobCode: this.formData.pwoJobCode
}).then(async (res) => {
if(!res.total > 0) return;
this.formData.createByName = res.rows[0].operateBy;
if(!this.formData.createByName) return;
listEmployee({
name: this.formData.createByName
}).then(async (res) => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
});
});
});
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
};
listEmployee(obj).then(async (res) => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg('未查询到该人员信息!');
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
/**
* 隐藏软键盘
*/
focus() {
uni.hideKeyboard();
},
/**
* 不让手动输入
* @param {Object} value
*/
handleInput(value) {
const { inputValue } = this.input;
if (value.length - inputValue.length == 1 || inputValue.length - value.length == 1) {
this.$modal.msg('请扫描');
this.formData.pwoJobCode = null;
this.input.inputValue = value;
this.input.boolean = this.input.boolean == 0 ? 10 : 0;
return;
}
this.input.inputValue = value;
}
}
};
</script>

View File

@@ -0,0 +1,315 @@
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='80' name="pwoJobCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth='80' name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='80' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='80' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='80' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='80' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程编码" :labelWidth='80' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程名称" :labelWidth='80' name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="用时(s)" :labelWidth='80' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="报工类型" :labelWidth='80' name="type">
<uni-easyinput disabled type="text" v-model="formData.type" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报工数量" :labelWidth='80' name="reportNumber">
<uni-easyinput type="number" :placeholder="'可报工数量:'+reportableNum" v-model="formData.reportNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='80' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @confirm="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='80' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="是否录入件号" :labelWidth='120'>
<uni-data-checkbox v-model="radio" :localdata="pieceIn"></uni-data-checkbox>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<view v-show="radio==1">
<uni-forms-item label="件号" :labelWidth='80' name="pieceNo">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPieceNo" type="text" v-model="formData.pieceNo" />
</uni-forms-item>
</view>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='90'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='90' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit" v-if="!isPwoRoute">提交</u-button>
</view>
</template>
<script>
import {
listPwoJob,
addReport,
getEquipment,
addReportEnterPiece
} from "@/api/mes/jobReport.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
export default {
onLoad: function(option) {
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.formData.type = '合格品';
if (option) {
this.formData = JSON.parse(decodeURIComponent(option.formData));
this.isPwoRoute = true;
}
},
data() {
return {
isPwoRoute: false,
formData: {
pwoJobCode: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
pieceNo: null,
startTime: null,
endTime: null,
},
reportableNum: 0,
radio: 0,
pieceIn: [{
text: '是',
value: 1
},
{
text: '否',
value: 0
}
],
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
reportNumber: {
rules: [{
required: true,
errorMessage: '请输入报工数量!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
},
}
}
},
methods: {
submit() {
this.$refs.form.validate().then(res => {
//判断是否选择录入件号
if (this.radio == 1) {
//判断是否输入件号
if (this.formData.pieceNo && this.formData.pieceNo != "") {
this.$modal.loading('提交中')
addReportEnterPiece(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
this.$modal.msg("请输入件号!");
}
} else {
this.$modal.loading('提交中')
addReport(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
}
});
},
scanBarCode() {
if (this.formData.pwoJobCode) {
let obj = {
code: this.formData.pwoJobCode
}
listPwoJob(obj).then(async res => {
let jobs = res.rows;
if (jobs.length == 0) {
this.$modal.msg("未检索到该作业编码相关的信息!");
} else {
let job = jobs[0];
this.formData.pwoCode = job.pwoCode;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.reportableNum = job.targetNum - job.finishQty;
if (job.eqpId) {
await getEquipment(job.eqpId).then(res => {
console.log(res);
this.formData.machineId = res.data.equipmentCode;
})
//调取最后一条转入记录的操作人
let code = {
powJobCode: this.formData.pwoJobCode
}
listConversion(code).then(async res => {
if (res.rows[0].operateBy && res.rows[0].operateBy != "") {
this.formData.createByName = res.rows[0].operateBy;
let arry = {
name: this.formData.createByName
}
listEmployee(arry).then(async res => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
})
}
})
}
this.formData.batchNo = job.batchNo;
}
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
scanBarPieceNo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pieceNo = res.result;
}
});
}
}
}
</script>

View File

@@ -0,0 +1,710 @@
<template>
<view class="container">
<uni-segmented-control :current="current" :values="items" active-color="#2979FF" @clickItem="current = (current + 1) % 2" />
<t-gap />
<view v-if="current === 0" class="segmented-wrapper">
<uni-forms label-position="left" :label-width="75" label-align="right">
<uni-forms-item label="生产工单" name="pwoCode">
<uni-easyinput v-model="pwoCode" suffixIcon="scan" @iconClick="handleScanPwoCode" @confirm="fetchPwoJobList"
placeholder="请输入工单编码" />
</uni-forms-item>
<uni-forms-item label="产线" name="proLineId">
<uni-data-select v-model="proLineId" :localdata="proLineOptions" :disabled="!pwoCode"
@change="handleSelectProLine" :clear="false" placeholder="请选择产线" />
</uni-forms-item>
<uni-forms-item label="开始作业" name="startJobCode">
<uni-data-select v-model="startJobCode" :localdata="startJobOptions" :disabled="!pwoCode"
@change="handleJobChange($event, 'start')" :clear="false" placeholder="请选择开始作业" />
</uni-forms-item>
<uni-forms-item label="结束作业" name="endJobCode">
<uni-data-select v-model="endJobCode" :localdata="endJobOptions" :disabled="!pwoCode"
@change="handleJobChange($event, 'end')" :clear="false" placeholder="请选择结束作业" />
</uni-forms-item>
<uni-forms-item label="合格数量">
<uni-number-box v-model="mesJobReportOnceRequestDTO.pass.reportNumber" />
</uni-forms-item>
<uni-forms-item label="不良数量">
<uni-number-box v-model="mesJobReportOnceRequestDTO.defect.reportNumber" />
</uni-forms-item>
<uni-forms-item label="不良原因" v-if="mesJobReportOnceRequestDTO.defect.reportNumber">
<uni-data-checkbox v-model="mesJobReportOnceRequestDTO.defect.reason" :localdata="defectOptions"
placeholder="请选择不良原因" />
</uni-forms-item>
<uni-forms-item label="报废数量">
<uni-number-box v-model="mesJobReportOnceRequestDTO.scrap.reportNumber" />
</uni-forms-item>
<uni-forms-item label="报废原因" v-if="mesJobReportOnceRequestDTO.scrap.reportNumber">
<uni-data-checkbox v-model="mesJobReportOnceRequestDTO.scrap.reason" :localdata="scrapOptions"
placeholder="请选择报废原因" />
</uni-forms-item>
</uni-forms>
</view>
<view v-if="current === 1" class="segmented-wrapper">
<uni-card v-for="(item, index) in selectedJobs" :key="index">
<template #title>
<view class="header">
<view class="jobInfo">
<uni-tag :text="String(index + 1)" />
<text class="jobCode">
{{ item.pwoJobCode }}
</text>
<uni-tag :text="item.status" :type="item.labelStyle" />
</view>
</view>
</template>
<view class="card-list">
<view class="card-item">
<span class="card-item__label">目标产品编码</span>
<span class="card-item__value">{{ item.ptNoTar || '/' }}</span>
</view>
<view class="card-item">
<span class="card-item__label">目标产品名称</span>
<span class="card-item__value">{{ item.ptTitleTar || '/' }}</span>
</view>
<view class="card-item">
<span class="card-item__label">制程名称</span>
<span class="card-item__value">{{ item.opTitle || '/' }}</span>
</view>
</view>
<view class="card-data">
<view class="card-data-item">
<span class="card-data-item__label">完成数量</span>
<span class="card-data-item__value finish">
{{ typeof item.finishQty === 'number' ? item.finishQty : '/' }}
</span>
</view>
<view class="card-data-item">
<span class="card-data-item__label">目标数量</span>
<span class="card-data-item__value">
{{ typeof item.targetNum === 'number' ? item.targetNum : '/' }}
</span>
</view>
</view>
<template #actions>
<view class="actions">
<uni-forms-item label="加工人员" :labelWidth="80">
<uni-easyinput @change="validateEmpCode(index)"
v-model="item.createByCode">
<template #right>
<uni-tag :text="item.createByName" />
<uni-icons type="scan" size="30" @click="handleScanEmpCode(index)" />
</template>
</uni-easyinput>
</uni-forms-item>
</view>
</template>
</uni-card>
<u-empty v-if="selectedJobs.length == 0" mode="list" />
<view class="btns">
<u-button v-if="startJobCode && endJobCode" type="primary" @click="submit" class="pri-btn">提交</u-button>
</view>
</view>
</view>
</template>
<script>
import { getConfigKey } from '@/api/system/config';
import { listPwo } from '@/api/mes/pwo';
import {
listPwoJob,
addReport,
getEquipment,
addPipelineReport
} from "@/api/mes/jobReport";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn";
import { getDicts } from "@/api/system/dict/dictData";
import { listProLine } from "@/api/basic/proLine";
import { listEmployeeInProLines } from "@/api/basic/employee";
import { setProductionLine } from '@/api/mes/pwo';
export default {
data() {
return {
proLineEmployeeDataSet: 1,
empSelectOptions: [],
proLineMap: {},
items: ['报工信息', '作业列表'],
current: 0,
dataSet: null,
isCollapse: false,
pwoCode: null,
pwoId: null,
proLineId: null,
startJobCode: null,
endJobCode: null,
mesJobReportOnceRequestDTO: {
defect: { reportNumber: 0, reason: null },
loss: { reportNumber: 0, reason: null },
pass: { reportNumber: 0, reason: null },
scrap: { reportNumber: 0, reason: null }
},
rawList: [],
pwoJobList: [],
startJobOptions: [],
endJobOptions: [],
proLineOptions: [],
defectOptions: [],
scrapOptions: [],
statusMap: {},
selectedJobs: [],
startIndex: null,
endIndex: null,
}
},
async mounted() {
// 获取产线人员对应列表数据源
await getConfigKey('mes.proline-employee-dataset').then(res => {
this.proLineEmployeeDataSet = +res.msg;
});
// 获取产线列表
this.fetchProLineOptions();
// 获取作业状态列表
this.fetchJobStatusList();
// 获取不良原因列表
this.fetchDefectOptions();
// 获取产线人员对应列表
this.getEmpOptions();
console.log('PWO100022136');
},
methods: {
// 获取产线列表
fetchProLineOptions() {
this.$modal.loading('加载产线列表...');
listProLine().then(res => {
this.$modal.closeLoading();
res.rows
.filter(item => !item.delStatus)
.forEach(item => {
this.proLineOptions.push({
text: item.productLineTitle,
value: item.id,
proLineCode: item.productLineCode
})
})
}).catch(err => {
this.$modal.closeLoading();
this.$modal.alert('加载产线列表失败', err.msg || err);
})
},
// 获取作业状态列表
fetchJobStatusList() {
// this.$modal.loading('加载作业类型...');
getDicts('mes_job_status').then(res => {
// this.$modal.closeLoading();
res.data.forEach(item => {
this.statusMap[item.dictValue] = [item.dictLabel, item.listClass];
})
}).catch(err => {
// this.$modal.closeLoading();
this.$modal.alert('加载作业列表失败', err.msg || err);
})
},
// 获取不良原因列表
async fetchDefectOptions() {
try {
await getDicts("mes_job_report_defect").then(res => {
this.defectOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
await getDicts("mes_job_report_scrap").then(res => {
this.scrapOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
} catch (err) {
this.$modal.msgError('加载不良原因列表失败');
console.error(`加载不良原因列表失败:\n${err}`);
}
},
// 获取作业列表
async fetchPwoJobList() {
if (!this.pwoCode) return;
this.resetForm();
this.$modal.loading('获取工单信息...');
await listPwo({ pwoCode: this.pwoCode }).then(res => {
this.$modal.closeLoading();
if (res.total === 1) {
this.proLineId = res.rows[0].proLineId;
}
}).catch(err => {
this.$modal.closeLoading();
this.$modal.msgError('获取工单信息失败');
console.error(`获取工单信息失败:\n${err}`);
return;
})
this.$modal.loading('获取作业列表...');
await listPwoJob({
pwoCode: this.pwoCode
}).then(res => {
this.$modal.closeLoading();
this.rawList = res.rows;
this.pwoId = res.rows[0].pwoId;
res.rows.forEach((item, index) => {
this.isCollapse = true;
this.pwoJobList.push({
pwoJobCode: item.code,
status: this.statusMap[item.status][0],
labelStyle: this.statusMap[item.status][1] || 'default',
ptTitleTar: item.ptTitleTar,
ptNoTar: item.ptNoTar,
opTitle: item.opTitle,
targetNum: item.targetNum,
finishQty: item.finishQty,
createByCode: null
})
this.startJobOptions.push({
text: `${item.code}(${item.opTitle})`,
value: item.code,
disable: index === res.rows.length - 1
})
this.endJobOptions.push({
text: `${item.code}(${item.opTitle})`,
value: item.code,
disable: index === 0
})
})
}).catch(err => {
this.$modal.closeLoading();
console.log(err)
this.$modal.alert('获取作业列表失败', err.msg || err);
})
},
// 扫描工单编码
handleScanPwoCode() {
const _this = this;
this.$modal.scanCode((res) => {
if (!res.result) {
_this.$modal.msg('未扫描到有效值,请重试');
return;
}
_this.pwoCode = res.result;
_this.fetchPwoJobList();
});
},
// 扫描员工编码
handleScanEmpCode(index) {
const _this = this;
this.$modal.scanCode((res) => {
if (!res.result) {
_this.$modal.msg('未扫描到有效值,请重试');
return;
}
_this.selectedJobs[index].createByCode = res.result;
_this.validateEmpCode(index);
});
},
// 绑定产线
async handleSelectProLine(e) {
if (!e) return;
await setProductionLine({
pwoId: [this.pwoId],
productionLineId: this.proLineId
}).then((res) => {
if (res.code == 200) {
this.$modal.msgSuccess("绑定成功");
}
}).catch(err => {
console.error(`绑定失败:${err.msg}`);
this.proLineId = null;
});
this.renderEmpInProLine();
},
// 根据产线人员对应关系填写人员编码
async renderEmpInProLine() {
let proLineChildren = this.proLineMap[this.proLineId];
proLineChildren = [];
if (this.proLineEmployeeDataSet === 0) {
console.log(this.empSelectOptions)
this.empSelectOptions
.find(item => item.proLineId == this.proLineId)?.children
.forEach(item => {
proLineChildren.push({
name: item.empName,
empId: item.value,
empCode: item.empCode,
lineNum: item.serialNum,
});
})
} else {
await listProductLineEmployee(this.proLineId).then((res) => {
res.rows.forEach(item => {
proLineChildren.push({
name: item.employeeName,
empId: item.employeeId,
empCode: item.employeeCode,
lineNum: item.serialNum,
});
});
})
}
console.log(proLineChildren);
this.selectedJobs.forEach((job, index) => {
const emp = proLineChildren.find(item => item.lineNum == index + 1);
const empName = emp?.name;
const empCode = emp?.empCode;
const empId = emp?.empId;
this.$set(job, 'createByCode', empCode || null);
this.$set(job, 'createByName', empName || null);
this.$set(job, 'createById', empId || null);
console.log(`${index + 1}个作业的员工名称为${empName}id为${empId}`);
})
},
// 获取产线人员对应关系
async getEmpOptions() {
// 一人员一产线
if (this.proLineEmployeeDataSet === 1) {
const proLineMap = new Map(); // 用于存储产线信息
await listProLine().then((res) => {
res.rows.forEach(item => {
const { id, productLineTitle } = item;
// 如果产线不存在,初始化产线
proLineMap.set(id, {
proLineId: id,
label: productLineTitle,
children: []
});
})
})
await listEmployee().then((res) => {
res.rows.forEach(item => {
const { empCode, name, proLineId,id } = item;
// 添加员工到对应产线
if (proLineId) {
proLineMap.get(proLineId).children.push({
value: id,
label: empCode + ': ' + name,
empId: id,
empName: name,
empCode: empCode
});
}
});
});
// 将Map转换为数组
this.empSelectOptions = Array.from(proLineMap.values());
} else {
// 一人员多产线
listEmployeeInProLines().then(res => {
if (!res.data) return;
res.data.forEach(proLine => {
const children = proLine.employees.map(emp => {
return {
value: emp.id,
label: emp.employeeCode + ': ' + emp.employeeName,
empId: emp.id,
empName: emp.employeeName,
empCode: emp.employeeCode,
serialNum: emp.serialNum
}
})
this.empSelectOptions.push({
proLineId: proLine.id,
label: proLine.productLineTitle,
children
})
})
})
}
},
// 校验员工编码
validateEmpCode(index) {
if (!this.selectedJobs[index].createByCode) return;
listEmployee({
empCode: this.selectedJobs[index].createByCode
}).then(res => {
if (res.total === 0) {
this.$modal.msgError(`员工不存在,请重新输入!`);
this.selectedJobs[index].createByCode = null;
} else if (res.total > 1) {
this.$modal.msgError(`员工编码异常,请联系管理员!`);
this.selectedJobs[index].createByCode = null;
} else {
this.selectedJobs[index].createByName = res.rows[0].name;
this.selectedJobs[index].createById = res.rows[0].id;
}
}).catch(err => {
this.$modal.msgError(`校验失败,请重试!\n${err}`);
this.selectedJobs[index].createByCode = null;
})
},
// 重置表单
resetForm() {
this.isCollapse = false;
this.proLineId = null;
this.startJobCode = null;
this.endJobCode = null;
this.mesJobReportOnceRequestDTO = {
defect: { reportNumber: 0, reason: null },
loss: { reportNumber: 0, reason: null },
pass: { reportNumber: 0, reason: null },
scrap: { reportNumber: 0, reason: null }
};
this.pwoJobList = [];
this.startJobOptions = [];
this.endJobOptions = [];
this.selectedJobs = [];
this.startIndex = null;
this.endIndex = null;
},
// 校验表单
async validateForm() {
try {
if (!this.pwoCode) throw new Error("请填写工单编码");
if (!this.startJobCode) throw new Error("请选择起始作业");
if (!this.endJobCode) throw new Error("请选择结束作业");
if (!this.proLineId) {
await this.$modal.confirm('未选择产线,是否继续提交').then(res => {
if (res.cancel) {
throw new Error("取消提交");
}
})
}
// 校验报工数量
let hasReport = false;
for (const key in this.mesJobReportOnceRequestDTO) {
const item = this.mesJobReportOnceRequestDTO[key];
const { reportNumber, reason } = item;
if (reportNumber !== 0) {
hasReport = true;
}
// 除了 pass数量不为0 且 原因为空时抛错
if (key !== "pass" && reportNumber !== 0 && (reason == null || reason === "")) {
throw new Error("请选择不良原因");
}
}
if (!hasReport) {
throw new Error("请填写报工数量");
}
this.selectedJobs.forEach((item, index) => {
if (!item.createByCode) {
throw new Error(`请填写第 ${index + 1} 条作业的加工人员`);
}
})
return true;
} catch (err) {
this.$modal.msg(String(err).replace('Error: ', ''));
console.error(`表单校验失败:\n${err}`);
return false;
}
},
// 切换作业
handleJobChange(e, type) {
if (!e) return;
switch (type) {
case 'start':
this.startIndex = this.pwoJobList.findIndex(item => item.pwoJobCode === e);
this.endJobOptions.forEach((job, i) => {
job.disable = i <= this.startIndex;
})
break;
case 'end':
this.endIndex = this.pwoJobList.findIndex(item => item.pwoJobCode === e);
this.startJobOptions.forEach((job, i) => {
job.disable = i >= this.endIndex;
})
break;
}
this.selectedJobs = [];
if (typeof this.startIndex === 'number' && typeof this.endIndex === 'number') {
this.selectedJobs = this.pwoJobList.slice(this.startIndex, this.endIndex + 1);
}
this.renderEmpInProLine();
},
// 提交
async submit() {
const res = await this.validateForm();
if (!res) return;
const submitList = this.rawList.slice(this.startIndex, this.endIndex + 1)
this.selectedJobs.forEach((item, index) => {
submitList[this.startIndex + index] = Object.assign({}, submitList[this.startIndex + index], item);
})
const data = {
reasonFrom: "0",
endTime: this.$time.getTime(),
endPwoJobId: this.rawList[this.endIndex].id,
startPwoJobId: this.rawList[this.startIndex].id,
productLineId: this.proLineId,
mesJobReportList: submitList,
mesJobReportOnceRequestDTO: this.mesJobReportOnceRequestDTO
}
addPipelineReport(data).then(() => {
this.$modal.msgSuccess('提交成功');
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 1000);
}).catch(err => {
this.$modal.alert('提交失败', err.msg);
console.error(`提交失败:\n${err}`);
})
}
}
}
</script>
<style scoped lang="scss">
.container {
/* #ifdef H5 */
height: calc(100vh - 44px);
/* #endif */
/* #ifndef H5 */
height: 100vh;
/* #endif */
padding: 10px;
display: flex;
flex-direction: column;
.card-list__title {
background: transparent;
border-top: 1px solid #d9d9d9;
margin-top: 5px;
}
.segmented-wrapper {
flex: 1;
overflow: scroll;
.u-empty {
height: 100%;
}
}
.uni-card {
margin: 0 0 10px !important;
padding: 0 !important;
box-shadow: none !important;
border-radius: 11px;
.header {
display: flex;
align-items: center;
padding: 8px;
border-bottom: 1px solid #d9d9d9;
.jobInfo {
display: flex;
align-items: center;
flex: 1;
.jobCode {
font-size: 16px;
font-weight: bold;
flex: 1;
}
.uni-tag {
box-sizing: border-box;
height: 100%;
text-align: center;
margin-right: 8px;
}
}
}
.card-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 4px;
.card-item {
display: flex;
flex-direction: column;
align-items: flex-start;
.card-item__label {
font-size: 13px;
}
.card-item__value {
font-weight: bold;
font-size: 15px;
color: #333;
}
}
}
.card-data {
display: flex;
margin-top: 10px;
background-color: #f1f1f1;
border-radius: 4px;
padding: 6px 0;
.card-data-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.card-data-item__label {
font-size: 13px;
}
.card-data-item__value {
font-weight: bold;
font-size: 15px;
color: #333;
&.finish {
color: #059669;
}
}
}
}
.actions {
padding: 0 10px;
}
}
.btns {
padding-top: 5px;
}
}
::v-deep .uni-numbox__value {
flex: 1;
height: 36px;
}
::v-deep .uni-forms-item.is-direction-left {
align-items: baseline;
}
</style>

View File

@@ -0,0 +1,445 @@
<template>
<view style="background-color: #fff;">
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="工单编码" :labelWidth='100' name="pwoCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoCode"
@blur="scanBarCode" :key="input.boolean" :focus='true' />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='100' name="pwoJobCode">
<uni-data-select :localdata="formData.pwoJobs" v-model="formData.pwoJobCode"
@change="getJobInfo"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='100' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='100' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='100' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='100' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程编码" :labelWidth='100' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程名称" :labelWidth='100' name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="用时(h)" :labelWidth='100' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='100' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @blur="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='100' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
<u-divider :text="'可报工数量:'+reportableNum"></u-divider>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="合格数量" :labelWidth='100' name="pass">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.pass.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良数量" :labelWidth='100' name="defect">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.defect.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良原因" :labelWidth='100' name="defectReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['defect'].reason"
:localdata="defectReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废数量" :labelWidth='100' name="scrap">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.scrap.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废原因" :labelWidth='100' name="scrapReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['scrap'].reason"
:localdata="scrapReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗数量" :labelWidth='100' name="loss">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.loss.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗原因" :labelWidth='100' name="lossReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['loss'].reason"
:localdata="lossReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='100'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='100' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="备注" :labelWidth='100' name="remark">
<uni-easyinput autoHeight type="textarea" v-model="formData.remark"></uni-easyinput>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
<!-- <u-button type="primary" @click="end">关闭</u-button> -->
</view>
</template>
<script>
import {
listPwoJob,
addReport,
getEquipment,
addReportOnce
} from "@/api/mes/jobReport.js";
import { listPwoJobLike } from "@/api/mes/pwoIn.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
import { getDicts } from "@/api/system/dict/dictData.js";
import { login } from "../../../api/login";
// const serialPort = uni.requireNativePlugin('Fvv-UniSerialPort')
export default {
data() {
return {
input: {
boolean: 0,
inputValue: '',
},
//判断是否从工单状态页面查询过来
isSearchRoute: false,
lossReasonOptions: [],
scrapReasonOptions: [],
defectReasonOptions: [],
formData: {
pwoJobCode: null,
pwoJobs: [],
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
opTitle: null,
opCode: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
remark: null,
mesJobReportOnceRequestDTO: {
pass: {
reportNumber: 0,
reason: null
},
defect: {
reportNumber: 0,
reason: null
},
scrap: {
reportNumber: 0,
reason: null
},
loss: {
reportNumber: 0,
reason: null
}
},
startTime: null,
endTime: null,
},
reportableNum: 0,
rules: {
pwoCode: {
rules: [{
required: true,
errorMessage: '请输入工单编码!'
}]
},
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请选择作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
}
}
}
},
methods: {
test() {
serialPort.sendHex("A00102A3")
},
end() {
serialPort.sendHex("A00100A1")
},
getOptions() {
getDicts("mes_job_report_defect").then(res => {
this.defectReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
getDicts("mes_job_report_scrap").then(res => {
this.scrapReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
getDicts("mes_job_report_loss").then(res => {
this.lossReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
},
submit() {
if (this.sumReportNum() <= 0 || this.sumReportNum() > this.reportableNum) {
this.$modal.showToast("请重新检查报工数量")
return
}
this.$refs.form.validate().then(res => {
this.$modal.loading('提交中')
addReportOnce(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
if (this.isSearchRoute = true) {
setTimeout(() => {
this.$tab.navigateBack();
}, 500);
} else {
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
}
})
})
},
sumReportNum() {
const sum = ['pass', 'defect', 'scrap', 'loss'].reduce((total, key) => {
const value = Number(this.formData.mesJobReportOnceRequestDTO[key].reportNumber)
this.formData.mesJobReportOnceRequestDTO[key].reportNumber = value
return total + value
}, 0)
return sum
},
scanBarCode() {
if (this.formData.pwoCode) {
this.formData.pwoJobs = []
this.formData.pwoJobCode = null
this.clearJobInfo()
listPwoJob({
pwoCode: this.formData.pwoCode
}).then((res) => {
if (res.rows.length > 0) {
this.$set(this.formData, "pwoJobs", res.rows.map(item => ({
text: item.code + ":" + item.opTitle,
value: item.code,
disabled: false
})))
console.log(this.formData.pwoJobs)
} else {
this.$modal.showToast("未查询到该工单编码")
}
})
}
},
clearJobInfo() {
this.reportableNum = 0
const resetFields = [
"ptNoTar", "ptTitleTar", "batchNo",
"createByName", "createByCode", "createById", "remark", "startTime",
"machineId", "opCode", "opTitle"
]
// 重置表单信息
resetFields.forEach(field => {
this.$set(this.formData, field, null)
})
// 重置报工数量
Object.keys(this.formData.mesJobReportOnceRequestDTO).forEach(key => {
const item = this.formData.mesJobReportOnceRequestDTO[key];
this.$set(item, 'reportNumber', 0);
this.$set(item, 'reason', null);
});
},
async getJobInfo(e) {
this.formData.pwoJobCode = e
if (this.formData.pwoJobCode) {
this.clearJobInfo()
await listPwoJob({
code: this.formData.pwoJobCode
}).then(async res => {
this.formData.ptNoTar = res.rows[0].ptNoTar
this.formData.ptTitleTar = res.rows[0].ptTitleTar
this.formData.opCode = res.rows[0].opCode
this.formData.opTitle = res.rows[0].opTitle
this.formData.batchNo = res.rows[0].batchNo
this.reportableNum = res.rows[0].targetNum - res.rows[0].finishQty
await listPwoJobLike({
code: this.formData.pwoJobCode
}).then(res => {
this.formData.eqpId = res.rows[0].eqpId
})
if (this.formData.eqpId) {
getEquipment(this.formData.eqpId).then(res => {
this.formData.machineId = res.data.equipmentCode
}).catch(() => {
this.$modal.showToast("获取设备编号失败")
})
}
}).catch(() => {
this.$modal.showToast("获取作业信息失败!")
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoCode = res.result;
_this.scanBarCode();
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
/**
* 隐藏软键盘
*/
focus() {
uni.hideKeyboard()
},
/**
* 不让手动输入
* @param {Object} value
handleInput(value) {
const {
inputValue
} = this.input
if (value.length - inputValue.length == 1 || inputValue.length - value.length == 1) {
this.$modal.msg("请扫描")
this.formData.pwoJobCode = null
this.input.inputValue = value
this.input.boolean = this.input.boolean == 0 ? 10 : 0
return
}
this.input.inputValue = value
}*/
},
onLoad: function(option) {
if (option.pwoCode) {
this.isSearchRoute = true;
this.formData.pwoCode = option.pwoCode;
this.scanBarCode();
}
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.getOptions();
}
}
</script>

View File

@@ -0,0 +1,345 @@
<template>
<view>
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth='80' name="pwoJobCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanBar" type="text" v-model="formData.pwoJobCode"
@confirm="scanBarCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单" :labelWidth='80' name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='80' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='80' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='80' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='80' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程编码" :labelWidth='80' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="制程名称" :labelWidth='80' name="opTitle">
<uni-easyinput disabled disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="用时(s)" :labelWidth='80' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="报工类型" :labelWidth='80' name="type">
<uni-easyinput disabled disabled type="text" v-model="formData.type" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报工数量" :labelWidth='80' name="reportNumber">
<uni-easyinput type="number" :placeholder="'可报工数量:'+reportableNum" v-model="formData.reportNumber" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废原因" :labelWidth='80' name="reason">
<uni-data-select v-model="formData.reason" :localdata="reasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='80' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @confirm="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='80' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="是否录入件号" :labelWidth='120'>
<uni-data-checkbox v-model="radio" :localdata="pieceIn"></uni-data-checkbox>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<view v-show="radio==1">
<uni-forms-item label="件号" :labelWidth='80' name="pieceNo">
<uni-easyinput suffixIcon="scan" @iconClick="scanBarPieceNo" type="text" v-model="formData.pieceNo" />
</uni-forms-item>
</view>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='90'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='90' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit" v-if="!isPwoRoute">提交</u-button>
</view>
</template>
<script>
import {
listPwoJob,
addReport,
getEquipment,
addReportEnterPiece
} from "@/api/mes/jobReport.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
import { getDicts } from "@/api/system/dict/dictData.js";
export default {
onLoad: function(option) {
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.formData.type = '报废品';
if (option) {
this.formData = JSON.parse(decodeURIComponent(option.formData));
this.isPwoRoute = true;
}
getDicts("mes_job_report_scrap").then(res => {
this.reasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
// this.formData.createByName = this.$store.state.user.name;
},
data() {
return {
isPwoRoute: false,
reasonOptions: [],
formData: {
pwoJobCode: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
pieceNo: null,
startTime: null,
endTime: null,
},
reportableNum: 0,
radio: 0,
pieceIn: [{
text: '是',
value: 1
},
{
text: '否',
value: 0
}
],
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
reportNumber: {
rules: [{
required: true,
errorMessage: '请输入报工数量!'
}]
},
reason: {
rules: [{
required: true,
errorMessage: '请输入不良原因!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
},
// machineId: {
// rules: [
// { required: true, errorMessage:'请输入设备编码!' }
// ]
// },
}
}
},
methods: {
submit() {
this.$refs.form.validate().then(res => {
//判断是否选择录入件号
if (this.radio == 1) {
//判断是否输入件号
if (this.formData.pieceNo && this.formData.pieceNo != "") {
this.$modal.loading('提交中')
addReportEnterPiece(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
} else {
this.$modal.msg("请输入件号!");
}
} else {
this.$modal.loading('提交中')
addReport(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
})
}
})
},
scanBarCode() {
if (this.formData.pwoJobCode) {
let obj = {
code: this.formData.pwoJobCode
}
listPwoJob(obj).then(async res => {
let jobs = res.rows;
if (jobs.length == 0) {
this.$modal.msg("未检索到该作业编码相关的信息!");
} else {
let job = jobs[0];
console.log(job);
this.formData.pwoCode = job.pwoCode;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.reportableNum = job.targetNum - job.finishQty;
if (job.eqpId) {
await getEquipment(job.eqpId).then(res => {
console.log(res);
this.formData.machineId = res.data.equipmentCode;
})
//调取最后一条转入记录的操作人
let code = {
powJobCode: this.formData.pwoJobCode
}
listConversion(code).then(async res => {
if (res.rows[0].operateBy && res.rows[0].operateBy != "") {
this.formData.createByName = res.rows[0].operateBy;
let arry = {
name: this.formData.createByName
}
listEmployee(arry).then(async res => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
})
}
})
}
this.formData.batchNo = job.batchNo;
console.log(this.formData);
}
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
scanBarPieceNo() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pieceNo = res.result;
}
});
}
}
}
</script>

View File

@@ -0,0 +1,535 @@
<template>
<view style="background-color: #fff;">
<uni-forms ref="form" :modelValue="formData" :rules="rules">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="班产任务编码" :label-width='120' name="taskCode">
<uni-easyinput suffixIcon="scan" @iconClick="scanTaskCode" type="text" v-model="formData.taskCode"
@blur="scanBarTaskCode" :key="input.boolean" :focus='true' />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单编码" :labelWidth='120' name="pwoCode">
<uni-easyinput type="text" v-model="formData.pwoCode" disabled />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="班产作业编码" :labelWidth='120' name="shiftJobCode">
<uni-data-select :localdata="formData.shiftJobs" v-model="formData.shiftJobCode"
@change="getShiftJobInfo"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="工单作业编码" :labelWidth='120' name="pwoJobCode">
<uni-easyinput v-model="formData.pwoJobCode" disabled />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth='120' name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth='120' name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="规格" :labelWidth='50' name="specification1">
<uni-easyinput disabled type="text" v-model="formData.specification1" />
</uni-forms-item>
</uni-col>
<uni-col :span="12">
<uni-forms-item label="材质" :labelWidth='50' name="texture">
<uni-easyinput disabled type="text" v-model="formData.texture" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="设备编号" :labelWidth='120' name="machineId">
<uni-easyinput disabled type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth='120' name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程编码" :labelWidth='120' name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程名称" :labelWidth='120' name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="用时(h)" :labelWidth='120' name="timeTake">
<uni-easyinput type="number" v-model="formData.timeTake" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工编码" :labelWidth='120' name="createByCode">
<uni-easyinput type="text" suffixIcon="scan" @iconClick="scanBar1" @blur="scanBarCreateBy"
v-model="formData.createByCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="生产员工" :labelWidth='120' name="createByName">
<uni-easyinput disabled type="text" v-model="formData.createByName" />
</uni-forms-item>
<u-divider :text="'可报工数量:'+reportableNum"></u-divider>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="合格数量" :labelWidth='100' name="pass">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.pass.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良数量" :labelWidth='100' name="defect">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.defect.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="不良原因" :labelWidth='100' name="defectReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['defect'].reason"
:localdata="defectReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废数量" :labelWidth='100' name="scrap">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.scrap.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="报废原因" :labelWidth='100' name="scrapReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['scrap'].reason"
:localdata="scrapReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗数量" :labelWidth='100' name="loss">
<u-number-box button-size="36" inputWidth="120"
v-model="formData.mesJobReportOnceRequestDTO.loss.reportNumber" min="0"></u-number-box>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="损耗原因" :labelWidth='100' name="lossReason">
<uni-data-select v-model="formData.mesJobReportOnceRequestDTO['loss'].reason"
:localdata="lossReasonOptions"></uni-data-select>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth='100'>
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="完工时间" :labelWidth='100' name="endTime">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.endTime" />
</view>
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="备注" :labelWidth='100' name="remark">
<uni-easyinput autoHeight type="textarea" v-model="formData.remark"></uni-easyinput>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">提交</u-button>
<!-- <u-button type="primary" @click="end">关闭</u-button> -->
</view>
</template>
<script>
import {
listPwoJob,
addReportOnce
} from "@/api/mes/jobReport.js";
import {
getEquipment
} from "@/api/mes/jobIn.js";
import {
listPwoJobLike
} from "@/api/mes/pwoIn.js";
import {
listShiftTask
} from "@/api/mes/shiftTask.js";
import {
listShiftJobWithAssociatedData,
getShiftJobByShiftJobCode
} from "@/api/mes/shiftJob.js";
import {
listMaterial
} from "@/api/mes/material.js";
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from "@/api/mes/jobIn.js";
import {
getDicts
} from "@/api/system/dict/dictData.js";
import {
login
} from "../../../api/login";
// const serialPort = uni.requireNativePlugin('Fvv-UniSerialPort')
export default {
data() {
return {
input: {
boolean: 0,
inputValue: '',
},
//判断是否从工单状态页面查询过来
isSearchRoute: false,
lossReasonOptions: [],
scrapReasonOptions: [],
defectReasonOptions: [],
formData: {
taskCode: null,
shiftJobCode: null,
pwoJobCode: null,
shiftJobs: [],
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
eqpId: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
remark: null,
mesJobReportOnceRequestDTO: {
pass: {
reportNumber: 0,
reason: null
},
defect: {
reportNumber: 0,
reason: null
},
scrap: {
reportNumber: 0,
reason: null
},
loss: {
reportNumber: 0,
reason: null
}
},
startTime: null,
endTime: null,
specification1: null,
jobType: 1,
texture: null,
opCode: null,
opTitle: null
},
reportableNum: 0,
rules: {
taskCode: {
rules: [{
required: true,
errorMessage: '请输入班产任务编码!'
}]
},
pwoCode: {
rules: [{
required: true,
errorMessage: '请输入工单编码!'
}]
},
shiftJobCode: {
rules: [{
required: true,
errorMessage: '请选择班产作业编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
endTime: {
rules: [{
required: true,
errorMessage: '请输入完工时间!'
}]
}
}
}
},
methods: {
getOptions() {
getDicts("mes_job_report_defect").then(res => {
this.defectReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
getDicts("mes_job_report_scrap").then(res => {
this.scrapReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
getDicts("mes_job_report_loss").then(res => {
this.lossReasonOptions = res.data.map(dict => {
return {
text: dict.dictLabel,
value: dict.dictValue,
diasble: false
}
});
})
},
submit() {
if (this.sumReportNum() <= 0 || this.sumReportNum() > this.reportableNum) {
this.$modal.showToast("请重新检查报工数量")
return
}
this.$refs.form.validate().then(res => {
this.$modal.loading('提交中')
addReportOnce(this.formData).then(res => {
this.$modal.closeLoading();
this.$modal.msgSuccess("报工成功!");
if (this.isSearchRoute = true) {
setTimeout(() => {
this.$tab.navigateBack();
}, 500);
} else {
setTimeout(() => {
this.$tab.switchTab("/pages/work/index");
}, 500);
}
})
})
},
sumReportNum() {
const sum = ['pass', 'defect', 'scrap', 'loss'].reduce((total, key) => {
const value = Number(this.formData.mesJobReportOnceRequestDTO[key].reportNumber)
this.formData.mesJobReportOnceRequestDTO[key].reportNumber = value
return total + value
}, 0)
return sum
},
scanBarPwoCode() {
this.formData.shiftJobs = []
if (this.formData.pwoCode) {
listShiftJobWithAssociatedData({
pwoCode: this.formData.pwoCode
}).then((res) => {
if (res.rows.length > 0) {
this.$set(this.formData, "shiftJobs", res.rows.map(item => ({
text: item.shiftJobCode + ":" + item.opTitle,
value: item.shiftJobCode,
disabled: false
})))
console.log(this.formData.shiftJobs)
} else {
this.$modal.showToast("未查询到该工单编码")
}
})
}
},
clearJobInfo() {
this.reportableNum = 0
const resetFields = [
"ptNoTar", "ptTitleTar", "eqpId", "batchNo",
"createByName", "createByCode", "createById", "remark", "startTime",
"texture", "specification1", "machineId", "pwoJobCode",
"opCode", "opTitle"
]
// 重置表单信息
resetFields.forEach(field => {
this.$set(this.formData, field, null)
})
// 重置报工数量
Object.keys(this.formData.mesJobReportOnceRequestDTO).forEach(key => {
const item = this.formData.mesJobReportOnceRequestDTO[key];
this.$set(item, 'reportNumber', 0);
this.$set(item, 'reason', null);
});
},
async getShiftJobInfo(e) {
this.formData.shiftJobCode = e
if (this.formData.shiftJobCode) {
this.clearJobInfo()
await getShiftJobByShiftJobCode(this.formData.shiftJobCode).then(async res => {
this.formData.pwoJobCode = res.data.code
this.formData.ptNoTar = res.data.ptNoTar
this.formData.ptTitleTar = res.data.ptTitleTar
this.formData.opCode = res.data.opCode
this.formData.opTitle = res.data.opTitle
this.formData.batchNo = res.data.batchNo
this.reportableNum = res.data.targetNum - res.data.finishQty
await listPwoJobLike({
code: this.formData.pwoJobCode
}).then(resp => {
this.formData.eqpId = resp.rows[0].eqpId
})
if (this.formData.eqpId) {
getEquipment(this.formData.eqpId).then(res => {
this.formData.machineId = res.data.equipmentCode
}).catch(() => {
this.$modal.showToast("获取设备编号失败")
})
}
if (res.data.ptNoTar) {
listMaterial({
materialCode: res.data.ptNoTar
}).then(resp => {
if (resp.rows.length > 0) {
if (resp.rows[0].specification1) this.formData.specification1 =
resp.rows[0].specification1
if (resp.rows[0].texture) this.formData.texture = resp.rows[0]
.texture
// this.formData.specification1 = resp.rows[0].specification1 ?
// resp.rows[0].specification1 : ''
// this.formData.texture = resp.rows[0].texture ? res.rows[0]
// .texture : ''
}
}).catch(() => {
this.$modal.showToast("查询产品规格/材质信息失败!")
})
}
}).catch(() => {
this.$modal.showToast("获取作业信息失败!")
})
}
},
scanBarCreateBy() {
if (this.formData.createByCode) {
let obj = {
empCode: this.formData.createByCode
}
listEmployee(obj).then(async res => {
if (res.rows.length != 0) {
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
} else {
this.$modal.msg("未查询到该人员信息!");
}
});
}
},
scanBar() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoCode = res.result;
_this.scanBarCode();
}
});
},
scanBar1() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.scanBarCreateBy();
}
});
},
scanTaskCode() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.taskCode = res.result
_this.scanBarTaskCode()
}
});
},
scanBarTaskCode() {
console.log(this.formData.taskCode)
if (this.formData.taskCode) {
this.formData.pwoCode = null
this.formData.shiftJobCode = null
this.formData.shiftJobs = []
this.clearJobInfo()
listShiftTask({
// taskCode: "ST000003017"
taskCode: this.formData.taskCode
}).then((res) => {
this.formData.pwoCode = res.rows[0].pwoCode
this.scanBarPwoCode()
}).catch(() => {
this.$modal.showToast("获取工单编码失败")
})
}
},
/**
* 隐藏软键盘
*/
focus() {
uni.hideKeyboard()
},
/**
* 不让手动输入
* @param {Object} value
handleInput(value) {
const {
inputValue
} = this.input
if (value.length - inputValue.length == 1 || inputValue.length - value.length == 1) {
this.$modal.msg("请扫描")
this.formData.pwoJobCode = null
this.input.inputValue = value
this.input.boolean = this.input.boolean == 0 ? 10 : 0
return
}
this.input.inputValue = value
}*/
},
onLoad: function(option) {
if (option.taskCode) {
this.isSearchRoute = true;
this.formData.taskCode = option.taskCode;
this.scanTaskCode();
}
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ("0" + (currentDate.getMonth() + 1)).slice(-2);
var day = ("0" + currentDate.getDate()).slice(-2);
var hours = ("0" + currentDate.getHours()).slice(-2);
var minutes = ("0" + currentDate.getMinutes()).slice(-2);
var seconds = ("0" + currentDate.getSeconds()).slice(-2);
var formattedDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
// 将当前时间赋值给 formData.endTime
this.formData.endTime = formattedDate;
this.formData.way = '人工报工';
this.getOptions();
// this.formData.type = '报废品';
// this.formData.createByName = this.$store.state.user.name;
}
}
</script>

View File

@@ -0,0 +1,292 @@
<template>
<view style="background-color: #fff">
<uni-forms ref="form" :modelValue="formData" :rules="rules" label-align="right">
<uni-row>
<uni-col :span="24">
<uni-forms-item label="作业编码" :labelWidth="90" name="pwoJobCode" required>
<uni-easyinput suffixIcon="scan" @iconClick="scanJob" type="text" v-model="formData.pwoJobCode"
@confirm="getJobInfo" focus />
</uni-forms-item>
</uni-col>
<uni-col :span="18">
<uni-forms-item label="员工编码" :labelWidth="90" name="createByCode" required>
<uni-easyinput type="text" @confirm="getEmpInfo" v-model="formData.createByCode" />
<!-- <uni-easyinput type="text" suffixIcon="scan" @iconClick="scanEmp" @confirm="getEmpInfo"
v-model="formData.createByCode" /> -->
</uni-forms-item>
</uni-col>
<uni-col :span="6">
<uni-easyinput disabled type="text" v-model="formData.createByName || '/'" />
</uni-col>
<uni-col :span="18">
<uni-forms-item label="设备编码" :labelWidth="90" name="machineId" required>
<uni-easyinput type="text" v-model="formData.machineId" />
</uni-forms-item>
</uni-col>
<uni-col :span="6">
<u-button style="height: 37px;" @click="handleBindEqp" text="绑定设备"
:disabled="!formData.pwoJobCode || !formData.machineId" />
</uni-col>
<uni-col :span="24">
<u-divider />
<uni-forms-item label="工单编码" :labelWidth="90" name="pwoCode">
<uni-easyinput disabled type="text" v-model="formData.pwoCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品编码" :labelWidth="90" name="ptNoTar">
<uni-easyinput disabled type="text" v-model="formData.ptNoTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="产品名称" :labelWidth="90" name="ptTitleTar">
<uni-easyinput disabled type="text" v-model="formData.ptTitleTar" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="批号" :labelWidth="90" name="batchNo">
<uni-easyinput disabled type="text" v-model="formData.batchNo" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程编码" :labelWidth="90" name="opCode">
<uni-easyinput disabled type="text" v-model="formData.opCode" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
<uni-forms-item label="制程名称" :labelWidth="90" name="opTitle">
<uni-easyinput disabled type="text" v-model="formData.opTitle" />
</uni-forms-item>
</uni-col>
<uni-col :span="24">
</uni-col>
<uni-col :span="24">
<uni-forms-item label="开工时间" :labelWidth="90">
<view class="example-body">
<uni-datetime-picker type="datetime" v-model="formData.startTime" :disabled="!checkPermi(['mes:jobStartRecord:edit'])" />
</view>
</uni-forms-item>
</uni-col>
</uni-row>
</uni-forms>
<u-button type="primary" @click="submit">开工</u-button>
</view>
</template>
<script>
import {
addStart,
listPwoJob,
updatePwoJob,
getEquipment,
listEquipment
} from '@/api/mes/jobReport.js';
import {
listEmpEqpHistory,
listEmployee,
listConversion
} from '@/api/mes/jobIn.js';
import { getConfigKey } from '@/api/system/config.js';
import { checkPermi } from "@/utils/permission";
export default {
data() {
return {
timer: null,
formData: {
pwoJobCode: null,
pwoJobId: null,
pwoCode: null,
ptNoTar: null,
ptTitleTar: null,
machineId: null,
batchNo: null,
createByName: null,
createByCode: null,
createById: null,
startTime: null,
},
rules: {
pwoJobCode: {
rules: [{
required: true,
errorMessage: '请输入作业编码!'
}]
},
machineId: {
rules: [{
required: true,
errorMessage: '请输入设备编码!'
}]
},
createByCode: {
rules: [{
required: true,
errorMessage: '请输入生产员工编码!'
}]
},
startTime: {
rules: [{
required: true,
errorMessage: '请输入开工时间!'
}]
}
}
};
},
created() {
this.timer = setInterval(() => {
this.renderStartTime();
}, 1000);
},
methods: {
checkPermi,
renderStartTime() {
// 获取当前时间
var currentDate = new Date();
// 格式化为字符串YYYY-MM-DD HH:mm:ss
var year = currentDate.getFullYear();
var month = ('0' + (currentDate.getMonth() + 1)).slice(-2);
var day = ('0' + currentDate.getDate()).slice(-2);
var hours = ('0' + currentDate.getHours()).slice(-2);
var minutes = ('0' + currentDate.getMinutes()).slice(-2);
var seconds = ('0' + currentDate.getSeconds()).slice(-2);
var formattedDate = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
// 将当前时间赋值给 formData.startTime
this.formData.startTime = formattedDate;
},
async handleRenderEmp() {
if(!this.formData.machineId) return;
const { rows, total } = await listEmpEqpHistory({ equipmentCode: this.formData.machineId });
const emp = rows.filter(item => !item.endTime)?.[0];
if(!emp || !total > 0) return this.$modal.msg('该设备下没有绑定人员');
this.formData.createByCode = rows[0].empCode || '';
this.formData.createByName = rows[0].empName || '';
this.formData.createById = rows[0].empId || '';
},
// 绑定设备
async handleBindEqp() {
let eqpId = '';
this.$modal.loading('绑定中');
try {
const { rows, total } = await listEquipment({ equipmentCode: this.formData.machineId });
if(total == 1) {
eqpId = rows[0].id;
} else {
this.$modal.msg('未检索到该设备编码相关的信息!');
return;
}
await updatePwoJob({
id: this.formData.pwoJobId,
eqpId
});
this.$modal.msgSuccess("绑定成功!");
this.handleRenderEmp();
} catch (err) {
console.log(err);
this.$modal.msgError('绑定失败!');
} finally {
this.$modal.closeLoading();
}
},
submit() {
this.$refs.form.validate().then(() => {
this.$modal.loading('提交中');
addStart({
jobCode: this.formData.pwoJobCode,
equipmentCode: this.formData.machineId,
employeeCode: this.formData.createByCode,
startTime: this.formData.startTime
}).then(() => {
this.$modal.closeLoading();
this.$modal.msgSuccess('操作成功!');
setTimeout(() => {
this.$tab.switchTab('/pages/work/index');
}, 500);
});
});
},
getJobInfo() {
if (!this.formData.pwoJobCode) return;
listPwoJob({
code: this.formData.pwoJobCode
}).then(async (res) => {
if (!res.total > 0) return this.$modal.msg('未检索到该作业编码相关的信息!');
const job = res.rows[0];
this.formData.pwoCode = job.pwoCode;
this.formData.pwoJobId = job.id;
this.formData.ptNoTar = job.ptNoTar;
this.formData.ptTitleTar = job.ptTitleTar;
this.formData.opCode = job.opCode;
this.formData.opTitle = job.opTitle;
this.formData.batchNo = job.batchNo;
if (job.eqpId) {
await getEquipment(job.eqpId).then((res) => {
this.formData.machineId = res.data.equipmentCode;
});
// 查找该设备下上机人员
await this.handleRenderEmp();
}
if(this.formData.createById) return;
// 若没有人员,则调取最后一条转入记录的操作人
listConversion({
powJobCode: this.formData.pwoJobCode
}).then(async (res) => {
if(!res.total > 0) return;
this.formData.createByName = res.rows[0].operateBy;
if(!this.formData.createByName) return;
listEmployee({
name: this.formData.createByName
}).then(async (res) => {
this.formData.createByCode = res.rows[0].empCode;
this.formData.createById = res.rows[0].id;
});
});
});
},
getEmpInfo() {
if (!this.formData.createByCode) {
this.formData.createByName = null;
this.formData.createById = null;
return;
}
listEmployee({
empCode: this.formData.createByCode
}).then(res => {
if (res.rows.length == 0) {
this.$modal.msg('未查询到该人员信息!');
return;
}
this.formData.createByName = res.rows[0].name;
this.formData.createById = res.rows[0].id;
});
},
scanJob() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.pwoJobCode = res.result;
_this.scanBarCode(_this.formData.pwoJobCode);
}
});
},
scanEmp() {
const _this = this;
uni.scanCode({
scanType: ['barCode', 'qrCode'],
success: function(res) {
_this.formData.createByCode = res.result;
_this.getEmpInfo();
}
});
},
},
beforeDestroy() {
clearInterval(this.timer);
},
};
</script>