Browse Source

新增:区域二级

master
小久哥 3 years ago
parent
commit
d48538cc69
  1. 46
      src/views/farm/area/index.vue
  2. 2
      src/views/farm/taskCate/index.vue

46
src/views/farm/area/index.vue

@ -30,7 +30,8 @@
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" stripe :data="list">
<el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id" border lazy
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column label="ID" align="center" prop="id" />
<el-table-column label="区域名" align="center" prop="name" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
@ -54,6 +55,17 @@
<!-- 对话框(添加 / 修改) -->
<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="projectId">
<el-select v-model="form.parentId" placeholder="请选择">
<el-option
v-for="item in firstList"
:key="item.id"
:label="item.name"
:value="item.id">
{{item.name}}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="" prop="name">
<el-input v-model="form.name" placeholder="请输入" />
</el-form-item>
@ -100,7 +112,12 @@ export default {
form: {},
//
rules: {
}
},
allList:[],
firstList:[],
secondList:[],
assembleList:[]
};
},
created() {
@ -115,8 +132,30 @@ export default {
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
//
getAreaPage(params).then(response => {
this.list = response.data.list;
this.list = response.data.list;
this.total = response.data.total;
this.allList = 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;
});
},
@ -147,6 +186,7 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.firstList = this.allList.filter(t => t.parentId == 0);
this.open = true;
this.title = "添加";
},

2
src/views/farm/taskCate/index.vue

@ -32,7 +32,7 @@
<!-- 列表 -->
<el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id" border lazy
:load="load" :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
: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">

Loading…
Cancel
Save