新增:区域二级
This commit is contained in:
@@ -30,7 +30,8 @@
|
|||||||
</el-row>
|
</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="ID" align="center" prop="id" />
|
||||||
<el-table-column label="区域名" align="center" prop="name" />
|
<el-table-column label="区域名" align="center" prop="name" />
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
<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-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<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-form-item label="" prop="name">
|
||||||
<el-input v-model="form.name" placeholder="请输入" />
|
<el-input v-model="form.name" placeholder="请输入" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -100,7 +112,12 @@ export default {
|
|||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
}
|
},
|
||||||
|
|
||||||
|
allList:[],
|
||||||
|
firstList:[],
|
||||||
|
secondList:[],
|
||||||
|
assembleList:[]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -115,8 +132,30 @@ export default {
|
|||||||
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
|
||||||
// 执行查询
|
// 执行查询
|
||||||
getAreaPage(params).then(response => {
|
getAreaPage(params).then(response => {
|
||||||
this.list = response.data.list;
|
this.list = response.data.list;
|
||||||
this.total = response.data.total;
|
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;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -147,6 +186,7 @@ export default {
|
|||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
this.firstList = this.allList.filter(t => t.parentId == 0);
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "添加";
|
this.title = "添加";
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id" border lazy
|
<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="id" label="id" sortable width="180"></el-table-column>
|
||||||
<el-table-column prop="name" label="名" 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">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
|||||||
Reference in New Issue
Block a user