addTask.vue
4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<template>
<!-- 编辑 -->
<dialogBox ref="addTask" width="60%" @submitForm="handleSubmit" @closeDialog="handleClose" v-model="myValue"
customClass="editValidRule" title="新增定时任务">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="任务名" prop="jobName">
<el-input v-model="ruleForm.jobName" placeholder="任务名"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="类名" prop="beanName">
<el-input v-model="ruleForm.beanName" placeholder="类名"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="cron表达式" prop="cronExpression">
<el-input v-model="ruleForm.cronExpression" placeholder="cron表达式"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="方法名" prop="methodName">
<el-input v-model="ruleForm.methodName" placeholder="方法名"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="任务描述" prop="remark">
<el-input v-model="ruleForm.remark" placeholder="任务描述"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<message-tips :message="message" ref="msg" />
</dialogBox>
</template>
<script>
import sjsbTask from '@/api/sjsbTask.js'
export default {
props: {
value: { type: Boolean, default: false },
taskData: {
type: Object,
default: null
}
},
data () {
return {
myValue: this.value,
ruleForm: {
jobName: '',
cronExpression: '',
beanName: '',
methodName: '',
methodParams: '',
remark: ''
},
rules: {
jobName: [
{ required: true, message: '任务名', trigger: 'blur' }
],
cronExpression: [
{ required: true, message: 'cron表达式', trigger: 'blur' }
],
beanName: [
{ required: true, message: '任务类名', trigger: 'blur' }
],
methodName: [
{ required: true, message: '任务方法名', trigger: 'blur' }
]
},
message: ''
}
},
methods: {
handleSubmit () {
let _this = this
this.$refs['ruleForm'].validate(async (valid) => {
if (valid) {
if (!_this.taskData) {
try {
let res = await sjsbTask.sjsbTaskSave(_this.ruleForm)
if (res.code == 200) {
_this.loading = false
_this.$message({
message: res.message,
type: 'success'
})
_this.handleClose()
_this.$parent.featchData()
}
} catch (error) {
_this.message = error
_this.$refs.msg.messageShow()
}
} else {
try {
let res = await sjsbTask.updateCron(_this.ruleForm)
if (res.code == 200) {
_this.$message({
message: res.message,
type: 'success'
})
_this.handleClose()
_this.$parent.featchData()
}
} catch (error) {
_this.message = error
_this.$refs.msg.messageShow()
}
}
} else {
this.$message('请检查表单完整性')
return false;
}
})
},
handleClose () {
this.$emit("input", false);
}
},
watch: {
value(val) {
this.myValue = val
},
taskData(val) {
if (val != null) {
this.ruleForm = val
} else {
this.ruleForm = {
jobName: '',
cronExpression: '',
beanName: '',
methodName: '',
methodParams: '',
remark: ''
}
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "~@/styles/public.scss";
.editDialogBox-box {
margin: 14px 18px 30px 18px !important
}
/deep/.el-form-item__label {
color: #fff;
}
/deep/.el-form-item {
color: #fff;
margin-bottom: 10px;
}
/deep/ .el-input__inner {
background-color: transparent;
border: 1px solid #458ACF;
}
</style>