From 50385820e308376432c078b1a7cfc3d17bd13cf0 Mon Sep 17 00:00:00 2001 From: smallchill Date: Sat, 9 May 2020 11:03:41 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E8=A1=8C=E6=94=BF=E5=8C=BA=E5=88=92?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/base/region.vue | 156 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 151 insertions(+), 5 deletions(-) diff --git a/src/views/base/region.vue b/src/views/base/region.vue index 586f18a..ae605f4 100644 --- a/src/views/base/region.vue +++ b/src/views/base/region.vue @@ -15,19 +15,37 @@ 新增下级 删除 - 导入 - 导出 - 调试 + 导入 + 导出 + 调试 + + + + + + + + @@ -37,6 +55,7 @@ import {getLazyTree, getDetail, submit, remove} from "@/api/base/region"; import {mapGetters} from "vuex"; import {validatenull} from "@/util/validate"; + import {getToken} from "@/util/auth"; export default { data() { @@ -153,12 +172,115 @@ }, ] }, - data: [] + excelBox: false, + excelForm: {}, + excelOption: { + submitBtn: false, + emptyBtn: false, + column: [ + { + label: '模板上传', + prop: 'excelFile', + type: 'upload', + drag: true, + loadText: '模板上传中,请稍等', + span: 24, + propsHttp: { + res: 'data' + }, + tip: '请上传 .xls,.xlsx 标准格式文件', + action: "/api/blade-system/region/import-region" + }, + { + label: "数据覆盖", + prop: "isCovered", + type: "switch", + align: "center", + width: 80, + dicData: [ + { + label: "否", + value: 0 + }, + { + label: "是", + value: 1 + } + ], + value: 0, + slot: true, + rules: [ + { + required: true, + message: "请选择是否覆盖", + trigger: "blur" + } + ] + }, + { + label: '模板下载', + prop: 'excelTemplate', + formslot: true, + span: 24, + } + ] + }, + debugBox: false, + debugForm: {}, + debugOption: { + labelWidth: 50, + submitBtn: false, + emptyBtn: false, + column: [ + { + label: '省份', + prop: 'province', + type: 'select', + props: { + label: 'name', + value: 'code' + }, + cascaderItem: ['city', 'district'], + dicUrl: '/api/blade-system/region/select', + span: 24, + }, + { + label: '地市', + prop: 'city', + type: 'select', + props: { + label: 'name', + value: 'code' + }, + dicFlag: false, + dicUrl: '/api/blade-system/region/select?code={{key}}', + span: 24, + }, + { + label: '区县', + prop: 'district', + type: 'select', + props: { + label: 'name', + value: 'code' + }, + dicFlag: false, + dicUrl: '/api/blade-system/region/select?code={{key}}', + span: 24, + } + ] + } }; }, watch: { 'regionForm.subCode'() { this.regionForm.code = this.regionForm.parentCode + this.regionForm.subCode; + }, + 'excelForm.isCovered'() { + if (this.excelForm.isCovered !== '') { + const column = this.findObject(this.excelOption.column, "excelFile"); + column.action = `/api/blade-system/region/import-region?isCovered=${this.excelForm.isCovered}`; + } } }, computed: { @@ -253,6 +375,30 @@ this.$refs.form.resetForm(); }); }, + uploadAfter(res, done, loading, column) { + window.console.log(column); + this.excelBox = false; + this.initTree(); + done(); + }, + handleDebug() { + this.debugBox = true; + }, + handleImport() { + this.excelBox = true; + }, + handleExport() { + this.$confirm("是否导出行政区划数据?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" + }).then(() => { + window.open(`/api/blade-system/region/export-region?Blade-Auth=${getToken()}`); + }); + }, + handleTemplate() { + window.open(`/api/blade-system/region/export-template?Blade-Auth=${getToken()}`); + }, } };