<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
append-to-body
|
:visible.sync="visible">
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
<el-form-item label="定时名称" prop="name">
|
<el-input v-model="dataForm.name" placeholder="定时名称"></el-input>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<!-- 取消按钮 -->
|
<button class="btn-cancel" @click="visible = false"></button>
|
<!-- 确定按钮 -->
|
<button class="btn-config" type="primary" @click="dataFormSubmit()"></button>
|
</span>
|
</el-dialog>
|
</template>
|
|
<script>
|
export default {
|
data () {
|
return {
|
visible: false,
|
dataForm: {
|
timeId: 0,
|
parentId: '',
|
name: '',
|
type: '',
|
beanName: '',
|
value: '',
|
cron: '',
|
createUserId: '',
|
createTime: '',
|
groupId: []
|
},
|
dataRule: {
|
name: [
|
{ required: true, message: '定时名称不能为空', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
methods: {
|
init (id) {
|
this.dataForm.timeId = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs['dataForm'].resetFields()
|
this.$http({
|
url: this.$http.adornUrl(`/pole/poletime/info/${this.dataForm.timeId}`),
|
method: 'get',
|
params: this.$http.adornParams()
|
}).then(({data}) => {
|
if (data && data.code === 0) {
|
this.dataForm.parentId = data.poleTime.parentId
|
this.dataForm.name = data.poleTime.name
|
this.dataForm.type = data.poleTime.type
|
this.dataForm.beanName = data.poleTime.beanName
|
this.dataForm.value = data.poleTime.value
|
this.dataForm.cron = data.poleTime.cron
|
this.dataForm.groupId = data.poleTime.groupId || []
|
} else {
|
this.dataForm.parentId = ''
|
this.dataForm.name = ''
|
this.dataForm.type = 0
|
this.dataForm.beanName = ''
|
this.dataForm.value = ''
|
this.dataForm.cron = ''
|
this.dataForm.groupId = []
|
}
|
})
|
})
|
},
|
// 表单提交
|
dataFormSubmit () {
|
this.$refs['dataForm'].validate((valid) => {
|
if (valid) {
|
this.$http({
|
url: this.$http.adornUrl(`/pole/poletime/${!this.dataForm.timeId ? 'save' : 'update'}`),
|
method: 'post',
|
data: this.$http.adornData({
|
'timeId': this.dataForm.timeId || undefined,
|
'parentId': this.dataForm.parentId,
|
'name': this.dataForm.name,
|
'type': this.dataForm.type,
|
'beanName': this.dataForm.beanName,
|
'value': this.dataForm.value,
|
'cron': this.dataForm.cron,
|
'groupId': this.dataForm.groupId
|
})
|
}).then(({data}) => {
|
if (data && data.code === 0) {
|
this.$message({
|
message: '操作成功',
|
type: 'success',
|
duration: 1500,
|
onClose: () => {
|
this.visible = false
|
this.$emit('refreshDataList')
|
}
|
})
|
} else {
|
this.$message.error(data.msg)
|
}
|
})
|
}
|
})
|
},
|
// 类型改变
|
typeChange () {
|
},
|
// 编辑cron
|
editCron () {
|
this.scheduleVisible = true
|
this.$nextTick(() => {
|
this.$refs.schedule.init(this.dataForm.cron)
|
})
|
},
|
// 更改cron回调方法
|
changeCron (val) {
|
this.dataForm.cron = val
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
div {
|
/deep/ .el-dialog__header {
|
background: url(~@/assets/img/streetlight/dialog-title.png);
|
background-size:100% 100%;
|
};
|
/deep/ .el-dialog{
|
background: #143251;
|
border:3px solid #458aad;
|
/deep/ .el-form-item__label {
|
color: #fff
|
}
|
/deep/ .el-input__inner {
|
background-color: transparent;
|
color: #fff
|
}
|
};
|
}
|
</style>
|