创建报送任务vue

This commit is contained in:
caoqianming 2021-03-15 09:21:12 +08:00
parent a408760d71
commit f199b9d68f
5 changed files with 149 additions and 175 deletions

View File

@ -1,9 +1,7 @@
import request from '@/utils/request' import request from '@/utils/request'
export function gettasklist(query) {
export function getTaskList(query) {
return request({ return request({
url: '/supervision/task/', url: '/supervision/task/',
method: 'get', method: 'get',
@ -11,14 +9,14 @@ export function getTaskList(query) {
}) })
} }
export function getTask(id) { export function gettask(id) {
return request({ return request({
url: `/supervision/task/${id}/`, url: `/supervision/task/${id}/`,
method: 'get' method: 'get'
}) })
} }
export function createTask(data) { export function createtask(data) {
return request({ return request({
url: '/supervision/task/', url: '/supervision/task/',
method: 'post', method: 'post',
@ -26,7 +24,7 @@ export function createTask(data) {
}) })
} }
export function updateTask(id, data) { export function updatetask(id, data) {
return request({ return request({
url: `/supervision/task/${id}/`, url: `/supervision/task/${id}/`,
method: 'put', method: 'put',
@ -34,7 +32,7 @@ export function updateTask(id, data) {
}) })
} }
export function deleteTask(id, data) { export function deletetask(id, data) {
return request({ return request({
url: `/supervision/task/${id}/`, url: `/supervision/task/${id}/`,
method: 'delete', method: 'delete',

View File

@ -118,7 +118,7 @@ export const asyncRoutes = [
path: 'content', path: 'content',
name: 'Content', name: 'Content',
component: () => import('@/views/supervision/content.vue'), component: () => import('@/views/supervision/content.vue'),
meta: { title: '料清单', icon: 'documentation', perms: ['content_manage'] } meta: { title: '料清单', icon: 'documentation', perms: ['content_manage'] }
}, },
{ {
path: 'task', path: 'task',

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div style="margin-top: 10px"> <el-card>
<el-button type="primary" icon="el-icon-plus" @click="handleAddContent" <el-button type="primary" icon="el-icon-plus" @click="handleAddContent"
>新增</el-button >新增</el-button
> >
</div> </el-card>
<el-card <el-card
style="margin-top: 10px" style="margin-top: 10px"
> >
@ -31,8 +31,7 @@
<el-table-column align="center" label="是否可主动报送"> <el-table-column align="center" label="是否可主动报送">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="success" v-if="scope.row.can_doself"></el-tag> <el-tag type="success" v-if="scope.row.can_doself"></el-tag>
<el-tag type="danger" v-else></el-tag></template </template>
>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="200px" fixed="right"> <el-table-column align="center" label="操作" width="200px" fixed="right">
@ -99,31 +98,6 @@
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<style>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
.avatar {
width: 100px;
height: 100px;
display: block;
}
</style>
<script> <script>
import { import {
getContentList, getContentList,

View File

@ -1,97 +1,133 @@
<template> <template>
<div class="app-container"> <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"> <div style="margin-top: 10px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate" <el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>创建报送任务</el-button> >创建报送任务</el-button
>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate2" <el-button type="primary" icon="el-icon-plus" @click="handleCreate2"
>创建主动报送任务</el-button> >创建主动报送任务</el-button
>
</div> </div>
<el-card </el-card>
style="margin-top: 10px" <el-card style="margin-top: 10px">
> <el-table
<el-table v-loading="listLoading"
v-loading="listLoading" :data="taskList.results"
:data="contentList" border
border fit
fit stripe
stripe highlight-current-row
highlight-current-row max-height="600"
max-height="600" >
> <el-table-column type="index" width="50" />
<el-table-column type="index" width="50" /> <el-table-column label="任务名">
<el-table-column label="名称"> <template slot-scope="scope">{{ scope.row.name }}</template>
<template slot-scope="scope">{{ scope.row.name }}</template> </el-table-column>
</el-table-column> <el-table-column label="是否主动报送">
<el-table-column label="详情"> <template slot-scope="scope">
<template slot-scope="scope">{{ scope.row.desc }}</template> <el-tag v-if="scope.row.is_self" type="success"></el-tag>
</el-table-column> </template>
</el-table-column>
<el-table-column label="截止日期">
<template slot-scope="scope">{{ scope.row.end_date }}</template>
</el-table-column>
<el-table-column label="材料类型"> <el-table-column label="任务备注">
<template slot-scope="scope">{{ scope.row.type_ }}</template> <template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="是否可主动报送">
<template slot-scope="scope"> <el-table-column
<el-tag type="success" v-if="scope.row.can_doself"></el-tag> align="center"
<el-tag type="danger" v-else></el-tag></template label="操作"
width="220px"
fixed="right"
> >
</el-table-column> <template slot-scope="scope">
<el-button
<el-table-column align="center" label="操作" width="200px" fixed="right"> type="primary"
<template slot-scope="scope"> :disabled="!checkPermission(['task_view'])"
<el-button size="small"
:disabled="!checkPermission(['content_update'])" @click="handleDetail(scope)"
type="primary" >详情</el-button>
size="small" <el-button
icon="el-icon-edit" :disabled="!checkPermission(['task_update'])"
@click="handleEdit(scope)" size="small"
/> @click="handleEdit(scope)"
<el-button >编辑</el-button>
:disabled="!checkPermission(['content_delete'])" <el-button
type="danger" :disabled="!checkPermission(['task_delete'])"
size="small" type="danger"
icon="el-icon-delete" size="small"
@click="handleDelete(scope)" @click="handleDelete(scope)"
/> >删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-card> <pagination
v-show="taskList.count > 0"
:total="taskList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
</el-card>
<el-dialog <el-dialog
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:title="dialogType === 'edit' ? '编辑资料' : '新增资料'" :title="dialogType === 'edit' ? '编辑任务' : '新增任务'"
> >
<el-form <el-form
ref="Form" ref="Form"
:model="Content" :model="task"
label-width="80px" label-width="80px"
label-position="right" label-position="right"
:rules="rule1" :rules="rule1"
> >
<el-form-item label="" prop="name"> <el-form-item label="任务" prop="name">
<el-input v-model="Content.name" placeholder="名称" /> <el-input v-model="task.name" placeholder="名称" />
</el-form-item> </el-form-item>
<el-form-item label="材料类型" prop="type" > <el-form-item label="截止日期" prop="end_date">
<el-cascader <el-date-picker
v-model = "Content.type" v-model="task.end_date"
:options="typeOptions" type="date"
:props="{ emitPath : false , }" placeholder="选择日期"
clearable value-format="yyyy-MM-dd"
style="width:100%" style="width:100%"
></el-cascader> >
</el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="详情" prop="desc"> <el-form-item label="任务备注" prop="note">
<el-input <el-input
type="textarea" type="textarea"
:rows="4" :rows="4"
v-model="Content.desc" v-model="task.note"
placeholder="详情" placeholder="任务备注"
/> />
</el-form-item> </el-form-item>
<el-form-item label="是否可主动报送" prop="can_doself" label-width="120px">
<el-switch v-model="Content.can_doself" ></el-switch>
</el-form-item>
</el-form> </el-form>
<div style="text-align: right"> <div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button> <el-button type="danger" @click="dialogVisible = false">取消</el-button>
@ -100,114 +136,77 @@
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<style>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
.avatar {
width: 100px;
height: 100px;
display: block;
}
</style>
<script> <script>
import { import { gettasklist, createtask, deletetask, updatetask } from "@/api/task";
getContentList,
createContent,
deleteContent,
updateContent,
} from "@/api/content";
import { genTree } from "@/utils";
import checkPermission from "@/utils/permission"; import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import Treeselect from "@riophae/vue-treeselect"; const defaulttask = {
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getDictList, getDictTypeList } from "@/api/dict";
const defaultContent = {
name: "", name: "",
desc: "", note: "",
type: null, end_date: null,
can_doself: false,
}; };
export default { export default {
components: { Pagination, Treeselect }, components: { Pagination },
data() { data() {
return { return {
Content: defaultContent, task: defaulttask,
contentList: [], taskList: {
typeOptions: [], count: 0,
},
listQuery: {
page: 1,
page_size: 20,
},
listLoading: true, listLoading: true,
dialogVisible: false, dialogVisible: false,
dialogType: "new", dialogType: "new",
rule1: { rule1: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }], name: [{ required: true, message: "请输入", trigger: "blur" }],
end_date: [{ required: true, message: "请选择", trigger: "blur" }],
}, },
filterOrgText: "",
treeLoding: false,
}; };
}, },
computed: {}, computed: {},
watch: { watch: {},
filterOrgText(val) {
this.$refs.tree.filter(val);
},
},
created() { created() {
this.getList(); this.getList();
this.getTypeAll();
}, },
methods: { methods: {
checkPermission, checkPermission,
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
getList() { getList() {
this.listLoading = true; this.listLoading = true;
getContentList().then((response) => { gettasklist(this.listQuery).then((response) => {
if (response.data) { if (response.data) {
this.contentList = response.data; this.taskList = response.data;
} }
this.listLoading = false; this.listLoading = false;
}); });
}, },
getTypeAll() {
getDictList({ type__code: "data_type" }).then((res) => {
this.typeOptions = genTree(res.data);
});
},
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;
this.getList(); this.getList();
}, },
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20,
}
this.getList();
},
handleCreate() { handleCreate() {
this.Content = Object.assign({}, defaultContent); this.task = Object.assign({}, defaulttask);
this.dialogType = "new"; this.dialogType = "new";
this.dialogVisible = true; this.dialogVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs["Form"].clearValidate(); this.$refs["Form"].clearValidate();
}); });
},
handleCreate2() {
}, },
handleEdit(scope) { handleEdit(scope) {
this.Content = Object.assign({}, scope.row); // copy obj this.task = Object.assign({}, scope.row); // copy obj
this.dialogType = "edit"; this.dialogType = "edit";
this.dialogVisible = true; this.dialogVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
@ -221,20 +220,23 @@ export default {
type: "error", type: "error",
}) })
.then(async () => { .then(async () => {
await deleteContent(scope.row.id); await deletetask(scope.row.id);
this.getList(); this.getList();
this.$message.success("成功"); this.$message.success("成功");
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
}); });
},
handleDetail(scope){
}, },
async confirm(form) { async confirm(form) {
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (valid) { if (valid) {
const isEdit = this.dialogType === "edit"; const isEdit = this.dialogType === "edit";
if (isEdit) { if (isEdit) {
updateContent(this.Content.id, this.Content).then((res) => { updatetask(this.task.id, this.task).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.getList(); this.getList();
this.dialogVisible = false; this.dialogVisible = false;
@ -242,7 +244,7 @@ export default {
} }
}); });
} else { } else {
createContent(this.Content).then((res) => { createtask(this.task).then((res) => {
if (res.code >= 200) { if (res.code >= 200) {
this.getList(); this.getList();
this.dialogVisible = false; this.dialogVisible = false;

View File