@ -115,13 +115,14 @@
< el -table -column align = "center" label = "派工标准工时(小时)" prop = "productionTime" width = "180" >
< template slot -scope = " scope " >
< el -input -number style = "width:150px;" :min ="0" v -model = " scope.row.productionTime " : disabled = "scope.row.children != null && scope.row.children !== undefined" / >
< el -input -number style = "width:150px;" :min ="0" v -model = " scope.row.productionTime "
: disabled = "scope.row.processType === PROCESS_TYPE.MANUAL && 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 " style = "width:200px;"
: disabled = "scope.row. children != null && scope.row.children !== undefined"
: disabled = "scope.row. processType === PROCESS_TYPE.MANUAL && scope.row. children != null && scope.row.children !== undefined"
clearable
placeholder = "请选择计划开始时间"
type = "datetime" value - format = "yyyy-MM-dd HH:mm:ss"
@ -131,7 +132,7 @@
< el -table -column align = "center" label = "计划完成时间" prop = "planEndTime" width = "230" >
< template slot -scope = " scope " >
< el -date -picker v -model = " scope.row.planEndTime " style = "width:200px;"
: disabled = "scope.row. children != null && scope.row.children !== undefined"
: disabled = "scope.row. processType === PROCESS_TYPE.MANUAL && scope.row. children != null && scope.row.children !== undefined"
clearable
placeholder = "请选择计划完成时间"
type = "datetime" value - format = "yyyy-MM-dd HH:mm:ss" / >
@ -159,7 +160,7 @@
size = "mini"
type = "primary"
@ click = "handleDrawing(scope.row)"
v - if = "scope.row. children != null && scope.row.children !== undefined"
v - if = "scope.row. processType !== PROCESS_TYPE.AUTO && scope.row. children != null && scope.row.children !== undefined"
> 图纸
< / e l - b u t t o n >
< el -button
@ -167,7 +168,7 @@
size = "mini"
type = "success"
@ click = "handleSOP(scope.row)"
v - if = "scope.row. children != null && scope.row.children !== undefined"
v - if = "scope.row. processType !== PROCESS_TYPE.AUTO && scope.row. children != null && scope.row.children !== undefined"
> SOP
< / e l - b u t t o n >
@ -185,7 +186,6 @@
< / 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 " >
@ -271,7 +271,7 @@
: limit = "limit"
: headers = "headers"
: before - upload = "handleBeforeUpload"
: http - request = "http Request"
: http - request = "http Sop Request"
: on - exceed = "handleExceed"
: file - list = "fileList"
>
@ -455,8 +455,18 @@ export default {
} ,
/ / 文 件 列 表
fileList : [ ] ,
/ / 上 传 文 件 回 调 列 表
uploadList : [ ] ,
/ / 根 据 工 序 和 派 工 单 号 分 组 S o p 文 件
groupSopFile : { } ,
/ / 根 据 工 序 和 派 工 单 号 分 组 S o p 文 件 列 表
groupSopFileList : [ ] ,
/ / 根 据 工 序 和 派 工 单 号 分 组 图 纸 文 件
groupAttachFile : { } ,
/ / 根 据 工 序 和 派 工 单 号 分 组 图 纸 文 件 列 表
groupAttachFileList : [ ] ,
/ / 上 传 图 纸 文 件 回 调 列 表
uploadAttachList : [ ] ,
/ / 上 传 S O P 文 件 回 调 列 表
uploadSopList : [ ] ,
/ / 文 件 上 传 - 生 产 派 工 对 象
addProductPlanObject : { } ,
headers : {
@ -537,21 +547,24 @@ export default {
let obj = { } ;
let dispatchCode = dispatchCodeProcessId . split ( "-" ) [ 0 ] ;
if ( ! firstDispatch [ dispatchCode ] ) {
if ( ! firstDispatch [ dispatchCode ] ) {
firstDispatch [ dispatchCode ] = "1" ;
obj . deleteFlag = "1" ;
}
obj . id = this . id
this . id = this . id + 1 ;
let i = 0 ;
let processType ;
productPlansByDispatch . forEach ( groupedProductPlan => {
processType = groupedProductPlan . processType ;
groupedProductPlan . id = this . id ;
groupedProductPlan . productionTime = groupedProductPlan . productionTime / 60 / 60 ;
this . id = this . id + 1 ;
groupedProductPlan . productionTime = groupedProductPlan . productionTime / 60 / 60 ;
obj . sopId = groupedProductPlan . sopId ;
obj . attachId = groupedProductPlan . attachId ;
if ( i === 0 ) {
if ( i === 0 || groupedProductPlan . processType !== this . PROCESS _TYPE . MANUAL ) {
obj . dispatchCode = groupedProductPlan . dispatchCode ;
obj . dispatchAmount = groupedProductPlan . dispatchAmount ;
obj . processId = groupedProductPlan . processId ;
@ -572,17 +585,26 @@ export default {
obj . saleorderCode = this . form . saleorderCode ;
/ / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
obj . oldRowFlag = true ;
if ( groupedProductPlan . processType !== this . PROCESS _TYPE . MANUAL ) {
let cloneObj = deepClone ( obj ) ;
cloneObj . id = this . id
cloneObj . planId = groupedProductPlan . planId ;
cloneObj . productionTime = groupedProductPlan . productionTime / 60 / 60 ;
this . id = this . id + 1 ;
cloneObj . children = [ ] ;
this . mesProductPlanList . push ( cloneObj ) ;
}
i ++ ;
}
} ) ;
obj . children = productPlansByDispatch ;
this . mesProductPlanList . push ( obj ) ;
if ( processType === this . PROCESS _TYPE . MANUAL ) {
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 ) ;
} ,
@ -633,10 +655,11 @@ export default {
/** 提交按钮 */
submitForm ( ) {
/ / 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 ;
/ / }
if ( this . mesProductPlanList . length === 0 ) {
this . $modal . msgError ( "无派工信息提交" ) ;
return ;
}
let dataList = this . mesProductPlanList ;
let toUpdatedProductPlans = [ ] ;
let undispathDesc ;
@ -645,37 +668,45 @@ export default {
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 {
if ( e . processType !== this . PROCESS _TYPE . AUTO ) {
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 . attachId = e . attachId ;
toUpdatedProductPlan . sopId = e . sopId ;
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 ;
}
}
} else {
toUpdatedProductPlans . push ( e ) ;
}
if ( toUpdatedProductPlans . length <= 0 ) {
this . $modal . msgError ( "无派工信息提交" ) ;
return ;
}
}
if ( toUpdatedProductPlans . length <= 0 ) {
this . $modal . msgError ( "无派工信息提交" ) ;
return ;
}
/ / 校 验 派 工 数 量 ( 已 派 工 数 量 + 派 工 数 量 < = 计 划 数 量 )
@ -685,7 +716,7 @@ export default {
let processId = planData . processId ;
let newFlag = planData . newFlag ;
let dispatchAmount = planData . dispatchAmount ;
if ( newFlag && newFlag === "1" ) {
if ( newFlag && newFlag === "1" ) {
dispatchAmount = dispatchAmount == null || dispatchAmount === '' ? 0 : dispatchAmount ;
const numericAmount = parseInt ( dispatchAmount , 10 ) ;
if ( ! this . isPositiveInteger ( numericAmount ) || numericAmount <= 0 ) {
@ -716,7 +747,7 @@ export default {
this . $modal . msgError ( "每个工序的派工数量之和需小于等于该工单计划数量!" ) ;
return ;
}
} else if ( uniqueSum . size > 1 ) {
} else if ( uniqueSum . size > 1 ) {
this . $modal . msgError ( "每个工序的派工数量之和需相等!" ) ;
return ;
}
@ -728,7 +759,12 @@ export default {
orderAddMesProductPlanList (
{ productOrderId : this . form . productOrderId , dispatchAmount : currentDispatchAmount , mesProductPlanList : toUpdatedProductPlans , toDeletedPlanIds : this . toDeletedPlanIds } )
{
productOrderId : this . form . productOrderId ,
dispatchAmount : currentDispatchAmount ,
mesProductPlanList : toUpdatedProductPlans ,
toDeletedPlanIds : this . toDeletedPlanIds
} )
. then ( res => {
this . $modal . msgSuccess ( res . msg ) ;
this . close ( ) ;
@ -754,7 +790,7 @@ export default {
const planIds = this . mesProductPlanList . filter ( function ( item ) {
return scope . row . dispatchCode === item . dispatchCode
} ) . map ( item => {
if ( item . planStatus !== this . PLAN _STATUS . DISPATCHED && item . planStatus !== this . PLAN _STATUS . TO _DISPATCH ) {
if ( item . planStatus !== this . PLAN _STATUS . DISPATCHED && item . planStatus !== this . PLAN _STATUS . TO _DISPATCH ) {
throw Error ( "只能删除还未开始过状态的生产派工单!" ) ;
}
@ -762,7 +798,11 @@ export default {
return item . planId ;
} ) ;
deleteProductPlansByDispatchCode ( { productOrderId : this . form . productOrderId , dispatchCode : dispatchCode , dispatchAmount : dispatchSum } ) . then ( res => {
deleteProductPlansByDispatchCode ( {
productOrderId : this . form . productOrderId ,
dispatchCode : dispatchCode ,
dispatchAmount : dispatchSum
} ) . then ( res => {
this . mesProductPlanList = this . mesProductPlanList . filter ( function ( item ) {
return dispatchCode !== item . dispatchCode
} ) ;
@ -793,45 +833,7 @@ export default {
const obj = { path : "/mes/plan/productOrder" , query : { t : Date . now ( ) , queryParams : this . $route . query . queryParams } } ;
this . $tab . closeOpenPage ( obj ) ;
} ,
/** 查看图纸 */
handleDrawing ( row ) {
this . fileList = [ ] ;
this . uploadList = [ ] ;
if ( row . planId != null ) {
getDispatchDrawingList ( row . planId ) . then ( res => {
let attachList = res . data ;
attachList . forEach ( e => {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadList . push ( e . attachId ) ;
} )
} )
}
this . addProductPlanObject = row ;
this . blueprintModel = true ;
} ,
/** 查看SOP附件 */
handleSOP ( row ) {
this . fileList = [ ] ;
this . uploadList = [ ] ;
if ( row . planId != null ) {
getDispatchSOPAttachList ( row . planId ) . then ( res => {
let attachList = res . data ;
attachList . forEach ( e => {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadList . push ( e . attachId ) ;
} )
} )
}
this . addProductPlanObject = row ;
this . sopViewModel = true ;
} ,
/** 生产计划添加按钮操作 */
handleAddMesProductPlan ( ) {
@ -846,8 +848,8 @@ export default {
let i = 0 ;
res . data . forEach ( ( e , index ) => {
let obj = { } ;
if ( i === 0 ) {
obj . deleteFlag = "1" ;
if ( i === 0 ) {
obj . deleteFlag = "1" ; / / 设 置 第 一 条 记 录 删 除 标 识 , 代 表 只 能 此 派 工 单 号 只 有 第 一 条 记 录 上 有 删 除 按 钮 , 删 除 时 同 意 删 除 此 派 工 单 号 的 派 工
i ++ ;
}
obj . id = this . id
@ -880,11 +882,16 @@ export default {
/ / 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
} ]
if ( e . processType === this . PROCESS _TYPE . AUTO ) {
obj . children = [ ] ;
} else {
obj . children = [ {
id : this . id ,
processId : obj . processId ,
planStatus : this . PLAN _STATUS . DISPATCHED
} ]
}
this . id += 1 ;
@ -921,53 +928,98 @@ export default {
handleDownload ( file ) {
window . open ( file . url ) ;
} ,
/** 查看图纸 */
handleDrawing ( row ) {
this . fileList = [ ] ;
this . uploadAttachList = [ ] ;
if ( row . oldRowFlag ) {
getDispatchDrawingList ( row . dispatchCode , row . processId ) . then ( res => {
let attachList = res . data ;
attachList . forEach ( e => {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadAttachList . push ( e . attachId ) ;
} )
} )
}
this . groupAttachFileList . forEach ( e => {
if ( e . dispatchCode === row . dispatchCode && e . processId === row . processId ) {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadAttachList . push ( e . attachId ) ;
}
} )
this . addProductPlanObject = row ;
this . blueprintModel = true ;
} ,
/** 查看SOP附件 */
handleSOP ( row ) {
this . fileList = [ ] ;
this . uploadSopList = [ ] ;
if ( row . oldRowFlag ) {
getDispatchSOPAttachList ( row . dispatchCode , row . processId ) . then ( res => {
let attachList = res . data ;
attachList . forEach ( e => {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadSopList . push ( e . attachId ) ;
} )
} )
}
this . groupSopFileList . forEach ( e => {
if ( e . dispatchCode === row . dispatchCode && e . processId === row . processId ) {
let previewFile = { } ;
previewFile . url = e . attachPath ;
previewFile . name = e . attachName ;
this . fileList . push ( previewFile ) ;
this . uploadSopList . push ( e . attachId ) ;
}
} )
this . addProductPlanObject = row ;
this . sopViewModel = true ;
} ,
/ / 添 加 图 纸 提 交
drawingFileUploadSubmit ( ) {
/ / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
if ( this . addProductPlanObject . oldRowFlag ) {
updateProductplan ( {
planId : this . addProductPlanObject . planId ,
attachId : this . uploadList . join ( "," ) ,
} ) . then ( res => {
this . $modal . msgSuccess ( "上传图纸成功!" ) ;
}
)
} else {
for ( let i = 0 ; i < this . mesProductPlanList . length ; i ++ ) {
if ( this . mesProductPlanList [ i ] . index === this . addProductPlanObject . index ) {
this . mesProductPlanList [ i ] . attachId = this . uploadList . join ( "," ) ;
}
for ( let i = 0 ; i < this . mesProductPlanList . length ; i ++ ) {
let mesProductPlan = this . mesProductPlanList [ i ] ;
if ( mesProductPlan . dispatchCode === this . addProductPlanObject . dispatchCode
&& mesProductPlan . processId === this . addProductPlanObject . processId ) {
this . mesProductPlanList [ i ] . attachId = this . uploadAttachList . join ( "," ) ;
}
}
this . uploadList = [ ] ;
this . uploadAttachList = [ ] ;
this . addProductPlanObject = null ;
this . blueprintModel = false ;
} ,
/ / 添 加 S O P 附 件 提 交
sopFileUploadSubmit ( ) {
/ / 新 添 加 列 标 识 f a l s e = 新 添 加 , t r u e = 历 史 行
if ( this . addProductPlanObject . oldRowFlag ) {
updateProductplan ( {
planId : this . addProductPlanObject . planId ,
sopId : this . uploadList . join ( "," ) ,
} ) . then ( res => {
this . $modal . msgSuccess ( "上传SOP附件成功! " ) ;
}
)
} else {
for ( let i = 0 ; i < this . mesProductPlanList . length ; i ++ ) {
if ( this . mesProductPlanList [ i ] . index === this . addProductPlanObject . index ) {
this . mesProductPlanList [ i ] . sopId = this . uploadList . join ( "," ) ;
}
for ( let i = 0 ; i < this . mesProductPlanList . length ; i ++ ) {
let mesProductPlan = this . mesProductPlanList [ i ] ;
if ( mesProductPlan . dispatchCode === this . addProductPlanObject . dispatchCode
&& mesProductPlan . processId === this . addProductPlanObject . processId ) {
this . mesProductPlanList [ i ] . sopId = this . uploadSopList . join ( "," ) ;
}
}
this . uploadList = [ ] ;
this . uploadSopList = [ ] ;
this . addProductPlanObject = null ;
this . sopViewModel = false ;
} ,
/ / 图 片 上 传
/ / 图 纸 图 片 上 传
httpRequest ( file ) {
/ / 文 件 信 息
const fileData = file . file ;
@ -978,13 +1030,48 @@ export default {
uploadFile ( formData ) . then (
( res ) => {
/ / 存 储 附 件 信 息 主 键
this . uploadList . push ( res . attachId ) ;
let groupAttachFile = { } ;
groupAttachFile . dispatchCode = this . addProductPlanObject . dispatchCode ;
groupAttachFile . processId = this . addProductPlanObject . processId ;
groupAttachFile . attachId = res . attachId ;
groupAttachFile . attachPath = res . imgUrl ;
groupAttachFile . attachName = res . fileName ;
this . groupAttachFileList . push ( groupAttachFile ) ;
this . uploadAttachList . push ( res . attachId ) ;
} , ( err ) => {
this . $refs . drawingUpload . clearFiles ( ) ; / / 上 传 失 败 后 清 除 当 前 上 传 的 图 片
this . $modal . closeLoading ( ) ;
}
) ;
} ,
/ / S O P 图 片 上 传
httpSopRequest ( file ) {
/ / 文 件 信 息
const fileData = file . file ;
const formData = new FormData ( ) ;
formData . append ( "file" , fileData ) ;
formData . append ( "processId" , this . addProductPlanObject . processId ) ;
formData . append ( "attachType" , "1" ) ;
uploadFile ( formData ) . then (
( res ) => {
/ / 存 储 附 件 信 息 主 键
let groupSopFile = { } ;
groupSopFile . dispatchCode = this . addProductPlanObject . dispatchCode ;
groupSopFile . processId = this . addProductPlanObject . processId ;
groupSopFile . attachId = res . attachId ;
groupSopFile . attachPath = res . imgUrl ;
groupSopFile . attachName = res . fileName ;
this . groupSopFileList . push ( groupSopFile ) ;
this . uploadSopList . push ( res . attachId ) ;
} , ( err ) => {
this . $refs . drawingUpload . clearFiles ( ) ; / / 上 传 失 败 后 清 除 当 前 上 传 的 图 片
this . $modal . closeLoading ( ) ;
}
) ;
} ,
/ / 上 传 结 束 处 理
uploadedSuccessfully ( ) {
if ( this . number > 0 && this . uploadList . length === this . number ) {