@ -87,14 +87,14 @@
< / div >
< el -dialog center :title ="title" :close-on-click-modal ="false" :visible.sync ="open" width = "42%" append -to -body >
< el -form :model ="form " label -width = " 80px " >
< el -form ref = "form" :model ="form " :rules ="rules " label -width = " 80px " >
<!-- 通知名称 -- >
< el -form -item label = "通知名称" :required ="true" >
< el -form -item label = "通知名称" prop = "notificationName" :required ="true" >
< el -input v -model = " form.notificationName " placeholder = "请输入通知名称" > < / e l - i n p u t >
< / e l - f o r m - i t e m >
<!-- 通知类型 -- >
< el -form -item label = "通知类型" :required ="true" >
< el -form -item label = "通知类型" prop = "notificationType" :required ="true" >
< el -select v-model ="form.notificationType" placeholder="请选择通知类型" style="width: 100%" >
< el -option label = "到期通知" value = "到期通知" > < / e l - o p t i o n >
< el -option label = "库存预警" value = "库存预警" > < / e l - o p t i o n >
@ -104,7 +104,7 @@
< / e l - f o r m - i t e m >
<!-- 通知模板 -- >
< el -form -item label = "通知模板" :required ="true" >
< el -form -item label = "通知模板" prop = "templateContent" :required ="true" >
< el -input type = "textarea" v -model = " form.templateContent " :rows ="3" placeholder = "请输入通知内容"
: maxlength = "200" show - word - limit > < / e l - i n p u t >
< div >
@ -115,7 +115,7 @@
< / div >
< / e l - f o r m - i t e m >
<!-- 接收角色 -- >
< el -form -item label = "接收角色" :required ="true" >
< el -form -item label = "接收角色" prop = "recipientRoles" :required ="true" >
< el -select v-model ="form.recipientRoles" multiple placeholder="请选择角色" style="width: 100%" >
< el -option v-for ="item in dutyList1" :label="item.dutyName" :value="item.dutyId" > < / el -option >
< / e l - s e l e c t >
@ -125,7 +125,7 @@
< el -switch v-model ="form.templateStatus" active-color="#13ce66" inactive-color="#ff4949" > < / el -switch >
< / e l - f o r m - i t e m >
<!-- 发送条件 -- >
< el -form -item label = "发送条件" style= "margin-bottom: 10px" :required ="true" >
< el -form -item label = "发送条件" prop= "conditions" style= "margin-bottom: 10px" :required ="true" >
< div v -for = " ( condition , index ) in form.conditions " :key ="index" class = "condition-group"
style = "margin-bottom: 10px" >
< el -select v -model = " condition.field " placeholder = "请选择条件" style = "width: 35%;margin-right: 10px"
@ -151,7 +151,7 @@
< / e l - f o r m >
< div style = "display: flex; justify-content: center; align-items: center;margin-top: 30px" >
< el -button @click ="handleReset" > 取消 < / el -button >
< el -button type = "primary" @click ="handleSubmit" > 保存 < / el -button >
< el -button type = "primary" @ click = "handleSubmit('form' )" > 保存 < / e l - b u t t o n >
< / div >
< / e l - d i a l o g >
< / div >
@ -206,6 +206,24 @@ export default {
legalRepresentativeContact : '' ,
appStatus : '' ,
} ,
rules : {
notificationName : [
{ required : true , message : '不能为空' , trigger : 'blur' } ,
] ,
notificationType : [
{ required : true , message : '不能为空' , trigger : 'blur' } ,
] ,
templateContent : [
{ required : true , message : '不能为空' , trigger : 'blur' } ,
] ,
recipientRoles : [
{ required : true , message : '不能为空' , trigger : 'blur' } ,
] ,
conditions : [
{ required : true , message : '不能为空' , trigger : 'blur' } ,
] ,
} ,
roleList : [ ] ,
} ;
} ,
@ -264,38 +282,34 @@ export default {
/ / } ) ;
/ / } ,
handleSubmit ( ) {
this . open = false
handleSubmit ( formName ) {
this . $refs [ formName ] . validate ( ( valid ) => {
if ( valid ) {
/ / 表 单 验 证 通 过 , 可 以 提 交 数 据
this . open = false
if ( this . form . id ) {
updateSysNotifyApi ( this . form ) . then ( res => {
if ( res . code === 200 ) {
this . getList ( )
this . open = false
}
} )
} else {
saveSysNotifyApi ( this . form ) . then ( res => {
if ( res . code === 200 ) {
this . getList ( )
this . open = false
}
} )
}
}
} )
/ / 在 这 里 调 用 接 口 提 交 设 备 信 息 数 据
console . log ( '提交设备信息数据:' , this . form ) ;
if ( this . form . conditions . length === 0 || this . form . conditions [ 0 ] . field == '' ) {
this . form . conditions = ''
this . $message ( {
type : 'info' ,
message : '请选择发送条件!'
} ) ;
return
} else {
this . form . conditions = JSON . stringify ( this . form . conditions )
}
this . form . recipientRoles = JSON . stringify ( this . form . recipientRoles )
if ( this . form . id ) {
updateSysNotifyApi ( this . form ) . then ( res => {
if ( res . code === 200 ) {
this . getList ( )
this . open = false
}
} )
} else {
saveSysNotifyApi ( this . form ) . then ( res => {
if ( res . code === 200 ) {
this . getList ( )
this . open = false
}
} )
}
} ,
handleReset ( ) {
this . open = false