Commit ac7b0e9f authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 任务管理完成

parent c351dac8
import { request, METHOD } from '@/utils'; import { request, METHOD } from '@/utils';
export * from './menu'; export * from './menu';
export * from './system'; export * from './system';
export * from './task';
export function getUserDetailInfoApi() { export function getUserDetailInfoApi() {
return request('/api/v1/detail', METHOD.GET); return request('/api/v1/detail', METHOD.GET);
......
import { postReq, putReq } from '@/utils';
export function addTaskApi(data) {
return postReq('/api/v1/schedules', data);
}
export function updateTaskApi(data) {
return putReq('/api/v1/schedules', data);
}
<template> <template>
<div class="components-input-demo-presuffix"> <div class="components-input-demo-presuffix">
<a-input :placeholder="placeholder" :value="cron" @input="handleinput"> <a-input :placeholder="placeholder" :value="cron" @input="handleinput" :disabled="disabled">
<a-icon slot="prefix" type="schedule" title="corn控件" @click="openModal" /> <a-icon slot="prefix" type="schedule" title="corn控件" @click="openModal" />
<a-icon v-if="cron" slot="suffix" type="close-circle" @click="handleEmpty" title="清空" /> <a-icon v-if="cron" slot="suffix" type="close-circle" @click="handleEmpty" title="清空" />
</a-input> </a-input>
...@@ -8,29 +8,30 @@ ...@@ -8,29 +8,30 @@
</div> </div>
</template> </template>
<script> <script>
import AntCron from "./AntCron"; import AntCron from './AntCron';
import { replaceWeekName } from "./validator"; import { replaceWeekName } from './validator';
export default { export default {
name: "ACron", name: 'ACron',
components: { components: {
AntCron AntCron,
}, },
props: { props: {
value: { value: {
required: false, required: false,
type: String, type: String,
default: "" default: '',
}, },
placeholder: { placeholder: {
required: false, required: false,
type: String, type: String,
default: "" default: '',
} },
disabled: Boolean,
}, },
data() { data() {
return { return {
cron: this.value, cron: this.value,
afterCron: "" afterCron: '',
}; };
}, },
watch: { watch: {
...@@ -41,33 +42,35 @@ export default { ...@@ -41,33 +42,35 @@ export default {
console.log(replaceWeekName(val)); console.log(replaceWeekName(val));
this.afterCron = replaceWeekName(val); this.afterCron = replaceWeekName(val);
console.log(val); console.log(val);
this.$emit("input", val); this.$emit('input', val);
} },
}, },
methods: { methods: {
openModal() { openModal() {
if (this.disabled) return;
this.$refs.innerVueCron.show(); this.$refs.innerVueCron.show();
}, },
handleOK(val) { handleOK(val) {
this.cron = val; this.cron = val;
this.$emit("change", this.cron); this.$emit('change', this.cron);
}, },
handleinput(evt) { handleinput(evt) {
this.cron = evt.target.value; this.cron = evt.target.value;
if (this.cron !== "") { if (this.cron !== '') {
this.$emit("change", this.cron); this.$emit('change', this.cron);
} else { } else {
this.$emit("change", undefined); this.$emit('change', undefined);
} }
}, },
handleEmpty() { handleEmpty() {
this.handleOK(""); if (this.disabled) return;
} this.handleOK('');
},
}, },
model: { model: {
prop: "value", prop: 'value',
event: "change" event: 'change',
} },
}; };
</script> </script>
<style scoped> <style scoped>
......
This diff is collapsed.
...@@ -20,15 +20,16 @@ export default { ...@@ -20,15 +20,16 @@ export default {
async submit() { async submit() {
await this.$refs.DrawerForm.validate(); await this.$refs.DrawerForm.validate();
if (this.isAdd) { if (this.isAdd) {
return this?.add(); return this.add();
} }
if (this.isEdit) { if (this.isEdit) {
return this?.edit(); return this.edit();
} }
}, },
setData(data, type) { setData(data, type) {
this.form = { ...data }; this.form = { ...data };
this.type = type; this.type = type;
console.log(data, type);
}, },
}, },
}; };
...@@ -62,7 +62,6 @@ export default { ...@@ -62,7 +62,6 @@ export default {
}, },
created() { created() {
this.init(); this.init();
console.log(this.buttonsArr);
}, },
computed: { computed: {
basicBtns() { basicBtns() {
......
...@@ -180,6 +180,7 @@ export default { ...@@ -180,6 +180,7 @@ export default {
this.addVisible = true; this.addVisible = true;
this.type = 0; this.type = 0;
this.noFooter = false; this.noFooter = false;
this.title = '新增';
}, },
addDrawerClose() { addDrawerClose() {
this.addVisible = false; this.addVisible = false;
......
...@@ -37,7 +37,6 @@ export default { ...@@ -37,7 +37,6 @@ export default {
addBtn: { addBtn: {
text: '新建', text: '新建',
onOk() { onOk() {
console.log(vm.addCom);
return vm.addCom ? vm.$refs['addCom']?.submit() : vm.$refs['addForm']?.submit(); return vm.addCom ? vm.$refs['addCom']?.submit() : vm.$refs['addForm']?.submit();
}, },
onCancel() { onCancel() {
...@@ -50,7 +49,7 @@ export default { ...@@ -50,7 +49,7 @@ export default {
{ {
label: '新增组件', label: '新增组件',
option: { option: {
type: 'danger', style: 'color: #ff4d4f',
}, },
click(row) { click(row) {
vm.show(); vm.show();
......
<template> <template>
<a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm"> <a-form-model layout="vertical" :model="form" :rules="rules" ref="DrawerForm">
<a-form-model-item label="任务名称" prop="jobName"> <a-form-model-item label="任务名称" prop="taskName">
<a-input v-model="form.jobName" :disabled="isView" /> <a-input v-model="form.taskName" :disabled="isView" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="调度规则" prop="jobDescription"> <a-form-model-item label="调度规则" prop="taskRule">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" /> <ACron v-model="form.taskRule" :disabled="isView" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="实现类" prop="jobDescription"> <a-form-model-item label="实现类" prop="implementClass">
<a-input v-model="form.jobDescription" :disabled="isView" /> <a-input v-model="form.implementClass" :disabled="isView" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="说明" prop="jobDescription"> <a-form-model-item label="说明" prop="remark">
<a-textarea v-model="form.jobDescription" :disabled="isView" :rows="4" /> <a-textarea v-model="form.remark" :disabled="isView" :rows="4" />
</a-form-model-item> </a-form-model-item>
</a-form-model> </a-form-model>
</template> </template>
<script> <script>
import JobsApi from '@/api/organization'; import { addTaskApi, updateTaskApi } from '@/api';
import FormMixin from '@/components/FormMixin'; import FormMixin from '@/components/FormMixin';
import ACron from '@/components/Acron/ACron.vue';
export default { export default {
components: { ACron },
props: ['row'],
mixins: [FormMixin], mixins: [FormMixin],
data() { data() {
return { return {
rules: { rules: {
jobName: [{ required: true, message: 'Please select Activity zone', trigger: 'change' }], taskName: [{ required: true }],
jobDescription: [ taskRule: [{ required: true }],
{ required: true, message: 'Please select Activity zone', trigger: 'change' },
],
}, },
}; };
}, },
methods: { methods: {
add() { add() {
return JobsApi.add({ ...this.form }); return addTaskApi({ ...this.form });
}, },
edit() { edit() {
return JobsApi.update({ ...this.form }); return updateTaskApi({ ...this.form });
}, },
}, },
}; };
......
<template> <template>
<my-table url="/api/v1/schedules" rowKey="taskId" :addBtn="addBtn" ref="table"> <my-table url="/api/v1/schedules" rowKey="taskId" :addBtn="addBtn" ref="table">
<template #drawer> <template #drawer>
<Form ref="form" /> <Form ref="form" :row="currentClickRow" />
</template> </template>
<a-table-column title="任务名称" data-index="taskName" /> <a-table-column title="任务名称" data-index="taskName" />
<a-table-column title="调度规则" data-index="taskRule" /> <a-table-column title="调度规则" data-index="taskRule" />
...@@ -23,7 +23,12 @@ export default { ...@@ -23,7 +23,12 @@ export default {
components: { ActionButton, Form }, components: { ActionButton, Form },
data() { data() {
return { return {
addBtn: {}, addBtn: {
onOk: () => {
return this.$refs.form.submit();
},
},
currentClickRow: null,
buttons: [ buttons: [
{ {
label: '查看', label: '查看',
...@@ -47,8 +52,9 @@ export default { ...@@ -47,8 +52,9 @@ export default {
type: 'confirm', type: 'confirm',
label: '失效', label: '失效',
title: '确认是否失效?', title: '确认是否失效?',
url: row => `/api/v1/schedules/${row.taskId}`, url: row => ({ url: `/api/v1/schedules/${row.taskId}/pause`, method: 'del' }),
after: () => this.refreshTable(), after: () => this.refreshTable(),
isHidden: row => row.isPaused === 1,
}, },
{ {
type: 'confirm', type: 'confirm',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment