This commit is contained in:
libing 2023-12-16 15:00:31 +08:00
parent 46ab730f58
commit c46617a6c8
3 changed files with 103 additions and 11 deletions

View File

@ -47,7 +47,7 @@
style="width:100%"> style="width:100%">
<template> <template>
<span style="font-size:13px">{{ data.label }}</span> <span style="font-size:13px">{{ data.label }}</span>
<span v-show="data.show && data.id > 0" style="margin-left: 10px;"> <span v-show="data.show && data.id > 0" style="margin-left: 10px;" >
<i @click="handleUpdateContinent(data)" class="el-icon-edit"></i> <i @click="handleUpdateContinent(data)" class="el-icon-edit"></i>
<i @click="handleDeleteContinent(data)" class="el-icon-delete"></i> <i @click="handleDeleteContinent(data)" class="el-icon-delete"></i>
</span> </span>

View File

@ -17,6 +17,18 @@
<el-input v-model="form.code" placeholder="请输入编码" /> <el-input v-model="form.code" placeholder="请输入编码" />
</el-form-item> </el-form-item>
</el-col> --> </el-col> -->
<el-col :span="24">
<el-form-item label="所属国家" prop="countryId">
<el-select v-model="form.countryId" placeholder="所属区域" clearable filterable>
<el-option
v-for="item in countryIdsOptions"
v-bind:key="item.value"
v-bind:label="item.label"
v-bind:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" /> <el-input v-model="form.remark" placeholder="请输入备注" />
@ -33,6 +45,7 @@
<script> <script>
import { listEmisCountryArea, getEmisCountryArea, delEmisCountryArea, addEmisCountryArea, updateEmisCountryArea } from "@/api/emis/emisCountryArea"; import { listEmisCountryArea, getEmisCountryArea, delEmisCountryArea, addEmisCountryArea, updateEmisCountryArea } from "@/api/emis/emisCountryArea";
import { listEmisCountry, getEmisCountry, delEmisCountry, addEmisCountry, updateEmisCountry } from "@/api/emis/emisCountry";
export default { export default {
name: "emisCountryAreaForm", name: "emisCountryAreaForm",
@ -45,6 +58,7 @@ export default {
data() { data() {
return { return {
emisCountryAreaOptions: [], emisCountryAreaOptions: [],
countryIdsOptions:[],
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 表单参数 // 表单参数
@ -73,6 +87,7 @@ export default {
methods: { methods: {
initData() { initData() {
this.reset(); this.reset();
this.getCountryList();
if(this.id !=undefined) { if(this.id !=undefined) {
this.loading = true; this.loading = true;
getEmisCountryArea(this.id).then(response => { getEmisCountryArea(this.id).then(response => {
@ -82,6 +97,17 @@ export default {
} }
this.getTreeselect(); this.getTreeselect();
}, },
getCountryList(){
this.loading = true;
listEmisCountry(this.queryParams).then(response => {
this.loading = false;
this.countryIdsOptions = [];
response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name};
this.countryIdsOptions.push(optItem)
});
});
},
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.reset(); this.reset();

View File

@ -231,13 +231,27 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="国家id" prop="countryId"> <el-form-item label="所属国家" prop="countryId">
<el-input v-model="form.countryId" placeholder="请输入国家id" /> <el-select v-model="form.countryId" placeholder="所属国家" @change="handleCountrySelectionChange" clearable filterable>
<el-option
v-for="item in countryIdsOptions"
v-bind:key="item.value"
v-bind:label="item.label"
v-bind:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="国家大区id" prop="countryAreaId"> <el-form-item label="国家大区" prop="countryAreaId">
<el-input v-model="form.countryAreaId" placeholder="请输入国家大区id" /> <el-select v-model="form.countryAreaId" placeholder="国家大区" clearable filterable>
<el-option
v-for="item in countryAreaIdsOptionsForm"
v-bind:key="item.value"
v-bind:label="item.label"
v-bind:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@ -302,7 +316,8 @@ export default {
return { return {
countryName:"", countryName:"",
areaName:'', areaName:'',
currentId:0, currentId:null,
currentCountryId:40,
// 是否展开,默认全部折叠 // 是否展开,默认全部折叠
isExpandAll: false, isExpandAll: false,
// 重新渲染表格状态 // 重新渲染表格状态
@ -311,6 +326,7 @@ export default {
countryIdsOptions:[], countryIdsOptions:[],
areaTree:[], areaTree:[],
countryAreaIdsOptions:[], countryAreaIdsOptions:[],
countryAreaIdsOptionsForm:[],
tableDataCopy:[], tableDataCopy:[],
tableData:[], tableData:[],
showTable:false, showTable:false,
@ -384,6 +400,7 @@ export default {
created() { created() {
this.getList(); this.getList();
this.getCountryList(); this.getCountryList();
//this.getAreaFormList();
}, },
watch: { watch: {
// 根据名称筛选部门树 // 根据名称筛选部门树
@ -423,8 +440,7 @@ export default {
//var lastContinentId = -1; //var lastContinentId = -1;
response.rows.forEach(item =>{ response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name}; var optItem={value:item.id,label:item.name};
this.countryAreaIdsOptions.push(optItem) this.countryAreaIdsOptions.push(optItem);
var treeItem={"id":item.id,"label":item.name,"show":false}; var treeItem={"id":item.id,"label":item.name,"show":false};
cTree.children.push(treeItem); cTree.children.push(treeItem);
//lastContinentId = item.id; //lastContinentId = item.id;
@ -434,6 +450,18 @@ export default {
//this.getList(); //this.getList();
}); });
}, },
getAreaFormList(){
this.loading = true;
this.queryParams.countryId = this.currentCountryId;
listEmisCountryArea(this.queryParams).then(response => {
this.loading = false;
this.countryAreaIdsOptionsForm = [];
response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name};
this.countryAreaIdsOptionsForm.push(optItem);
});
});
},
getCountryList() { getCountryList() {
this.loading = true; this.loading = true;
listEmisCountry(this.queryParams).then(response => { listEmisCountry(this.queryParams).then(response => {
@ -441,20 +469,43 @@ export default {
this.countryTree = []; this.countryTree = [];
this.countryIdsOptions = []; this.countryIdsOptions = [];
var cTree={"id":"","label":"国家列表","children":[]}; var cTree={"id":"","label":"国家列表","children":[]};
cTree.children.push({"id":40,"label":"中国"});
this.countryIdsOptions.push({"value":40,"label":"中国"})
//var lastContinentId = -1; //var lastContinentId = -1;
response.rows.forEach(item =>{ response.rows.forEach(item =>{
if(item.id != 40){
var optItem={value:item.id,label:item.name}; var optItem={value:item.id,label:item.name};
this.countryIdsOptions.push(optItem) this.countryIdsOptions.push(optItem)
var treeItem={"id":item.id,"label":item.name}; var treeItem={"id":item.id,"label":item.name};
cTree.children.push(treeItem); cTree.children.push(treeItem);
}
//lastContinentId = item.id; //lastContinentId = item.id;
}); });
//this.queryParams.continentId = lastContinentId; this.queryParams.countryId = this.currentCountryId;
this.countryTree.push(cTree); this.countryTree.push(cTree);
//this.getAreaList(); //this.getAreaList();
}); });
}, },
handleCountrySelectionChange(id){
this.loading = true;
var oldCountryId = this.queryParams.countryId;
this.currentCountryId = id;
this.queryParams.countryId = this.currentCountryId;
listEmisCountryArea(this.queryParams).then(response => {
this.loading = false;
this.countryAreaIdsOptionsForm = [];
response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name};
this.countryAreaIdsOptionsForm.push(optItem);
});
});
if(oldCountryId>0){
this.queryParams.countryId = oldCountryId;
}else{
this.queryParams.countryId = null;
}
},
load (tree, treeNode, resolve) { load (tree, treeNode, resolve) {
// 层级关系备份 // 层级关系备份
const idCopy = JSON.parse(JSON.stringify(tree.idList)) const idCopy = JSON.parse(JSON.stringify(tree.idList))
@ -514,7 +565,7 @@ export default {
}, },
// 节点单击事件 // 节点单击事件
handleNodeAreaClick(data) { handleNodeAreaClick(data) {
this.queryParams.areaId = data.id; this.queryParams.countryAreaId = data.id;
//this.form.continentId= data.id; //this.form.continentId= data.id;
this.handleAreaQuery(); this.handleAreaQuery();
}, },
@ -548,7 +599,10 @@ export default {
updateTime: null, updateTime: null,
areaName: null, areaName: null,
countryCode: null, countryCode: null,
countryName: null countryName: null,
name: null,
nameEn: null,
remark: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -566,6 +620,7 @@ export default {
handleCountryAreaQuery() { handleCountryAreaQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.getAreaList(); this.getAreaList();
this.getList();
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
@ -600,10 +655,21 @@ export default {
const id = row.id || this.ids const id = row.id || this.ids
getEmisRegion(id).then(response => { getEmisRegion(id).then(response => {
this.form = response.data; this.form = response.data;
this.currentCountryId = response.data.countryId;
this.open = true; this.open = true;
this.queryParams.countryId = this.currentCountryId;
listEmisCountryArea(this.queryParams).then(response => {
this.loading = false;
this.countryAreaIdsOptionsForm = [];
response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name};
this.countryAreaIdsOptionsForm.push(optItem);
});
});
this.title = "修改"; this.title = "修改";
}); });
// 子组件打开模式 // 子组件打开模式
// this.currentId= row.id || this.ids; // this.currentId= row.id || this.ids;
// this.openEmisRegion = true; // this.openEmisRegion = true;