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

535 lines
17 KiB
Vue
Raw Normal View History

2023-11-27 08:29:42 +00:00
<template>
<div class="app-container">
<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" /> -->
<el-table-column label="类型" align="center" prop="regionType" min-width="100" >
<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-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">
<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>
2023-12-13 06:00:09 +00:00
<el-col :span="8">
<el-form-item label="父区域" prop="parentId">
<el-input v-model="form.parentId" 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="8">
<el-form-item label="代码" prop="code">
<el-input v-model="form.code" 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="8">
<el-form-item label="国家id" prop="countryId">
<el-input v-model="form.countryId" placeholder="请输入国家id" />
2023-11-27 08:29:42 +00:00
</el-form-item>
</el-col>
2023-12-13 06:00:09 +00:00
<el-col :span="8">
<el-form-item label="国家大区id" prop="countryAreaId">
<el-input v-model="form.countryAreaId" placeholder="请输入国家大区id" />
2023-11-27 08:29:42 +00:00
</el-form-item>
</el-col>
2023-12-13 06:00:09 +00:00
<el-col :span="8">
<el-form-item label="类型" prop="regionType">
<el-select v-model="form.regionType" placeholder="请选择类型">
<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>
<el-dialog :title="titleView" :visible.sync="openView" width="60%" :close-on-click-modal="false" append-to-body>
<emisRegionView :id="id" ></EmisRegionView>
</el-dialog>
</div>
</template>
<script>
import { listEmisRegion, getEmisRegion, delEmisRegion, addEmisRegion, updateEmisRegion } from "@/api/emis/emisRegion";
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
import emisRegionView from '@/views/emis/emisRegion/emisRegionView';
import emisRegionForm from '@/views/emis/emisRegion/emisRegionForm';
export default {
name: "emisRegion",
components: { elDateSimplePicker,emisRegionView,emisRegionForm },
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 06:18:00 +00:00
// 是否展开,默认全部折叠
isExpandAll: false,
// 重新渲染表格状态
refreshTable: true,
2023-12-13 06:50:11 +00:00
tableDataCopy:[],
tableData:[],
showTable:false,
2023-11-27 08:29:42 +00:00
// 遮罩层
loading: true,
// 选中数组
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,
},
// 表单参数
form: {},
// 表单校验
rules: {
regionName: [
{ required: true, message: "区域名称不能为空", trigger: "blur" }
],
regionNameEn: [
{ required: true, message: "英文名称不能为空", trigger: "blur" }
],
parentId: [
{ required: true, message: "父区域不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询四级省市区镇表列表 */
getList() {
this.loading = true;
2023-12-13 06:18:00 +00:00
listEmisRegion(this.queryParams).then(response => {
2023-12-13 06:50:11 +00:00
this.tableDataCopy = this.handleTree(response.rows, "id");
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-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();
},
// 表单重置
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,
countryName: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
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 = "新增";
// 子组件打开模式
// 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;
this.open = true;
this.title = "修改";
});
// 子组件打开模式
// this.currentId= row.id || this.ids;
// this.openEmisRegion = true;
// this.titleEmisRegion = "修改";
},
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>