默认添加方法
add() {
this.edit({})
},
默认编辑
edit(record) {
this.form.resetFields()//打开清空form表单
this.model = Object.assign({}, record)//通过index赋值表单
this.visible = true
this.dataSource = [] //清空下方列表
//设置字段
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'noticeType', 'noticeTitle', 'noticeBody', 'sendTargets'))
//时间格式化
this.form.setFieldsValue({ sendTime: this.model.sendTime ? moment(this.model.sendTime) : null })
})
},
验证表单方法
//验证是否有发送短信的权限
validateCheckSMS(rule, value, callback) {
if (this.formState.noticeType == 1) {
getAction(this.url.checkSMS).then((res) => {
console.log(res, '读取的结果')
if (res.success) {
callback()
} else {
//不符合返回错误
callback(new Error(''))
}
})
} else {
callback()
}
},
关闭
//默认关闭 有其他清空方法放这里
close() {
this.$emit('close')
this.visible = false
},