|
|
|
@ -18,23 +18,23 @@
|
|
|
|
<uni-forms-item label="工位" required name="orgId">
|
|
|
|
<uni-forms-item label="工位" required name="orgId">
|
|
|
|
<uni-data-select v-model="customFormData.orgId" :localdata="orgIdList"></uni-data-select>
|
|
|
|
<uni-data-select v-model="customFormData.orgId" :localdata="orgIdList"></uni-data-select>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="计件时段" name="reportTime">
|
|
|
|
<uni-forms-item label="计时时段" name="reportTime">
|
|
|
|
<uni-easyinput type="text" v-model="customFormData.reportTime" placeholder="如:8:00-12:00" />
|
|
|
|
<uni-easyinput type="text" v-model="customFormData.reportTime" placeholder="如:8:00-12:00" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="计件时间/h" required name="totalTime">
|
|
|
|
<uni-forms-item label="总计时/h" required name="totalTime">
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.totalTime" placeholder="" />
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.totalTime" placeholder="" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
<uni-group title="card 模式" mode="card" v-for="(item,index) in customFormData.productList" :key="item.id"
|
|
|
|
<uni-group title="card 模式" mode="card" v-for="(item,index) in customFormData.produceReportDetails" :key="item.id"
|
|
|
|
:name="['productList',index,'value']">
|
|
|
|
:name="['produceReportDetails',index,'value']">
|
|
|
|
<template v-slot:title>
|
|
|
|
<template v-slot:title>
|
|
|
|
<view class="uni-group-title">
|
|
|
|
<view class="uni-group-title">
|
|
|
|
<uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="20">
|
|
|
|
<uni-forms-item label="产品" required name="planId">
|
|
|
|
<uni-forms-item label="产品" required name="planId">
|
|
|
|
<uni-data-select v-model="customFormData.productList[index].planId" :localdata="planProductList"></uni-data-select>
|
|
|
|
<uni-data-select v-model="customFormData.produceReportDetails[index].planId" :localdata="planProductList"></uni-data-select>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
<uni-col :span="12" align="center">
|
|
|
|
<uni-col :span="4" align="center">
|
|
|
|
<!-- <button class="button" size="mini" type="warn" @click="del(item.id)">删除</button>-->
|
|
|
|
<!-- <button class="button" size="mini" type="warn" @click="del(item.id)">删除</button>-->
|
|
|
|
<uni-icons type="trash" size="25" color="red" @click="del(item.id)"></uni-icons>
|
|
|
|
<uni-icons type="trash" size="25" color="red" @click="del(item.id)"></uni-icons>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
@ -44,36 +44,36 @@
|
|
|
|
<uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="成品数" required name="qualityNumber">
|
|
|
|
<uni-forms-item label="成品数" required name="qualityNumber">
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.productList[index].qualityNumber" @change="changeNumber(item.id)"/>
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.produceReportDetails[index].qualityNumber" @change="changeNumber(item.id)"/>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="废品数" name="wasteNumber">
|
|
|
|
<uni-forms-item label="废品数" name="wasteNumber">
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.productList[index].wasteNumber" @change="changeNumber(item.id)"/>
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.produceReportDetails[index].wasteNumber" @change="changeNumber(item.id)"/>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
</uni-row>
|
|
|
|
</uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="总数" name="totalNumber">
|
|
|
|
<uni-forms-item label="总数" name="totalNumber">
|
|
|
|
<uni-easyinput disabled v-model="customFormData.productList[index].totalNumber" placeholder="" />
|
|
|
|
<uni-easyinput disabled v-model="customFormData.produceReportDetails[index].totalNumber" placeholder="" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="成品率%" required name="qualityRate">
|
|
|
|
<uni-forms-item label="成品率%" required name="qualityRate">
|
|
|
|
<uni-easyinput disabled type="number" v-model="customFormData.productList[index].qualityRate" />
|
|
|
|
<uni-easyinput disabled type="number" v-model="customFormData.produceReportDetails[index].qualityRate" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
</uni-row>
|
|
|
|
</uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-row>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="打包数" name="packageNumber">
|
|
|
|
<uni-forms-item label="打包数" name="packageNumber">
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.productList[index].packageNumber" />
|
|
|
|
<uni-easyinput type="number" v-model="customFormData.produceReportDetails[index].packageNumber" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-col :span="12">
|
|
|
|
<uni-forms-item label="备注" name="remark">
|
|
|
|
<uni-forms-item label="备注" name="remark">
|
|
|
|
<uni-easyinput type="text" v-model="customFormData.productList[index].remark" />
|
|
|
|
<uni-easyinput type="text" v-model="customFormData.produceReportDetails[index].remark" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-col>
|
|
|
|
</uni-col>
|
|
|
|
</uni-row>
|
|
|
|
</uni-row>
|
|
|
|
@ -95,10 +95,11 @@
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
import {processTypes, groupTypes} from "@/api/system/dict/data";
|
|
|
|
import {processTypes, groupTypes} from "@/api/system/dict/data";
|
|
|
|
import {getOrgList, getProductList, createReport, getPlanProductList} from "@/api/mes/organization"
|
|
|
|
import {getOrgList, getProductList, createReport, getPlanProductList} from "@/api/mes/organization"
|
|
|
|
import {getCurrentDate} from "@/utils/dateUtil"
|
|
|
|
import {getCurrentDate, timestampToTime} from "@/utils/dateUtil"
|
|
|
|
import {showConfirm} from "@/utils/common";
|
|
|
|
import {showConfirm} from "@/utils/common";
|
|
|
|
import tab from "@/plugins/tab";
|
|
|
|
import tab from "@/plugins/tab";
|
|
|
|
import modal from "@/plugins/modal";
|
|
|
|
import modal from "@/plugins/modal";
|
|
|
|
|
|
|
|
import {getById, getDetailByReportId, update} from "@/api/mes/report";
|
|
|
|
const userStore = useUserStore()
|
|
|
|
const userStore = useUserStore()
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
components: {},
|
|
|
|
components: {},
|
|
|
|
@ -119,7 +120,7 @@ export default {
|
|
|
|
reportType: undefined,
|
|
|
|
reportType: undefined,
|
|
|
|
reportDateString: getCurrentDate(),
|
|
|
|
reportDateString: getCurrentDate(),
|
|
|
|
reportDate: undefined,
|
|
|
|
reportDate: undefined,
|
|
|
|
productList: []
|
|
|
|
produceReportDetails: []
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// 自定义表单校验规则
|
|
|
|
// 自定义表单校验规则
|
|
|
|
customRules: {
|
|
|
|
customRules: {
|
|
|
|
@ -127,10 +128,10 @@ export default {
|
|
|
|
orgId: {rules: [{required: true, errorMessage: '工位不能为空'}]},
|
|
|
|
orgId: {rules: [{required: true, errorMessage: '工位不能为空'}]},
|
|
|
|
orgType: {rules: [{required: true, errorMessage: '工序不能为空'}]},
|
|
|
|
orgType: {rules: [{required: true, errorMessage: '工序不能为空'}]},
|
|
|
|
reportDateString: {rules: [{required: true, errorMessage: '报工日期不能为空'}]},
|
|
|
|
reportDateString: {rules: [{required: true, errorMessage: '报工日期不能为空'}]},
|
|
|
|
totalTime: {rules: [{required: true, errorMessage: '计件时间不能为空'},
|
|
|
|
totalTime: {rules: [{required: true, errorMessage: '总计时不能为空'},
|
|
|
|
{format: 'number', errorMessage: '计件时间格式错误,应填计件小时数'}]},
|
|
|
|
{format: 'number', errorMessage: '总计时格式错误,应填计时小时数'}]},
|
|
|
|
groupType: {rules: [{required: true, errorMessage: '班别不能为空'}]},
|
|
|
|
groupType: {rules: [{required: true, errorMessage: '班别不能为空'}]},
|
|
|
|
productList: {rules: [
|
|
|
|
produceReportDetails: {rules: [
|
|
|
|
{format: 'array', errorMessage: '产品列表格式错误'},
|
|
|
|
{format: 'array', errorMessage: '产品列表格式错误'},
|
|
|
|
{validateFunction: function(rule, value, data, callback) {
|
|
|
|
{validateFunction: function(rule, value, data, callback) {
|
|
|
|
if (value.length < 2) {
|
|
|
|
if (value.length < 2) {
|
|
|
|
@ -142,7 +143,8 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
orgIdList:[],
|
|
|
|
orgIdList:[],
|
|
|
|
planProductList:[]
|
|
|
|
planProductList:[],
|
|
|
|
|
|
|
|
updateId: undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
|
@ -150,6 +152,20 @@ export default {
|
|
|
|
onLoad() {
|
|
|
|
onLoad() {
|
|
|
|
this.getOrgIdList()
|
|
|
|
this.getOrgIdList()
|
|
|
|
// this.getPlanProductList()
|
|
|
|
// this.getPlanProductList()
|
|
|
|
|
|
|
|
this.updateId = tab.getParams()
|
|
|
|
|
|
|
|
if(this.updateId){
|
|
|
|
|
|
|
|
this.disableEnable = true
|
|
|
|
|
|
|
|
//请求编辑数据
|
|
|
|
|
|
|
|
getById(this.updateId).then(response => {
|
|
|
|
|
|
|
|
this.customFormData = response.data
|
|
|
|
|
|
|
|
this.customFormData.reportDateString = timestampToTime(this.customFormData.reportDate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getDetailByReportId(this.updateId).then(res => {
|
|
|
|
|
|
|
|
this.customFormData.produceReportDetails = res.data
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.getPlanProductList()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onReady() {
|
|
|
|
onReady() {
|
|
|
|
// 设置自定义表单校验规则,必须在节点渲染完毕后执行
|
|
|
|
// 设置自定义表单校验规则,必须在节点渲染完毕后执行
|
|
|
|
@ -168,10 +184,10 @@ export default {
|
|
|
|
console.log(this.customFormData);
|
|
|
|
console.log(this.customFormData);
|
|
|
|
this.$refs[ref].validate().then(res => {
|
|
|
|
this.$refs[ref].validate().then(res => {
|
|
|
|
var ok = 1;
|
|
|
|
var ok = 1;
|
|
|
|
if(this.customFormData.productList && this.customFormData.productList.length > 0) {
|
|
|
|
if(this.customFormData.produceReportDetails && this.customFormData.produceReportDetails.length > 0) {
|
|
|
|
for (let i = 0; i < this.customFormData.productList.length; i++) {
|
|
|
|
for (let i = 0; i < this.customFormData.produceReportDetails.length; i++) {
|
|
|
|
if(!this.customFormData.productList[i].planId || this.customFormData.productList[i].planId===''
|
|
|
|
if(!this.customFormData.produceReportDetails[i].planId || this.customFormData.produceReportDetails[i].planId===''
|
|
|
|
|| !this.customFormData.productList[i].qualityNumber|| this.customFormData.productList[i].qualityNumber <= 0) {
|
|
|
|
|| !this.customFormData.produceReportDetails[i].qualityNumber|| this.customFormData.produceReportDetails[i].qualityNumber <= 0) {
|
|
|
|
ok = 0;
|
|
|
|
ok = 0;
|
|
|
|
uni.showToast({
|
|
|
|
uni.showToast({
|
|
|
|
title: `产品信息不能为空!`,
|
|
|
|
title: `产品信息不能为空!`,
|
|
|
|
@ -184,10 +200,19 @@ export default {
|
|
|
|
if(ok===1){
|
|
|
|
if(ok===1){
|
|
|
|
showConfirm("确认保存生产报工单吗?").then(res => {
|
|
|
|
showConfirm("确认保存生产报工单吗?").then(res => {
|
|
|
|
if (res.confirm) {
|
|
|
|
if (res.confirm) {
|
|
|
|
createReport(this.customFormData).then(response => {
|
|
|
|
if(this.updateId){
|
|
|
|
modal.msgSuccess("保存成功")
|
|
|
|
this.customFormData.id = this.updateId
|
|
|
|
tab.switchTab('/pages/report')
|
|
|
|
update(this.customFormData).then(response => {
|
|
|
|
})
|
|
|
|
modal.msgSuccess("修改成功")
|
|
|
|
|
|
|
|
tab.navigateBack()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
this.customFormData.id = null
|
|
|
|
|
|
|
|
createReport(this.customFormData).then(response => {
|
|
|
|
|
|
|
|
modal.msgSuccess("保存成功")
|
|
|
|
|
|
|
|
tab.switchTab('/pages/report')
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -227,7 +252,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
add() {
|
|
|
|
add() {
|
|
|
|
if(this.customFormData.orgType){
|
|
|
|
if(this.customFormData.orgType){
|
|
|
|
this.customFormData.productList.push({
|
|
|
|
this.customFormData.produceReportDetails.push({
|
|
|
|
id: Date.now(),
|
|
|
|
id: Date.now(),
|
|
|
|
productId: undefined,
|
|
|
|
productId: undefined,
|
|
|
|
planId: undefined,
|
|
|
|
planId: undefined,
|
|
|
|
@ -246,20 +271,20 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
del(id) {
|
|
|
|
del(id) {
|
|
|
|
let index = this.customFormData.productList.findIndex(v => v.id === id)
|
|
|
|
let index = this.customFormData.produceReportDetails.findIndex(v => v.id === id)
|
|
|
|
this.customFormData.productList.splice(index, 1)
|
|
|
|
this.customFormData.produceReportDetails.splice(index, 1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
changeNumber(id){
|
|
|
|
changeNumber(id){
|
|
|
|
let index = this.customFormData.productList.findIndex(v => v.id === id)
|
|
|
|
let index = this.customFormData.produceReportDetails.findIndex(v => v.id === id)
|
|
|
|
if(!this.customFormData.productList[index].qualityNumber)
|
|
|
|
if(!this.customFormData.produceReportDetails[index].qualityNumber)
|
|
|
|
this.customFormData.productList[index].qualityNumber=0;
|
|
|
|
this.customFormData.produceReportDetails[index].qualityNumber=0;
|
|
|
|
if(!this.customFormData.productList[index].wasteNumber)
|
|
|
|
if(!this.customFormData.produceReportDetails[index].wasteNumber)
|
|
|
|
this.customFormData.productList[index].wasteNumber=0;
|
|
|
|
this.customFormData.produceReportDetails[index].wasteNumber=0;
|
|
|
|
|
|
|
|
|
|
|
|
this.customFormData.productList[index].totalNumber =
|
|
|
|
this.customFormData.produceReportDetails[index].totalNumber =
|
|
|
|
Number(this.customFormData.productList[index].qualityNumber) + Number(this.customFormData.productList[index].wasteNumber);
|
|
|
|
Number(this.customFormData.produceReportDetails[index].qualityNumber) + Number(this.customFormData.produceReportDetails[index].wasteNumber);
|
|
|
|
this.customFormData.productList[index].qualityRate =
|
|
|
|
this.customFormData.produceReportDetails[index].qualityRate =
|
|
|
|
(Number(this.customFormData.productList[index].qualityNumber)*100/Number(this.customFormData.productList[index].totalNumber)).toFixed(2);
|
|
|
|
(Number(this.customFormData.produceReportDetails[index].qualityNumber)*100/Number(this.customFormData.produceReportDetails[index].totalNumber)).toFixed(2);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handleOrgTypeChange(e){
|
|
|
|
handleOrgTypeChange(e){
|
|
|
|
console.log(e)
|
|
|
|
console.log(e)
|
|
|
|
|