提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false"> |
|
3 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px"> |
|
4 |
<el-form-item prop="beanName" :label="$t('schedule.beanName')"> |
|
5 |
<el-input v-model="dataForm.beanName" :placeholder="$t('schedule.beanNameTips')"></el-input> |
|
6 |
</el-form-item> |
|
7 |
<el-form-item prop="params" :label="$t('schedule.params')"> |
|
8 |
<el-input v-model="dataForm.params" :placeholder="$t('schedule.params')"></el-input> |
|
9 |
</el-form-item> |
|
10 |
<el-form-item prop="cronExpression" :label="$t('schedule.cronExpression')"> |
|
11 |
<el-popover v-model="cronPopover"> |
|
12 |
<cron @change="changeCron" @close="cronPopover=false" i18n="cn"></cron> |
|
13 |
<el-input slot="reference" @click="cronPopover=true" v-model="dataForm.cronExpression" :placeholder="$t('schedule.cronExpressionTips')"></el-input> |
|
14 |
</el-popover> |
|
15 |
</el-form-item> |
|
16 |
<el-form-item prop="remark" :label="$t('schedule.remark')"> |
|
17 |
<el-input v-model="dataForm.remark" :placeholder="$t('schedule.remark')"></el-input> |
|
18 |
</el-form-item> |
|
19 |
</el-form> |
|
20 |
<template slot="footer"> |
|
21 |
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|
22 |
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|
23 |
</template> |
|
24 |
</el-dialog> |
|
25 |
</template> |
|
26 |
|
|
27 |
<script> |
|
28 |
import debounce from 'lodash/debounce' |
|
29 |
import { cron } from 'vue-cron' |
|
30 |
export default { |
|
31 |
data () { |
|
32 |
return { |
|
33 |
visible: false, |
|
34 |
dataForm: { |
|
35 |
id: '', |
|
36 |
beanName: '', |
|
37 |
params: '', |
|
38 |
cronExpression: '', |
|
39 |
remark: '', |
|
40 |
status: 0 |
|
41 |
}, |
|
42 |
cronPopover: false |
|
43 |
} |
|
44 |
}, |
|
45 |
components: { |
|
46 |
cron |
|
47 |
}, |
|
48 |
computed: { |
|
49 |
dataRule () { |
|
50 |
return { |
|
51 |
beanName: [ |
|
52 |
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
53 |
], |
|
54 |
cronExpression: [ |
|
55 |
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|
56 |
] |
|
57 |
} |
|
58 |
} |
|
59 |
}, |
|
60 |
methods: { |
|
61 |
init () { |
|
62 |
debugger |
|
63 |
console.info(this.dataForm.id) |
|
64 |
this.visible = true |
|
65 |
this.$nextTick(() => { |
|
66 |
this.$refs['dataForm'].resetFields() |
|
67 |
if (this.dataForm.id) { |
|
68 |
this.getInfo() |
|
69 |
} |
|
70 |
}) |
|
71 |
}, |
|
72 |
changeCron (val) { |
|
73 |
this.dataForm.cronExpression = val |
|
74 |
}, |
|
75 |
// 获取信息 |
|
76 |
getInfo () { |
|
77 |
this.$http.get(`/iailab-ntt-model/mcs/schedule/${this.dataForm.id}`).then(({ data: res }) => { |
|
78 |
if (res.code !== 0) { |
|
79 |
return this.$message.error(res.msg) |
|
80 |
} |
|
81 |
this.dataForm = res.data |
|
82 |
}).catch(() => {}) |
|
83 |
}, |
|
84 |
// 表单提交 |
|
85 |
dataFormSubmitHandle: debounce(function () { |
|
86 |
this.$refs['dataForm'].validate((valid) => { |
|
87 |
if (!valid) { |
|
88 |
return false |
|
89 |
} |
|
90 |
this.$http[!this.dataForm.id ? 'post' : 'put']('/iailab-ntt-model/mcs/schedule', this.dataForm).then(({ data: res }) => { |
|
91 |
if (res.code !== 0) { |
|
92 |
return this.$message.error(res.msg) |
|
93 |
} |
|
94 |
this.$message({ |
|
95 |
message: this.$t('prompt.success'), |
|
96 |
type: 'success', |
|
97 |
duration: 500, |
|
98 |
onClose: () => { |
|
99 |
this.visible = false |
|
100 |
this.$emit('refreshDataList') |
|
101 |
} |
|
102 |
}) |
|
103 |
}).catch(() => {}) |
|
104 |
}) |
|
105 |
}, 1000, { 'leading': true, 'trailing': false }) |
|
106 |
} |
|
107 |
} |
|
108 |
</script> |