zhaoxuebing
6 months ago
12 changed files with 309 additions and 191 deletions
@ -0,0 +1,185 @@ |
|||
<template> |
|||
<Dialog |
|||
:title="dialogTitle" |
|||
v-model="dialogVisible" |
|||
:close-on-click-modal="true" |
|||
:vLoading="formLoading" |
|||
width="fit-content" |
|||
> |
|||
<template #title>{{ dialogTitle }} </template> |
|||
<el-button type="primary" @click="addRow" style="float:right;;">添加</el-button> |
|||
<el-table :data="tableData" style="border: 1px;stripe; width:1300px ;" > |
|||
<el-table-column prop="processName" label="工序名称" width="200px"> |
|||
<template #default="scope"> |
|||
<el-select v-model="scope.row.processCodeSelected" @change="processChange" value-key="processCode"> |
|||
<el-option v-for="item in processOption" :key="item.processCode" :label="item.processName" :value="item.processCode" /> |
|||
</el-select> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="reportName" label="报工人" width="200px"> |
|||
<template #default="scope"> |
|||
<el-select v-model="scope.row.personSelected" multiple :value-key="workerCode"> |
|||
<el-option v-for="item in personOption" :key="item.workerCode" :label="item.workerName" :value="item.workerCode" /> |
|||
</el-select> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="reportCount" label="报工数量" width="200px" > |
|||
<template #default="scope"> |
|||
<el-input-number v-model="scope.row.reportCount" @change="handleCount(scope.row)" :key="count"></el-input-number> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="workTerm" label="工时" width="200px" > |
|||
<template #default="scope"> |
|||
<el-input-number v-model="scope.row.workTerm"></el-input-number> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="checkFlag" label="已质检" width="80px" > |
|||
<template #default="scope"> |
|||
|
|||
<el-switch inactive-value="false" v-model="scope.row.checkFlag" ></el-switch> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="qualified" label="合格数" width="200px" > |
|||
|
|||
<template #default="scope" > |
|||
<el-input-number v-model="scope.row.qualified" @change="handleCount(scope.row)" :key="qcount" :disabled="scope.row.checkFlag=='false'" ></el-input-number> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="unqualified" label="不合格数" width="100px"> |
|||
<template #default="scope"> |
|||
<el-input v-model="scope.row.unqualified" disabled="true">{{scope.row.unqualified= scope.row.reportCount -scope.row.qualified}}</el-input> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="操作" width="100px"> |
|||
<template #default="scope"> |
|||
<el-button type="text" @click="deleteRow(scope.$index)">删除</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
|
|||
<template #footer> |
|||
<el-button @click="dialogVisible = false">关闭</el-button> |
|||
<el-button type="primary" :disabled="saveFlag" @click="saveReport">保存</el-button> |
|||
</template> </Dialog |
|||
> |
|||
</template> |
|||
<script lang="ts" setup> |
|||
import { Dialog } from '@/components/Dialog' |
|||
import * as workschedulingApi from '@/api/mes/workScheduling' |
|||
import dayjs from 'dayjs' |
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
const rowData = ref() |
|||
const openDetail = async (row: any, titleName: any) => { |
|||
rowData.value = row |
|||
dialogVisible.value = true |
|||
dialogTitle.value = titleName |
|||
getProcessList(row) |
|||
|
|||
} |
|||
const dialogVisible = ref(false) |
|||
const dialogTitle = ref() |
|||
const formLoading = ref(false) |
|||
const processOption = ref([]) |
|||
const personOption=ref([]) |
|||
const processCodeSelected = ref() |
|||
const personSelected = ref() |
|||
const checkFlag = ref(false) |
|||
const reportCount = ref() |
|||
const workTerm = ref() |
|||
const saveFlag=ref(false) |
|||
const tableData=ref([{}]) |
|||
const addRow=()=>{ |
|||
|
|||
if(tableData.value.length<processOption.value.length){ |
|||
tableData.value.push({ |
|||
processCode:processCodeSelected.value, |
|||
processName:processOption.value?.find(item=>item.processCode==processCodeSelected.value)?.processName, |
|||
reportName:personOption.value?.find(item=>item.workerCode==personSelected.value)?.workerName, |
|||
reportCount:reportCount.value, |
|||
workTerm:workTerm.value, |
|||
checkFlag:checkFlag.value}) |
|||
}else{ |
|||
message.alert('超出可报工的工序数量,不能再添加!') |
|||
} |
|||
|
|||
} |
|||
const deleteRow = (index: number) => { |
|||
tableData.value.splice(index, 1) |
|||
} |
|||
//获取工序列表 |
|||
const getProcessList=async(row)=>{ |
|||
let params={ |
|||
planDayCode:row.planMasterCode, |
|||
schedulingCode:row.schedulingCode |
|||
} |
|||
processOption.value=await workschedulingApi.getProcessList(params) |
|||
} |
|||
const processChange=(val:any)=>{ |
|||
//console.log("processChange-81",val) |
|||
getCurrentWorkerList(val) |
|||
} |
|||
//获取工序人员 |
|||
const getCurrentWorkerList = async (val) => { |
|||
//console.log("personOption-91",val) |
|||
let params = { |
|||
planDayCode: rowData.value.planMasterCode, |
|||
processCode: val |
|||
} |
|||
personOption.value = await workschedulingApi.getCurrentWorkerList(params) |
|||
|
|||
} |
|||
const count = ref(0) |
|||
const qcount = ref(1) |
|||
//报工数量处理 |
|||
const handleCount = (row) => { |
|||
if (row.reportCount > rowData.value.planCount) { |
|||
message.alert('报工数量不能超出计划数量!计划数【'+rowData.value.planCount+'】') |
|||
row.reportCount =rowData.value.planCount |
|||
//tableData.value[index].reportCount =rowData.value.planCount |
|||
count.value++ |
|||
return |
|||
} |
|||
//message.alert(row.checkFlag==true?'1':'2') |
|||
if (row.checkFlag) { |
|||
if (row.reportCount < row.qualified) { |
|||
message.alert('合格数不能超出报工数!') |
|||
row.qualified=row.reportCount |
|||
qcount.value++ |
|||
return |
|||
} |
|||
if (row.qualified == undefined || row.qualified == 0) { |
|||
row.qualified = row.reportCount |
|||
qcount.value++ |
|||
} |
|||
|
|||
row.unqualified= row.reportCount- row.qualified |
|||
} |
|||
} |
|||
//提交报工 |
|||
const saveReport = async() => { |
|||
|
|||
saveFlag.value = true |
|||
try { |
|||
let data = { |
|||
planMasterCode: rowData.value.planMasterCode, |
|||
schedulingCode: rowData.value.schedulingCode, |
|||
schedulingDetailList: tableData.value |
|||
} |
|||
//console.log("report-saveReport-170",data) |
|||
workschedulingApi.reportWorkByTask(data) |
|||
}finally{ |
|||
saveFlag.value = false |
|||
dialogVisible.value = false |
|||
emit('close') |
|||
} |
|||
//console.log("report-saveReport-82",data) |
|||
//await workschedulingApi.reportWorkByProcess(data) |
|||
|
|||
} |
|||
// 传递给父类 |
|||
const emit = defineEmits(['success', 'close']) |
|||
|
|||
defineExpose({ openDetail }) // 提供 open 方法,用于打开弹窗 |
|||
</script> |
Loading…
Reference in new issue