fix bug
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
<el-col :span="15">
|
||||
<basic-container>
|
||||
<el-button-group>
|
||||
<el-button
|
||||
v-if="permission.region_add"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="addCountry"
|
||||
>新增国家
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="permission.region_add"
|
||||
type="primary"
|
||||
@@ -48,19 +55,29 @@
|
||||
@click="handleSync"
|
||||
>同步
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="permission.region_debug"
|
||||
type="primary"
|
||||
icon="el-icon-video-play"
|
||||
@click="handleDebug"
|
||||
>调试
|
||||
</el-button>
|
||||
<!-- <el-button-->
|
||||
<!-- v-if="permission.region_debug"-->
|
||||
<!-- type="primary"-->
|
||||
<!-- icon="el-icon-video-play"-->
|
||||
<!-- @click="handleDebug"-->
|
||||
<!-- >调试-->
|
||||
<!-- </el-button>-->
|
||||
</el-button-group>
|
||||
</basic-container>
|
||||
<basic-container>
|
||||
<avue-form ref="form" :option="regionOption" v-model="regionForm" @submit="handleSubmit">
|
||||
<template #code="{}">
|
||||
<el-input placeholder="请输入 区划子编号" v-model="regionForm.subCode">
|
||||
<el-input
|
||||
v-if="isCountryRegion"
|
||||
placeholder="请输入国家编码,如 +86"
|
||||
v-model="regionForm.code"
|
||||
/>
|
||||
<el-input
|
||||
v-else-if="isProvinceRegion"
|
||||
placeholder="请输入省级区划编号"
|
||||
v-model="regionForm.subCode"
|
||||
/>
|
||||
<el-input v-else placeholder="请输入 区划子编号" v-model="regionForm.subCode">
|
||||
<template #prepend>{{ regionForm.parentCode }}</template>
|
||||
</el-input>
|
||||
</template>
|
||||
@@ -92,10 +109,12 @@ import { getToken } from '@/utils/auth';
|
||||
import NProgress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
|
||||
const ROOT_PARENT_CODE = '0';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
topCode: '00',
|
||||
topCode: ROOT_PARENT_CODE,
|
||||
treeCode: '',
|
||||
treeParentCode: '',
|
||||
treeData: [],
|
||||
@@ -104,7 +123,7 @@ export default {
|
||||
nodeKey: 'id',
|
||||
lazy: true,
|
||||
treeLoad: function (node, resolve) {
|
||||
const parentCode = node.level === 0 ? '00' : node.data.id;
|
||||
const parentCode = node.level === 0 ? ROOT_PARENT_CODE : node.data.id;
|
||||
getLazyTree(parentCode).then(res => {
|
||||
resolve(
|
||||
res.data.data.map(item => {
|
||||
@@ -323,7 +342,11 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
'regionForm.subCode'() {
|
||||
this.regionForm.code = this.regionForm.parentCode + this.regionForm.subCode;
|
||||
if (this.isCountryRegion) {
|
||||
return;
|
||||
}
|
||||
const parentCode = this.isProvinceRegion ? '' : this.regionForm.parentCode;
|
||||
this.regionForm.code = parentCode + this.regionForm.subCode;
|
||||
},
|
||||
'excelForm.isCovered'() {
|
||||
if (this.excelForm.isCovered !== '') {
|
||||
@@ -334,6 +357,12 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permission']),
|
||||
isCountryRegion() {
|
||||
return Number(this.regionForm.regionLevel) === 0 || this.regionForm.parentCode === this.topCode;
|
||||
},
|
||||
isProvinceRegion() {
|
||||
return Number(this.regionForm.regionLevel) === 1;
|
||||
},
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.validData(this.permission.region_add, false),
|
||||
@@ -369,9 +398,27 @@ export default {
|
||||
this.treeParentCode = data.parentId;
|
||||
getDetail(this.treeCode).then(res => {
|
||||
this.regionForm = res.data.data;
|
||||
this.regionForm.subCode = this.regionForm.code.replace(this.regionForm.parentCode, '');
|
||||
this.regionForm.subCode =
|
||||
this.regionForm.parentCode === this.topCode
|
||||
? this.regionForm.code
|
||||
: this.regionForm.code.replace(this.regionForm.parentCode, '');
|
||||
});
|
||||
},
|
||||
addCountry() {
|
||||
const column = this.findColumn(this.regionOption.column, 'parentCode');
|
||||
column.disabled = true;
|
||||
this.treeCode = '';
|
||||
this.treeParentCode = this.topCode;
|
||||
this.regionForm = {
|
||||
parentCode: this.topCode,
|
||||
parentName: '根节点',
|
||||
code: '',
|
||||
subCode: '',
|
||||
name: '',
|
||||
regionLevel: 0,
|
||||
sort: 1,
|
||||
};
|
||||
},
|
||||
addChildren() {
|
||||
if (validatenull(this.regionForm.code) || validatenull(this.regionForm.name)) {
|
||||
this.$message.warning('请先选择一项区划');
|
||||
@@ -386,8 +433,14 @@ export default {
|
||||
this.regionForm.regionLevel === 5 ? 5 : this.regionForm.regionLevel + 1;
|
||||
},
|
||||
handleSubmit(form, done) {
|
||||
const parentCode = form.parentCode === this.topCode ? '' : form.parentCode;
|
||||
form.code = parentCode + form.subCode;
|
||||
if (Number(form.regionLevel) === 0) {
|
||||
form.parentCode = this.topCode;
|
||||
form.ancestors = this.topCode;
|
||||
form.subCode = form.code;
|
||||
} else {
|
||||
const parentCode = Number(form.regionLevel) === 1 ? '' : form.parentCode;
|
||||
form.code = parentCode + form.subCode;
|
||||
}
|
||||
submit(form).then(
|
||||
() => {
|
||||
this.$message({
|
||||
|
||||
Reference in New Issue
Block a user