|
|
|
@ -3,18 +3,7 @@
|
|
|
|
|
|
|
|
|
|
<!-- 搜索工作栏 --> |
|
|
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
|
|
|
|
<el-form-item label="" prop="parentId"> |
|
|
|
|
<el-select v-model="queryParams.parentId" placeholder="请选择任务类型" clearable size="small"> |
|
|
|
|
<el-option lable="顶层" value="0"/> |
|
|
|
|
<el-option v-for="item in tasks" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="" prop="projectId"> |
|
|
|
|
<el-select v-model="queryParams.projectId" placeholder="请选择绑定项目部" clearable size="small"> |
|
|
|
|
<el-option lable="不绑定项目" value="0"/> |
|
|
|
|
<el-option v-for="item in projects" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
|
<el-form-item label="名称" prop="name"> |
|
|
|
|
<el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> |
|
|
|
|
</el-form-item> |
|
|
|
@ -42,10 +31,10 @@
|
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
<!-- 列表 --> |
|
|
|
|
<el-table v-loading="loading" :data="list"> |
|
|
|
|
<el-table-column label="上级分类" align="center" prop="parentId" /> |
|
|
|
|
<el-table-column label="绑定项目" align="center" prop="projectId" /> |
|
|
|
|
<el-table-column label="分类名称" align="center" prop="name" /> |
|
|
|
|
<el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id" border lazy |
|
|
|
|
:load="load" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> |
|
|
|
|
<el-table-column prop="id" label="id" sortable width="180"></el-table-column> |
|
|
|
|
<el-table-column prop="name" label="名" sortable width="180"></el-table-column> |
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span>{{ parseTime(scope.row.createTime) }}</span> |
|
|
|
@ -60,6 +49,7 @@
|
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
</el-table> |
|
|
|
|
|
|
|
|
|
<!-- 分页组件 --> |
|
|
|
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
|
|
|
|
@pagination="getList"/> |
|
|
|
@ -67,16 +57,15 @@
|
|
|
|
|
<!-- 对话框(添加 / 修改) --> |
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
|
|
|
<el-form-item label="上级选择" prop="parentId"> |
|
|
|
|
<el-select v-model="form.parentId" placeholder="请选择"> |
|
|
|
|
<el-option lable="顶层" value="0"/> |
|
|
|
|
<el-option v-for="item in tasks" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="项目选择" prop="projectId"> |
|
|
|
|
<el-select v-model="form.projectId" placeholder="请选择"> |
|
|
|
|
<el-option lable="不绑定项目" value="0"/> |
|
|
|
|
<el-option v-for="item in projects" :key="item.id" :label="item.name" :value="item.id" /> |
|
|
|
|
<el-form-item label="上级" prop="projectId"> |
|
|
|
|
<el-select v-model="form.parentId" placeholder="请选择"> |
|
|
|
|
<el-option |
|
|
|
|
v-for="item in parentList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id"> |
|
|
|
|
{{item.name}} |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="分类名称" prop="name"> |
|
|
|
@ -93,8 +82,6 @@
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { createTaskCate, updateTaskCate, deleteTaskCate, getTaskCate, getTaskCatePage, exportTaskCateExcel } from "@/api/farm/taskCate"; |
|
|
|
|
import { getProjectPage } from "@/api/farm/project"; |
|
|
|
|
import { getTaskPage } from "@/api/farm/task"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: "TaskCate", |
|
|
|
@ -120,9 +107,8 @@ export default {
|
|
|
|
|
// 查询参数 |
|
|
|
|
queryParams: { |
|
|
|
|
pageNo: 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
pageSize: 100, |
|
|
|
|
parentId: null, |
|
|
|
|
projectId: null, |
|
|
|
|
name: null, |
|
|
|
|
}, |
|
|
|
|
// 表单参数 |
|
|
|
@ -131,19 +117,13 @@ export default {
|
|
|
|
|
rules: { |
|
|
|
|
name: [{ required: true, message: "不能为空", trigger: "blur" }], |
|
|
|
|
}, |
|
|
|
|
projects:[], |
|
|
|
|
tasks:[], |
|
|
|
|
|
|
|
|
|
cateList:[], |
|
|
|
|
|
|
|
|
|
parentList:[] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
|
|
|
|
|
getProjectPage().then(res=>{ |
|
|
|
|
this.projects = res.data.list; |
|
|
|
|
}); |
|
|
|
|
getTaskPage().then(res=>{ |
|
|
|
|
this.tasks = res.data.list; |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.getList(); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
@ -157,6 +137,28 @@ export default {
|
|
|
|
|
getTaskCatePage(params).then(response => { |
|
|
|
|
this.list = response.data.list; |
|
|
|
|
this.total = response.data.total; |
|
|
|
|
|
|
|
|
|
this.cateList = this.list; |
|
|
|
|
let filterList = this.list.filter(t => t.parentId == 0); |
|
|
|
|
let oneList = []; |
|
|
|
|
if(filterList.length == 0){ |
|
|
|
|
//没有上级 |
|
|
|
|
this.list.forEach(t => { |
|
|
|
|
oneList.push({id:one.id, name:one.name, createTime:one.createTime, children:twoList}); |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
filterList.forEach((one) => { |
|
|
|
|
let twoList = []; |
|
|
|
|
this.list.forEach((two) => { |
|
|
|
|
if(one.id == two.parentId){ |
|
|
|
|
twoList.push({id:two.id, name:two.name, createTime:two.createTime}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
oneList.push({id:one.id, name:one.name, createTime:one.createTime, children:twoList}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.list = oneList; |
|
|
|
|
this.loading = false; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
@ -169,7 +171,6 @@ export default {
|
|
|
|
|
reset() { |
|
|
|
|
this.form = { |
|
|
|
|
parentId: undefined, |
|
|
|
|
projectId: undefined, |
|
|
|
|
name: undefined, |
|
|
|
|
}; |
|
|
|
|
this.resetForm("form"); |
|
|
|
@ -188,6 +189,8 @@ export default {
|
|
|
|
|
/** 新增按钮操作 */ |
|
|
|
|
handleAdd() { |
|
|
|
|
this.reset(); |
|
|
|
|
this.parentList = this.cateList.filter(t => t.parentId == 0); |
|
|
|
|
|
|
|
|
|
this.open = true; |
|
|
|
|
this.title = "添加任务类型"; |
|
|
|
|
}, |
|
|
|
@ -196,6 +199,8 @@ export default {
|
|
|
|
|
this.reset(); |
|
|
|
|
const id = row.id; |
|
|
|
|
getTaskCate(id).then(response => { |
|
|
|
|
this.parentList = this.cateList.filter(t => t.parentId == 0); |
|
|
|
|
|
|
|
|
|
this.form = response.data; |
|
|
|
|
this.open = true; |
|
|
|
|
this.title = "修改任务类型"; |
|
|
|
|