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

459 lines
16 KiB
Vue
Raw Normal View History

2024-04-22 05:35:19 +00:00
<template>
<div >
<search-form :model="queryParams" ref="queryForm" size="small" :maxShow="20" label-width="68px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<el-form-item :label="$t('国家')" prop="countryCode">
<CountryPicker :placeholder="$t('国家')" v-model="queryParams.countryCode" @onChange="handleQuery"></CountryPicker>
</el-form-item>
<el-form-item :label="$t('行政级别')" prop="regionType">
<el-select v-model="queryParams.regionType" :placeholder="$t('行政级别')" @change="handleQuery">
<el-option
v-for="dict in dict.type.emis_region_level_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<!-- v-show="dict.value != 4" -->
<el-form-item :label="$t('名称')" prop="regionName">
<el-input
v-model="queryParams.regionName"
:placeholder="$t('名称')"
clearable
@keyup.enter.native="handleQuery"
@input="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('编码')" prop="regionCode">
<el-input
v-model="queryParams.regionCode"
:placeholder="$t('编码')"
clearable
@keyup.enter.native="handleQuery"
@input="handleQuery"
/>
</el-form-item>
<el-form-item :label="$t('所属片区')" prop="regionCode">
<CountryAreaPicker :placeholder="$t('所属片区')" :countryCode="queryParams.countryCode" v-model="queryParams.areaId" @onChange="handleQuery"></CountryAreaPicker>
</el-form-item>
</search-form>
<!-- :cell-style="{ color: '#FFF', background: '#333' }"
:header-cell-style="{ color: '#000', background: '#fff' }"
-->
<xd-table
v-loading="loading"
:data="tableData"
:default-expand-all="false"
row-key="id"
lazy
:load="treeLoad"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
border stripe
size="small"
:showSearch.sync="showSearch"
:queryParams="queryParams"
:total="total"
@queryTable="getList"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
>
<div slot="toolbar">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd(1)"
v-hasPermi="['emis:emisRegion:add']"
>新增省份</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd(2)"
v-hasPermi="['emis:emisRegion:add']"
>新增城市</el-button>
</el-col> -->
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd(3)"
v-hasPermi="['emis:emisRegion:add']"
>新增县区</el-button>
</el-col> -->
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd(4)"
v-hasPermi="['emis:emisRegion:add']"
>新增街镇</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">
<div style="display:inline-flex;margin-left:20px">
<span>所属片区:</span>
<span><CountryAreaPicker size="mini" :placeholder="$t('所属片区')" :countryCode="queryParams.countryCode" v-model="queryParams.areaId" @onChange="handleQuery"></CountryAreaPicker></span>
</div>
</el-col> -->
</el-row>
</div>
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="名称" align="left" prop="regionName" min-width="170" /> -->
<el-table-column :label="$t('名称')" align="left" prop="regionName" :sort-orders="['descending','ascending']" sortable="custom" min-width="120">
<template slot-scope="scope">
<span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.regionName}}</span>
<span @click="handleAddSub(scope.row)" v-if="scope.row.regionType!=4" v-hasPermi="['emis:emisRegion:add']" class="icon iconfont" style="font-size: 20px;margin-left:10px;color: #b12e29;cursor: pointer;">&#xe620;</span>
</template>
</el-table-column>
<el-table-column label="编码" align="left" prop="regionCode" :sort-orders="['descending','ascending']" sortable="custom" width="100" />
<!-- <el-table-column label="英文名称" align="center" prop="regionNameEn" min-width="80" /> -->
<!-- <el-table-column label="简称" align="center" prop="shortName" min-width="100" /> -->
<el-table-column label="行政级别" align="center" prop="regionType" width="80" >
<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="$t('所属片区')" align="center" prop="areaName" width="80" />
<!-- <el-table-column :label="$t('国家代码')" align="center" prop="countryCode" min-width="100" /> -->
<el-table-column :label="$t('所属国家')" align="center" prop="countryName" width="80" />
<!-- <el-table-column label="备注" align="center" prop="remark" min-width="100" /> -->
2024-06-02 09:59:42 +00:00
<el-table-column label="创建人" align="center" prop="createByName" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="创建网点" align="center" prop="createSiteName" width="80" :show-overflow-tooltip="true"/>
2024-05-22 22:44:51 +00:00
<el-table-column label="创建时间" align="center" prop="createTime" width="170"/>
2024-06-02 09:59:42 +00:00
<el-table-column label="修改人" align="center" prop="updateByName" width="80" :show-overflow-tooltip="true"/>
<el-table-column label="修改网点" align="center" prop="updateSiteName" width="80" :show-overflow-tooltip="true"/>
2024-05-22 22:44:51 +00:00
<el-table-column label="修改时间" align="center" prop="updateTime" width="170"/>
2024-04-22 05:35:19 +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>
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="handleAddSub(scope.row)"
v-hasPermi="['emis:emisRegion:edit']"
>添加下级</el-button>
</template>
</el-table-column>
</xd-table>
<el-dialog :title="titleForm" :visible.sync="openForm" :destroy-on-close="true" width="50%" v-dialogDrag append-to-body>
<emisRegionForm :id="currentId" :regionType="regionType" :countryCode="currentCountryCode" :parentCode="parentCode" @on-changed="handleFormChanged" @on-cancel="cancelForm"></EmisRegionForm>
</el-dialog>
</div>
</template>
<script>
import { listEmisRegion, delEmisRegion} from "@/api/emis/emisRegion";
import emisRegionForm from '@/views/emis/emisRegion/emisRegionForm';
import CountryPicker from '@/views/emis/EmisBaseTools/CountryPicker.vue';
import CountryAreaPicker from '@/views/emis/EmisBaseTools/CountryAreaPicker.vue';
export default {
name: "emisRegion",
components: { emisRegionForm,CountryPicker,CountryAreaPicker },
props: {
countryCode: {
type: String,
required: false
},
},
dicts: [
'emis_region_level_type',
],
data() {
return {
// 是否展开,默认全部折叠
isExpandAll: false,
expandKeys:[],
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 四级省市区镇表表格数据
emisRegionList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
openForm: false,
titleForm: "",
tableDataCopy:[],
tableData:[],
regionType:1,
parentCode:null,
currentCountryCode:this.countryCode,
// 显示编辑框更多
moreInputVisible: false,
// 弹出展示层
currentId:null,
id:null,
titleView:"",
openView: false,
// 删除标志(0代表存在时间范围
daterangeCreateTime: [],
// 删除标志(0代表存在时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 50,
regionCode: null,
regionName: null,
regionNameEn: null,
regionType: '1',
shortName: null,
parentCode: null,
areaName: null,
countryCode: this.countryCode,
countryName: null,
zipCode: null,
orderNum: null,
remark: null,
delFlag: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
watch: {
countryCode(newVal) {
this.queryParams.countryCode = newVal;
this.getList();
}
},
created() {
this.getList();
},
methods: {
getList() {
this.loading = true;
if(this.queryParams.regionType == ''){
this.queryParams.regionType = 1;
}
listEmisRegion(this.queryParams).then(response => {
this.total = response.total;
this.tableDataCopy = this.handleTree(response.rows, "regionCode", "parentCode");
this.tableData = JSON.parse(JSON.stringify(this.tableDataCopy)).map(item => { // 展示数据
item.hasChildren = item.regionType!=4
item.children = []
item.idList = [item.id]
return item
})
this.loading = false;
});
},
treeLoad(tree, treeNode, resolve) {
listEmisRegion(Object({ parentCode: tree.regionCode })).then((response) => {
let tb = this.handleTree(response.rows, "regionCode", "parentCode");
const result = JSON.parse(JSON.stringify(tb)).map(item => { // 展示数据
item.hasChildren = item.regionType!=4
item.children = []
item.idList = [item.id]
return item
})
resolve(result);
});
},
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
// })
},
/** 搜索按钮操作 */
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
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 新增按钮操作 */
handleAdd(regionType) {
this.currentId= null;
this.regionType=regionType;
this.currentCountryCode = this.queryParams.countryCode;
this.openForm= true;
this.titleForm = "新增";
},
handleAddSub(row) {
this.currentId= null;
this.regionType= row.regionType+1;
this.currentCountryCode = row.countryCode;
this.parentCode = row.regionCode;
this.openForm= true;
this.titleForm = "新增";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
handleUpdate(row) {
// 子组件打开模式
this.regionType=row.regionType;
this.currentId= row.id;
console.log("111=>"+this.currentId);
this.openForm = true;
this.titleForm = "修改";
},
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','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','创建网点','更新网点',];
const filterVal = ['id','regionCode','regionName','regionNameEn','regionType','shortName','parentCode','areaId','areaName','countryCode','countryName','zipCode','orderNum','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime','createSite','updateSite',];
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>