<template>
|
<div style="height:100%;">
|
<el-alert
|
v-if="!operationTasks || operationTasks.length == 0"
|
title="还没有工单下发到此机台!"
|
type="warning"
|
effect="dark"
|
>
|
</el-alert>
|
<el-table
|
v-show="operationTasks && operationTasks.length > 0"
|
:data="operationTasks"
|
border
|
highlight-current-row
|
@row-click="optaskRowManualClick"
|
height="100%"
|
ref="operationTaskTable"
|
>
|
<el-table-column align="center" width="55" label="单选">
|
<template slot-scope="scope">
|
<el-checkbox
|
class="operation-task-table-single-checkbox"
|
v-model="scope.row.commonChecked"
|
disabled
|
></el-checkbox>
|
</template>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="status"
|
label="状态变更"
|
width="100"
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.statusAction"
|
placeholder="更改状态"
|
@change="
|
changeTaskState(
|
scope.row.statusAction,
|
scope.row.status,
|
scope.row.id
|
)
|
"
|
>
|
<el-option
|
v-for="ele in statusActions"
|
:key="ele.value"
|
:label="ele.label"
|
:value="ele.value"
|
:disabled="ele.disabled"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="customerOrderNo"
|
label="订单号"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="mpsNo"
|
label="主计划号"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="partName"
|
label="零件名称"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="discNum"
|
label="盘长"
|
width="100"
|
show-overflow-tooltip
|
>
|
<template slot-scope="scope">
|
<span>
|
{{
|
scope.row.discNum == null
|
? 0
|
: (scope.row.plannedQuantity / scope.row.discNum).toFixed(5)
|
}}{{ scope.row.unit }}*{{
|
scope.row.discNum == null ? 0 : scope.row.discNum
|
}}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="operationName"
|
label="工序"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="plannedQuantity"
|
label="计划数量"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
align="center"
|
prop="completedQuantity"
|
label="完成数量"
|
width="100"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
</el-table>
|
</div>
|
</template>
|
<style lang="scss" scoped>
|
.operation-task-table-single-checkbox
|
>>> .el-checkbox__input.is-disabled.is-checked
|
.el-checkbox__inner {
|
background-color: #006eff;
|
border-color: #006eff;
|
}
|
.operation-task-table-single-checkbox
|
>>> .el-checkbox__input.is-disabled
|
.el-checkbox__inner {
|
background-color: #ffffff;
|
cursor: pointer;
|
}
|
.operation-task-table-single-checkbox >>> .el-checkbox__inner::after {
|
border: 1px solid #fff !important;
|
border-left: 0 !important;
|
border-top: 0 !important;
|
cursor: pointer !important;
|
}
|
</style>
|
<script>
|
import {
|
getOperationTask,
|
changeOperationTaskState
|
} from '@/api/product/personboard'
|
import { getOperationTaskById, checkIsStart } from '@/api/plan/operationtask'
|
const task_storage_key = 'OPERATION_TASK_ID'
|
export default {
|
props: {
|
workstationId: {
|
type: Number
|
},
|
productSn: {
|
type: String
|
},
|
orderNumber: {
|
type: String
|
},
|
spec: {
|
type: String
|
},
|
mpsNo: {
|
type: String
|
}
|
},
|
data() {
|
return {
|
operationTasks: [],
|
currOperateTask: {
|
id: null,
|
taskNo: null,
|
technologyName: null,
|
technologyRequire: null,
|
partName: null,
|
manufacturingOrder: null,
|
status: null,
|
statusDesc: null,
|
saleOrder: null,
|
custom: null,
|
remark: null,
|
partId: null,
|
partNo: null,
|
unit: null,
|
operationName: null,
|
routingId: null,
|
operationId: null,
|
discNum: null,
|
routingOperationRemark: null,
|
mpsNo: null,
|
customerName: null,
|
productName: null,
|
moNo: null,
|
customerOrderNo: null,
|
commonChecked: false,
|
statusAction: null,
|
reelSpec: null,
|
sunit: null
|
},
|
statusActions: [
|
{ value: 'start', label: '开始', disabled: false },
|
{ value: 'over', label: '结束', disabled: false }
|
]
|
}
|
},
|
created() {
|
if (!this.defaultOperationId) {
|
const opId = localStorage.getItem(task_storage_key)
|
if (opId) {
|
this.defaultOperationId = parseInt(opId)
|
this.currOperateTask.id = this.defaultOperationId
|
}
|
}
|
this.loadOperateTaskByWorkstation(this.currOperateTask.id)
|
},
|
methods: {
|
optaskRowManualClick(row) {
|
if (!row.commonChecked) {
|
const checkOptask = {
|
id: row.id,
|
workstationId: this.workstationId
|
}
|
checkIsStart(checkOptask)
|
.then((response) => {
|
const resData = response.data.data
|
const resCode = response.data.code
|
if (resCode === 0) {
|
if (resData) {
|
this.optaskRowClick(row)
|
} else {
|
this.$message.warning('当前工单优先级较低,不可先进行生产')
|
}
|
} else {
|
console.log('校验工单优先级时,code返回值为1')
|
}
|
})
|
.catch(() => {})
|
} else {
|
// 取消工单选中
|
this.optaskRowClick(row)
|
}
|
},
|
optaskRowClick(row) {
|
this.operationTasks.forEach((item) => {
|
if (row.id !== item.id) {
|
item.commonChecked = false
|
}
|
})
|
if (row.commonChecked) {
|
row.commonChecked = false
|
this.currOptask = null
|
this.$refs.operationTaskTable.setCurrentRow()
|
} else {
|
row.commonChecked = true
|
this.currOptask = row
|
this.$refs.operationTaskTable.setCurrentRow(row)
|
}
|
this.currentTaskChange(row)
|
// 点击工单时,触发事件,当前选中工单信息
|
this.$emit('changeCurrOperateTask', this.currOperateTask)
|
},
|
// 为当前工单赋值
|
currentTaskChange(val) {
|
if (val.commonChecked) {
|
var operationTask = val
|
this.currOperateTask.id = operationTask.id
|
this.currOperateTask.taskNo = operationTask.taskNo
|
this.currOperateTask.technologyName = operationTask.technologyName
|
this.currOperateTask.technologyRequire = operationTask.technologyRequire
|
this.currOperateTask.partName = operationTask.partName
|
this.currOperateTask.manufacturingOrder =
|
operationTask.manufacturingOrder
|
this.currOperateTask.status = operationTask.status
|
this.currOperateTask.statusDesc = operationTask.statusDesc
|
this.currOperateTask.saleOrder = operationTask.saleOrder
|
this.currOperateTask.custom = operationTask.custom
|
this.currOperateTask.remark = operationTask.remark
|
this.currOperateTask.partNo = operationTask.partNo
|
this.currOperateTask.partId = operationTask.partId
|
this.currOperateTask.unit = operationTask.unit
|
this.currOperateTask.operationName = operationTask.operationName
|
this.currOperateTask.routingId = operationTask.routingId
|
this.currOperateTask.operationId = operationTask.operationId
|
this.currOperateTask.partNo = operationTask.partNo
|
this.currOperateTask.moNo = operationTask.moNo
|
this.currOperateTask.optaskNo = operationTask.optaskNo
|
this.currOperateTask.operationName = operationTask.operationName
|
this.currOperateTask.plannedQuantity = operationTask.plannedQuantity
|
this.currOperateTask.completedQuantity = operationTask.completedQuantity
|
this.currOperateTask.priority = operationTask.priority
|
this.currOperateTask.unit = operationTask.unit
|
this.currOperateTask.plannedStartDate = operationTask.plannedStartDate
|
this.currOperateTask.plannedFinishDate = operationTask.plannedFinishDate
|
this.currOperateTask.actualStartDate = operationTask.actualStartDate
|
this.currOperateTask.actualFinishDate = operationTask.actualFinishDate
|
this.currOperateTask.createTime = operationTask.createTime
|
this.currOperateTask.discNum = operationTask.discNum
|
this.currOperateTask.routingOperationRemark =
|
operationTask.routingOperationRemark
|
this.currOperateTask.mpsNo = operationTask.mpsNo
|
this.currOperateTask.customerName = operationTask.customerName
|
this.currOperateTask.productName = operationTask.productName
|
this.currOperateTask.customerOrderNo = operationTask.customerOrderNo
|
this.currOperateTask.commonChecked = operationTask.commonChecked
|
this.currOperateTask.statusAction = operationTask.statusAction
|
this.currOperateTask.reelSpec = operationTask.reelSpec
|
this.currOperateTask.sunit = operationTask.sunit
|
} else {
|
this.initOperateTask()
|
}
|
},
|
// 更改工单状态
|
changeTaskState(statusAction, taskStatus, taskId) {
|
let changeFlag = false
|
let changeEvent
|
if (statusAction === 'start') {
|
if (taskStatus === '01pending') {
|
changeFlag = true
|
changeEvent = 'START'
|
} else {
|
this.$message.error('工单不是【等待】状态,无法开始。')
|
}
|
}
|
if (statusAction === 'over') {
|
if (taskStatus === '02inProgress') {
|
changeFlag = true
|
changeEvent = 'COMPLETE'
|
} else {
|
this.$message.error('工单不是【进行中】状态,无法结束')
|
}
|
}
|
if (changeFlag) {
|
changeOperationTaskState([taskId], changeEvent).then((response) => {
|
if (response.data.code === 0) {
|
this.$message.success('工单状态变更成功')
|
// 刷新工单列表
|
this.loadOperateTaskByWorkstation(this.currOperateTask.id)
|
} else {
|
this.$message.success('工单状态变更失败')
|
}
|
})
|
}
|
},
|
// 根据工作站,加载工单信息,选中当前工单
|
loadOperateTaskByWorkstation(taskId) {
|
return new Promise((resolve, reject) => {
|
this.operationTasks = []
|
if (this.workstationId && this.workstationId != null) {
|
var query = { workstationId: this.workstationId }
|
if (this.productSn && this.productSn != null) {
|
query.productSn = this.productSn
|
}
|
if (this.orderNumber && this.orderNumber != null) {
|
query.salesOrder = this.orderNumber
|
}
|
if (this.spec && this.spec != null) {
|
query.productName = this.spec
|
}
|
if (this.mpsNo && this.mpsNo != null) {
|
query.mpsNo = this.mpsNo
|
}
|
getOperationTask(query)
|
.then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
var tasks = data.data
|
var operationTask
|
for (var i = 0; i < tasks.length; i++) {
|
operationTask = {}
|
Object.assign(operationTask, tasks[i])
|
operationTask.taskNo = tasks[i].optaskNo
|
if (tasks[i].state == '01pending') {
|
operationTask.cssStyle = 'waitClass'
|
} else if (tasks[i].state == '02inProgress') {
|
operationTask.cssStyle = 'inprogressClass'
|
} else if (tasks[i].state == '03interrupted') {
|
operationTask.cssStyle = 'pauseClass'
|
} else if (tasks[i].state == '04completed') {
|
operationTask.cssStyle = 'completeClass'
|
}
|
operationTask.completedQuantity =
|
tasks[i].completedQuantity == null
|
? 0
|
: tasks[i].completedQuantity
|
operationTask.technologyRequire =
|
tasks[i].technologyRequirement
|
operationTask.status = tasks[i].state
|
operationTask.statusDesc = this.formaterState(tasks[i].state)
|
operationTask.custom = tasks[i].customer
|
operationTask.saleOrder = tasks[i].salesOrder
|
operationTask.partNo = tasks[i].partNo
|
operationTask.moNo = tasks[i].moNo
|
operationTask.optaskNo = tasks[i].optaskNo
|
operationTask.operationName = tasks[i].operationName
|
operationTask.plannedQuantity = tasks[i].plannedQuantity
|
operationTask.completedQuantity = tasks[i].completedQuantity
|
operationTask.priority = tasks[i].priority
|
operationTask.unit = tasks[i].unit
|
operationTask.plannedStartDate = tasks[i].plannedStartDate
|
operationTask.plannedFinishDate = tasks[i].plannedFinishDate
|
operationTask.actualStartDate = tasks[i].actualStartDate
|
operationTask.actualFinishDate = tasks[i].actualFinishDate
|
operationTask.createTime = tasks[i].createTime
|
operationTask.statusAction = null
|
operationTask.discNum = tasks[i].discNum
|
operationTask.routingOperationRemark =
|
tasks[i].routingOperationRemark
|
operationTask.mpsNo = tasks[i].mpsNo
|
operationTask.customerName = tasks[i].customerName
|
operationTask.productName = tasks[i].productName
|
operationTask.customerOrderNo = tasks[i].customerOrderNo
|
operationTask.partName = tasks[i].partName
|
operationTask.reelSpec = tasks[i].reelSpec
|
operationTask.sunit = tasks[i].sunit
|
operationTask.commonChecked = false
|
this.operationTasks.push(operationTask)
|
}
|
// 选中当前工单
|
if (
|
this.operationTasks.length > 0 &&
|
taskId != null &&
|
taskId
|
) {
|
let isResetCurrOpertionTaskFlag = true
|
let currTask
|
for (var k = 0; k < this.operationTasks.length; k++) {
|
if (this.operationTasks[k].id === taskId) {
|
isResetCurrOpertionTaskFlag = false
|
currTask = this.operationTasks[k]
|
break
|
}
|
}
|
if (!isResetCurrOpertionTaskFlag) {
|
const checkOptask = {
|
id: taskId,
|
workstationId: this.workstationId
|
}
|
checkIsStart(checkOptask)
|
.then((response) => {
|
const resData = response.data.data
|
const resCode = response.data.code
|
if (resCode === 0) {
|
if (resData) {
|
this.optaskRowClick(currTask)
|
} else {
|
this.$message.warning(
|
'当前工单优先级较低,不可先进行生产'
|
)
|
this.initOperateTask()
|
this.$emit(
|
'changeCurrOperateTask',
|
this.currOperateTask
|
)
|
}
|
} else {
|
this.initOperateTask()
|
this.$emit(
|
'changeCurrOperateTask',
|
this.currOperateTask
|
)
|
}
|
})
|
.catch(() => {
|
this.initOperateTask()
|
this.$emit(
|
'changeCurrOperateTask',
|
this.currOperateTask
|
)
|
})
|
} else {
|
// 若当前工单在工单列表未被找到且当前工单状态为已完成或已取消时,则将当前工单重置为空并抛出事件,否则不管
|
getOperationTaskById(taskId).then((res) => {
|
const resData = res.data
|
if (resData.code === 0) {
|
// 当前工单状态为已完成或已取消或不存在
|
if (resData.data.status === '1') {
|
this.initOperateTask()
|
this.$emit(
|
'changeCurrOperateTask',
|
this.currOperateTask
|
)
|
}
|
}
|
})
|
}
|
} else if (
|
this.operationTasks.length <= 0 &&
|
taskId != null &&
|
taskId
|
) {
|
// 工单列表为空,且taskId有值,则找到且当前工单状态为已完成或已取消时,将当前工单重置为空并抛出事件,否则不管
|
getOperationTaskById(taskId).then((res) => {
|
var resData = res.data
|
if (resData.code === 0) {
|
// 当前工单状态为已完成或已取消或不存在
|
if (resData.data.status === '1') {
|
this.initOperateTask()
|
this.$emit(
|
'changeCurrOperateTask',
|
this.currOperateTask
|
)
|
}
|
}
|
})
|
}
|
|
resolve()
|
} else {
|
this.$message.error('获取工单信息失败')
|
reject()
|
}
|
})
|
.catch((error) => {
|
reject(error)
|
})
|
}
|
})
|
},
|
// 刷新某个工单的信息
|
updateSomeOpTask() {
|
const opTask = this.operationTasks.find((item) => {
|
return item.id == this.currOperateTask.id
|
})
|
if (opTask) {
|
opTask.statusAction = 'start'
|
}
|
},
|
// 工单状态格式化
|
formaterState(val) {
|
var statusDesc = ''
|
if (val == '01pending') {
|
statusDesc = '等待'
|
} else if (val == '02inProgress') {
|
statusDesc = '进行中'
|
} else if (val == '03interrupted') {
|
statusDesc = '已暂停'
|
} else if (val == '04completed') {
|
statusDesc = '已完成'
|
}
|
return statusDesc
|
},
|
// 初始化页面变量
|
initOperateTask() {
|
this.currOperateTask.id = null
|
this.currOperateTask.taskNo = null
|
this.currOperateTask.technologyName = null
|
this.currOperateTask.technologyRequire = null
|
this.currOperateTask.partName = null
|
this.currOperateTask.manufacturingOrder = null
|
this.currOperateTask.status = null
|
this.currOperateTask.statusDesc = null
|
this.currOperateTask.saleOrder = null
|
this.currOperateTask.custom = null
|
this.currOperateTask.remark = null
|
this.currOperateTask.partNo = null
|
this.currOperateTask.partId = null
|
this.currOperateTask.unit = null
|
this.currOperateTask.operationName = null
|
this.currOperateTask.routingId = null
|
this.currOperateTask.operationId = null
|
this.currOperateTask.partNo = null
|
this.currOperateTask.partId = null
|
this.currOperateTask.unit = null
|
this.currOperateTask.operationName = null
|
this.currOperateTask.routingId = null
|
this.currOperateTask.operationId = null
|
this.currOperateTask.partNo = null
|
this.currOperateTask.moNo = null
|
this.currOperateTask.optaskNo = null
|
this.currOperateTask.operationName = null
|
this.currOperateTask.plannedQuantity = null
|
this.currOperateTask.completedQuantity = null
|
this.currOperateTask.priority = null
|
this.currOperateTask.unit = null
|
this.currOperateTask.plannedStartDate = null
|
this.currOperateTask.plannedFinishDate = null
|
this.currOperateTask.actualStartDate = null
|
this.currOperateTask.actualFinishDate = null
|
this.currOperateTask.createTime = null
|
this.currOperateTask.discNum = null
|
this.currOperateTask.routingOperationRemark = null
|
this.currOperateTask.mpsNo = null
|
this.currOperateTask.customerName = null
|
this.currOperateTask.productName = null
|
this.currOperateTask.customerOrderNo = null
|
this.currOperateTask.commonChecked = false
|
this.currOperateTask.statusAction = null
|
this.currOperateTask.reelSpec = null
|
this.currOperateTask.sunit = null
|
}
|
},
|
watch: {
|
workstationId() {
|
if (this.workstationId) {
|
this.loadOperateTaskByWorkstation(this.currOperateTask.id)
|
}
|
},
|
currOperateTask: {
|
handler(newValue, oldValue) {
|
if (newValue.id) {
|
localStorage.setItem(task_storage_key, newValue.id)
|
} else {
|
localStorage.setItem(task_storage_key, null)
|
}
|
},
|
deep: true
|
}
|
}
|
}
|
</script>
|