@ -10,7 +10,11 @@
< el -form -item label = "成品编码:" > { { form . materialCode } } < / e l - f o r m - i t e m >
< el -form -item label = "计划开始时间:" > { { parseTime ( form . planBeginTime ) } } < / e l - f o r m - i t e m >
< el -form -item label = "计划数量/已派工数量/完成数量:" label -width = " 220px " >
{ { form . planAmount } } / { { form . dispatchAmount } } / { { form . completeAmount } }
{ {
form . planAmount
} } / { {
form . dispatchAmount == null || form . dispatchAmount === undefined ? 0 : form . dispatchAmount
} } / { { form . completeAmount } }
< / e l - f o r m - i t e m >
< / e l - c o l >
< el -col :span ="12" >
@ -28,65 +32,112 @@
< el -button icon = "el-icon-plus" size = "mini" type = "primary" @click ="handleAddMesProductPlan" > 新 增
< / e l - b u t t o n >
< / e l - c o l >
< el -col :span ="1.5" >
< el -button type = "danger" icon = "el-icon-delete" size = "mini" @click ="handleDeleteMesProductPlan"
: disabled = "single" > 删除
< / e l - b u t t o n >
< / e l - c o l >
< / e l - r o w >
< el -table ref = "mesProductPlan" :data ="mesProductPlanList"
: row - class - name = "rowMesProductPlanIndex" @ selection - change = "handleMesProductPlanSelectionChange" >
< el -table -column align = "center" type = "selection" width = "50" / >
< el -table -column align = "center" label = "序号" prop = "index" width = "50" v -if = " false " / >
< el -table -column align = "center" label = "派工单号" prop = "dispatchCode" width = "290" >
: row - class - name = "rowMesProductPlanIndex" @ selection - change = "handleMesProductPlanSelectionChange"
: tree - props = "{children: 'children'}"
style = "width: 100%;margin-bottom: 20px;"
row - key = "id"
border
default - expand - all
>
< el -table -column
width = "80"
type = ""
>
< template slot -scope = " scope " >
< el -input v -model = " scope.row.dispatchCode " :disabled ="true" / >
< el -button type = "danger" icon = "el-icon-delete" @click ="handleDeleteMesProductPlan(scope)"
v - if = "scope.row.deleteFlag != null && scope.row.deleteFlag == '1'" > < / e l - b u t t o n >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "工序" prop = "processName" width = "140" >
< el -table -column
width = "80"
type = ""
>
< template slot -scope = " scope " >
< el -input v -model = " scope.row.processName " :disabled ="true" / >
< el -button type = "primary" icon = "el-icon-plus" @click ="addProcessUser(scope)"
v - if = "scope.row.children != null && scope.row.children !== undefined" > < / e l - b u t t o n >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "步骤" prop = "processOrder" >
< el -table -column
width = "50"
>
<!-- < template slot -scope = " scope " > -- >
<!-- < el -button type = "primary" icon = "el-icon-plus" @click ="add(scope)" > < / el -button > -- >
<!-- < / template > -- >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "派工单号" prop = "dispatchCode" width = "230" >
< template slot -scope = " scope " >
< el -input v -model = " scope.row.dispatchCode " :disabled ="true"
v - if = "scope.row.children != null && scope.row.children !== undefined" / >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "工序" prop = "processName" width = "140" >
< template slot -scope = " scope " >
< el -input v -model = " scope.row.processOrder " :disabled ="true" / >
< el -input v -model = " scope.row.processName " :disabled ="true"
v - if = "scope.row.children != null && scope.row.children !== undefined" / >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "工位" prop = "stationName" width = "140" >
< el -table -column align = "center" label = " 步骤" prop = "processOrder ">
< template slot -scope = " scope " >
< el -input v -model = " scope.row.stationName " :disabled ="true" / >
< el -input v -model = " scope.row.processOrder " :disabled ="true"
v - if = "scope.row.children != null && scope.row.children !== undefined" / >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "派工数量" prop = "dispatchAmount" width = "100" >
< template slot -scope = " scope " >
< el -input v -model = " scope.row.dispatchAmount " :disabled ="scope.row.oldRowFlag" / >
< el -input v -model = " scope.row.dispatchAmount " :disabled ="scope.row.oldRowFlag"
v - if = "scope.row.children != null && scope.row.children !== undefined" / >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "计划数量" prop = "planAmount" width = "100" >
< el -table -column align = "center" label = "用户" prop = "userId" width = "140" >
< template slot -scope = " scope " >
< el -input v -model = " scope.row.planAmount " : disabled = "scope.row.oldRowFlag || scope.row.processId!==PROCESS_ID.BENDING_PROCESS_ID" / >
< el -select v -model = " scope.row.userId " placeholder = "请选择用户"
v - if = "scope.row.children == null || scope.row.children === undefined"
: disabled = "scope.row.planId != null && scope.row.planId !== undefined && scope.row.planId !== ''"
>
< el -option
v - for = "item in processUsers[scope.row.processId]"
: key = "item.userId"
: label = "item.userName"
: value = "item.userId"
> < / e l - o p t i o n >
< / e l - s e l e c t >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "派工标准工时" prop = "productionTime" width = "100" >
< el -table -column align = "center" label = "派工标准工时(小时)" prop = "productionTime" width = "180" >
< template slot -scope = " scope " >
< el -input v -model = " scope.row.productionTime " :disabled ="scope.row.oldRowFlag" / >
< el -input -number style = "width:150px;" :min ="0" v -model = " scope.row.productionTime " : disabled = "scope.row.children != null && scope.row.children !== undefined "/ >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "计划开始时间" prop = "planBeginTime" width = "230" >
< template slot -scope = " scope " >
< el -date -picker v -model = " scope.row.planBeginTime " :disabled ="scope.row.oldRowFlag" clearable
< el -date -picker v -model = " scope.row.planBeginTime " style = "width:200px;"
: disabled = "scope.row.children != null && scope.row.children !== undefined"
clearable
placeholder = "请选择计划开始时间"
type = "datetime" value - format = "yyyy-MM-dd HH:mm:ss" / >
type = "datetime" value - format = "yyyy-MM-dd HH:mm:ss"
/ >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "计划完成时间" prop = "planEndTime" width = "230" >
< template slot -scope = " scope " >
< el -date -picker v -model = " scope.row.planEndTime " :disabled ="scope.row.oldRowFlag" clearable
< el -date -picker v -model = " scope.row.planEndTime " style = "width:200px;"
: disabled = "scope.row.children != null && scope.row.children !== undefined"
clearable
placeholder = "请选择计划完成时间"
type = "datetime" value - format = "yyyy-MM-dd HH:mm:ss" / >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" label = "状态" prop = "planStatus" width = "150" >
< template slot -scope = " scope " >
< el -select v-model ="scope.row.planStatus" :disabled="true" placeholder="请选择状态" >
@ -99,6 +150,8 @@
< / e l - s e l e c t >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column align = "center" class -name = " small -padding fixed -width " label = "操作" width = "100" >
< template slot -scope = " scope " >
< el -button
@ -106,6 +159,7 @@
size = "mini"
type = "primary"
@ click = "handleDrawing(scope.row)"
v - if = "scope.row.children != null && scope.row.children !== undefined"
> 图纸
< / e l - b u t t o n >
< el -button
@ -113,10 +167,25 @@
size = "mini"
type = "success"
@ click = "handleSOP(scope.row)"
v - if = "scope.row.children != null && scope.row.children !== undefined"
> SOP
< / e l - b u t t o n >
< el -button
icon = "el-icon-delete"
size = "mini"
type = "danger"
@ click = "handleDeleteDispatchUser(scope.row)"
v - if = " ( scope . row . children == null || scope . row . children == undefined )
&& ( scope . row . planStatus === PLAN _STATUS . STARTED || scope . row . planStatus === PLAN _STATUS . DISPATCHED ) "
> 删除
< / e l - b u t t o n >
< / template >
< / e l - t a b l e - c o l u m n >
< / e l - t a b l e >
< / e l - f o r m >
< el -form label -width = " 100px " >
@ -179,7 +248,7 @@
<!-- 上传提示 -- >
< div class = "el-upload__tip" slot = "tip" v-if ="isShowTip" >
请上传
< template v-if ="fileSize" > 大 小 不 超 过 < b style = "color: #f 56c6 c"> { { fileSize } } MB < / b > < / template >
< template v-if ="fileSize" > 大 小 不 超 过 < b style = "color: #f 67c7 c"> { { fileSize } } MB < / b > < / template >
< template v-if ="fileType" > 格 式 为 < b style = "color: #f56c6c" > { { fileType . join ( "/" ) } } < / b > < / template >
的文件
< / div >
@ -268,19 +337,43 @@
< script >
import { getProductOrder , updateProductOrder } from "@//api/mes/productOrder" ;
import {
del Productplan ,
del eteProductPlansByDispatchCode ,
getDispatchCode , getDispatchDrawingList , getDispatchSOPAttachList ,
getProductPlan ,
selectProductPlans ,
orderAddMesProductPlanList ,
updateProductplan ,
getBaseRouteProcesses ,
getProcessUsers ,
uploadFile
} from "@//api/mes/productplan" ;
import { getStationByRouteId} from "@//api/mes/baseRoute ";
import { deepClone} from "@//utils/index ";
import { getToken } from "@//utils/auth" ;
let id = 0
let deepSearch = ( arr , target ) => {
let results = [ ]
arr . forEach ( element => {
console . log ( element )
id = Math . max ( id , element . id )
if ( element . id === target ) {
results . push ( element )
} else if ( Array . isArray ( element . children ) ) {
results = results . concat ( deepSearch ( element . children , target ) )
}
/ / i f ( A r r a y . i s A r r a y ( e l e m e n t . c h i l d r e n ) ) {
/ / r e s u l t s = r e s u l t s . c o n c a t ( d e e p S e a r c h ( e l e m e n t . c h i l d r e n , t a r g e t ) )
/ / } e l s e i f ( e l e m e n t . i d = = = t a r g e t ) {
/ / r e s u l t s . p u s h ( e l e m e n t )
/ / }
} )
return results
}
export default {
name : "productPlanEdit" ,
dicts : [ 'product_status' ] ,
dicts : [ 'product_status' , 'mes_dispatch_flag' ],
props : {
value : [ String , Object , Array , Number ] ,
/ / 文 件 数 量 限 制
@ -326,6 +419,9 @@ export default {
columns : [ ] ,
/ / 生 产 计 划 表 格 数 据
mesProductPlanList : [ ] ,
/ / 待 删 除 的 生 产 计 划 I D
toDeletedPlanIds : [ ] ,
/ / 表 详 细 信 息
info : { } ,
/ / 表 单 参 数
@ -368,7 +464,22 @@ export default {
} ,
PROCESS _ID : {
BENDING _PROCESS _ID : 42
}
} ,
PROCESS _TYPE : {
MANUAL : '1' ,
AUTO : '3' ,
} ,
PLAN _STATUS : {
TO _DISPATCH : '0' , / / 待 派 工
DISPATCHED : '1' , / / 已 派 工
STARTED : '2' , / / 已 开 始
FINISHED : '3' / / 已 完 成
} ,
id : 1 ,
processUsers : [ ]
} ;
} ,
created ( ) {
@ -377,17 +488,143 @@ export default {
/ / 获 取 表 详 细 信 息
getProductOrder ( productOrderId ) . then ( res => {
this . form = res . data ;
this . getProcessUsers ( productOrderId ) ;
} ) ;
getProductPlan ( { productOrderId : productOrderId } ) . then ( res => {
res . data . forEach ( e => {
/ / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
e . oldRowFlag = true ;
this . mesProductPlanList . push ( e ) ;
} )
} )
}
} ,
methods : {
getProcessUsers ( productOrderId ) {
getProcessUsers ( this . form . dispatchId ) . then ( res => {
res . data . forEach ( processUser => {
if ( ! this . processUsers [ processUser . processId ] ) {
this . processUsers [ processUser . processId ] = [ ] ;
}
this . processUsers [ processUser . processId ] . push ( processUser ) ;
} ) ;
selectProductPlans ( { productOrderId : productOrderId } ) . then ( res => {
this . groupProductPlans ( res . data )
/ / r e s . d a t a . f o r E a c h ( e = > {
/ / / / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
/ / e . o l d R o w F l a g = t r u e ;
/ / t h i s . m e s P r o d u c t P l a n L i s t . p u s h ( e ) ;
/ / } )
} )
} ) ;
} ,
groupProductPlans ( productPlans ) {
const groupedProductPlans = { } ;
productPlans . forEach ( productPlan => {
const key = ` ${ productPlan . dispatchCode } - ${ productPlan . processId } ` ;
if ( ! groupedProductPlans [ key ] ) {
groupedProductPlans [ key ] = [ ] ;
}
groupedProductPlans [ key ] . push ( productPlan ) ;
} ) ;
let firstDispatch = { } ;
for ( let dispatchCodeProcessId in groupedProductPlans ) {
let productPlansByDispatch = groupedProductPlans [ dispatchCodeProcessId ] ;
/ / c o n s o l e . l o g ( p r o c e s s I d + " : " + J S O N . s t r i n g i f y ( g r o u p e d P r o d u c t P l a n s [ p r o c e s s I d ] ) ) ;
let obj = { } ;
let dispatchCode = dispatchCodeProcessId . split ( "-" ) [ 0 ] ;
if ( ! firstDispatch [ dispatchCode ] ) {
firstDispatch [ dispatchCode ] = "1" ;
obj . deleteFlag = "1" ;
}
obj . id = this . id
this . id = this . id + 1 ;
let i = 0 ;
productPlansByDispatch . forEach ( groupedProductPlan => {
groupedProductPlan . id = this . id ;
groupedProductPlan . productionTime = groupedProductPlan . productionTime / 60 / 60 ;
this . id = this . id + 1 ;
if ( i === 0 ) {
obj . dispatchCode = groupedProductPlan . dispatchCode ;
obj . dispatchAmount = groupedProductPlan . dispatchAmount ;
obj . processId = groupedProductPlan . processId ;
obj . processName = groupedProductPlan . processName ;
obj . lastProcessId = groupedProductPlan . lastProcessId ;
obj . processType = groupedProductPlan . processType ;
obj . processOrder = groupedProductPlan . processOrder ;
obj . planBeginTime = this . form . planBeginTime ;
obj . planEndTime = this . form . planEndTime ;
obj . planStatus = groupedProductPlan . planStatus ;
/ / o b j . d i s p a t c h A m o u n t = t h i s . f o r m . p l a n A m o u n t - t h i s . f o r m . d i s p a t c h A m o u n t ;
obj . materialId = this . form . materialId ;
obj . materialBomId = this . form . materialBomId ;
obj . productOrderId = this . form . productOrderId ;
obj . saleOrderId = this . form . saleOrderId ;
obj . saleorderCode = this . form . saleorderCode ;
/ / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
obj . oldRowFlag = true ;
i ++ ;
}
} ) ;
obj . children = productPlansByDispatch ;
this . mesProductPlanList . push ( obj ) ;
}
/ / c o n s o l e . l o g ( J S O N . s t r i n g i f y ( t h i s . m e s P r o d u c t P l a n L i s t ) )
this . getId ( this . mesProductPlanList ) ;
} ,
getId ( arr ) {
arr . forEach ( element => {
this . id = this . id + 1 ;
if ( Array . isArray ( element . children ) ) {
this . getId ( element . children )
}
} )
} ,
addProcessUser ( scope ) {
let data = deepSearch ( this . mesProductPlanList , scope . row . id ) ? . [ 0 ]
let id = this . id + 1
this . id += 1 ;
if ( Array . isArray ( data . children ) ) {
this . $set ( data . children , data . children . length , {
id : id ,
processId : scope . row . processId ,
planStatus : this . PLAN _STATUS . DISPATCHED ,
userId : ""
} )
} else {
this . $set ( data , 'children' , [
{
id : id ,
processId : scope . row . processId ,
planStatus : this . PLAN _STATUS . DISPATCHED ,
userId : "" ,
}
] )
}
this . id += 1
/ / t h i s . s h o w = f a l s e
/ / t h i s . s h o w = t r u e
} ,
isAssetTypeAnImage ( ext ) {
let suffix = ext . lastIndexOf ( "." ) ;
let name = ext . substr ( suffix + 1 ) ;
@ -395,90 +632,146 @@ export default {
} ,
/** 提交按钮 */
submitForm ( ) {
let dataList = this . mesProductPlanList . filter ( plan => ! plan . oldRowFlag ) ;
if ( dataList . length === 0 ) {
this . close ( ) ;
/ / l e t d a t a L i s t = t h i s . m e s P r o d u c t P l a n L i s t . f i l t e r ( p l a n = > ! p l a n . o l d R o w F l a g ) ;
/ / i f ( d a t a L i s t . l e n g t h = = = 0 ) {
/ / t h i s . c l o s e ( ) ;
/ / r e t u r n ;
/ / }
let dataList = this . mesProductPlanList ;
let toUpdatedProductPlans = [ ] ;
let undispathDesc ;
for ( let i = 0 ; i < dataList . length ; i ++ ) {
let e = dataList [ i ] ;
let dispatchFlag = false ;
undispathDesc = "派工单号为[" + e . dispatchCode + "],工序为[" + e . processName + "],请选择用户派工" ;
if ( ! e . children || e . children . length <= 0 ) {
this . $modal . msgError ( undispathDesc ) ;
return ;
}
for ( let j = 0 ; j < e . children . length ; j ++ ) {
let processUser = e . children [ j ] ;
let toUpdatedProductPlan = deepClone ( e ) ;
if ( processUser . userId && processUser . userId !== '' ) {
toUpdatedProductPlan . userId = processUser . userId ;
toUpdatedProductPlan . planBeginTime = processUser . planBeginTime ;
toUpdatedProductPlan . planEndTime = processUser . planEndTime ;
toUpdatedProductPlan . planId = processUser . planId ;
toUpdatedProductPlan . children = null ;
let productionTimeHour = processUser . productionTime ;
let productionTimeSecond = productionTimeHour * 60 * 60 ;
toUpdatedProductPlan . productionTime = productionTimeSecond ;
toUpdatedProductPlans . push ( toUpdatedProductPlan ) ;
dispatchFlag = true ;
} else {
this . $modal . msgError ( undispathDesc ) ;
return ;
}
}
}
if ( toUpdatedProductPlans . length <= 0 ) {
this . $modal . msgError ( "无派工信息提交" ) ;
return ;
}
/ / 校 验 派 工 数 量 ( 已 派 工 数 量 + 派 工 数 量 < = 计 划 数 量 )
/ / 按 照 p r o c e s s I d 分 组 , 所 有 分 组 的 p l a n A m o u n t 之 和 是 否 相 等 , 相 等 后 输 出 p l a n A m o u n t 之 和 的 值
const sumList = dataList . reduce ( ( result , { processId , dispatchAmount } ) => {
const numericAmount = parseInt ( dispatchAmount , 10 ) ;
if ( ! this . isPositiveInteger ( numericAmount ) ) {
this . $modal . msgError ( "派工数量须为大于等于0的正整数! " ) ;
return ;
let dispatchAmountErrorMsg = "" ;
const sumList = dataList . reduce ( ( result , planData ) => {
let processId = planData . processId ;
let newFlag = planData . newFlag ;
let dispatchAmount = planData . dispatchAmount ;
if ( newFlag && newFlag === "1" ) {
dispatchAmount = dispatchAmount == null || dispatchAmount === '' ? 0 : dispatchAmount ;
const numericAmount = parseInt ( dispatchAmount , 10 ) ;
if ( ! this . isPositiveInteger ( numericAmount ) || numericAmount <= 0 ) {
dispatchAmountErrorMsg = "派工数量须为大于等于0的正整数! " ;
}
if ( ! result [ processId ] ) {
result [ processId ] = 0 ;
}
result [ processId ] = ( result [ processId ] || 0 ) + numericAmount ;
}
result [ processId ] = ( result [ processId ] || 0 ) + numericAmount ;
return result ;
} , { } ) ;
if ( dispatchAmountErrorMsg !== "" ) {
this . $modal . msgError ( dispatchAmountErrorMsg ) ;
return ;
}
/ / 一 种 快 速 去 除 数 组 中 重 复 元 素 的 方 法 , 特 别 适 合 处 理 从 对 象 中 提 取 的 属 性 值 数 组 , ( 例 如 按 工 序 相 加 的 数 量 都 是 一 样 的 , 则 去 重 后 就 剩 一 个 数 )
const uniqueSum = new Set ( Object . values ( sumList ) ) ;
let currentDispatchAmount = 0 ;
if ( uniqueSum . size === 1 ) {
const finalSum = Array . from ( uniqueSum ) [ 0 ] ;
let dispatchedAmount = this . form . dispatchAmount + finalSum ;
currentDispatchAmount = finalSum ;
let dispatchedAmount = this . form . dispatchAmount + finalSum ; / / 加 上 此 次 派 工 的 数 量 , 总 共 的 派 工 数 量
if ( dispatchedAmount > this . form . planAmount ) {
this . $modal . msgError ( "每个工序的派工数量之和需小于等于该工单计划数量!" ) ;
return ;
}
dataList . forEach ( e => {
e . dispatchedAmount = dispatchedAmount ;
}
)
} else {
} else if ( uniqueSum . size > 1 ) {
this . $modal . msgError ( "每个工序的派工数量之和需相等!" ) ;
return ;
}
orderAddMesProductPlanList ( dataList ) . then ( res => {
this . $modal . msgSuccess ( res . msg ) ;
this . close ( ) ;
} ) ;
/ / c o n s o l e . l o g ( J S O N . s t r i n g i f y ( t o U p d a t e d P r o d u c t P l a n s ) ) ;
/ / a l e r t ( t h i s . t o D e l e t e d P l a n I d s )
/ / r e t u r n ;
orderAddMesProductPlanList (
{ productOrderId : this . form . productOrderId , dispatchAmount : currentDispatchAmount , mesProductPlanList : toUpdatedProductPlans , toDeletedPlanIds : this . toDeletedPlanIds } )
. then ( res => {
this . $modal . msgSuccess ( res . msg ) ;
this . close ( ) ;
} ) ;
} ,
/** 删除按钮操作 */
handleDeleteMesProductPlan ( ) {
let productPlan = this . checkedMesProductPlanList [ 0 ] ;
this . $modal . confirm ( '是否确认删除生产派工编号为"' + productPlan . dispatchCode + '"的数据项?' ) . then ( function ( ) {
handleDeleteMesProductPlan ( scope ) {
let dispatchCode = scope . row . dispatchCode ;
this . $modal . confirm ( '是否确认删除生产派工 单号为"' + dispatchCode + '"的数据项?' ) . then ( function ( ) {
return true ;
} ) . then ( ( ) => {
if ( productPlan. planId === undefined || productPlan . planId === null ) {
if ( scope. row . newFlag != null || scope . row . newFlag === '1' ) {
/ / 新 增 删 除
const mesProductPlanDetailList = this . mesProductPlanList ;
this . mesProductPlanList = mesProductPlanDetailList . filter ( function ( item ) {
return productPlan . dispatchCode !== item . dispatchCode
this . mesProductPlanList = this . mesProductPlanList . filter ( function ( item ) {
return scope . row . dispatchCode !== item . dispatchCode
} ) ;
} else {
/ / 历 史 删 除
const delList = this . mesProductPlanList ;
let dispatchSum = 0 ;
let dispatchSum = 0 ; / / 需 要 减 去 的 派 工 数 量
try {
const planIds = del List. filter ( function ( item ) {
return productPlan . dispatchCode === item . dispatchCode
const planIds = this . mesProductPlan List. filter ( function ( item ) {
return scope. row . dispatchCode === item . dispatchCode
} ) . map ( item => {
if ( item . planStatus !== '1' ) {
throw Error ( "只能删除未派工状态的生产派工单!" ) ;
}
if ( item . processId === productPlan . processId ) {
dispatchSum = dispatchSum + item . planAmount ;
if ( item . planStatus !== this . PLAN _STATUS . DISPATCHED && item . planStatus !== this . PLAN _STATUS . TO _DISPATCH ) {
throw Error ( "只能删除还未开始过状态的生产派工单!" ) ;
}
dispatchSum = item . dispatchAmount ; / / 派 工 数 量 每 一 个 工 序 都 一 样
return item . planId ;
} ) ;
dispatchSum = this . form . dispatchAmount - dispatchSum ;
delProductplan ( planIds ) . then ( res => {
/ / 更 新 生 产 工 单
updateProductOrder ( {
productOrderId : this . form . productOrderId ,
dispatchAmount : dispatchSum
} )
getProductOrder ( this . form . productOrderId ) . then ( res => {
this . form = res . data ;
deleteProductPlansByDispatchCode ( { productOrderId : this . form . productOrderId , dispatchCode : dispatchCode , dispatchAmount : dispatchSum } ) . then ( res => {
this . mesProductPlanList = this . mesProductPlanList . filter ( function ( item ) {
return dispatchCode !== item . dispatchCode
} ) ;
this . form . dispatchAmount = this . form . dispatchAmount - dispatchSum ;
this . $modal . msgSuccess ( "删除成功" ) ;
} ) ;
const mesProductPlanDetailList = this . mesProductPlanList ;
this . mesProductPlanList = mesProductPlanDetailList . filter ( function ( item ) {
return productPlan . dispatchCode !== item . dispatchCode
} ) ;
this . $modal . msgSuccess ( "删除成功" ) ;
} catch ( e ) {
this . $modal . msgError ( e ) ;
}
@ -545,34 +838,56 @@ export default {
let dispatchCode = "" ;
getDispatchCode ( ) . then ( res => {
dispatchCode = res . msg ;
get StationByRouteId( this . form . dispatchId ) . then ( res => {
if ( res . data . length === 0 ) {
this . $modal . msgError ( "工艺路线未维护工位信息!" ) ;
}
get BaseRouteProcesses( { routeId : this . form . dispatchId } ) . then ( res => {
/ / i f ( r e s . d a t a . l e n g t h = = = 0 ) {
/ / t h i s . $ m o d a l . m s g E r r o r ( " 工 艺 路 线 未 维 护 工 位 信 息 ! " ) ;
/ / }
let lastProcessId = null ;
let i = 0 ;
res . data . forEach ( ( e , index ) => {
let obj = { } ;
if ( i === 0 ) {
obj . deleteFlag = "1" ;
i ++ ;
}
obj . id = this . id
this . id = this . id + 1 ;
obj . dispatchCode = dispatchCode ;
obj . processId = e . processId ;
obj . processName = e . processName ;
obj . processType = e . processType ;
obj . processOrder = e . processOrder ;
obj . stationId = e . stationId ;
obj . stationName = e . stationName ;
obj . productionTime = 0 ;
obj . planBeginTime = this . form . planBeginTime ;
obj . planEndTime = this . form . planEndTime ;
obj . planStatus = '1' ;
/ / m u l t i S t a t i o n F l a g : 一 个 工 序 对 应 工 位 个 数
if ( e . multiStationFlag > 1 ) {
obj . dispatchAmount = 0 ; / / 代 表 p r o d u c t p l a n 的 派 工 数 量 , o b j . p l a n A m o u n t 代 表 实 际 工 位 上 要 工 作 的 数 量 ( 默 认 p l a n a m o u n t = d i s p a t c h a m o u n t , 像 折 弯 工 序 可 能 两 个 不 相 同 ) t h i s . f o r m . p l a n A m o u n t 是 o r d e r 计 划 生 产 的 数 量 , t h i s . f o r m . d i s p a t c h A m o u n t 是 o r d e r 中 已 派 工 的 数 量
} else {
obj . dispatchAmount = this . form . planAmount - this . form . dispatchAmount ;
}
/ / o b j . d i s p a t c h A m o u n t = t h i s . f o r m . p l a n A m o u n t - t h i s . f o r m . d i s p a t c h A m o u n t ;
obj . dispatchFlag = null ;
obj . materialId = this . form . materialId ;
obj . materialBomId = this . form . materialBomId ;
obj . productOrderId = this . form . productOrderId ;
obj . saleOrderId = this . form . saleOrderId ;
obj . saleorderCode = this . form . saleorderCode ;
obj . newFlag = "1" ; / / 代 表 新 增
/ / e . m e s B a s e P r o c e s s U s e r L i s t . f o r E a c h ( ( m e s B a s e P r o c e s s U s e r , i n d e x ) = > {
/ / m e s B a s e P r o c e s s U s e r . i d = t h i s . i d + 1 ;
/ / m e s B a s e P r o c e s s U s e r . d i s p a t c h F l a g = n u l l ;
/ / m e s B a s e P r o c e s s U s e r . p l a n B e g i n T i m e = n u l l ;
/ / m e s B a s e P r o c e s s U s e r . p l a n E n d T i m e = n u l l ;
/ / t h i s . i d = t h i s . i d + 1 ;
/ / } ) ;
obj . children = [ {
id : this . id ,
processId : obj . processId ,
planStatus : this . PLAN _STATUS . DISPATCHED
} ]
this . id += 1 ;
/ / 上 一 工 序 I D
if ( lastProcessId == null ) {
obj . lastProcessId = 0 ;
@ -586,9 +901,13 @@ export default {
obj . oldRowFlag = false ;
this . mesProductPlanList . push ( obj ) ;
} )
this . getId ( this . mesProductPlanList )
} )
} )
} ,
isPositiveInteger ( value ) {
/ / 使 用 正 则 表 达 式 匹 配 正 整 数
return /^[0-9]\d*$/ . test ( value ) ;
@ -724,7 +1043,19 @@ export default {
handleExceed ( ) {
this . $modal . msgError ( ` 上传文件数量不能超过 ${ this . limit } ! ` ) ;
} ,
} ,
handleDeleteDispatchUser ( row ) {
this . mesProductPlanList . forEach ( mesProductPlan => {
mesProductPlan . children = mesProductPlan . children . filter ( item => item . id !== row . id ) ;
} ) ;
if ( row . planId != null && row . planId !== '' ) {
this . toDeletedPlanIds . push ( row . planId ) ;
}
} ,
}
,
mounted ( ) {
}