@ -100,6 +100,11 @@
< el -table -column label = "物料名称" align = "left" prop = "materialName" v -if = " columns [ 4 ] .visible " / >
< el -table -column label = "BOM说明" align = "center" prop = "materialBomDesc" v -if = " columns [ 15 ] .visible " / >
< el -table -column label = "标准数量" align = "center" prop = "standardAmount" v -if = " columns [ 5 ] .visible " / >
< el -table -column label = "安装时长" align = "center" prop = "assembleTime" v-if ="columns[16].visible" >
< template slot -scope = " scope " >
< span > { { formatDayHourMinutes ( scope . row . assembleTime ) } } < / span >
< / template >
< / e l - t a b l e - c o l u m n >
< el -table -column label = "顶级标识" align = "center" prop = "topFlag" v-if ="columns[6].visible" >
< template slot -scope = " scope " >
< dict -tag :options ="dict.type.active_flag" :value ="scope.row.topFlag" / >
@ -150,13 +155,13 @@
<!-- 添加或修改物料BOM信息对话框 -- >
< el -dialog :title ="title" :visible.sync ="open" width = "500px" append -to -body >
< el -form ref = "form" :model ="form" :rules ="rules" label -width = " 100px " >
< el -form -item label = "父级BOM" prop = "parentId" >
< treeselect v -model = " form.parentId " :options ="materialBomOptions" :normalizer ="normalizer" disabled/ >
< el -form -item label = "父级BOM" prop = "parentId" v-if ="topBomVisible" >
< treeselect v -model = " form.parentId " :options ="materialBomOptions" :normalizer ="normalizer" v-if = " topBomVisible " disabled/ >
< / e l - f o r m - i t e m >
<!-- < el -form -item label = "物料ID" prop = "materialId" > -- >
<!-- < el -input v -model = " form.materialId " placeholder = "请输入物料ID" / > -- >
<!-- < / e l - f o r m - i t e m > - - >
< el -form -item label = "子级BOM " prop = "materialName" >
< el -form -item :label ="childBomName " prop = "materialName" >
< el -input v -model = " form.materialName " placeholder = "请点击右侧检索子BOM" readonly >
< el -button slot = "append" icon = "el-icon-search" @click ="handleMaterialAdd" > < / el -button >
< / e l - i n p u t >
@ -164,8 +169,19 @@
< el -form -item label = "BOM说明" prop = "materialBomDesc" >
< el -input v -model = " form.materialBomDesc " placeholder = "请输入BOM说明(BOM版本)" / >
< / e l - f o r m - i t e m >
< el -form -item label = "安装时长" prop = "assembleTime" v-if ="assembleTimeVisible" >
< el -input -number v -model = " form.productionTimeDays " placeholder = "请输入天数" :min ="0" :max ="10000"
: controls = "false" : style = "{ width: '50px' }" / >
天
< el -input -number v -model = " form.productionTimeHours " placeholder = "请输入小时" :min ="0" :max ="23"
: controls = "false" : style = "{ width: '50px' }" / >
小时
< el -input -number v -model = " form.productionTimeMinutes " placeholder = "请输入分钟" :min ="0" :max ="59"
: controls = "false" : style = "{ width: '50px' }" / >
分钟
< / e l - f o r m - i t e m >
< el -form -item label = "标准数量" prop = "standardAmount" >
< el -input -number v -model = " form.standardAmount " :min ="1" placeholder = "请输入标准数量" / >
< el -input -number v -model = " form.standardAmount " :min ="1" placeholder = "请输入标准数量" :disabled ="amountDisabled" / >
< / e l - f o r m - i t e m >
<!-- < el -form -item label = "顶级标识" prop = "topFlag" > -- >
<!-- < el -radio -group v-model ="form.topFlag" > - - >
@ -186,9 +202,6 @@
< / e l - r a d i o >
< / e l - r a d i o - g r o u p >
< / e l - f o r m - i t e m >
< el -form -item label = "项目ID" prop = "projectId" >
< el -input v -model = " form.projectId " placeholder = "请输入项目ID" / >
< / e l - f o r m - i t e m >
< el -form -item label = "激活标识" prop = "activeFlag" >
< el -radio -group v-model ="form.activeFlag" >
< el -radio
@ -255,6 +268,14 @@ export default {
title : "" ,
/ / 是 否 显 示 弹 出 层
open : false ,
/ / 安 装 时 长 顶 级 B O M 不 显 示
assembleTimeVisible : true ,
/ / 添 加 时 顶 级 B O M 不 显 示
topBomVisible : true ,
/ / 顶 级 B O M 数 量 不 可 输 入
amountDisabled : false ,
/ / 子 级 B O M 名 称 变 化
childBomName : "子级BOM" ,
/ / 是 否 显 示 物 料 弹 出 层
materialOpen : false ,
/ / 是 否 展 开 , 默 认 全 部 展 开
@ -308,9 +329,23 @@ export default {
{ key : 13 , label : ` 更新人 ` , visible : true } ,
{ key : 14 , label : ` 更新时间 ` , visible : true } ,
{ key : 15 , label : ` BOM说明 ` , visible : true } ,
{ key : 16 , label : ` 安装时长 ` , visible : true } ,
] ,
} ;
} ,
watch : {
'form.parentId' : function ( newValue , oldValue ) {
if ( newValue === 0 ) {
this . topBomVisible = false ;
this . amountDisabled = true ;
this . childBomName = "成品BOM" ;
} else {
this . topBomVisible = true ;
this . amountDisabled = false ;
this . childBomName = "子级BOM" ;
}
} ,
} ,
created ( ) {
this . getList ( ) ;
} ,
@ -343,6 +378,15 @@ export default {
this . materialBomOptions . push ( data ) ;
} ) ;
} ,
/** 查询物料BOM信息下拉树结构 */
getBomTreeselect ( selectData ) {
let dataBom = [ ] ;
dataBom . push ( selectData )
this . materialBomOptions = [ ] ;
const data = { materialBomId : 0 , materialName : '顶级节点' , children : [ ] } ;
data . children = this . handleTree ( dataBom , "materialBomId" , "parentId" ) ;
this . materialBomOptions . push ( data ) ;
} ,
/ / 取 消 按 钮
cancel ( ) {
this . open = false ;
@ -358,16 +402,21 @@ export default {
materialName : null ,
standardAmount : null ,
materialBomDesc : null ,
productionTimeDays : 0 ,
productionTimeHours : 0 ,
productionTimeMinutes : 0 ,
topFlag : 1 ,
checkType : '0' ,
projectId : null ,
activeFlag : '1' ,
remark : null ,
assembleTime : null ,
createBy : null ,
createTime : null ,
updateBy : null ,
updateTime : null
} ;
this . assembleTimeVisible = true ;
this . resetForm ( "form" ) ;
} ,
/** 搜索按钮操作 */
@ -382,24 +431,34 @@ export default {
/** 新增按钮操作 */
handleAdd ( row ) {
this . reset ( ) ;
this . getTreeselect ( ) ;
/ / t h i s . g e t T r e e s e l e c t ( ) ;
if ( row != null && row . materialBomId ) {
this . form . parentId = row . materialBomId ;
verifyBOMIsProduction ( row . materialBomId ) . then ( res => {
if ( res . data ) {
throw Error ( )
}
getMaterialBom ( row . materialBomId ) . then ( e => {
/ / B O M 说 明 , 顶 级 不 能 为 空 , 在 选 择 b o m 时 可 以 用 此 字 段 区 分
this . rules . materialBomDesc [ 0 ] . required = this . form . parentId === 0 ;
if ( row . parentId === 0 ) {
this . assembleTimeVisible = false ;
}
this . form . checkType = e . data . checkType ;
this . getBomTreeselect ( e . data ) ;
this . open = true ;
this . title = "添加物料BOM信息" ;
} )
} ) . catch ( ( e ) => {
this . $modal . msgError ( "该物料BOM已被生产工单选择, 无法新增! " ) ;
return ;
} ) ;
} else {
this . form . parentId = 0 ;
}
this . assembleTimeVisible = false ;
this . open = true ;
this . title = "添加物料BOM信息" ;
}
} ,
/** 新增按钮操作 */
handleMaterialAdd ( ) {
@ -425,6 +484,10 @@ export default {
} else {
getMaterialBom ( row . materialBomId ) . then ( response => {
this . form = response . data ;
this . convertToTime ( ) ;
if ( this . form . parentId === 0 ) {
this . assembleTimeVisible = false ;
}
/ / B O M 说 明 , 顶 级 不 能 为 空 , 在 选 择 b o m 时 可 以 用 此 字 段 区 分
this . rules . materialBomDesc [ 0 ] . required = this . form . parentId === 0 ;
this . open = true ;
@ -434,10 +497,35 @@ export default {
} )
}
} ,
/** 天小时分钟转换为秒 */
convertToSeconds ( ) {
const daysInSeconds = this . form . productionTimeDays * 24 * 60 * 60 ;
const hoursInSeconds = this . form . productionTimeHours * 60 * 60 ;
const minutesInSeconds = this . form . productionTimeMinutes * 60 ;
this . form . assembleTime = daysInSeconds + hoursInSeconds + minutesInSeconds ;
} ,
/** 秒转换为天小时分钟 */
convertToTime ( ) {
const totalSeconds = this . form . assembleTime ;
const days = Math . floor ( totalSeconds / ( 24 * 60 * 60 ) ) ;
const hours = Math . floor ( ( totalSeconds % ( 24 * 60 * 60 ) ) / 3600 ) ;
const minutes = Math . floor ( ( totalSeconds % 3600 ) / 60 ) ;
/ / 更 新 到 表 单 中
this . form . productionTimeDays = days ;
this . form . productionTimeHours = hours ;
this . form . productionTimeMinutes = minutes ;
} ,
/** 提交按钮 */
submitForm ( ) {
this . $refs [ "form" ] . validate ( valid => {
if ( valid ) {
if ( ! /^[0-9]\d*$/ . test ( this . form . productionTimeDays )
|| ! /^[0-9]\d*$/ . test ( this . form . productionTimeHours )
|| ! /^[0-9]\d*$/ . test ( this . form . productionTimeMinutes ) ) {
this . $modal . msgError ( "安装时长天、小时、分钟需为大于等于0的正整数! " ) ;
return ;
}
this . convertToSeconds ( ) ;
if ( this . form . materialBomId != null ) {
updateMaterialBom ( this . form ) . then ( response => {
this . $modal . msgSuccess ( "修改成功" ) ;