268 lines
7.4 KiB
Python
268 lines
7.4 KiB
Python
<template>
|
|
<div class="app-container">
|
|
<el-card>
|
|
<div>
|
|
<el-input
|
|
v-model="listQuery.search"
|
|
placeholder="任务名"
|
|
style="width: 300px"
|
|
class="filter-item"
|
|
@keyup.enter.native="handleFilter"
|
|
/>
|
|
<el-button
|
|
class="filter-item"
|
|
type="primary"
|
|
icon="el-icon-search"
|
|
@click="handleFilter"
|
|
>搜索</el-button
|
|
>
|
|
<el-button
|
|
class="filter-item"
|
|
type="primary"
|
|
icon="el-icon-refresh-left"
|
|
@click="resetFilter"
|
|
>刷新重置</el-button
|
|
>
|
|
</div>
|
|
<div style="margin-top: 10px">
|
|
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
|
|
>创建报送任务</el-button
|
|
>
|
|
<el-button type="primary" icon="el-icon-plus" @click="handleCreate2"
|
|
>创建主动报送任务</el-button
|
|
>
|
|
</div>
|
|
</el-card>
|
|
<el-card style="margin-top: 10px">
|
|
<el-table
|
|
v-loading="listLoading"
|
|
:data="taskList.results"
|
|
border
|
|
fit
|
|
stripe
|
|
highlight-current-row
|
|
max-height="600"
|
|
>
|
|
<el-table-column type="index" width="50" />
|
|
<el-table-column label="任务名">
|
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="是否主动报送">
|
|
<template slot-scope="scope">
|
|
<el-tag v-if="scope.row.is_self" type="success">是</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="状态">
|
|
<template slot-scope="scope">
|
|
<el-tag>{{scope.row.state}}</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="截止日期">
|
|
<template slot-scope="scope">{{ scope.row.end_date }}</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="任务备注">
|
|
<template slot-scope="scope">{{ scope.row.note }}</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
align="center"
|
|
label="操作"
|
|
width="220px"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
type="primary"
|
|
:disabled="!checkPermission(['task_view'])"
|
|
size="small"
|
|
@click="handleDo(scope)"
|
|
>执行</el-button>
|
|
<el-button
|
|
:disabled="!checkPermission(['task_update'])"
|
|
size="small"
|
|
@click="handleEdit(scope)"
|
|
>编辑</el-button>
|
|
<el-button
|
|
:disabled="!checkPermission(['task_delete'])"
|
|
type="danger"
|
|
size="small"
|
|
@click="handleDelete(scope)"
|
|
>删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination
|
|
v-show="taskList.count > 0"
|
|
:total="taskList.count"
|
|
:page.sync="listQuery.page"
|
|
:limit.sync="listQuery.page_size"
|
|
@pagination="getList"
|
|
/>
|
|
</el-card>
|
|
<el-dialog
|
|
:visible.sync="dialogVisible"
|
|
:title="dialogType === 'edit' ? '编辑任务' : '新增任务'"
|
|
>
|
|
<el-form
|
|
ref="Form"
|
|
:model="task"
|
|
label-width="80px"
|
|
label-position="right"
|
|
:rules="rule1"
|
|
>
|
|
<el-form-item label="任务名" prop="name">
|
|
<el-input v-model="task.name" placeholder="名称" />
|
|
</el-form-item>
|
|
<el-form-item label="截止日期" prop="end_date">
|
|
<el-date-picker
|
|
v-model="task.end_date"
|
|
type="date"
|
|
placeholder="选择日期"
|
|
value-format="yyyy-MM-dd"
|
|
style="width:100%"
|
|
>
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="任务备注" prop="note">
|
|
<el-input
|
|
type="textarea"
|
|
:rows="4"
|
|
v-model="task.note"
|
|
placeholder="任务备注"
|
|
/>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div style="text-align: right">
|
|
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
|
|
<el-button type="primary" @click="confirm('Form')">确认</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import { gettasklist, createtask, deletetask, updatetask } from "@/api/task";
|
|
import checkPermission from "@/utils/permission";
|
|
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
|
|
const defaulttask = {
|
|
name: "",
|
|
note: "",
|
|
end_date: null,
|
|
};
|
|
export default {
|
|
components: { Pagination },
|
|
data() {
|
|
return {
|
|
task: defaulttask,
|
|
taskList: {
|
|
count: 0,
|
|
},
|
|
listQuery: {
|
|
page: 1,
|
|
page_size: 20,
|
|
},
|
|
listLoading: true,
|
|
dialogVisible: false,
|
|
dialogType: "new",
|
|
rule1: {
|
|
name: [{ required: true, message: "请输入", trigger: "blur" }],
|
|
end_date: [{ required: true, message: "请选择", trigger: "blur" }],
|
|
},
|
|
};
|
|
},
|
|
computed: {},
|
|
watch: {},
|
|
created() {
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
checkPermission,
|
|
getList() {
|
|
this.listLoading = true;
|
|
gettasklist(this.listQuery).then((response) => {
|
|
if (response.data) {
|
|
this.taskList = response.data;
|
|
}
|
|
this.listLoading = false;
|
|
});
|
|
},
|
|
|
|
handleFilter() {
|
|
this.listQuery.page = 1;
|
|
this.getList();
|
|
},
|
|
resetFilter() {
|
|
this.listQuery = {
|
|
page: 1,
|
|
page_size: 20,
|
|
}
|
|
this.getList();
|
|
},
|
|
handleCreate() {
|
|
this.task = Object.assign({}, defaulttask);
|
|
this.dialogType = "new";
|
|
this.dialogVisible = true;
|
|
this.$nextTick(() => {
|
|
this.$refs["Form"].clearValidate();
|
|
});
|
|
},
|
|
handleCreate2() {
|
|
|
|
},
|
|
handleDo(scope) {
|
|
this.$router.push({name: "Taskdo", params: { id: scope.row.id }, })
|
|
},
|
|
handleEdit(scope) {
|
|
this.task = Object.assign({}, scope.row); // copy obj
|
|
this.dialogType = "edit";
|
|
this.dialogVisible = true;
|
|
this.$nextTick(() => {
|
|
this.$refs["Form"].clearValidate();
|
|
});
|
|
},
|
|
handleDelete(scope) {
|
|
this.$confirm("确认删除?", "警告", {
|
|
confirmButtonText: "确认",
|
|
cancelButtonText: "取消",
|
|
type: "error",
|
|
})
|
|
.then(async () => {
|
|
await deletetask(scope.row.id);
|
|
this.getList();
|
|
this.$message.success("成功");
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
});
|
|
},
|
|
async confirm(form) {
|
|
this.$refs[form].validate((valid) => {
|
|
if (valid) {
|
|
const isEdit = this.dialogType === "edit";
|
|
if (isEdit) {
|
|
updatetask(this.task.id, this.task).then((res) => {
|
|
if (res.code >= 200) {
|
|
this.getList();
|
|
this.dialogVisible = false;
|
|
this.$message.success("成功");
|
|
}
|
|
});
|
|
} else {
|
|
createtask(this.task).then((res) => {
|
|
if (res.code >= 200) {
|
|
this.getList();
|
|
this.dialogVisible = false;
|
|
this.$router.push({name: "Taskdo", params: { id: res.data.id }, })
|
|
this.$message.success("成功");
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|