emis-frontend/src/views/emis/emisRegion/index.vue

860 lines
28 KiB
Vue
Raw Normal View History

2023-11-27 08:29:42 +00:00
<template>
<div class="app-container">
2023-12-13 15:02:24 +00:00
<el-row :gutter="20" type='flex'>
<el-col :span="5" :xs="5">
<div class="head-container">
<el-row :gutter="10">
<el-col :span="15" :xs="15">
<el-input
v-model="countryName"
placeholder="国家名称"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</el-col>
</el-row>
</div>
<div class="head-container">
<el-tree
ref="tree"
class="filter-tree tree"
:data="countryTree"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
node-key="id"
highlight-current
default-expand-all
@node-click="handleNodeClick"
>
</el-tree>
</div>
</el-col>
<el-col :span="4" :xs="4">
<div class="head-container">
<el-row :gutter="10">
<el-col :span="15" :xs="15">
<el-input
v-model="areaName"
placeholder="片区"
clearable
size="small"
prefix-icon="el-icon-search"
style="margin-bottom: 20px"
/>
</el-col>
<el-col :span="4" :xs="4">
<el-button
type="normal"
size="mini"
icon="el-icon-plus"
:disabled="false"
@click="handleAreaAdd">
</el-button>
</el-col>
</el-row>
</div>
<div class="head-container">
<el-tree
ref="areaTree"
class="filter-tree tree"
:data="areaTree"
:props="defaultProps"
:expand-on-click-node="false"
:filter-node-method="filterNode"
node-key="id"
highlight-current
default-expand-all
@node-click="handleNodeAreaClick"
>
<span slot-scope="{ node, data }"
@mouseenter="mouseenter(data)"
@mouseleave="mouseleave(data)"
style="width:100%">
<template>
<span style="font-size:13px">{{ data.label }}</span>
<span v-show="data.show && data.id > 0" style="margin-left: 10px;">
<i @click="handleUpdateArea(data)" class="el-icon-edit"></i>
<i @click="handleDeleteArea(data)" class="el-icon-delete"></i>
</span>
</template>
</span>
</el-tree>
</div>
</el-col>
<el-col :span="20" :xs="20">
2023-11-27 08:29:42 +00:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="" prop="regionName">
<el-input
v-model="queryParams.regionName"
placeholder="区域名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="regionType">
2023-12-13 06:00:09 +00:00
<el-select v-model="queryParams.regionType" placeholder="类型" clearable>
<el-option
v-for="dict in dict.type.emis_region_level_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
2023-11-27 08:29:42 +00:00
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['emis:emisRegion:add']"
>新增</el-button>
</el-col>
2023-12-13 06:00:09 +00:00
<!--
2023-11-27 08:29:42 +00:00
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['emis:emisRegion:edit']"
>修改</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['emis:emisRegion:remove']"
>删除</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['emis:emisRegion:export']"
>导出</el-button>
</el-col> -->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2023-12-13 06:50:11 +00:00
<el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange"
2023-12-13 06:00:09 +00:00
row-key="id"
:default-expand-all="isExpandAll"
2023-12-13 06:50:11 +00:00
lazy
:load="load"
2023-12-13 06:00:09 +00:00
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
2023-11-27 08:29:42 +00:00
<el-table-column type="selection" width="55" align="center" />
2023-12-13 06:18:00 +00:00
<el-table-column label="区域名称" align="left" prop="regionName" min-width="100" />
<el-table-column label="区域编码" align="left" prop="code" min-width="100" />
2023-12-13 06:00:09 +00:00
<!-- <el-table-column label="英文名称" align="center" prop="regionNameEn" min-width="100" /> -->
<!-- <el-table-column label="简称" align="center" prop="shortName" min-width="100" /> -->
2023-12-24 05:29:19 +00:00
<el-table-column label="行政级别" align="center" prop="regionType" min-width="100" >
2023-12-13 06:00:09 +00:00
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_region_level_type" :value="scope.row.regionType"/>
</template>
</el-table-column>
<!-- <el-table-column label="备注" align="center" prop="remark" min-width="100" /> -->
2023-11-27 08:29:42 +00:00
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['emis:emisRegion:edit']"
>修改</el-button>
2023-12-24 05:29:19 +00:00
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAdd(scope.row)"
v-hasPermi="['emis:emisRegion:edit']"
>添加</el-button>
2023-12-13 06:00:09 +00:00
<!--
2023-11-27 08:29:42 +00:00
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['emis:emisRegion:remove']"
>删除</el-button> -->
</template>
</el-table-column>
</el-table>
<!-- 添加或修改四级省市区镇表对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" :close-on-click-modal="false" append-to-body>
<el-row :gutter="0">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
2023-12-26 14:01:40 +00:00
<el-col :span="12">
2023-12-16 07:00:31 +00:00
<el-form-item label="所属国家" prop="countryId">
<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>
2023-11-27 08:29:42 +00:00
</el-form-item>
</el-col>
2023-12-26 14:01:40 +00:00
<el-col :span="12">
2023-12-16 07:00:31 +00:00
<el-form-item label="国家大区" prop="countryAreaId">
<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>
2023-11-27 08:29:42 +00:00
</el-form-item>
</el-col>
2023-12-26 14:01:40 +00:00
<el-col :span="24">
<el-form-item label="上级区域" prop="parentId">
<!--<el-input v-model="form.parentId" placeholder="请输入上级区域" />-->
<treeselect
ref="tree"
v-model="form.parentId"
:options="parentAreaOptions"
:normalizer="normalizer"
:default-expand-level="1"
:show-count="true"
placeholder="请输入上级区域"
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="区域名称" prop="regionName">
<el-input v-model="form.regionName" placeholder="请输入区域名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="英文名称" prop="regionNameEn">
<el-input v-model="form.regionNameEn" placeholder="请输入英文名称" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="简称" prop="shortName">
<el-input v-model="form.shortName" placeholder="请输入简称" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="代码" prop="code">
<el-input v-model="form.code" placeholder="请输入代码" />
</el-form-item>
</el-col>
2023-12-13 06:00:09 +00:00
<el-col :span="8">
2023-12-24 05:29:19 +00:00
<el-form-item label="行政级别" prop="regionType">
<el-select v-model="form.regionType" placeholder="请选择">
2023-12-13 06:00:09 +00:00
<el-option
v-for="dict in dict.type.emis_region_level_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
2023-11-27 08:29:42 +00:00
</el-form-item>
2023-12-13 06:00:09 +00:00
</el-col>
<el-col :span="8">
<el-form-item label="邮编" prop="zipCode">
<el-input v-model="form.zipCode" placeholder="请输入邮编" />
2023-11-27 08:29:42 +00:00
</el-form-item>
</el-col>
2023-12-13 06:00:09 +00:00
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
2023-11-27 08:29:42 +00:00
</el-form-item>
2023-12-13 06:00:09 +00:00
</el-col>
2023-11-27 08:29:42 +00:00
</el-form>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
2023-12-13 15:02:24 +00:00
<el-dialog :title="titleForm" :visible.sync="openForm" width="500px" append-to-body>
<emisCountryAreaForm :id="currentId" @on-changed="handleFormChanged" @on-cancel="cancelForm"></EmisCountryAreaForm>
</el-dialog>
2023-11-27 08:29:42 +00:00
<el-dialog :title="titleView" :visible.sync="openView" width="60%" :close-on-click-modal="false" append-to-body>
<emisRegionView :id="id" ></EmisRegionView>
</el-dialog>
2023-12-13 15:02:24 +00:00
</el-col>
</el-row>
2023-11-27 08:29:42 +00:00
</div>
</template>
<script>
import { listEmisRegion, getEmisRegion, delEmisRegion, addEmisRegion, updateEmisRegion } from "@/api/emis/emisRegion";
2023-12-13 15:02:24 +00:00
import { listEmisCountry, getEmisCountry, delEmisCountry, addEmisCountry, updateEmisCountry } from "@/api/emis/emisCountry";
import { listEmisCountryArea, getEmisCountryArea, delEmisCountryArea, addEmisCountryArea, updateEmisCountryArea } from "@/api/emis/emisCountryArea";
2023-11-27 08:29:42 +00:00
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
import emisRegionView from '@/views/emis/emisRegion/emisRegionView';
import emisRegionForm from '@/views/emis/emisRegion/emisRegionForm';
2023-12-13 15:02:24 +00:00
import emisCountryAreaForm from '@/views/emis/emisCountryArea/emisCountryAreaForm';
2023-12-26 14:01:40 +00:00
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";
2023-11-27 08:29:42 +00:00
export default {
name: "emisRegion",
2023-12-26 14:01:40 +00:00
components: { elDateSimplePicker,emisRegionView,emisRegionForm ,emisCountryAreaForm,Treeselect,IconSelect},
2023-11-27 08:29:42 +00:00
dicts: [
2023-12-13 06:00:09 +00:00
'emis_region_level_type',
2023-11-27 08:29:42 +00:00
],
data() {
return {
2023-12-13 15:02:24 +00:00
countryName:"",
areaName:'',
2023-12-16 07:00:31 +00:00
currentId:null,
currentCountryId:40,
2023-12-13 06:18:00 +00:00
// 是否展开,默认全部折叠
isExpandAll: false,
// 重新渲染表格状态
refreshTable: true,
2023-12-13 15:02:24 +00:00
countryTree:[],
countryIdsOptions:[],
areaTree:[],
countryAreaIdsOptions:[],
2023-12-16 07:00:31 +00:00
countryAreaIdsOptionsForm:[],
2023-12-13 06:50:11 +00:00
tableDataCopy:[],
tableData:[],
2023-12-26 14:01:40 +00:00
parentAreaOptions:[],
2023-12-13 06:50:11 +00:00
showTable:false,
2023-12-13 15:02:24 +00:00
defaultProps: {
children: "children",
label: "label"
},
2023-12-13 06:50:11 +00:00
2023-11-27 08:29:42 +00:00
// 遮罩层
loading: true,
2023-12-26 14:01:40 +00:00
//判断是否是编辑或者添加选择的国家
from_inner:false,
2023-11-27 08:29:42 +00:00
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 四级省市区镇表表格数据
emisRegionList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
openForm: false,
titleForm: "",
titleEmisRegion: "",
openEmisRegion: false,
// 显示编辑框更多
moreInputVisible: false,
// 弹出展示层
id:null,
titleView:"",
openView: false,
2023-12-13 06:00:09 +00:00
// 备注时间范围
2023-11-27 08:29:42 +00:00
daterangeCreateTime: [],
2023-12-13 06:00:09 +00:00
// 备注时间范围
2023-11-27 08:29:42 +00:00
daterangeUpdateTime: [],
// 查询参数
queryParams: {
regionName: null,
regionNameEn: null,
shortName: null,
regionType: null,
zipCode: null,
2023-12-26 14:01:40 +00:00
currentCountryId:null,
2023-11-27 08:29:42 +00:00
},
// 表单参数
form: {},
// 表单校验
rules: {
regionName: [
{ required: true, message: "区域名称不能为空", trigger: "blur" }
],
regionNameEn: [
{ required: true, message: "英文名称不能为空", trigger: "blur" }
],
parentId: [
2023-12-24 05:29:19 +00:00
{ required: true, message: "上级区域不能为空", trigger: "blur" }
2023-11-27 08:29:42 +00:00
],
}
};
},
created() {
this.getList();
2023-12-13 15:02:24 +00:00
this.getCountryList();
2023-12-16 07:00:31 +00:00
//this.getAreaFormList();
2023-12-13 15:02:24 +00:00
},
watch: {
// 根据名称筛选部门树
countryName(val) {
this.$refs.tree.filter(val);
},
areaName(val) {
this.$refs.areaTree.filter(val);
},
2023-11-27 08:29:42 +00:00
},
methods: {
/** 查询四级省市区镇表列表 */
getList() {
this.loading = true;
2023-12-26 14:01:40 +00:00
this.queryParams.currentCountryId = this.currentCountryId;
2023-12-13 06:18:00 +00:00
listEmisRegion(this.queryParams).then(response => {
2023-12-26 14:01:40 +00:00
//console.log(response.rows);
2023-12-13 06:50:11 +00:00
this.tableDataCopy = this.handleTree(response.rows, "id");
2023-12-26 14:01:40 +00:00
this.parentAreaOptions = this.handleTree(response.rows, "id");
//编辑或者添加的时候选择国家不影响外面
if(this.from_inner!=true){
//console.log(this.from_inner);
this.tableData = JSON.parse(JSON.stringify(this.tableDataCopy)).map(item => { // 展示数据
item.hasChildren = item.children && item.children.length > 0
item.children = null
// 记住层级关系
item.idList = [item.id]
return item
})
}
2023-11-27 08:29:42 +00:00
this.loading = false;
});
},
2023-12-26 14:01:40 +00:00
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.regionName,
children: node.children,
};
},
2023-12-13 15:02:24 +00:00
getAreaList(){
this.loading = true;
listEmisCountryArea(this.queryParams).then(response => {
this.loading = false;
this.areaTree = [];
this.countryAreaIdsOptions = [];
var cTree={"id":"","label":"片区","children":[]};
//var lastContinentId = -1;
response.rows.forEach(item =>{
var optItem={value:item.id,label:item.name};
2023-12-16 07:00:31 +00:00
this.countryAreaIdsOptions.push(optItem);
2023-12-13 15:02:24 +00:00
var treeItem={"id":item.id,"label":item.name,"show":false};
cTree.children.push(treeItem);
//lastContinentId = item.id;
});
//this.queryParams.continentId = lastContinentId;
this.areaTree.push(cTree);
//this.getList();
});
},
2023-12-16 07:00:31 +00:00
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);
});
});
},
2023-12-13 15:02:24 +00:00
getCountryList() {
this.loading = true;
listEmisCountry(this.queryParams).then(response => {
this.loading = false;
this.countryTree = [];
this.countryIdsOptions = [];
var cTree={"id":"","label":"国家列表","children":[]};
2023-12-16 07:00:31 +00:00
cTree.children.push({"id":40,"label":"中国"});
this.countryIdsOptions.push({"value":40,"label":"中国"})
2023-12-13 15:02:24 +00:00
//var lastContinentId = -1;
response.rows.forEach(item =>{
2023-12-16 07:00:31 +00:00
if(item.id != 40){
2023-12-13 15:02:24 +00:00
var optItem={value:item.id,label:item.name};
this.countryIdsOptions.push(optItem)
var treeItem={"id":item.id,"label":item.name};
cTree.children.push(treeItem);
2023-12-16 07:00:31 +00:00
}
2023-12-13 15:02:24 +00:00
//lastContinentId = item.id;
});
2023-12-16 07:00:31 +00:00
this.queryParams.countryId = this.currentCountryId;
2023-12-13 15:02:24 +00:00
this.countryTree.push(cTree);
//this.getAreaList();
});
},
2023-12-16 07:00:31 +00:00
handleCountrySelectionChange(id){
this.loading = true;
var oldCountryId = this.queryParams.countryId;
this.currentCountryId = id;
this.queryParams.countryId = this.currentCountryId;
2023-12-26 14:01:40 +00:00
this.from_inner = true;
2023-12-16 07:00:31 +00:00
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);
});
});
2023-12-26 14:01:40 +00:00
//更新上级区域列表
this.getList();
2023-12-16 07:00:31 +00:00
if(oldCountryId>0){
this.queryParams.countryId = oldCountryId;
}else{
this.queryParams.countryId = null;
}
},
2023-12-13 06:50:11 +00:00
load (tree, treeNode, resolve) {
// 层级关系备份
const idCopy = JSON.parse(JSON.stringify(tree.idList))
// 查找下一层数据
let resolveArr = this.tableDataCopy
let id
// eslint-disable-next-line
while (id = tree.idList.shift()) {
const tarItem = resolveArr.find(item => item.id === id)
tarItem.loadedChildren = true
resolveArr = tarItem.children
}
// 处理下一层数据的属性
resolveArr = JSON.parse(JSON.stringify(resolveArr))
resolveArr.forEach(item => {
item.hasChildren = item.children && item.children.length > 0
item.children = null
// 此处需要深拷贝,以防各个item的idList混乱
item.idList = JSON.parse(JSON.stringify(idCopy))
item.idList.push(item.id)
})
// 标识已经加载子节点
tree.loadedChildren = true
// 渲染子节点
resolve(resolveArr)
},
unload () {
this.showTable = false
// eslint-disable-next-line
this.$nextTick(() => this.showTable = true)
this.tableData = JSON.parse(JSON.stringify(this.tableDataCopy)).map(item => {
// hasChildren 表示需要展示一个箭头图标
item.hasChildren = item.children && item.children.length > 0
// 只展示一层
item.children = null
// 记住层级关系
item.idList = [item.id]
return item
})
},
2023-11-27 08:29:42 +00:00
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
2023-12-13 15:02:24 +00:00
// 筛选节点
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.countryId = data.id;
2023-12-26 14:01:40 +00:00
this.from_inner = false;
2023-12-13 15:02:24 +00:00
//this.form.continentId= data.id;
this.handleCountryAreaQuery();
},
// 节点单击事件
handleNodeAreaClick(data) {
2023-12-16 07:00:31 +00:00
this.queryParams.countryAreaId = data.id;
2023-12-13 15:02:24 +00:00
//this.form.continentId= data.id;
2023-12-26 14:01:40 +00:00
this.from_inner = false;
2023-12-13 15:02:24 +00:00
this.handleAreaQuery();
},
mouseenter(data) {
console.log("111"+data);
this.$set(data, 'show', true)
},
mouseleave(data) {
console.log("222"+data);
this.$set(data, 'show', false)
},
2023-11-27 08:29:42 +00:00
// 表单重置
reset() {
this.form = {
id: null,
regionName: null,
regionNameEn: null,
shortName: null,
parentId: null,
code: null,
countryId: null,
countryAreaId: null,
regionType: null,
zipCode: null,
remark: null,
tenantId: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
areaName: null,
countryCode: null,
2023-12-16 07:00:31 +00:00
countryName: null,
name: null,
nameEn: null,
remark: null
2023-11-27 08:29:42 +00:00
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
2023-12-26 14:01:40 +00:00
this.from_inner = false;
2023-11-27 08:29:42 +00:00
this.queryParams.pageNum = 1;
this.getList();
},
2023-12-13 15:02:24 +00:00
/** 搜索按钮操作 */
handleAreaQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 搜索按钮操作 */
handleCountryAreaQuery() {
this.queryParams.pageNum = 1;
this.getAreaList();
2023-12-16 07:00:31 +00:00
this.getList();
2023-12-13 15:02:24 +00:00
},
2023-11-27 08:29:42 +00:00
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd(row) {
this.reset();
this.open = true;
this.title = "新增";
2023-12-26 14:01:40 +00:00
this.form.countryId = row.countryId;
this.queryParams.currentCountryId = row.countryId;
this.getList();
this.form.parentId = row.id;
console.log(this.form);
2023-11-27 08:29:42 +00:00
// 子组件打开模式
// if(row != undefined){
// this.currentParentId = row.id
// }
// this.openEmisRegion = true;
// this.titleEmisRegion = "新增";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getEmisRegion(id).then(response => {
this.form = response.data;
2023-12-16 07:00:31 +00:00
this.currentCountryId = response.data.countryId;
2023-11-27 08:29:42 +00:00
this.open = true;
2023-12-16 07:00:31 +00:00
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);
});
});
2023-11-27 08:29:42 +00:00
this.title = "修改";
});
2023-12-16 07:00:31 +00:00
2023-11-27 08:29:42 +00:00
// 子组件打开模式
// this.currentId= row.id || this.ids;
// this.openEmisRegion = true;
// this.titleEmisRegion = "修改";
2023-12-13 15:02:24 +00:00
},
/** 新增按钮操作 */
handleAreaAdd(row) {
this.reset();
this.openForm = true;
this.title = "新增";
},
handleUpdateArea(row){
this.currentId = row.id || this.ids;
this.openForm = true;
this.titleForm = "修改";
},
handleDeleteArea(row){
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisCountryArea(ids);
}).then(() => {
this.getAreaList()
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
2023-11-27 08:29:42 +00:00
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisRegion/viewDetail', query: { id: row.id }})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEmisRegion(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addEmisRegion(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
handleFormChanged(){
this.openForm = false;
this.getList();
},
cancelForm(){
this.openForm = false;
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisRegion(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisRegion/export', {
// ...this.queryParams
// }, `emisRegion_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisRegion(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id','区域名称','英文名称','简称','父区域','代码','国家id','国家大区id','类型','邮编','备注','租户ID','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','区域名称','国家代码','国家名称',];
const filterVal = ['id','regionName','regionNameEn','shortName','parentId','code','countryId','countryAreaId','regionType','zipCode','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime','areaName','countryCode','countryName',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '四级省市区镇表',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
</style>