|
|
|
@ -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 = "添加"; |
|
|
|
|
}, |
|
|
|
|