emis-frontend/src/views/emis/emisCountryArea/indexPanel.vue
2024-07-13 16:48:53 +08:00

411 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<XdPageContainer>
<search-form slot="pageHeader" :model="queryParams" ref="queryForm" size="small" :maxShow="3" label-width="68px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<el-form-item label="" prop="countryCode">
<country-picker :placeholder="$t('国家')" v-model="queryParams.countryCode" @onChange="handleQuery"></country-picker>
</el-form-item>
<el-form-item label="" prop="name">
<el-input
v-model="queryParams.name"
:placeholder="$t('片区名称')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
</search-form>
<xd-table
slot="pageContent"
slot-scope="slotProps"
:height="(slotProps.contentHeight-50)+'px'"
storageName="emisCountryAreaList_main"
v-loading="loading"
border
size="mini"
:data="emisCountryAreaList"
: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"
v-hasPermi="['emis:emisCountryArea:add']"
>新增片区</el-button>
</el-col>
<!--
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['emis:emisCountryArea: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:emisCountryArea: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:emisCountryArea:export']"
>导出</el-button>
</el-col> -->
</el-row>
</div>
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('片区名称')" align="left" prop="name" :sort-orders="['descending','ascending']" sortable="custom" >
<template slot-scope="scope">
<div class="link-type" @click="handleUpdate(scope.row)">{{scope.row.name}}</div>
</template>
</el-table-column>
<!-- <el-table-column :label="$t('英文名称')" align="center" prop="nameEn" min-width="100" /> -->
<!-- <el-table-column :label="$t('国家编码')" align="center" prop="countryCode" min-width="100" /> -->
<el-table-column :label="$t('国家')" align="center" prop="countryName" :sort-orders="['descending','ascending']" sortable="custom" />
<el-table-column :label="$t('服务网点')" align="center" prop="siteName" :sort-orders="['descending','ascending']" sortable="custom" />
<el-table-column :label="$t('操作')" 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:emisCountryArea:edit']"
>修改</el-button>
</template>
</el-table-column>
</xd-table>
<el-dialog :title="titleForm" :visible.sync="openForm" width="500px" :destroy-on-close="true" v-dialogDrag append-to-body>
<emisCountryAreaForm :id="currentId" @on-changed="handleFormChanged" @on-cancel="cancelForm"></EmisCountryAreaForm>
</el-dialog>
</XdPageContainer>
</template>
<script>
import { listEmisCountryArea, getEmisCountryArea, delEmisCountryArea, addEmisCountryArea, updateEmisCountryArea } from "@/api/emis/emisCountryArea";
import emisCountryAreaForm from '@/views/emis/emisCountryArea/emisCountryAreaForm';
import CountryPicker from '@/views/emis/EmisBaseTools/CountryPicker.vue';
export default {
name: "emisCountryArea",
components: { emisCountryAreaForm,CountryPicker },
dicts: [
],
props: {
countryCode: {
type: String,
required: false
},
},
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 国家大区表表格数据
emisCountryAreaList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
openForm: false,
titleForm: "",
titleEmisCountryArea: "",
openEmisCountryArea: false,
// 显示编辑框更多
moreInputVisible: false,
// 弹出展示层
currentId:null,
id:null,
titleView:"",
openView: false,
// 删除标志(0代表存在时间范围
daterangeCreateTime: [],
// 删除标志(0代表存在时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
name: null,
nameEn: null,
countryCode: this.countryCode,
countryName: null,
remark: null,
delFlag: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
id: [
{ required: true, message: "区域序号不能为空", trigger: "blur" }
],
}
};
},
watch: {
countryCode(newVal) {
this.queryParams.countryCode = newVal;
this.getList();
}
},
created() {
this.getList();
},
methods: {
/** 查询国家大区表列表 */
getList() {
this.loading = true;
this.queryParams.params = {};
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
}
if (null != this.daterangeUpdateTime && '' != this.daterangeUpdateTime) {
this.queryParams.params["beginUpdateTime"] = this.daterangeUpdateTime[0];
this.queryParams.params["endUpdateTime"] = this.daterangeUpdateTime[1];
}
listEmisCountryArea(this.addDateRange(this.queryParams, this.dateTimeRange)).then(response => {
this.emisCountryAreaList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
name: null,
nameEn: null,
countryCode: null,
countryName: null,
remark: null,
tenantId: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
createSite: null,
updateSite: 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
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 新增按钮操作 */
handleAdd(row) {
// this.reset();
// this.open = true;
// this.title = "新增";
// 子组件打开模式
this.openForm = true;
this.titleForm = "新增";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
handleUpdate(row) {
// this.reset();
// const id = row.id || this.ids
// getEmisCountryArea(id).then(response => {
// this.form = response.data;
// this.open = true;
// this.title = "修改";
// });
// 子组件打开模式
this.currentId= row.id || this.ids;
this.openForm = true;
this.titleForm = "修改";
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisCountryArea/viewDetail', query: { id: row.id }})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateEmisCountryArea(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addEmisCountryArea(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 delEmisCountryArea(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisCountryArea/export', {
// ...this.queryParams
// }, `emisCountryArea_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisCountryArea(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','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','创建网点','更新网点',];
const filterVal = ['id','name','nameEn','countryCode','countryName','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>