<template>
|
<el-dialog
|
width="90%"
|
title="工单列表"
|
top="5vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
class="part-dialog"
|
:close-on-click-modal="false"
|
>
|
<el-table
|
class="ifs-stock-table"
|
:data="operationData"
|
style="width: 100%;"
|
height="450px"
|
border
|
stripe
|
ref="ifsStockTable"
|
>
|
<el-table-column type="index" width="50" label="序号" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="operationName"
|
label="工序"
|
align="center"
|
width="80px"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="workCenter"
|
label="工作中心"
|
align="center"
|
width="200px"
|
show-overflow-tooltip
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.workCenter"
|
filterable
|
placeholder="请选择工作中心"
|
style="width:100%"
|
@change="(val) => changeWorkCenter(val, scope.row)"
|
>
|
<el-option
|
v-for="(item, index) in workCenterOptions"
|
:label="item.label"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column prop="workstationId" label="工作站" align="center">
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.workstationId"
|
filterable
|
placeholder="请选择工作站"
|
style="width:100%"
|
clearable
|
@change="(val) => changeWorkstation(val, scope.row)"
|
>
|
<el-option
|
v-for="(item, index) in scope.row.workstations"
|
:label="item.name"
|
:value="item.id"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column prop="locationId" label="库位" align="center">
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.locationId"
|
filterable
|
placeholder="请选择库位"
|
style="width:100%"
|
clearable
|
>
|
<el-option
|
v-for="(item, index) in scope.row.locationOptions"
|
:label="item.locName"
|
:value="item.id"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="partNo"
|
label="零件号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="partName"
|
label="零件名称"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column prop="plannedQuantity" label="计划数量" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.plannedQuantity"
|
@blur="blurChangeCallback(scope.row)"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="unit" label="单位" align="center">
|
</el-table-column>
|
<!-- <el-table-column prop="splannedQuantity" label="计划数量2" align="center">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.splannedQuantity"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="sunit" label="单位2" align="center">
|
</el-table-column> -->
|
<el-table-column prop="reelSpec" label="载具规格" align="center">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.reelSpec"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="discNum" label="盘数" align="center">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.discNum"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column prop="remark" label="备注" align="center">
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.remark"></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="plannedStartDate"
|
label="计划开始时间"
|
align="center"
|
width="200px"
|
>
|
<template slot-scope="scope">
|
<el-date-picker
|
v-model="scope.row.plannedStartDate"
|
style="width: 100%"
|
type="datetime"
|
placeholder="计划开始时间"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="plannedFinishDate"
|
label="计划完成时间"
|
align="center"
|
width="200px"
|
>
|
<template slot-scope="scope">
|
<el-date-picker
|
v-model="scope.row.plannedFinishDate"
|
style="width: 100%"
|
type="datetime"
|
placeholder="计划完成时间"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="manufactureAttr"
|
label="制造属性"
|
align="center"
|
width="100px"
|
show-overflow-tooltip
|
>
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.manufactureAttr"
|
placeholder="请选择制造属性"
|
style="width:100%"
|
disabled
|
>
|
<el-option
|
v-for="(item, index) in manufactureAttrs"
|
:label="item.label"
|
:value="item.value"
|
:key="index"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="100" align="center">
|
<template slot-scope="scope">
|
<el-button @click="copyTask(scope.row)" type="text" size="small"
|
>复制</el-button
|
>
|
<el-button
|
@click="delTask(scope.row, scope.$index)"
|
type="text"
|
size="small"
|
style="color:#f56c6c;"
|
>删除</el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`saveSelectRow`"
|
>确 定</el-button
|
>
|
</div>
|
</el-dialog>
|
</template>
|
<script>
|
import { fetchListExt } from '@/api/warehouse/location'
|
import { getAllWorkstationList } from '@/api/basic/workstation'
|
import {
|
getFromMoOptionByMoId,
|
saveBatchOperationTask
|
} from '@/api/plan/operationtask'
|
import { remote } from '../../../api/admin/dict'
|
export default {
|
components: {},
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
orderId: {
|
type: Number,
|
default: 0
|
},
|
outPutBatchList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
},
|
qtyPlaned: {
|
type: Number,
|
default: 0
|
},
|
selectionArray: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
innerVisible: false,
|
isSubmit: false,
|
operationData: [],
|
workCenterOptions: [],
|
manufactureAttrs: [],
|
operationTaskType: ''
|
}
|
},
|
created() {
|
this.getWorkCenterOptions()
|
this.getManufactureAttrs('manufacture_attr_type')
|
},
|
methods: {
|
getManufactureAttrs(type) {
|
remote(type).then((response) => {
|
const code = response.data.code
|
if (code === 0) {
|
const _data = response.data.data
|
this.manufactureAttrs = _data
|
}
|
})
|
},
|
getWorkCenterOptions() {
|
remote('work_center_type').then((response) => {
|
if (response.data.code === 0) {
|
this.workCenterOptions = response.data.data
|
this.workCenterOptions.forEach((item) => {
|
item.label = '(' + item.value + ') ' + item.label
|
})
|
}
|
})
|
},
|
changeWorkCenter(val, row) {
|
row.workstations = []
|
row.workstationId = null
|
row.locationOptions = []
|
row.locationId = null
|
if (val) {
|
const queryParamStation = Object.assign({
|
workCenter: val
|
})
|
|
getAllWorkstationList(queryParamStation).then((response) => {
|
const resData = response.data.data
|
if (resData && resData.length > 0) {
|
row.workstations = resData
|
}
|
})
|
}
|
},
|
changeWorkstation(val, row) {
|
row.locationOptions = []
|
row.locationId = null
|
if (val) {
|
const queryParamLocation = Object.assign({
|
workstationId: val,
|
locationType: 4
|
})
|
|
fetchListExt(queryParamLocation).then((response) => {
|
const resData = response.data.data.records
|
if (resData && resData.length > 0) {
|
row.locationOptions = resData
|
row.locationId = resData[0].id
|
}
|
})
|
}
|
},
|
blurChangeCallback(row) {
|
this.checkQuality()
|
},
|
checkQuality() {
|
// 勾选合计校验,是否大于需求数量
|
let flag = true
|
let flagMsg = ''
|
for (let i = 0; i < this.operationData.length; i++) {
|
if (
|
this.operationData[i].plannedQuantity == null ||
|
this.operationData[i].plannedQuantity == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,计划数量不能为空;'
|
} else {
|
if (!this.checkZero(this.operationData[i].plannedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,计划数量不能为0;'
|
} else {
|
if (!this.checkPositive(this.operationData[i].plannedQuantity)) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,计划数量需为正数;'
|
} else {
|
if (!this.checkDecimal(this.operationData[i].plannedQuantity)) {
|
flag = false
|
flagMsg =
|
flagMsg + '第' + (i + 1) + '行,计划数量最多六位小数;'
|
}
|
}
|
}
|
}
|
}
|
if (!flag) {
|
this.$message.error(flagMsg)
|
}
|
return flag
|
},
|
checkZero(value) {
|
if (value == 0) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkPositive(value) {
|
if (!/^[0-9]+.?[0-9]*$/.test(value)) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkDecimal(value) {
|
if (
|
!/(^[1-9]([0-9]+)?(\.[0-9]{1,6})?$)|(^(0){1}$)|(^[0-9]\.[0-9]{1,6}$)/.test(
|
value
|
)
|
) {
|
return false
|
} else {
|
return true
|
}
|
},
|
checkField() {
|
let flag = true
|
let flagMsg = ''
|
for (let i = 0; i < this.operationData.length; i++) {
|
if (
|
this.operationData[i].workCenter == null ||
|
this.operationData[i].workCenter == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,工作中心不能为空;'
|
}
|
|
if (
|
this.operationData[i].plannedStartDate == null ||
|
this.operationData[i].plannedStartDate == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,计划开始时间不能为空;'
|
}
|
if (
|
this.operationData[i].plannedFinishDate == null ||
|
this.operationData[i].plannedFinishDate == ''
|
) {
|
flag = false
|
flagMsg = flagMsg + '第' + (i + 1) + '行,计划完成时间不能为空;'
|
}
|
}
|
if (!flag) {
|
this.$message.error(flagMsg)
|
}
|
return flag
|
},
|
saveSelectRow() {
|
this.isSubmit = true
|
let flag = this.checkQuality()
|
if (flag) {
|
flag = this.checkField()
|
if (flag) {
|
const batchTaskList = []
|
this.operationData.forEach((item) => {
|
batchTaskList.push({
|
partNo: item.partNo,
|
partName: item.partName,
|
operationName: item.operationName,
|
workCenter: item.workCenter,
|
workstationId: item.workstationId,
|
locationId: item.locationId,
|
plannedQuantity: item.plannedQuantity,
|
plannedStartDate: item.plannedStartDate,
|
plannedFinishDate: item.plannedFinishDate,
|
moRoutingOperationId: item.moRoutingOperationId,
|
routingOperationId: item.routingOperationId,
|
routingId: item.routingId,
|
partId: item.partId,
|
moId: this.orderId,
|
splannedQuantity: item.splannedQuantity,
|
unit: item.unit,
|
sunit: item.sunit,
|
manufactureAttr: item.manufactureAttr,
|
reelSpec: item.reelSpec,
|
operationTaskType: this.operationTaskType,
|
outPutBatchList: this.outPutBatchList
|
})
|
})
|
saveBatchOperationTask(batchTaskList)
|
.then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.innerVisible = false
|
this.$message.success('批量工单成功')
|
this.$emit('refreshDataList')
|
} else {
|
this.$message.error('批量工单失败')
|
}
|
this.isSubmit = false
|
})
|
.catch(() => {
|
this.isSubmit = false
|
})
|
} else {
|
this.isSubmit = false
|
}
|
} else {
|
this.isSubmit = false
|
}
|
},
|
initData() {},
|
// 复制行
|
copyTask(row) {
|
this.operationData.push({
|
operationName: row.operationName,
|
workCenter: row.workCenter,
|
workstationId: null,
|
locationId: null,
|
partNo: row.partNo,
|
partName: row.partName,
|
plannedQuantity: row.plannedQuantity,
|
plannedStartDate: row.plannedStartDate,
|
plannedFinishDate: row.plannedFinishDate,
|
workstations: row.workstations,
|
moRoutingOperationId: row.moRoutingOperationId,
|
routingOperationId: row.routingOperationId,
|
routingId: row.routingId,
|
partId: row.partId,
|
locationOptions: [],
|
splannedQuantity: row.splannedQuantity,
|
unit: row.unit,
|
sunit: row.sunit,
|
reelSpec: row.reelSpec,
|
operationTaskType: this.operationTaskType
|
})
|
},
|
// 删除行
|
delTask(row, index) {
|
this.$confirm('此操作将删除该工单, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
this.operationData.splice(index, 1)
|
this.$message({
|
type: 'success',
|
message: '删除成功!'
|
})
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
})
|
})
|
}
|
},
|
watch: {
|
currshowlist() {
|
console.log('orderId', this.orderId)
|
this.innerVisible = this.currshowlist
|
if (this.selectionArray && this.selectionArray.length > 0) {
|
this.operationTaskType = this.selectionArray[0].workshopTypeCode
|
}
|
|
if (this.currshowlist) {
|
this.initData()
|
this.operationData = []
|
this.$nextTick(() => {
|
getFromMoOptionByMoId(this.orderId).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
const autoTaskList = resData.data
|
console.log(this.selectionArray)
|
autoTaskList.forEach((item) => {
|
this.operationData.push({
|
operationName: item.operationName,
|
workCenter: item.workCenter,
|
workstationId: item.workstationId,
|
locationId: item.locationId,
|
partNo: item.partNo,
|
partName: item.partName,
|
plannedQuantity: item.plannedQuantity,
|
plannedStartDate: item.plannedStartDate,
|
plannedFinishDate: item.plannedFinishDate,
|
workstations: item.workstations,
|
moRoutingOperationId: item.moRoutingOperationId,
|
routingOperationId: item.routingOperationId,
|
routingId: item.routingId,
|
partId: item.partId,
|
locationOptions: [],
|
splannedQuantity: 0,
|
unit: item.unit,
|
sunit: item.sunit,
|
manufactureAttr: item.manufactureAttr,
|
reelSpec: null,
|
operationTaskType: this.operationTaskType
|
})
|
})
|
} else {
|
this.$message.error('获取自动工单列表失败')
|
}
|
})
|
})
|
}
|
}
|
}
|
}
|
</script>
|
<style>
|
.part-dialog .el-dialog__header {
|
padding: 10px 20px 10px;
|
}
|
.part-dialog .el-dialog__header .el-dialog__headerbtn {
|
top: 10px;
|
}
|
.part-dialog .el-dialog__body {
|
padding: 5px 20px;
|
}
|
|
.part-dialog .el-dialog__footer {
|
padding: 5px 20px 10px;
|
}
|
|
.part-dialog .el-dialog__body .avue-crud__pagination {
|
margin-top: 0px;
|
margin-bottom: 5px;
|
}
|
</style>
|