完善行政区划基础功能

dev
smallchill 6 years ago
parent f002a6d8d1
commit 73250784e5
  1. 56
      src/views/base/region.vue
  2. 21
      src/views/system/user.vue

@ -1,18 +1,23 @@
<template> <template>
<el-row> <el-row>
<el-col :span="9"> <el-col :span="9">
<basic-container> <div class="box">
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/> <el-scrollbar>
</basic-container> <basic-container>
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
</basic-container>
</el-scrollbar>
</div>
</el-col> </el-col>
<el-col :span="15"> <el-col :span="15">
<basic-container> <basic-container>
<el-button-group> <el-button-group>
<el-button type="primary" size="medium" icon="el-icon-circle-plus-outline" @click="addChildren">新增下级 <el-button type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addChildren">新增下级
</el-button> </el-button>
<el-button type="primary" size="medium" icon="el-icon-delete" @click="handleDelete">删除</el-button> <el-button type="primary" size="small" icon="el-icon-delete" @click="handleDelete">删除</el-button>
<el-button type="primary" size="medium" icon="el-icon-upload2">导入</el-button> <el-button type="primary" size="small" icon="el-icon-upload2">导入</el-button>
<el-button type="primary" size="medium" icon="el-icon-download">导出</el-button> <el-button type="primary" size="small" icon="el-icon-download">导出</el-button>
<el-button type="primary" size="small" icon="el-icon-video-play">调试</el-button>
</el-button-group> </el-button-group>
</basic-container> </basic-container>
<basic-container> <basic-container>
@ -36,6 +41,9 @@
export default { export default {
data() { data() {
return { return {
topCode: '00',
treeCode: '',
treeParentCode: '',
treeData: [], treeData: [],
treeOption: { treeOption: {
nodeKey: 'id', nodeKey: 'id',
@ -69,13 +77,19 @@
label: "父区划编号", label: "父区划编号",
prop: "parentCode", prop: "parentCode",
span: 24, span: 24,
disabled: false, disabled: true,
rules: [{ rules: [{
required: true, required: true,
message: "请输入父区划编号", message: "请输入父区划编号",
trigger: "blur" trigger: "blur"
}] }]
}, },
{
label: "父区划名称",
prop: "parentName",
span: 24,
disabled: true,
},
{ {
label: "区划编号", label: "区划编号",
prop: "code", prop: "code",
@ -168,7 +182,7 @@
methods: { methods: {
initTree() { initTree() {
this.treeData = []; this.treeData = [];
getLazyTree("00").then(res => { getLazyTree(this.topCode).then(res => {
this.treeData = res.data.data.map(item => { this.treeData = res.data.data.map(item => {
return { return {
...item, ...item,
@ -180,25 +194,28 @@
nodeClick(data) { nodeClick(data) {
const column = this.findObject(this.regionOption.column, "parentCode"); const column = this.findObject(this.regionOption.column, "parentCode");
column.disabled = true; column.disabled = true;
getDetail(data.id).then(res => { this.treeCode = data.id;
this.treeParentCode = data.parentId;
getDetail(this.treeCode).then(res => {
this.regionForm = res.data.data; this.regionForm = res.data.data;
debugger
this.regionForm.subCode = this.regionForm.code.replace(this.regionForm.parentCode, ''); this.regionForm.subCode = this.regionForm.code.replace(this.regionForm.parentCode, '');
}) })
}, },
addChildren() { addChildren() {
if (validatenull(this.regionForm.code)) { if (validatenull(this.regionForm.code) || validatenull(this.regionForm.name)) {
this.$message.warning("请先选择一项区划"); this.$message.warning("请先选择一项区划");
return; return;
} }
this.regionForm.parentCode = this.regionForm.code; this.regionForm.parentCode = this.regionForm.code;
this.regionForm.parentName = this.regionForm.name;
this.regionForm.code = ''; this.regionForm.code = '';
this.regionForm.subCode = ''; this.regionForm.subCode = '';
this.regionForm.name = ''; this.regionForm.name = '';
this.regionForm.level = (this.regionForm.level === 5) ? 5 : this.regionForm.level + 1; this.regionForm.level = (this.regionForm.level === 5) ? 5 : this.regionForm.level + 1;
}, },
handleSubmit(form, done, loading) { handleSubmit(form, done, loading) {
form.code = form.parentCode + form.subCode; const parentCode = form.parentCode === this.topCode ? '' : form.parentCode;
form.code = parentCode + form.subCode;
submit(form).then(() => { submit(form).then(() => {
this.$message({ this.$message({
type: "success", type: "success",
@ -224,7 +241,7 @@
type: "warning" type: "warning"
}) })
.then(() => { .then(() => {
return remove(this.regionForm.code); return remove(this.treeCode);
}) })
.then(() => { .then(() => {
this.$message({ this.$message({
@ -241,4 +258,15 @@
</script> </script>
<style> <style>
.box {
height: 800px;
}
.el-scrollbar {
height: 100%;
}
.box .el-scrollbar__wrap {
overflow: scroll;
}
</style> </style>

@ -1,9 +1,13 @@
<template> <template>
<el-row> <el-row>
<el-col :span="5"> <el-col :span="5">
<basic-container> <div class="box">
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/> <el-scrollbar>
</basic-container> <basic-container>
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
</basic-container>
</el-scrollbar>
</div>
</el-col> </el-col>
<el-col :span="19"> <el-col :span="19">
<basic-container> <basic-container>
@ -730,4 +734,15 @@
</script> </script>
<style> <style>
.box {
height: 800px;
}
.el-scrollbar {
height: 100%;
}
.box .el-scrollbar__wrap {
overflow: scroll;
}
</style> </style>

Loading…
Cancel
Save